Sign in to follow this  
Followers 0
mini

[SOLVED]Help with CheckBox PAUSE not DELAY... [SOLVED]

10 posts in this topic

#1 ·  Posted (edited)

Hello all once again.

I've been away, but i started a new program, sow today i found how to use checkox's 1, 2 and 3, if they're Tick.

Every one of them will have a func in it, and a "delay"/"Pause" between them, for example, they will be "stopped" for 1h30m.

Now here's the problem, during that period, if i want to change anything on the Editbox's or Inputbox's, the GUI dont stop if i press the STOP button.

How can i have control of the GUI, between of the execution Checkbox1 to checkbox2???

Here's a sample of my code, hope you guys can help me with it.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 373, 305)
$traker1 = GUICtrlCreateCheckbox("Tarker 1", 16, 16, 97, 17)
$traker2 = GUICtrlCreateCheckbox(" Traker 2", 136, 16, 97, 17)
$traker3 = GUICtrlCreateCheckbox("Traker3", 264, 16, 97, 17)
$Button_Start = GUICtrlCreateButton("Start", 75, 270, 50, 25)
$Button_Stop = GUICtrlCreateButton("Stop", 130, 270, 50, 25)
GUISetState(@SW_SHOW)

Dim $Start = 0

While 1 ;Code
    Sleep(10)
     $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -3
            _Check4CLOSEClicked()
                    Case $Button_Start
            _Check4Start()
                    Case $Button_Stop
            _Check4Stop()   
        EndSwitch
        
If $Start <> 1 Then
Else    
    if guictrlread($traker1) = 1 then
            MsgBox(0, "", "traker 1 ")
            sleep(5000)
        EndIf
    if guictrlread($traker2) = 1 then
            MsgBox(0, "", "traker 2 ")
            sleep (5000)
        EndIf
    if guictrlread($traker3) = 1 then
            MsgBox(0, "", "traker 3 ")
            sleep (5000)
        EndIf

EndIf
Sleep(10)
WEnd


Func _Check4Start()
    $Start = 1
    TrayTip("Start","Started", 5, 0)
EndFunc
;<==================================================================================
Func _Check4Stop()
    $Start = 0
    TrayTip("Stop","Stoped", 5, 0)
EndFunc
;<==================================================================================
Edited by mini

Share this post


Link to post
Share on other sites



mini,

Use TimerInit and TimerDiff instead of Sleep - that way you can still look for your button presses while waiting:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 373, 305)
$traker1 = GUICtrlCreateCheckbox("Tarker 1", 16, 16, 97, 17)
$traker2 = GUICtrlCreateCheckbox(" Traker 2", 136, 16, 97, 17)
$traker3 = GUICtrlCreateCheckbox("Traker3", 264, 16, 97, 17)
$Button_Start = GUICtrlCreateButton("Start", 75, 270, 50, 25)
$Button_Stop = GUICtrlCreateButton("Stop", 130, 270, 50, 25)
GUISetState(@SW_SHOW)

Dim $Start = 0

While 1 ;Code

    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Button_Stop
            _Check4Stop()
        Case $Button_Start
            _Check4Start()
    EndSwitch

    If $Start = 1 Then
        If GUICtrlRead($traker1) = 1 Then
            MsgBox(0, "", "traker 1 ")
             _Delayer()
        EndIf
        If GUICtrlRead($traker2) = 1 Then
            MsgBox(0, "", "traker 2 ")
             _Delayer()
        EndIf
        If GUICtrlRead($traker3) = 1 Then
            MsgBox(0, "", "traker 3 ")
             _Delayer()
        EndIf
    EndIf

WEnd

Func _Delayer()

    $iBegin = TimerInit() ; Get a timestamp
    Do ; Loop until
        Switch GUIGetMsg() ; Check the valid events (no point in looking for Start as we are already running!) 
            Case -3
                Exit
            Case $Button_Stop
                _Check4Stop()
                ExitLoop
        EndSwitch
    Until TimerDiff($iBegin) > 5000 ; Check if 5 secs have elapsed

EndFunc

Func _Check4Start()
    $Start = 1
    TrayTip("Start", "Started", 5, 0)
