Sign in to follow this  
Followers 0
MerkurAlex

pause button

7 posts in this topic

ok so i start my bot if i have the click mouse button checked i let it run awhile then i click pause it takes like a minute to stop.

yes i know my code is messy i just started autoit.

#region Main
#region Begin
#include <GUIConstants.au3>
$str=0

#Region Form=1

$Form1 = GUICreate("AForm1", 226, 190, 193, 115, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_CLIPCHILDREN,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetIcon("C:\Documents and Settings\Kernal Debug\My Documents\My Pictures\farm icon.ico")
$Tab1 = GUICtrlCreateTab(0, 0, 225, 189)
GUICtrlCreateTabItem("")
$Group2 = GUICtrlCreateGroup("Main", 8, 8, 209, 145)
$Group1 = GUICtrlCreateGroup("Select Mode", 12, 29, 193, 58)
$Combo1 = GUICtrlCreateCombo("", 28, 45, 163, 25)
GUICtrlSetData(-1, "Plant crops.|Harvest crops.")
$Button1 = GUICtrlCreateButton("Start", 30, 68, 54, 14, 0)
$Button2 = GUICtrlCreateButton("Pause", 130, 68, 54, 14, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button3 = GUICtrlCreateButton("Options", 18, 127, 187, 20, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
#Region Form=2
    $Form2 = GUICreate("AForm2", 192, 179, 441, 118, BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
    $Tab1 = GUICtrlCreateTab(4, 8, 187, 170)
    $TabSheet1 = GUICtrlCreateTabItem("plant options")
    $Button4 = GUICtrlCreateButton("Ok", 89, 144, 62, 20, 0)
    $Checkbox1 = GUICtrlCreateCheckbox("Click at mouse?", 13, 33, 134, 22)
    $Checkbox2 = GUICtrlCreateCheckbox("Press f1 alot?", 13, 69, 134, 22)
    $Checkbox3 = GUICtrlCreateCheckbox("Rest when needed?", 13, 109, 134, 22)
    $TabSheet2 = GUICtrlCreateTabItem("harvest options")
    $Button5 = GUICtrlCreateButton("Ok", 89, 144, 62, 20, 0)
    $Checkbox4 = GUICtrlCreateCheckbox("click at mouse?", 13, 69, 134, 22)
    $Checkbox5 = GUICtrlCreateCheckbox("autoloot?", 13, 33, 134, 22)
    $Checkbox6 = GUICtrlCreateCheckbox("press f4 for harvest skill?", 13, 109, 134, 22)
    GUICtrlCreateTabItem("")
    if fileexists("farm.ini") then
        $i1=iniread("farm.ini","options","c1","0")
        $i2=iniread("farm.ini","options","c2","0")
        $i3=iniread("farm.ini","options","c3","0")
        $i4=iniread("farm.ini","options","c4","0")
        $i5=iniread("farm.ini","options","c5","0")
        $i6=iniread("farm.ini","options","c6","0")
        if $i1=1 then guictrlsetstate($checkbox1,$GUI_CHECKED)
        if $i2=1 then guictrlsetstate($checkbox2,$GUI_CHECKED)
        if $i3=1 then guictrlsetstate($checkbox3,$GUI_CHECKED)
        if $i4=1 then guictrlsetstate($checkbox4,$GUI_CHECKED)
        if $i5=1 then guictrlsetstate($checkbox5,$GUI_CHECKED)
        if $i6=1 then guictrlsetstate($checkbox6,$GUI_CHECKED)
    EndIf
    #EndRegion ### END Koda GUI section ###
#endregion

While 1
    #region getstates
    $co=guictrlread($combo1)
    $c1=GUICtrlread($checkbox1)
    $c2=guictrlread($checkbox2)
    $c3=guictrlread($checkbox3)
    $c4=guictrlread($checkbox4)
    $c5=guictrlread($checkbox5)
    $c6=guictrlread($checkbox6)
    if $c1=$GUI_CHECKED then $cl=1
    if $c2=$GUI_CHECKED then $f1=1
    if $c3=$GUI_CHECKED then $rst=1
    if $c4=$GUI_CHECKED then $cl2=1
    if $c5=$GUI_CHECKED then $lo=1
    if $c6=$GUI_CHECKED then $f4=1
    #endregion

    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            IniWrite ( "farm.ini", "Options", "c1", $c1)
            IniWrite ( "farm.ini", "Options", "c2", $c2)
            IniWrite ( "farm.ini", "Options", "c3", $c3)
            IniWrite ( "farm.ini", "Options", "c4", $c4)
            IniWrite ( "farm.ini", "Options", "c5", $c5)
            IniWrite ( "farm.ini", "Options", "c6", $c6)
            Exit
        Case $Button1
            $str=1
        
        Case $Button2
            $str=0
        
        Case $Button3
            GUISetState(@SW_SHOW,$form2)
    
        case $button4
            GUISetState(@SW_HIDE,$form2)
        case $button5
            GUISetState(@SW_HIDE,$form2)

    Endswitch
    if $str=1 and $co="Plant crops." then
        winwaitactive("Voyage")
        if $c1=1 then c()
        if $c2=1 then ms()
    EndIf
WEnd
#region funcions
func c()
    if $str=1 then
        mousedown("left")
        mouseup("left")
        sleep(10)
    EndIf
EndFunc

Func ms()
    send("{f1}")
EndFunc

#endregion
#endregion

thanks. :)


[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Even if you just started AutoIt you should still format and comment code :)

How are you pasuing your bot? I do not see a pause function or anything that would pause your script.

Edit: spelling correction!

Edited by madmax

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Even if you just started AutoIt you should still format and comment code :)

How are you pasuing your bot? I do not see a pause function or anything that would pause your script.

Edit: spelling correction!

on the if to do the macros it checks variable $str=1 the button pause changes that to $str=0

I question some of the efficiency... but that aside...

Shouldn't you GUISwitch($Form1) before you start your While 1 loop? Just in case...

WinWaitActive("Voyage") could cause the script to hang indefinitely... use the [timeout] parameter and error check.... so...

WinActivate("Voyage")

If WinWaitActive("Voyage","",3) Then

if $c1=1 then c()

if $c2=1 then ms()

EndIf

Also... speed stuff up with Opt("WinWaitDelay",10) or so...

This is all I could find that may cause delay or hanging.

Lar.

this made it a little better though it still causes a delay.

EDIT:also GUISwitch($Form1) made it so much worse

Edited by EagleClaw

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You know... it is just the use of multiple dialogs and all of the GUICtrlRead junk... You may need to go back to formula on this one.

Lar.

ok, also how would i check if a window opened in the game at a certain position?

EDIT:is there a way to refresh the gui cause it make some of the stuff disappear like the group names and borders.

Edited by EagleClaw

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

Depends on what "a window" is... a "window" for the OS is a very specific thing, identified by a handle... or "hWnd"... A square that pops up with words and buttons is NOT a "window" if it does not have a "hWnd". So when you say "a window pops up" I am not sure if you mean An Object That Has an hWnd, or just a square picture with words and buttons that you interact with.

If it is a true "window", then you just interact with it in a standard way, using standard AutoIt functions...

If it is a square thing with words and buttons generated by a game "engine", then you would need to contact the authot of the game and ask him for an SDK.

Lar.

its a square with words and buttons would getpixel work if so i need to check if its open then im going to click certain places im just not sure how to use getpixel for this if it would work.

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

It's all in the help file and forum. The question is too nonspecific for me to entertain.

ok but you never answered my other questions is there a way to update the gui type of thing its in one of the posts above.

and is there a way i could remove my code from the top i dont want some1 stealing it.


[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

ok i figured out the getpixel thing it works how i want it to but i cant edit my code on the first post and i cant find out how to refresh the gui please help anyone.


[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

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