Hi!
I have posted this simple 2 subroutine sample for those who want to have
games and need script only hotkeys for any key press done during the game.
The big problem is how to simply assign keys to just one app and this is
the best solution.
These can also be modified to any value you want the keys to have inside the
second array called myKeyFunc;
but the standard keyboard keys I use the same string, but you could change them
by just adding another array corresponding to there respect array position
inside the string, starting at 1, since arrays are 0 based.
Sincerely
Bruce
'Global Script Create Assignments:
Dim myMainEscape: Set myMainEscape = Nothing
Dim myMainAltF4: Set myMainAltF4 = Nothing
CONST TotalKeys = 90 'Or any number you are using.
Dim myFuncKeys(): ReDim myFuncKeys( TotalKeys) 'Used when creating new or
destroying old.
'When Creating A Dialog or Closing it, use these 2 routines:
Queue "KeyRegister", dObj
Queue "KeyUnRegister"
Sub KeyRegister( dObj)
'Registering All Keys For Game.
Dim theKeys: theKeys = ",./ABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-="
Dim myKey: myKey = Array("Insert", "Delete", "Home", "End", "Page Up", "Page
Down", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10")
Dim myKeyFunc: myKeyFunc = Array("Insert", "Del", "Home", "End", "Page Up",
"Page Down", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10")
Set myMainEscape = Keyboard.RegisterHotkey("Escape", "ExitMenu", dObj.Window,
dObj)
Set myMainAltF4 = Keyboard.RegisterHotkey("Alt-F4", "ExitMenu", dObj.Window,
dObj)
Dim i
For i = 1 To 15
Set myFuncKeys( i) = Keyboard.RegisterHotkey(myKey(i), "FuncKeys",
dObj.Window, myKeyFunc(i))
Next
For i = 0 To 15
Set myFuncKeys( i+16) = Keyboard.RegisterHotkey("Shift-"&myKey(i),
"FuncKeys", dObj.Window, "Shift "&myKeyFunc(i))
Set myFuncKeys( i+30) = Keyboard.RegisterHotkey("Control-"&myKey(i),
"FuncKeys", dObj.Window, "Control "&myKeyFunc(i))
Next
For i = 1 To 42
Set myFuncKeys( i+45) = Keyboard.RegisterHotkey( Mid( theKeys, i, 1),
"FuncKeys", dObj.Window, Mid( theKeys, i, 1))
Next
End Sub
Sub KeyUnRegister()
ReDim myFuncKeys( TotalKeys)
Set myMainEscape = Nothing
Set myMainAltF4 = Nothing
End Sub
Sub ExitMenu( dObj)
dObj.Close
End Sub
Sub FuncKeys( txt)
'Test but will be used for game select case statements.
Speak " Function Key: " & txt
'Select Case txt
'End Select
End Sub