EndFunc   ;==>_Check4Start
;<==================================================================================
Func _Check4Stop()
    $Start = 0
    TrayTip("Stop", "Stopped", 5, 0)
EndFunc   ;==>_Check4Stop
;<==================================================================================

A couple of other points:

1. You do not need Sleep statements in a loop if there is a GUIGetMsg in the loop - the GUIGetMsg idles the CPU automatically.

- This second point goes for anyone reading as well! -

2. If you posting code, please make sure all the functions are included. It is a pain having to write additional code just to make some example code work before trying to debug it. And please learn to use Tidy to get your script in a readable form before posting - having random indentations does not make for easy reading! :(

I hope the script now does what you want - ask again if not. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

And please learn to use Tidy to get your script in a readable form before posting - having random indentations does not make for easy reading!

How do i do this??? or what do you mean?!? is it marking what will the functions do??

well with your example, i made my gui to work perfectly.

I post always some Example guys, because i try to implement all the suggestions on my GUY, sow like that i can understand perfectly what the code is doing.

Well, its not a good justification, but since I'm not a good programmer like you know, i think its a good way for me to find how to do it.

Thx again for your replay M23

Share this post


Link to post
Share on other sites

mini,

Tidy is a helper app written by Jos (one of the Devs) which, if you use the full SciTE4AutoIt3 package, you can find under the <Tools> menu - or you can press Ctrl-T. It tidies your script - makes all the indentations match (very helpful for spotting missing Next, WEnd, etc) removes added blank lines, and lots of other little things. Basically it make your script look much more professional - and it is a boon to those of us who are asked to debug scripts. :)

If you do not have the full SciTE4AutoIt3 package, I strongly recommend it - you get a lot of extra goodies to help you when you are coding in AutoIt. You can download it from here. I have yet to meet anyone who has regretted doing so. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

WOW just installed, it have a real new things =P

Its seams like a new all AutoIT =P

Bahhh, i need to learn again jejejeje

Thanks M23 for this tip

(BTW, i finished my program, till i remember what it can do more)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$sINI = @ScriptDir & "\"
$Form1 = GUICreate("Sbot Training Swapper", 373, 305)
$Button_Start = GUICtrlCreateButton("Start", 75, 270, 50, 25)
$Button_Stop = GUICtrlCreateButton("Stop", 130, 270, 50, 25)
$Button_Search = GUICtrlCreateButton("Search", 20, 270, 50, 25)
$Button_HideSbot = GUICtrlCreateButton("Hide Sbot", 185, 270, 60, 25)
$Button_ShowSbot = GUICtrlCreateButton("Show Sbot", 250, 270, 60, 25)
$training1 = GUICtrlCreateCheckbox("Training place 1", 16, 16, 97, 17)
$training2 = GUICtrlCreateCheckbox(" Training place 2", 136, 16, 97, 17)
$training3 = GUICtrlCreateCheckbox("Training place 3", 264, 16, 97, 17)
$Input1A = GUICtrlCreateInput("", 8, 48, 105, 21)
$Input2A = GUICtrlCreateInput("", 8, 88, 105, 21)
$Input3A = GUICtrlCreateInput("", 8, 128, 105, 21)
$Input4A = GUICtrlCreateInput("", 8, 168, 105, 21)
$Input1B = GUICtrlCreateInput("", 136, 48, 105, 21)
$Input2B = GUICtrlCreateInput("", 136, 88, 105, 21)
$Input3B = GUICtrlCreateInput("", 136, 128, 105, 21)
$Input4B = GUICtrlCreateInput("", 136, 168, 105, 21)
$Input1C = GUICtrlCreateInput("", 264, 48, 105, 21)
$Input2C = GUICtrlCreateInput("", 264, 88, 105, 21)
$Input3C = GUICtrlCreateInput("", 264, 128, 105, 21)
$Input4C = GUICtrlCreateInput("", 264, 168, 105, 21)
$Input_Sbot_Name = GUICtrlCreateInput("", 73, 200, 289, 21)
$Label1 = GUICtrlCreateLabel("Sbot Name", 13, 205, 57, 17)
$Label2 = GUICtrlCreateLabel("Time to switch traning place, time in ms, 3 600 000ms = 1H", 15, 225, 289, 17)
$Sleep_Time = GUICtrlCreateInput("", 250, 240, 60, 21)
GUISetState(@SW_SHOW)

