FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Projects/OnScreenTabletKeyboardInvocation.java at main · LEOKA037/Java-Projects · GitHub
LEOKA037
/
Java-Projects
Public
Notifications
You must be signed in to change notification settings
Fork
12
Star
22
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Projects
/
OnScreenTabletKeyboardInvocation.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (66 loc) · 3.65 KB
Breadcrumbs
Java-Projects
/
OnScreenTabletKeyboardInvocation.java
Copy path
File metadata and controls
81 lines (66 loc) · 3.65 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import
java
.
io
.
IOException
;
import
java
.
util
.
HashMap
;
import
java
.
util
.
Map
;
import
java
.
util
.
logging
.
Logger
;
public
class
OnScreenTabletKeyboardInvocation
{
public
static
final
int
REG_SUCCESS
=
0
;
public
static
final
String
SOFTWARE_MICROSOFT_TABLET_TIP_1_7
=
"SOFTWARE
\\
Microsoft
\\
TabletTip
\\
1.7"
;
public
static
final
String
IMMERSIVE_SHELL
=
"HKCU
\\
Software
\\
Microsoft
\\
windows
\\
CurrentVersion
\\
ImmersiveShell"
;
public
static
final
String
ENABLE_DESKTOP_MODE_AUTO_INVOKE
=
"EnableDesktopModeAutoInvoke"
;
public
static
final
String
DISABLE_NEW_KEYBOARD_EXPERIENCE
=
"DisableNewKeyboardExperience"
;
public
static
final
String
TABLET_MODE
=
"TabletMode"
;
public
static
final
String
REG_VALUE
=
"1"
;
public
static
final
String
VALUE_CREATED
=
"value created"
;
public
static
final
String
ERROR_COULD_NOT_CREATE_THE_VALUE
=
"Error: could not create the value"
;
public
static
final
Logger
logger
=
Logger
.
getAnonymousLogger
();
public
static
void
main
(
String
...
args
) {
OnScreenTabletKeyboardInvocation
reg
=
new
OnScreenTabletKeyboardInvocation
();
try
{
addRegistryValuesForTabTip
(
reg
);
invokeTabTip
();
}
catch
(
InterruptedException
|
IOException
e
) {
logger
.
warning
(
"An error occurred. "
+
e
.
getMessage
());
}
}
private
static
void
invokeTabTip
()
throws
IOException
{
ProcessBuilder
builder
=
new
ProcessBuilder
(
"cmd.exe"
,
"/c"
,
"start
\"
\"
\"
C:
\\
Program Files
\\
Common Files
\\
microsoft shared
\\
ink
\\
TabTip.exe
\"
"
);
builder
.
redirectErrorStream
(
true
);
Process
p
=
builder
.
start
();
logger
.
info
(
String
.
valueOf
(
p
.
pid
()));
}
private
static
void
addRegistryValuesForTabTip
(
OnScreenTabletKeyboardInvocation
reg
)
throws
IOException
,
InterruptedException
{
//Adding the required Registry entries for enabling Tablet keyboard invocation value TabTip
Map
<
String
,
String
>
dWordMap
=
new
HashMap
<>();
dWordMap
.
put
(
SOFTWARE_MICROSOFT_TABLET_TIP_1_7
,
ENABLE_DESKTOP_MODE_AUTO_INVOKE
);
dWordMap
.
put
(
SOFTWARE_MICROSOFT_TABLET_TIP_1_7
,
DISABLE_NEW_KEYBOARD_EXPERIENCE
);
dWordMap
.
put
(
IMMERSIVE_SHELL
,
TABLET_MODE
);
for
(
Map
.
Entry
<
String
,
String
>
entry
:
dWordMap
.
entrySet
()) {
if
(
reg
.
addValue
(
WRKey
.
HKCU
,
entry
.
getKey
(),
entry
.
getValue
(),
REG_VALUE
.
getBytes
(),
WRType
.
REG_DWORD
)) {
logger
.
info
(
VALUE_CREATED
);
}
else
{
logger
.
warning
(
ERROR_COULD_NOT_CREATE_THE_VALUE
);
}
}
}
public
String
createRegString
(
WRKey
hkey
,
String
key
,
String
valueName
,
byte
[]
data
,
WRType
type
,
boolean
force
) {
String
keyString
=
" "
+
hkey
+
"
\\
"
+
key
;
String
valueString
=
valueName
!=
null
?
" /v "
+
valueName
:
""
;
String
dataString
=
data
!=
null
? (
" "
+ (
data
.
length
>
0
?
" /d "
+
new
String
(
data
) :
""
)) :
""
;
String
typeString
=
type
!=
null
?
" /t "
+
type
:
""
;
return
keyString
+
valueString
+
dataString
+
typeString
+ (
force
?
" /f"
:
""
);
}
public
boolean
addValue
(
WRKey
hkey
,
String
key
,
String
valueName
,
byte
[]
data
,
WRType
type
)
throws
IOException
,
InterruptedException
{
String
regString
=
createRegString
(
hkey
,
key
,
valueName
,
data
,
type
,
true
);
Process
proc
=
Runtime
.
getRuntime
().
exec
(
"REG ADD "
+
regString
);
proc
.
waitFor
();
return
proc
.
exitValue
() ==
REG_SUCCESS
;
}
private
enum
WRKey
{
HKLM
,
HKCU
,
HKCR
,
HKU
,
HKCC
}
private
enum
WRType
{
REG_SZ
,
REG_MULTI_SZ
,
REG_EXPAND_SZ
,
REG_DWORD
,
REG_QWORD
,
REG_BINARY
,
REG_NONE
}
}
Back
|
FazBrowse Home
|
New Git URL