boogieoompa Posted August 7, 2005 Share Posted August 7, 2005 I am having a slight problem, basically I have some code that I would only like to work in one program so that when someone goes to word or IE all of the keys that I am capturing (my code basically sets up hot keys) are relayed back to the key board. Right now it works fine until the user pushes caps lock at which time the user can nolonger push shift+button. Basically after they push caps lock the only way you can get a capital letter is by pressing caps lock. But shift works fine before the user press caps lock. Any suggestions? Thanks If $KeyStates[3] then HotKeySet("R") Send("R") HotKeySet("R", "FunRuler") Else HotKeySet("r") Send("r") HotKeySet("r", "FunRuler") Endif Func _GetKeyState() ;code snit bit provided by gafrost Const $VK_NUMLOCK = 0x90 Const $VK_SCROLL = 0x91 Const $VK_CAPITAL = 0x14 Local $ret, $a_keystate[4] $a_keystate[0] = 3 $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_NUMLOCK) $a_keystate[1] = $ret[0] $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_SCROLL) $a_keystate[2] = $ret[0] $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_CAPITAL) $a_keystate[3] = $ret[0] Return $a_keystate EndFunc ;==>_GetKeyState Link to comment Share on other sites More sharing options...
hgeras Posted August 7, 2005 Share Posted August 7, 2005 (edited) Try to be more specific.... You say that if the user presses CAPSLOCK then the script doesnt work right.If he turns off CAPSLOCK then the script works right or continues to be wrong? If that is the case then make a hotkeyset with CAPSLOCK and put this in the function Send("{CAPSLOCK OFF}") Then you are goin to be sure that capslock is always turned off. If that is the case,good.Otherwise be more specific please... C ya Edited August 7, 2005 by hgeras Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
boogieoompa Posted August 7, 2005 Author Share Posted August 7, 2005 Sorry its a bit complicated. Basically if the user wants caps lock on it needs to stay on (we have some case sensitive apps ) Here is specifically the problem. When the user goes to another app with caps lock turned off the case is fine. The user can push shift and get a capital letter or get a lower case letter if he does not push shit. If the user then initiates caps lock the app starts to get a little wierd. With caps lock engaged the user can no longer make a lower case letter (even when holding down shift) and once the user turns caps lock off the user can no longer make captial letters using shift. Link to comment Share on other sites More sharing options...
hgeras Posted August 7, 2005 Share Posted August 7, 2005 You have to show us the whole code you wrote cos the one in the first post isnt completed and maybe we can figure out what the problem is....I cant be of any more help right now....sorry Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
boogieoompa Posted August 7, 2005 Author Share Posted August 7, 2005 I tested this as a standalone autoit app and it demonstrates the problem. If you run it and then go into notepad press caps lock and you will see what I am talking about. Incedentially I have noticed that the caps lock key flickers whenever I push a button during the wierd occurance. Thanks expandcollapse popupHotKeySet("r", "FunRuler") While 1 Sleep(100) WEnd Func FunRuler() $KeyStates = _GetKeyState() If WinActive("Calculations") Then mouseclick("Right") Send("{Down},{Down},{Right},{Enter}") mouseclick("Left") Else If $KeyStates[3] then HotKeySet("R") Send("R") HotKeySet("R", "FunRuler") Else HotKeySet("r") Send("r") HotKeySet("r", "FunRuler") Endif Endif EndFunc ;--------------------------------------------------------------------------------------------- Func _GetKeyState() ;Finds out if Caps is on Const $VK_NUMLOCK = 0x90 Const $VK_SCROLL = 0x91 Const $VK_CAPITAL = 0x14 Local $ret, $a_keystate[4] $a_keystate[0] = 3 $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_NUMLOCK) $a_keystate[1] = $ret[0] $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_SCROLL) $a_keystate[2] = $ret[0] $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_CAPITAL) $a_keystate[3] = $ret[0] Return $a_keystate EndFunc ;==>_GetKeyState Link to comment Share on other sites More sharing options...
hgeras Posted August 7, 2005 Share Posted August 7, 2005 (edited) I changed the code of Getkeystate() and your code to do this.... This will do the trick.There is no bother if you press r or R or SHIFT+r or CAPSLOCK on or off or if you change windows or anything.... While 1 $KeyStates = _GetKeyState() if $keystates=1 Then If WinActive("Calculations") Then mouseclick("Right") Send("{Down},{Down},{Right},{Enter}") mouseclick("Left") Endif EndIf WEnd ;--------------------------------------------------------------------------------------------- Func _GetKeyState() Const $VK_R= 0x52 Local $ret $ret = DllCall("user32.dll", "int", "GetAsyncKeyState", "int", $VK_R) If $ret[0] <> 0 Then Return 1 EndFunc;==>_GetKeyState Good luck. EDIT:I corrected some code.... EDIT:After messing for an hour with MSDN and struggling for another one to make this work,I found out that there was a function IsPressed() that does the same thing.... Edited August 7, 2005 by hgeras Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now