Dim $Start = 0

While 1 ;Code

    Switch GUIGetMsg()
        Case -3
            _Check4CLOSEClicked()
        Case $Button_Stop
            _Check4Stop()
        Case $Button_Start
            _Check4Start()
        Case $Button_Search
            _Check4Search()
    EndSwitch

    If $Start = 1 Then
        If GUICtrlRead($training1) = 1 Then
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1A))
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", GUICtrlRead($Input2A))
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", GUICtrlRead($Input3A))
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", GUICtrlRead($Input4A))
            WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Save settings", "[CLASS:Button; INSTANCE:192]", "{SPACE 5}"))
            WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Stop training", "[CLASS:Button; INSTANCE:195]", "{SPACE 5}"))
            WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:194]", "{SPACE 5}"))
            _Delayer()
        EndIf
        If GUICtrlRead($training2) = 1 Then
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1A))
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", GUICtrlRead($Input2A))
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", GUICtrlRead($Input3A))
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", GUICtrlRead($Input4A))
            WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Save settings", "[CLASS:Button; INSTANCE:192]", "{SPACE 5}"))
            WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Stop training", "[CLASS:Button; INSTANCE:195]", "{SPACE 5}"))
            WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:194]", "{SPACE 5}"))
            _Delayer()
        EndIf
        If GUICtrlRead($training3) = 1 Then
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1A))
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", GUICtrlRead($Input2A))
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", GUICtrlRead($Input3A))
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{DEL 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{BS 10}")
            ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", GUICtrlRead($Input4A))
            WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Save settings", "[CLASS:Button; INSTANCE:192]", "{SPACE 5}"))
            WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Stop training", "[CLASS:Button; INSTANCE:195]", "{SPACE 5}"))
            WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:194]", "{SPACE 5}"))
            _Delayer()
        EndIf
    EndIf

WEnd
;<==================================================================================
Func _Delayer()

    $iBegin = TimerInit() ; Get a timestamp
    Do ; Loop until
        Switch GUIGetMsg() ; Check the valid events (no point in looking for Start as we are already running!)
            Case -3
                Exit
            Case $Button_Stop
                _Check4Stop()
                ExitLoop
        EndSwitch
    Until TimerDiff($iBegin) > GUICtrlRead($Sleep_Time) ; Check if 5 secs have elapsed

