Jump to content

hotkeyset interrupting each other


Recommended Posts

How can I make sure that hotkeyset doesnt interrupting each other. If you press another hotkey at the same time the last one is still going through its function it will immediately start the new function. How can I make it wait?

Cheers,

David.

If you don't have a lot of hotkeys, you could unset the others and re-set them again at the end of the function...

To make life simple you could just make and call a function that sets and un-sets them...

Edited by exodius
Link to comment
Share on other sites

How can I make sure that hotkeyset doesnt interrupting each other. If you press another hotkey at the same time the last one is still going through its function it will immediately start the new function. How can I make it wait?

Cheers,

David.

Try the following code.

:D

global $IntFlag = 0

HotKeySet('^{F10}', '_MyFunc')
HotKeySet('!{F10}', '_Quit')

while 1
    Sleep(10)
wend

func _MyFunc()
    if $IntFlag then
        return
    endif
    $IntFlag = 1
    
    MsgBox(0, 'MyFunc', 'Ctrl-F10 has been pressed!')
    
    $IntFlag = 0
endfunc; _MyFunc

func _Quit()
    exit
endfunc; _Quit
Link to comment
Share on other sites

thx for your replies but i'm after a way for it to wait if possible.

global $Count = 1, $Queue = 0, $IntFlag = 0

HotKeySet('^{F10}', '_Count')
HotKeySet('!{F10}', '_Quit')

AdlibEnable('_Queue', 100)

while 1
    Sleep(10)
wend

func _Count()
    $Queue += 1
endfunc; _Count

func _MyFunc()
    MsgBox(0, 'MyFunc (' & $Count & ')', 'Ctrl-F10 has been pressed!')
endfunc; _MyFunc

func _Queue()
    if ($IntFlag) or ($Queue = 0) then
        return
    endif
    $IndFlag = 1
    _MyFunc()
    $Count += 1
    $Queue -= 1
    $IndFlag = 0
endfunc; _Queue

func _Quit()
    exit
endfunc; _Quit
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...