Jump to content

adding timer between pressing hokeys


Tomb
 Share

Recommended Posts

hi. i am creating this rpg about my dog, its called Toby's Quest. i have all of the hotkeys set up, just if you hold them down, or press them to fast, the images move to fast and they flash badly. is there some way i can set a delay of like 500 miliseconds before being able to press a hotkey again. I tried adding sleep(500) in the hotkey functions, but that becomes very buggy. i just want the functions to sleep like 500 miliseconds before they can be used again. is there some way i can do this?

Link to comment
Share on other sites

Disable the Hotkey at the start of your function and then reset it at the end using a sleep if required.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Parameters

key The key combination to use as the hotkey. Same format as Send().

function [optional] The name of the function to call when the key is pressed. Not specifying this parameter will unset a previous hotkey.

Ie

HotKeySet("{ESC}")

Edited by BigDod


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Parameters

key The key combination to use as the hotkey. Same format as Send().

function [optional] The name of the function to call when the key is pressed. Not specifying this parameter will unset a previous hotkey.

Ie

HotKeySet("{ESC}")

so if this were the normal function

Func _ScrollUp();UP

GUICtrlSetState($pic1, $GUI_HIDE)
GUICtrlSetState($pic2, $GUI_HIDE)
GUICtrlSetState($pic3, $GUI_HIDE)
GUICtrlSetState($pic4, $GUI_HIDE)

    $GetPos = ControlGetPos($GUI, "", $background)
    ControlMove($GUI, "", $background, $GetPos[0], $GetPos[1]+5)

GUICtrlSetState($pic1, $GUI_SHOW)
EndFunc

actually im still confused

Edited by Tomb616
Link to comment
Share on other sites

HotKeySet("{ESC}", '_ScrollUp')

Func _ScrollUp();UP
GUICtrlSetState($pic1, $GUI_HIDE)
GUICtrlSetState($pic2, $GUI_HIDE)
GUICtrlSetState($pic3, $GUI_HIDE)
GUICtrlSetState($pic4, $GUI_HIDE)

    $GetPos = ControlGetPos($GUI, "", $background)
    ControlMove($GUI, "", $background, $GetPos[0], $GetPos[1]+5)

GUICtrlSetState($pic1, $GUI_SHOW)
HotKeySet("{ESC}")
Sleep(500)
HotKeySet("{ESC}", '_ScrollUp')
EndFunc

Link to comment
Share on other sites

so if this were the normal function

Func _ScrollUp();UP

GUICtrlSetState($pic1, $GUI_HIDE)
GUICtrlSetState($pic2, $GUI_HIDE)
GUICtrlSetState($pic3, $GUI_HIDE)
GUICtrlSetState($pic4, $GUI_HIDE)

    $GetPos = ControlGetPos($GUI, "", $background)
    ControlMove($GUI, "", $background, $GetPos[0], $GetPos[1]+5)

GUICtrlSetState($pic1, $GUI_SHOW)
EndFunc

actually im still confused

Here is one way you could do it

HotKeySet("1", "hotkeys");set all hot keys to the same function
HotKeySet("2", "hotkeys")
;more hot keys
Global $HotOK = True;the hot keys will work

Func hotkeys()
    If Not $HotOK Then Return
    $HotOK = False
    AdlibEnable("releaseme", 500);set for the delay you want
    Switch @HotKeyPressed
        Case "1"
            func1;whatever you function is
            
        Case "2"
            func2
    EndSwitch

;might be better to put the ADlibEnable here so that the delay starts from when the func called ends
EndFunc ;==>hotkeys

Func Releaseme ()
    $HotOK = True
    AdlibDisable()
EndFunc

EDIT: added note about moving the position of AdlibEnable

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

if i press a hotkey, the only hotkeys there really are so far are {up}, {down}, {left}, {right}, can i disable all of the hotkeys for maybe 500 miliseconds, then reenable them? that is my main goal here.

Link to comment
Share on other sites

if i press a hotkey, the only hotkeys there really are so far are {up}, {down}, {left}, {right}, can i disable all of the hotkeys for maybe 500 miliseconds, then reenable them? that is my main goal here.

The example I gave does that, at least it stops the hot keys having any effect for 500 mS after any one is pressed.

There are other ways to do it but I would need to know what you didn't like about the way I've suggested already before I could suggest another.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

The example I gave does that, at least it stops the hot keys having any effect for 500 mS after any one is pressed.

There are other ways to do it but I would need to know what you didn't like about the way I've suggested already before I could suggest another.

yours confused me lol.

i keep rereading it, but im missing out on what is going on there.

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