Jump to content

Sticky Key?


Recommended Posts

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

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 ;==>ShowMessage

Actually, 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 by jaberwocky6669
Link to comment
Share on other sites

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

Nope doesn't help i've already, looked at that, but thanks anyway ;)

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.

So what would the whole script look like with out the continuous LCTRL key repeat?
Link to comment
Share on other sites

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 by jaberwocky6669
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...