Jump to content

holding hotkey calls func rapidedly, can I change this?


 Share

Recommended Posts

when I hold NUMPAD1 the script calls func over and over again rapidedly, is there a way for me to change this? for example if I hold down NUMPAD1 it cals func only 1 time and then if I press NUMPAD1 it calls the same func again (but only once as well)?

here's the script:

HotKeySet("{NUMPAD1}", "func1")

HotKeySet("{NUMPAD0}", "_exit")

Global $iCC

Func func1()

$iCC += 1

ToolTip('You have called func1 ' & $iCC & ' times.', 0, 0)

Sleep(10)

EndFunc

func _exit()

Exit

EndFunc

while 1

sleep(1)

WEnd

Link to comment
Share on other sites

when I hold NUMPAD1 the script calls func over and over again rapidedly, is there a way for me to change this? for example if I hold down NUMPAD1 it cals func only 1 time and then if I press NUMPAD1 it calls the same func again (but only once as well)?

here's the script:

HotKeySet("{NUMPAD1}", "func1")

HotKeySet("{NUMPAD0}", "_exit")

Global $iCC

Func func1()

$iCC += 1

ToolTip('You have called func1 ' & $iCC & ' times.', 0, 0)

Sleep(10)

EndFunc

func _exit()

Exit

EndFunc

while 1

sleep(1)

WEnd

#include <misc.au3>

$H1reset = False
$H2reset = false
HotKeySet("{NUMPAD1}", "func1")
HotKeySet("{NUMPAD0}", "_exit")

Global $iCC

Func func1()
    HotKeySet("{NUMPAD1}")
    $H1reset = true
$iCC += 1
ToolTip('You have called func1 ' & $iCC & ' times.', 0, 0)
Sleep(10)
EndFunc

func _exit()
Exit
EndFunc

while 1
if $H1reset and not _Ispressed("61") Then
    HotKeySet("{NUMPAD1}", "func1")
    $H1reset = false
    
EndIf
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

Along the same Lines as Martin

#Include <Misc.au3>
HotKeySet("{NUMPAD1}", "func1")
HotKeySet("{NUMPAD0}", "_exit")

Global $iCC

while 1
    sleep(100)
WEnd

Func func1()
    $iCC += 1
    ToolTip('You have called func1 ' & $iCC & ' times.', 0, 0)
    If _IsPressed(61) Then 
        Do 
            Sleep(100)
        Until NOT _IsPressed(61)
    EndIf
EndFunc

func _exit()
    Exit
EndFunc
Link to comment
Share on other sites

Along the same Lines as Martin

#Include <Misc.au3>
HotKeySet("{NUMPAD1}", "func1")
HotKeySet("{NUMPAD0}", "_exit")

Global $iCC

while 1
    sleep(100)
WEnd

Func func1()
    $iCC += 1
    ToolTip('You have called func1 ' & $iCC & ' times.', 0, 0)
    If _IsPressed(61) Then 
        Do 
            Sleep(100)
        Until NOT _IsPressed(61)
    EndIf
EndFunc

func _exit()
    Exit
EndFunc

That doesn't work Paulie, you need to stop the HotKey from working before you wait for the key to be released.

Func func1()
       HotKeySet("{NUMPAD1}")
    $iCC += 1
    ToolTip('You have called func1 ' & $iCC & ' times.', 0, 0)
    while _IsPressed(61) 
            Sleep(100)
    wend
     HotKeySet("{NUMPAD1}", "func1")
EndFunc
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

You are right, missed that.

#Include <Misc.au3>
HotKeySet("{NUMPAD1}", "func1")
HotKeySet("{NUMPAD0}", "_exit")

Global $iCC=0

while 1
    sleep(100)
WEnd

Func func1()
    $iCC += 1
    ToolTip('You have called func1 ' & $iCC & ' times.', 0, 0)
    If _IsPressed(61) Then
    HotKeySet(@HotKeyPressed)
        Do
            Sleep(100)
        Until NOT _IsPressed(61)
    HotKeySet(@HotKeyPressed,"Func1")
    EndIf
EndFunc

func _exit()
    Exit
EndFunc
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...