InjkttxD Posted October 7, 2010 Share Posted October 7, 2010 Hey guys, i've tried using this code to hold down the LCTRL button but i can't get it too terminate or pause the script. It's like the button is sticky, i've manually terminated the script but my pc still thinks the LCTRL button is held down until i actually physically push it down on my keyboard and release it. Then everything works fine. I'm so confused Global $Paused HotKeySet("{TAB}", "TogglePause") HotKeySet("{\}", "Terminate") HotKeySet("+!d", "ShowMessage") While 1 Send("{LCTRL down}") WEnd Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func ShowMessage() MsgBox(25,"","") EndFunc Link to comment Share on other sites More sharing options...
trung0407 Posted October 7, 2010 Share Posted October 7, 2010 (edited) welcome to au3 forum every up has a down Func Terminate() Send("{LCTRL up}") Exit 0 EndFunc at least call it when you exist the program OnAutoItExitRegister( "Terminate" ) Edited October 7, 2010 by trung0407 Link to comment Share on other sites More sharing options...
jaberwacky Posted October 7, 2010 Share Posted October 7, 2010 (edited) You need a sleep function...Global $Paused HotKeySet("{TAB}", "TogglePause") HotKeySet("{\}", "Terminate") HotKeySet("+!d", "ShowMessage") While 1 Send("{LCTRL down}") Sleep(50) WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate Func ShowMessage() MsgBox(25,"","") EndFunc ;==>ShowMessageActually, scratch that. That isn't true.Ok, I would like to add that you don't need the Send statement inside of a while loop.Global $Paused HotKeySet("^{TAB}", "TogglePause") HotKeySet("{\}" , "Terminate") HotKeySet("+!d" , "ShowMessage") Send("{LCTRL down}") While 1 Sleep(50) WEnd Func TogglePause() $Paused = Not $Paused ToolTip("Script is 'Paused'") Send("{LCTRL up}") While $Paused Sleep(50) WEnd ToolTip('') EndFunc ;==>TogglePause Func Terminate() Send("{LCTRL up}") Exit EndFunc ;==>Terminate Func ShowMessage() MsgBox(25, "", "") EndFunc ;==>ShowMessage Edited October 7, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
InjkttxD Posted October 7, 2010 Author Share Posted October 7, 2010 I've tried both, with no prevail. My pc still thinks the LCTRL key is pressed down, even once i release it or termiate the script. Unless someone can see what i've done wrong? Global $Paused HotKeySet("{TAB}", "TogglePause") HotKeySet("{\}", "Terminate") HotKeySet("+!d", "ShowMessage") While 1 Send("{LCTRL DOWN}") Sleep(50) WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate Func ShowMessage() MsgBox(25,"","") EndFunc ;==>ShowMessage or Global $Paused HotKeySet("{TAB}", "TogglePause") HotKeySet("{\}", "Terminate") HotKeySet("+!d", "ShowMessage") While 1 Send("{LCTRL down}") WEnd Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Send("{LCTRL up}") Exit 0 EndFunc Func ShowMessage() MsgBox(25,"","") EndFunc Link to comment Share on other sites More sharing options...
jaberwacky Posted October 7, 2010 Share Posted October 7, 2010 Strange, it isn't working for me anymore. I wonder what happened?! Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted October 7, 2010 Share Posted October 7, 2010 Does this help? 19 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...
trung0407 Posted October 7, 2010 Share Posted October 7, 2010 you need OnAutoItExitRegister( "Terminate" ) to prevent unexpected interruption of the program, which will never call the Terminate() function. And you need to throw out the idea of placing a Send({.. down}) inside a loop of your head since one call is enough. Link to comment Share on other sites More sharing options...
InjkttxD Posted October 7, 2010 Author Share Posted October 7, 2010 Does this help? 19 Why does the Ctrl key get stuck down after I run my script? Nope doesn't help i've already, looked at that, but thanks anyway you needOnAutoItExitRegister( "Terminate" )to prevent unexpected interruption of the program, which will never call the Terminate() function.And you need to throw out the idea of placing a Send({.. down}) inside a loop of your head since one call is enough. So what would the whole script look like with out the continuous LCTRL key repeat? Link to comment Share on other sites More sharing options...
InjkttxD Posted October 7, 2010 Author Share Posted October 7, 2010 ? Link to comment Share on other sites More sharing options...
jaberwacky Posted October 7, 2010 Share Posted October 7, 2010 (edited) So what would the whole script look like with out the continuous LCTRL key repeat?If you'll look at my revised post #3 you'll find an example...Please only bump posts every 24 hours. Edited October 7, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
InjkttxD Posted October 7, 2010 Author Share Posted October 7, 2010 I've tried your example and i still can't get my pc to stop thinking i've still got the LCTRL pressed down, it's really starting to frustrate me -.- Link to comment Share on other sites More sharing options...
jaberwacky Posted October 7, 2010 Share Posted October 7, 2010 I've tried your example and i still can't get my pc to stop thinking i've still got the LCTRL pressed down, it's really starting to frustrate me -.-Well, I only posted that not as a fix to your problem but that the Send() being in a while loop might just introduce it's own bug, who knows. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
InjkttxD Posted October 7, 2010 Author Share Posted October 7, 2010 Well, thanks for the help (: it is really appreciated. Gives me an error now something about 'Script did not respond, forcing abortion" or something like that Link to comment Share on other sites More sharing options...
trung0407 Posted October 7, 2010 Share Posted October 7, 2010 Strange, it isn't working for me anymore. I wonder what happened?!yours stop working because you forgot to ctrl down again once the script stops pausing.But putting a ctrl down out of the loop like you did is the correct way to do it. Link to comment Share on other sites More sharing options...
Valhalla1 Posted November 29, 2010 Share Posted November 29, 2010 I am trying to build this same script actually, but I replaced LCTRL with "a" but when I use example #3 it only sends 1 instance of "a", even though I have Send("{a down}") it should be holding down the button until Send("{a up}") but it doesn't 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