Sign in to follow this  
Followers 0
ChrisL

Buffer Hotkeys

4 posts in this topic

#1 ·  Posted (edited)

This is something I wrote for a guy in the support forum. I have cut it down to show the basics of how it works.

The issue was that when using multiple hotkeys with functions which took some time to process, the first hotkey function would not complete if a subsiquent hotkey was pressed until the second hotkey function had finished.

You end up with actions which could run out of sequence.

The code below will queue the Hotkeys and run them in order One at a time. You can set hotkeys that are allowed to queue. If you use the standard HotkeySet method then this/these hotkeys will interupt the queue.

If you try the below code and type abababababababab follewed by the c key you will see in the Scite console pain the hotkeys are buffered and the each function will not run until it's turn

If you run the script again and type abababababababab then the esc key you will see the esc key will jump the queue and exit the script, if the esc key performed another action other than exit then this would be performed and then the queue would be continued

#include "HotKeyBuffer.au3"

_HotKeySet("a","MyaFunc")
_HotKeySet("b","MybFunc")
_HotKeySet("c","MycFunc")

HotkeySet("{esc}","_quit")
While 1
    Sleep(100)
WEnd


Func MyaFunc()
    ConsoleWrite("This is my a function" & @crlf)
    Sleep(2000)
EndFunc

Func MybFunc()
    ConsoleWrite("This is my b function" & @crlf)
    Sleep(2000)
EndFunc

Func MycFunc()
    Msgbox(0,"","C key all done")
    Exit
EndFunc

Func _quit()
    Exit
Endfunc

Edited to make this a UDF for ease of use

HotKeyBuffer.au3

Edited by ChrisL

Share this post


Link to post
Share on other sites



If you had released this before _IsPressed() was included in the autoit release I would have loved you :)

It's a really nice script though, Good Work!


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Nice, this thread explains why pressing next really quiclky in AMP cuases it to play multiple files....

Thanks


[center][/center]

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  
Followers 0