Jump to content
Sign in to follow this  
J0ker

Hotkey work only ONE time

Recommended Posts

J0ker

How to set a hotkey to work only the first time it pressed? I have a hotkey that start my script and I want it to work only one time. Is there any way to do that?

HotKeySet("{ENTER}", "Begin") ; Run the script when ENTER is pressed
Edited by J0ker

Share this post


Link to post
Share on other sites
_Kurt

Hmm, well I'm not sure if this is what you want, but this works:

;UNTESTED but probably works
#include <Misc.au3>
While 1
    If _IsPressed("number") Then ; Look up _IsPressed in the UDF helpfile for the correct "number"
        ;do whatever you want
        ExitLoop
    EndIf
WEnd
;(.. the rest of your script)

This works, but it may not be what you want.

Good Luck with your script!

Kurt

EDIT: the script will loop until (hotkey) is pressed, after it is, you do whatever and exit the loop and finish the rest of your script

Edited by _Kurt

Awaiting Diablo III..

Share this post


Link to post
Share on other sites
J0ker

It's not exactly what I want. I dont want the script to loop until the key is pressed but to kinda block this hotkey or disable it when it pressed.

The Hotkey ENTER start my script so there's no reason why it should be used again during the script. It's why I want to disable it so if accidently someone press ENTER again when the script is running, nothing will happen.

Something like that:

HotKeySet("{ENTER}", "Begin") ; Run the script when ENTER is pressed

Func Begin()
Disable Hotkey "Enter"
;blablabla
EndFunc
Edited by J0ker

Share this post


Link to post
Share on other sites
Jabberwock

$hotkey = "{F10}"

$hotkeyset = 0

While 1

test()

Wend

Func test()

If $hotkeyset = 0 then

HotKeySet($hotkey, "somefunc")

Elseif $hotkeyset = 1 then

HotKeySet($hotkey)

EndIf

EndFunc

Func somefunc()

$hotkeyset = 1

MsgBox(0, "Test", "Works?")

EndFunc


Share this post


Link to post
Share on other sites
Jabberwock

yeah, seems i was over thinking that one, you simplified mine =P


Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.