Jump to content

two hotkey timers at once


Recommended Posts

hi all,

is it possible to use two timers for two different hot keys..

e.g. if hot key 6 press after hot key 5 then hot key 6 activate for 30 seconds. and during 30 sec if i press hotkey 7 then the timer of hot key 6 stop and hot key 7 timer starts working.

i want both timers to work individually at same time..

have a look at my script that may make you understand better.,

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Documents and Settings\saeed\My Documents\pak.ico
#AutoIt3Wrapper_outfile=new.exe
#AutoIt3Wrapper_Allow_Decompile=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <File.au3>
#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("5", "sevenup")
HotKeySet("6", "sevendown")
HotKeySet("7", "ndplaya")

Global $i = 0
Global $j = 0

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("", 640, 30, 0, 450, BitOR($WS_MINIMIZEBOX, $WS_GROUP, $WS_CLIPSIBLINGS, $WS_POPUP))
$label = GUICtrlCreateLabel("  coins: ", 0, 0, 200, 200)
GUICtrlSetColor($label, 0x00FF00)
GUICtrlSetFont($label, 18, 400, "", "Arial")
GUISetBkColor(0x0E1010)
WinMove($form1, "", 0, 450)
GUISetState(@SW_SHOW)
WinSetOnTop($Form1, "", 1)
#EndRegion ### END Koda GUI section ###

While 1
    
    Sleep(50)
WEnd

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If $hWnd = $Form1 And $iMsg = $WM_NCHITTEST Then
        $id = _API_DefWindowProc($hWnd, $iMsg, $iwParam, $ilParam)
        If $id = 2 Then;if it is the title handle
            Return 1;return the client handle
        Else
            Return $id;return the real handle
        EndIf
    EndIf

EndFunc   ;==>WM_NCHITTEST


Func _API_DefWindowProc($hWnd, $iMsg, $iwParam, $ilParam)
    Local $aResult

    $aResult = DllCall("User32.dll", "int", "DefWindowProc", "hwnd", $hWnd, "int", $iMsg, "int", $iwParam, "int", $ilParam)
    Return $aResult[0]
EndFunc   ;==>_API_DefWindowProc
   ;==>fuckoff

Func SevenDown()
    HotKeySet("6")
    If $i = 0 Then
        Send("0")
    EndIf
    ConsoleWrite("sdn" & @CRLF)
    If $i >= 1 Then;<----changed this so I could test it.
        Send("1")
        lod3Sleep(100)
        Send("1")
        lod3Sleep(100)
        Send("1")
    EndIf
    If $i > 0 Then
        $i -= 1
        SoundPlay(@WindowsDir & "\media\ir_end.wav")
        GUICtrlSetData($label, "  coins: " & $i)
        $s = lod3Sleep(30000)
    Else
        $i = 0
    EndIf
    
    ;HotKeySet("1")
    HotKeySet("6", "SevenDown")
    ConsoleWrite("Endsdn" & @CRLF)
EndFunc   ;==>SevenDown

Func lod3Sleep($lt)
    Opt("SendKeydelay", 200)
    $tin = TimerInit()

    While TimerDiff($tin) < $lt
        ;if NUm5 or 5 pressed
        HotKeySet("5", "sevenup")
        HotKeySet("7", "ndplaya")
    if _IsPressed("36") Then
        Send("1")
    EndIf
    WEnd


EndFunc   ;==>lod3Sleep

Func lod2Sleep($lt2)
    Opt("SendKeydelay", 200)
    $tin2 = TimerInit()

    While TimerDiff($tin2) < $lt2
        ;if NUm5 or 5 pressed
        HotKeySet("5", "sevenup")
        HotKeySet("6", "SevenDown")
    if _IsPressed("37") Then
        Send("2")
    EndIf
    WEnd


EndFunc  


Func sevenup()
    $i += 1
    SoundPlay(@WindowsDir & "\media\ringin.wav")
    GUICtrlSetData($label, "  coins: " & $i)
EndFunc   ;==>sevenup


Func ndplaya()
    HotKeySet("7")
    If $i = 0 Then
        Send("0")
    EndIf
    ConsoleWrite("sdn" & @CRLF)
    If $i >= 1 Then;<----changed this so I could test it.
        Send("2")
        lod2Sleep(100)
        Send("2")
        lod2Sleep(100)
        Send("2")
    EndIf
    If $i > 0 Then
        $i -= 1
        SoundPlay(@WindowsDir & "\media\ir_end.wav")
        GUICtrlSetData($label, "  coins: " & $i)
        $s = lod2Sleep(30000)
    Else
        $i = 0
    EndIf
    ;HotKeySet("1")
    HotKeySet("7", "ndplaya")
    ConsoleWrite("Endsdn" & @CRLF)
EndFunc   ;==>SevenDown

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Link to comment
Share on other sites

hi all,

is it possible to use two timers for two different hot keys..

e.g. if hot key 6 press after hot key 5 then hot key 6 activate for 30 seconds. and during 30 sec if i press hotkey 7 then the timer of hot key 6 stop and hot key 7 timer starts working.

i want both timers to work individually at same time..

have a look at my script that may make you understand better.,

Trim your reproducer down to just the issue at hand. Too much irrelevant stuff to pick through in there.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...