Sign in to follow this  
Followers 0
Elzie

using TimerInit()

2 posts in this topic

#1 ·  Posted (edited)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <UpDownConstants.au3>
#RequireAdmin

$Form1 = GUICreate("", 159, 180, 570, 388, -1, $WS_EX_TOPMOST)
$Button1 = GUICtrlCreateButton("Start", 40, 140, 75, 25)
$Input1 = GUICtrlCreateInput("1", 80, 8, 57, 24)
GUICtrlCreateUpdown($Input1)
$Input2 = GUICtrlCreateInput("2", 80, 40, 57, 24)
GUICtrlCreateUpdown($Input2)
$Input3 = GUICtrlCreateInput("3", 80, 72, 57, 24)
GUICtrlCreateUpdown($Input3)
$Input4 = GUICtrlCreateInput("4", 80, 104, 57, 24)
GUICtrlCreateUpdown($Input4)

$Checkbox1 = GUICtrlCreateCheckbox("F1", 24, 16, 57, 17)
$Checkbox2 = GUICtrlCreateCheckbox("F2", 24, 48, 57, 17)
$Checkbox3 = GUICtrlCreateCheckbox("F3", 24, 80, 57, 17)
$Checkbox4 = GUICtrlCreateCheckbox("F4", 24, 112, 57, 17)

GUISetState(@SW_SHOW)
Global $title = WinGetTitle("[CLASS:Notepad]", "")
HotKeySet("^q", "Terminate")

 $tim1 = TimerInit()
 $tim2 = TimerInit()
 $tim3 = TimerInit()
 $tim4 = TimerInit()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _help()
    EndSwitch
WEnd


Func _help()
    $on = 1
    While $on = 1

        $timed1 = TimerDiff($tim1)
        $timed2 = TimerDiff($tim2)
        $timed3 = TimerDiff($tim3)
        $timed4 = TimerDiff($tim4)


        If _IsChecked($Checkbox1) Then
            $a = GUICtrlRead($Input1) * 60000
            If $timed1 > $a Then
                Sleep(20)
                ControlSend($title, "", "", "{H}")
                $tim1 = TimerInit()

            EndIf
        EndIf
        Sleep(20)
        If _IsChecked($Checkbox2) Then
            $b = GUICtrlRead($Input2) * 60000
            If $timed1 > $b Then
                Sleep(20)
                ControlSend($title, "", "", "{E}")
                $tim2 = TimerInit()

            EndIf
        EndIf

        If _IsChecked($Checkbox3) Then
           $c = GUICtrlRead($Input3) * 60000
            If $timed1 > $c Then
                Sleep(20)
                ControlSend($title, "", "", "{L}")
                Sleep(20)
                $tim3 = TimerInit()

            EndIf
        EndIf

        If _IsChecked($Checkbox4) Then
          $d = GUICtrlRead($Input4) * 60000
            If $timed1 > $d Then
                Sleep(20)
                ControlSend($title, "", "", "{P}")
                $tim4 = TimerInit()

            EndIf
        EndIf

    WEnd
EndFunc   ;==>_buff

Func Terminate()
    MsgBox(0, "", "Have A Nice Day")
    Exit 0
EndFunc   ;==>Terminate


Func _IsChecked($idControlID);===================== check box ======================
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

If I set the time as 1 for all the inputs it works but if i change the input it stops working and only prints H.

I have looked at TimerInit() and have read all I found but still having truble please HELP

Thanks

Elzie

Edited by Elzie

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This seems a very slopy way to do it.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <UpDownConstants.au3>
#RequireAdmin

$Form1 = GUICreate("", 159, 180, 570, 388, -1, $WS_EX_TOPMOST)
$Button1 = GUICtrlCreateButton("Start", 40, 140, 75, 25)
$Input1 = GUICtrlCreateInput("1", 80, 8, 57, 24)
GUICtrlCreateUpdown($Input1)
$Input2 = GUICtrlCreateInput("2", 80, 40, 57, 24)
GUICtrlCreateUpdown($Input2)
$Input3 = GUICtrlCreateInput("3", 80, 72, 57, 24)
GUICtrlCreateUpdown($Input3)
$Input4 = GUICtrlCreateInput("4", 80, 104, 57, 24)
GUICtrlCreateUpdown($Input4)

$Checkbox1 = GUICtrlCreateCheckbox("F1", 24, 16, 57, 17)
$Checkbox2 = GUICtrlCreateCheckbox("F2", 24, 48, 57, 17)
$Checkbox3 = GUICtrlCreateCheckbox("F3", 24, 80, 57, 17)
$Checkbox4 = GUICtrlCreateCheckbox("F4", 24, 112, 57, 17)

GUISetState(@SW_SHOW)
Global $title = WinGetTitle("[CLASS:Notepad]", "")
HotKeySet("^q", "Terminate")

Global $tim1 = TimerInit()
Global $tim2 = TimerInit()
Global $tim3 = TimerInit()
Global $tim4 = TimerInit()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _timer()

    EndSwitch
WEnd

Func _timer()
    $on = 1
    While $on = 1
        $timed1 = TimerDiff($tim1)
        $timed2 = TimerDiff($tim2)
        $timed3 = TimerDiff($tim3)
        $timed4 = TimerDiff($tim4)

       $a = GUICtrlRead($Input1) * 60000
       $b = GUICtrlRead($Input2) * 60000
       $c = GUICtrlRead($Input3) * 60000
       $d = GUICtrlRead($Input4) * 60000

        If $timed1 > $a Then
            Call("_f1")
        EndIf

        If $timed2 > $b Then
            Call("_f2")
        EndIf

        If $timed3 > $c Then
            Call("_f3")
        EndIf

        If $timed4 > $d Then
            Call("_f4")
        EndIf
        WEnd
    EndFunc   ;==>_timer


Func _f1()
            If _IsChecked($Checkbox1) Then
                ControlSend($title, "", "", "{H}")
                $tim1 = TimerInit()
            EndIf
            Call("_timer")
EndFunc   ;==>_buff1

Func _f2()
        If _IsChecked($Checkbox2) Then
                Sleep(20)
                ControlSend($title, "", "", "{E}")
                $tim2 = TimerInit()
        EndIf
        Call("_timer")
EndFunc   

Func _f3()
        If _IsChecked($Checkbox3) Then
                Sleep(20)
                ControlSend($title, "", "", "{L}")
                $tim3 = TimerInit()
        EndIf
        Call("_timer")
EndFunc   ;==>_buff3

Func _f4()
        If _IsChecked($Checkbox4) Then
                Sleep(20)
                ControlSend($title, "", "", "{P}")
                $tim4 = TimerInit()
        EndIf
        Call("_timer")
EndFunc 


Func Terminate()
    MsgBox(0, "", "Have A Nice Day")
    Exit 0
EndFunc   ;==>Terminate


Func _IsChecked($idControlID);===================== check box ======================
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

O well

Elzie

Edited by Elzie

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