Jump to content

Recommended Posts

Posted (edited)

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
Posted (edited)

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

Posted (edited)

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
Posted

$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

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
  • Recently Browsing   0 members

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