Kard0 Posted August 22, 2010 Share Posted August 22, 2010 I managed to create a script that keeps the Left Control key pressed down, but getting it back up just doesn't want to work as it should be. If I press the hotkey that should trigger the script that releases the hotkey it just won't happen, LCTRL still stays pressed down. Also, is it possible to attach it to a certain program names / windows only, so for example in FireFox CTRL won't be pressed, but in another window like notepad it will be pressed down. Heres the code. HotKeySet("{PGUP}", "ctrldown") HotKeySet("{PGDN} ", "ctrlup") Func ctrldown() $ctrl = 1 $onoff3 = "ON" $color3 = "0x008000" GUICTRLSetColor($control,$color3) GUICTRLSetdata($control,$onoff3) Send("{LCTRL down}") EndFunc Func ctrlup() $onoff3 = "OFF" $color3 = "0xff0000" Send("{LCTRL up}") GUICTRLSetColor($control,$color3) GUICTRLSetdata($control,$onoff3) EndFunc I took out the parts that just make going over the code a bit longer, colors, GUI etc. Kardo. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted August 23, 2010 Share Posted August 23, 2010 Maybe this will help some, FAQ - AutoIt Wiki - Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Kard0 Posted August 23, 2010 Author Share Posted August 23, 2010 Maybe this will help some, FAQ - AutoIt Wiki - Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script.It's not that case, the FAQ you sent me says, if a key gets stuck after just Send key, I'm forcing it to stay down with Send keyname down behind it. After its down, I also made a hotkey to trigger a function that releases it, but it just doesn't to release it. Also, still a question to me, how can I make the script attach it to some certain window names, so that If I'm on msn for example and lets say Right Click is ON, then it would only work inside certain windows. A bit messy but I hope I managed to explain my idea.KardoPS: I love the small text in your Signature, no clue why. Link to comment Share on other sites More sharing options...
Kard0 Posted August 23, 2010 Author Share Posted August 23, 2010 Well, in my timezone, its a new day, and still the same problem, would love if someone could help me out. Thank you. Link to comment Share on other sites More sharing options...
targeter Posted August 23, 2010 Share Posted August 23, 2010 (edited) It's not that case, the FAQ you sent me says, if a key gets stuck after just Send key, I'm forcing it to stay down with Send keyname down behind it. After its down, I also made a hotkey to trigger a function that releases it, but it just doesn't to release it. Also, still a question to me, how can I make the script attach it to some certain window names, so that If I'm on msn for example and lets say Right Click is ON, then it would only work inside certain windows. A bit messy but I hope I managed to explain my idea.KardoPS: I love the small text in your Signature, no clue why.Look at WinExist or ControlFocus, etc... the Control_____ or Win_______ functions with some loop command for return status. Edited August 23, 2010 by targeter Link to comment Share on other sites More sharing options...
Sven Posted August 24, 2010 Share Posted August 24, 2010 OnAutoItExitRegister("_Exit") Global $onoff3 HotKeySet("{PGUP}", "ctrldown") HotKeySet("{PGDN} ", "ctrlup") While 1 Sleep(100) If WinActive("Firefox") And $onoff3 = "ON" Then ctrlup() WEnd Func ctrldown() $ctrl = 1 $onoff3 = "ON" $color3 = "0x008000" GUICtrlSetColor($control, $color3) GUICtrlSetData($control, $onoff3) Send("{LCTRL down}") EndFunc ;==>ctrldown Func ctrlup() $onoff3 = "OFF" $color3 = "0xff0000" Send("{LCTRL up}") GUICtrlSetColor($control, $color3) GUICtrlSetData($control, $onoff3) EndFunc ;==>ctrlup Func _exit() ctrlup() Exit EndFunc ;==>_exit Try this. Link to comment Share on other sites More sharing options...
abbarber Posted September 5, 2010 Share Posted September 5, 2010 I have the same problem. I found this problem on the same keys pressed to activate Hotkey. I need to press the same key to get control. Here is a little script with this problem used in Visual Studio 2008 HotKeySet("^+p", "Namespace") HotKeySet("^+e", "Terminate") While 1 Sleep(100) WEnd func Namespace() Send("namespace Cap15 {{} ^{END} {}} ") EndFunc func Terminate() Exit EndFunc I use this to add namespace to many source. When script terminates I need to press SHIFT and CTRL. Link to comment Share on other sites More sharing options...
legoman1 Posted September 6, 2010 Share Posted September 6, 2010 HotKeySet("{PGUP}", "ctrldown")HotKeySet("{PGDN} ", "ctrlup")i think that your problem would be hereyou are waiting for the user to press PageDown, however, once ctrl is held down, the user is actually pressing ctrl-pagedown.use HotKeySet("^{PGDN}", "ctrlup")also, if a user presses ctrl when ctrl is held down, the button is released. just an fyi. (you could block it so that they cant press it)legoman 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