Sign in to follow this  
Followers 0
Dgameman1

TimerInt() help

4 posts in this topic

So, I have two textboxes and one combobox and a start button.

I am able to select a letter from the combobox and put a delay in the textbox, press start and it works.

I am ALSO able to select a letter from the 2nd combo-box and put a delay in the 2nd text-box, press start and it works.

I am NOT able to select a letter from the 1st AND the 2nd combo-box and put a delay in the 1st AND 2nd text-box.

It only runs what it's the first pair.

The goal is to run them simultaionusly.

I read that I need to use timerint().

help please?

What's wrong with my code.

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d



;
; ----------------------------------------------------------------------------
;   AutoIt Version: 3.3.0.0
;   Author: Dgameman1 
; ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

GUICreate("DG v0.2", 335, 100)

GUISetState(@SW_SHOW)
GUICtrlCreateLabel("Auto Words", 270, 10)

GUICtrlCreateLabel("Word1", 8, 30)
$key1 = GUICtrlCreateCombo("", 40, 27, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time1 = GUICtrlCreateInput("Delay", 90, 27, 35)


GUICtrlCreateLabel("Word2", 8, 60)
$key2 = GUICtrlCreateCombo("", 40, 54, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time2 = GUICtrlCreateInput("Delay", 90, 54, 35)


$startbutton = GUICtrlCreateButton("Start", 265, 70, 60)

While 1
    $msg = GUIGetMsg()
    
    Select
        
        Case $msg = $startbutton
                
                $send1 = GUICtrlRead($key1)
                $sleep1 = GUICtrlRead($time1)
                $send2 = GUICtrlRead($key2)
                $sleep2 = GUICtrlRead($time2)
                
                $TimeStart1 = TimerInit()
                                        $TimeStart2 = TimerInit()
            While 1         

                    $TimeElapsed1 = TimerDiff($TimeStart1)
                                        $TimeElapsed2 = TimerDiff($TimeStart2)
    If $TimeElapsed1 >= $sleep1 Then
            If $TimeElapsed2 >= $sleep2 Then
                ControlSend("[CLASS:Notepad]", "", "", $send1)
                                ControlSend("[CLASS:Notepad]", "", "", $send2)
                        $TimeStart1 = TimerInit()
                                                $TimeStart2 = TimerInit()


                EndIf
                EndIf
            WEnd
            
        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete()
            ExitLoop
            
    EndSelect
        
    WEnd
    
    
    ;;;;;;;;;;;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

Share this post


Link to post
Share on other sites



You mean this?

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d



;
; ----------------------------------------------------------------------------
;   AutoIt Version: 3.3.0.0
;   Author: Dgameman1
; ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

GUICreate("DG v0.2", 335, 100)

GUISetState(@SW_SHOW)
GUICtrlCreateLabel("Auto Words", 270, 10)

GUICtrlCreateLabel("Word1", 8, 30)
$key1 = GUICtrlCreateCombo("", 40, 27, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time1 = GUICtrlCreateInput("Delay", 90, 27, 35)


GUICtrlCreateLabel("Word2", 8, 60)
$key2 = GUICtrlCreateCombo("", 40, 54, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time2 = GUICtrlCreateInput("Delay", 90, 54, 35)


$startbutton = GUICtrlCreateButton("Start", 265, 70, 60)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $startbutton

            $send1 = GUICtrlRead($key1)
            $sleep1 = GUICtrlRead($time1)
            $send2 = GUICtrlRead($key2)
            $sleep2 = GUICtrlRead($time2)

            $TimeStart1 = TimerInit()
            $TimeStart2 = TimerInit()
            While 1
                $TimeElapsed1 = TimerDiff($TimeStart1)
                $TimeElapsed2 = TimerDiff($TimeStart2)
                If $TimeElapsed1 >= $sleep1 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send1)
                    $TimeStart1 = TimerInit()
                EndIf
                If $TimeElapsed2 >= $sleep2 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send2)
                    $TimeStart2 = TimerInit()
                EndIf
            WEnd

        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete()
            ExitLoop

    EndSelect

WEnd


;;;;;;;;;;;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc   ;==>ShowMessage

P.S. update your Autoit/ 3.3.0.0 is two years old.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d



;
; ----------------------------------------------------------------------------
;   AutoIt Version: 3.3.0.0
;   Author: Dgameman1 
; ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

GUICreate("DG v0.2", 335, 100)

GUISetState(@SW_SHOW)
GUICtrlCreateLabel("Auto Words", 270, 10)

GUICtrlCreateLabel("Word1", 8, 30)
$key1 = GUICtrlCreateCombo("", 40, 27, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time1 = GUICtrlCreateInput("Delay", 90, 27, 35)


GUICtrlCreateLabel("Word2", 8, 60)
$key2 = GUICtrlCreateCombo("", 40, 54, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time2 = GUICtrlCreateInput("Delay", 90, 54, 35)


$startbutton = GUICtrlCreateButton("Start", 265, 70, 60)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $startbutton
            $send1 = GUICtrlRead($key1)
            $sleep1 = GUICtrlRead($time1)*1000 ;Add *60 for Minute delay
            $send2 = GUICtrlRead($key2)
            $sleep2 = GUICtrlRead($time2)*1000 ;Add *60 for Minute delay
            $TimeStart1 = TimerInit()
            $TimeStart2 = TimerInit()
            While 1         
                $TimeElapsed1 = TimerDiff($TimeStart1)
                $TimeElapsed2 = TimerDiff($TimeStart2)
                If $TimeElapsed1>= $sleep1 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send1)
                    $TimeStart1 = TimerInit()
                EndIf
                If $TimeElapsed2 >= $sleep2 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send2)
                    $TimeStart2 = TimerInit()
                EndIf
            WEnd
        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete()
            ExitLoop            
    EndSelect
WEnd
    
    
    ;;;;;;;;;;;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

Edited by rogue5099

Share this post


Link to post
Share on other sites

You mean this?

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d



;
; ----------------------------------------------------------------------------
;   AutoIt Version: 3.3.0.0
;   Author: Dgameman1
; ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

GUICreate("DG v0.2", 335, 100)

GUISetState(@SW_SHOW)
GUICtrlCreateLabel("Auto Words", 270, 10)

GUICtrlCreateLabel("Word1", 8, 30)
$key1 = GUICtrlCreateCombo("", 40, 27, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time1 = GUICtrlCreateInput("Delay", 90, 27, 35)


GUICtrlCreateLabel("Word2", 8, 60)
$key2 = GUICtrlCreateCombo("", 40, 54, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time2 = GUICtrlCreateInput("Delay", 90, 54, 35)


$startbutton = GUICtrlCreateButton("Start", 265, 70, 60)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $startbutton

            $send1 = GUICtrlRead($key1)
            $sleep1 = GUICtrlRead($time1)
            $send2 = GUICtrlRead($key2)
            $sleep2 = GUICtrlRead($time2)

            $TimeStart1 = TimerInit()
            $TimeStart2 = TimerInit()
            While 1
                $TimeElapsed1 = TimerDiff($TimeStart1)
                $TimeElapsed2 = TimerDiff($TimeStart2)
                If $TimeElapsed1 >= $sleep1 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send1)
                    $TimeStart1 = TimerInit()
                EndIf
                If $TimeElapsed2 >= $sleep2 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send2)
                    $TimeStart2 = TimerInit()
                EndIf
            WEnd

        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete()
            ExitLoop

    EndSelect

WEnd


;;;;;;;;;;;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc   ;==>ShowMessage

P.S. update your Autoit/ 3.3.0.0 is two years old.

Thank you sooo much

Oh and Will do =]

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