Jump to content



Photo

Buffer Hotkeys


  • Please log in to reply
3 replies to this topic

#1 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,746 posts

Posted 17 July 2007 - 08:28 PM

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



Plain Text         
#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

Attached Files


Edited by ChrisL, 20 March 2008 - 09:14 PM.






#2 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,746 posts

Posted 20 March 2008 - 09:16 PM

made this into a include file for ease of use

#3 monoceres

monoceres

    asdf

  • MVPs
  • 3,719 posts

Posted 21 March 2008 - 11:30 PM

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!
Posted ImageIs the link in my post broken? I do not longer own my domain, all the files are moved to my new domain.Example: http://monoceres.se/test.au3 -> http://andhen.mine.nu/monoceres.se/test.au3

#4 DirtDBaK

DirtDBaK

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 978 posts

Posted 23 March 2008 - 06:04 AM

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

Posted Image





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users