EndFunc   ;==>_Delayer
;<==================================================================================
Func _Check4Search()
    GUICtrlSetData($Input1A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input1A", "Coor. X"))
    GUICtrlSetData($Input2A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input2A", "Coor. Y"))
    GUICtrlSetData($Input3A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input3A", "Coor. Z"))
    GUICtrlSetData($Input4A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input4A", "Range"))
    GUICtrlSetData($Input1B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input1B", "Coor. X"))
    GUICtrlSetData($Input2B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input2B", "Coor. Y"))
    GUICtrlSetData($Input3B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input3B", "Coor. Z"))
    GUICtrlSetData($Input4B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input4B", "Range"))
    GUICtrlSetData($Input1C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input1C", "Coor. X"))
    GUICtrlSetData($Input2C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input2C", "Coor. Y"))
    GUICtrlSetData($Input3C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input3C", "Coor. Z"))
    GUICtrlSetData($Input4C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input4C", "Range"))
    GUICtrlSetData($Input_Sbot_Name, IniRead("Sbot Training Swapper.ini", "$Input_Sbot_Name", "$Input_Sbot_Name", "[CHAR NAME] SBot v1.66 (C)2008,2009 by bot-cave.net"))
    GUICtrlSetData($Sleep_Time, IniRead("Sbot Training Swapper.ini", "$Sleep_Time", "$Sleep_Time", "3600000"))
EndFunc   ;==>_Check4Search
;<==================================================================================
Func _Check4HideSbot()
    WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_HIDE)
EndFunc   ;==>_Check4HideSbot
;<==================================================================================
Func _Check4ShowSbot()
    WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_SHOW)
EndFunc   ;==>_Check4ShowSbot
;<==================================================================================
Func _Check4Start()
    $Start = 1
    TrayTip("", "Started", 3, 0)
    IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input1A", GUICtrlRead($Input1A))
    IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input2A", GUICtrlRead($Input2A))
    IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input3A", GUICtrlRead($Input3A))
    IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input4A", GUICtrlRead($Input4A))
    IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input1B", GUICtrlRead($Input1B))
    IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input2B", GUICtrlRead($Input2B))
    IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input3B", GUICtrlRead($Input3B))
    IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input4B", GUICtrlRead($Input4B))
    IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input4C", GUICtrlRead($Input1C))
    IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input4C", GUICtrlRead($Input2C))
    IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input4C", GUICtrlRead($Input3C))
    IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input4C", GUICtrlRead($Input4C))
    IniWrite("Sbot Training Swapper.ini", "$Input_Sbot_Name", "$Input_Sbot_Name", GUICtrlRead($Input_Sbot_Name))
    IniWrite("Sbot Training Swapper.ini", "$Sleep_Time", "$Sleep_Time", GUICtrlRead($Sleep_Time))
EndFunc   ;==>_Check4Start
;<==================================================================================
Func _Check4Stop()
    $Start = 0
    TrayTip("", "Stopped", 3, 0)
EndFunc   ;==>_Check4Stop
;<==================================================================================
Func _Check4CLOSEClicked();Exit
    Opt("WinTitleMatchMode", 2) ; Match substring
    WinSetTrans("Sbot Training Swapper", "", 0)
    $answer = MsgBox(36, "Warning", "Close??", 8)
    WinSetTrans("Sbot Training Swapper", "", 255)
    If $answer = 6 Then
        Exit
    EndIf
EndFunc   ;==>_Check4CLOSEClicked
;<==================================================================================
Edited by mini

Share this post


Link to post
Share on other sites

Well guys, i was mistaken by stating that the program was working...

In fact in the "test" program it really works, but implementing the rest of my code it does not work.

If I tick all CheckBox's, it will only use the 1st one...

what can i do to fix this :(

Sorry M23, i was thinking that it was working fine :) :)

Share this post


Link to post
Share on other sites

mini,

It works for me - why do you think it is not working? :(

However, I did notice a problem - at the moment you run all the trg programmes even if you press "Stop" after programme 1 or 2. You need to change your code like this (look for the <<<<<<< lines):

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$sINI = @ScriptDir & "\"
$Form1 = GUICreate("Sbot Training Swapper", 373, 305)
$Button_Start = GUICtrlCreateButton("Start", 75, 270, 50, 25)
$Button_Stop = GUICtrlCreateButton("Stop", 130, 270, 50, 25)
$Button_Search = GUICtrlCreateButton("Search", 20, 270, 50, 25)
$Button_HideSbot = GUICtrlCreateButton("Hide Sbot", 185, 270, 60, 25)
$Button_ShowSbot = GUICtrlCreateButton("Show Sbot", 250, 270, 60, 25)
$training1 = GUICtrlCreateCheckbox("Training place 1", 16, 16, 97, 17)
$training2 = GUICtrlCreateCheckbox(" Training place 2", 136, 16, 97, 17)
$training3 = GUICtrlCreateCheckbox("Training place 3", 264, 16, 97, 17)
$Input1A = GUICtrlCreateInput("", 8, 48, 105, 21)
$Input2A = GUICtrlCreateInput("", 8, 88, 105, 21)
$Input3A = GUICtrlCreateInput("", 8, 128, 105, 21)
$Input4A = GUICtrlCreateInput("", 8, 168, 105, 21)
$Input1B = GUICtrlCreateInput("", 136, 48, 105, 21)
$Input2B = GUICtrlCreateInput("", 136, 88, 105, 21)
$Input3B = GUICtrlCreateInput("", 136, 128, 105, 21)
$Input4B = GUICtrlCreateInput("", 136, 168, 105, 21)
$Input1C = GUICtrlCreateInput("", 264, 48, 105, 21)
$Input2C = GUICtrlCreateInput("", 264, 88, 105, 21)
$Input3C = GUICtrlCreateInput("", 264, 128, 105, 21)
$Input4C = GUICtrlCreateInput("", 264, 168, 105, 21)
$Input_Sbot_Name = GUICtrlCreateInput("", 73, 200, 289, 21)
$Label1 = GUICtrlCreateLabel("Sbot Name", 13, 205, 57, 17)
$Label2 = GUICtrlCreateLabel("Time to switch traning place, time in ms, 3 600 000ms = 1H", 15, 225, 289, 17)
$Sleep_Time = GUICtrlCreateInput("", 250, 240, 60, 21)
GUISetState(@SW_SHOW)

Dim $Start = 0

While 1 ;Code

    Switch GUIGetMsg()
        Case -3
            _Check4CLOSEClicked()
        Case $Button_Stop
            _Check4Stop()
        Case $Button_Start
            _Check4Start()
        Case $Button_Search
            _Check4Search()
    EndSwitch

    If $Start = 1 And GUICtrlRead($training1) = 1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        ConsoleWrite("Trg1" & @CRLF)
        #cs
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1A))
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", GUICtrlRead($Input2A))
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", GUICtrlRead($Input3A))
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", GUICtrlRead($Input4A))
        WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Save settings", "[CLASS:Button; INSTANCE:192]", "{SPACE 5}"))
        WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Stop training", "[CLASS:Button; INSTANCE:195]", "{SPACE 5}"))
        WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:194]", "{SPACE 5}"))
        #ce
        _Delayer()

    EndIf
    If $Start = 1 And GUICtrlRead($training2) = 1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        ConsoleWrite("Trg2" & @CRLF)
        #cs
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1A))
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", GUICtrlRead($Input2A))
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", GUICtrlRead($Input3A))
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", GUICtrlRead($Input4A))
        WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Save settings", "[CLASS:Button; INSTANCE:192]", "{SPACE 5}"))
        WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Stop training", "[CLASS:Button; INSTANCE:195]", "{SPACE 5}"))
        WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:194]", "{SPACE 5}"))
        #ce
        _Delayer()
    EndIf
    If $Start = 1 And GUICtrlRead($training3) = 1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        ConsoleWrite("Trg3" & @CRLF)
        #cs
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1A))
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", GUICtrlRead($Input2A))
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", GUICtrlRead($Input3A))
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{DEL 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{BS 10}")
        ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", GUICtrlRead($Input4A))
        WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Save settings", "[CLASS:Button; INSTANCE:192]", "{SPACE 5}"))
        WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Stop training", "[CLASS:Button; INSTANCE:195]", "{SPACE 5}"))
        WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:194]", "{SPACE 5}"))
        #ce
        _Delayer()
    EndIf

WEnd
;<==================================================================================
Func _Delayer()

    $iBegin = TimerInit() ; Get a timestamp
    Do ; Loop until
        Switch GUIGetMsg() ; Check the valid events (no point in looking for Start as we are already running!)
            Case -3
                Exit
            Case $Button_Stop
                _Check4Stop()
                ExitLoop
        EndSwitch
    Until TimerDiff($iBegin) > GUICtrlRead($Sleep_Time) ; Check if 5 secs have elapsed

EndFunc   ;==>_Delayer
;<==================================================================================
Func _Check4Search()
    GUICtrlSetData($Input1A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input1A", "Coor. X"))
    GUICtrlSetData($Input2A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input2A", "Coor. Y"))
    GUICtrlSetData($Input3A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input3A", "Coor. Z"))
    GUICtrlSetData($Input4A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input4A", "Range"))
    GUICtrlSetData($Input1B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input1B", "Coor. X"))
    GUICtrlSetData($Input2B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input2B", "Coor. Y"))
    GUICtrlSetData($Input3B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input3B", "Coor. Z"))
    GUICtrlSetData($Input4B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input4B", "Range"))
    GUICtrlSetData($Input1C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input1C", "Coor. X"))
    GUICtrlSetData($Input2C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input2C", "Coor. Y"))
    GUICtrlSetData($Input3C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input3C", "Coor. Z"))
    GUICtrlSetData($Input4C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input4C", "Range"))
    GUICtrlSetData($Input_Sbot_Name, IniRead("Sbot Training Swapper.ini", "$Input_Sbot_Name", "$Input_Sbot_Name", "[CHAR NAME] SBot v1.66 ©2008,2009 by bot-cave.net"))
    GUICtrlSetData($Sleep_Time, IniRead("Sbot Training Swapper.ini", "$Sleep_Time", "$Sleep_Time", "3600000"))
EndFunc   ;==>_Check4Search
;<==================================================================================
Func _Check4HideSbot()
    WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_HIDE)
EndFunc   ;==>_Check4HideSbot
;<==================================================================================
Func _Check4ShowSbot()
    WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_SHOW)
EndFunc   ;==>_Check4ShowSbot
;<==================================================================================
Func _Check4Start()
    $Start = 1
    ConsoleWrite("Starting!" & @CRLF)
    TrayTip("", "Started", 3, 0)
    IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input1A", GUICtrlRead($Input1A))
    IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input2A", GUICtrlRead($Input2A))
    IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input3A", GUICtrlRead($Input3A))
    IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input4A", GUICtrlRead($Input4A))
    IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input1B", GUICtrlRead($Input1B))
    IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input2B", GUICtrlRead($Input2B))
    IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input3B", GUICtrlRead($Input3B))
    IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input4B", GUICtrlRead($Input4B))
    IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input4C", GUICtrlRead($Input1C))
    IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input4C", GUICtrlRead($Input2C))
    IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input4C", GUICtrlRead($Input3C))
    IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input4C", GUICtrlRead($Input4C))
    IniWrite("Sbot Training Swapper.ini", "$Input_Sbot_Name", "$Input_Sbot_Name", GUICtrlRead($Input_Sbot_Name))
    IniWrite("Sbot Training Swapper.ini", "$Sleep_Time", "$Sleep_Time", GUICtrlRead($Sleep_Time))
EndFunc   ;==>_Check4Start
;<==================================================================================
Func _Check4Stop()
    $Start = 0
    ConsoleWrite("Stopped" & @CRLF)
    TrayTip("", "Stopped", 3, 0)
EndFunc   ;==>_Check4Stop
;<==================================================================================
Func _Check4CLOSEClicked();Exit
    Opt("WinTitleMatchMode", 2) ; Match substring
    WinSetTrans("Sbot Training Swapper", "", 0)
    $answer = MsgBox(36, "Warning", "Close??", 8)
    WinSetTrans("Sbot Training Swapper", "", 255)
    If $answer = 6 Then
        Exit
    EndIf
EndFunc   ;==>_Check4CLOSEClicked

I have put in a lot of ConsoleWrite lines so you can see what is happening. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

mini,

It works for me - why do you think it is not working? ;)

However, I did notice a problem - at the moment you run all the trg programmes even if you press "Stop" after programme 1 or 2. You need to change your code like this (look for the <<<<<<< lines):

I have put in a lot of ConsoleWrite lines so you can see what is happening. :D

M23

Thanks for the replay M23, after hammering my head on the desk, i found that all your posts were working perfectly...

I'm sow DUMB that i didn't see were I was making wrong.

This last post of yours made me check all my code again, cz it was doing the same error, even when you made the consolwrite.

Here was my code error:

ConsoleWrite("Trg1" & @CRLF)

ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1A)

ConsoleWrite("Trg2" & @CRLF)

ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1A)

ConsoleWrite("Trg3" & @CRLF)

ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1A)

I were getting the same info for all targets... :(:)

I just changed the 1A;1B;1C... Now its working like a charm.

That ConsoleWrite is very handy. :)

Thanks very much for your replays.

EDIT: One more question if you know how to do it!!!

How can i put my guy on Tray, without pushing any button, how can i do like:

WinGetState("name of GUI") if minimized then
winsetstate("name of GUI") tray 
if GUI tray clicked one time Restore GUI.

That isn't any code, its just what i'm thinking.

Edited by mini

Share this post


Link to post
Share on other sites

mini,

Does this do what you want? :(

#include <GUIConstantsEx.au3>
#include <Constants.au3>

Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu
Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown.
; Set left click on tray icon to restore window
TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "On_Show")

$hGUI = GUICreate("Test", 500, 500)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE, $hGUI)
    EndSwitch

WEnd

Func On_Show()

    GUISetState(@SW_SHOW, $hGUI)

EndFunc

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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