Jump to content

How to disable hotkeys after loop


Recommended Posts

I have a loop that has 4 hotkeys setup. The fourth hotkey is 'e' for exit. When I hit 'e' ,I exit from the loop, but anytime any of the other 3 hotkeys 'p','o', or 'i' is pressed from that point on they still operate. I want to exit from the loop once 'e' is pressed, and then e,p,o,i to not work anymore.

While $ExitValue = 1
        HotKeySet("p", "LogLocation")
        HotKeySet("o", "LogColor")
        HotKeySet("i", "LogColorAndLocation")
        HotKeySet("e", "ExitLoop1")
        sleep(1000)
        WEnd

Func ExitLoop1()
    $ExitValue = 0
EndFunc

I know that I am exiting the loop since other functions work, that do not work will im inside the loop will work after hitting 'e'.

Link to comment
Share on other sites

I have a loop that has 4 hotkeys setup. The fourth hotkey is 'e' for exit. When I hit 'e' ,I exit from the loop, but anytime any of the other 3 hotkeys 'p','o', or 'i' is pressed from that point on they still operate. I want to exit from the loop once 'e' is pressed, and then e,p,o,i to not work anymore.

While $ExitValue = 1
        HotKeySet("p", "LogLocation")
        HotKeySet("o", "LogColor")
        HotKeySet("i", "LogColorAndLocation")
        HotKeySet("e", "ExitLoop1")
        sleep(1000)
        WEnd

Func ExitLoop1()
    $ExitValue = 0
EndFunc

I know that I am exiting the loop since other functions work, that do not work will im inside the loop will work after hitting 'e'.

Hmm now that I think about it, I must have been braindead. This is a horrible way of accomplishing what I want. I guess I should just capture the key that is pressed, and do a case statement. I dunno why I didnt think of that before I wrote this out ; /

ok fixed it for anyone that might be curious

If _IsPressed("50", $dll) Then
        MsgBox(0,"_IsPressed", "P")
        EndIf
        If _IsPressed("4F", $dll) Then
        MsgBox(0,"_IsPressed", "O")
EndIf
Edited by loki1982
Link to comment
Share on other sites

  • 1 month later...

I need to be able to use something like this to make more flexible hotkeys I'm working on a simple program to replace one key with another when in a game (F2 to Left Arrow and F6 to Right Arrow) but I don't want it to effect the rest of the system when the game isn't active. Would it be possible to see the rest of your script so that I could learn more about how your handling the hotkeys here. Thanks you!

AutoIt changed my life.

Link to comment
Share on other sites

While $ExitValue = 1
        HotKeySet("p", "LogLocation")
        HotKeySet("o", "LogColor")
        HotKeySet("i", "LogColorAndLocation")
        HotKeySet("e", "ExitLoop1")
        sleep(1000)
WEnd
Func Pause()
       sleep(1000)
endfunc
Func ExitLoop1()
        HotKeySet("p", "Pause")
        HotKeySet("o", "Pause")
        HotKeySet("i", "Pause")
        HotKeySet("e", "Pause")
    $ExitValue = 0
EndFunc

Link to comment
Share on other sites

but I don't want it to effect the rest of the system when the game isn't active.

That's what conditional statements and WinActive() are for. Edited by Siao

"be smart, drink your wine"

Link to comment
Share on other sites

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...