Jump to content

Pause & Stop button Issue


Recommended Posts

Heya, I have some trouble with my script, I want to make my Stop ($Button3) and my Pause($Button2) to Stop respective pause the script. I got the start button to work but not the others. Here is some parts of the script,

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

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\pc\mina dokument\form3.kxf
$Form3 = GUICreate("Darkangel Leveling bot Beta v1.9", 563, 356, 302, 218)
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\pc\Skrivbord\namnlös.JPG", 0, 0, 561, 89, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Button1 = GUICtrlCreateButton("Button1", 176, 296, 49, 49, BitOR($BS_BITMAP,$WS_GROUP))
GUICtrlSetImage(-1, "C:\Documents and Settings\pc\Skrivbord\Kopia av fire-dancing-icon.bmp", -1)
$Button2 = GUICtrlCreateButton("Button2", 256, 296, 57, 49, BitOR($BS_BITMAP,$WS_GROUP))
GUICtrlSetImage(-1, "C:\Documents and Settings\pc\Skrivbord\Pause.bmp", -1)
$Button3 = GUICtrlCreateButton("Button3", 344, 296, 57, 49, BitOR($BS_BITMAP,$WS_GROUP))
GUICtrlSetImage(-1, "C:\Documents and Settings\pc\Skrivbord\fire-dancing-icon.bmp", -1)
$Group1 = GUICtrlCreateGroup("Welcome to Darkangel leveling Bot Beta v1.9 ", 136, 96, 297, 177)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Please setup the settings you want to use before starting", 144, 120, 270, 17)
$Label2 = GUICtrlCreateLabel("In the config.ini file that is located in your bot folder.", 144, 136, 245, 17)
$Label3 = GUICtrlCreateLabel("Start up WoW, login to your character, set resolution to", 144, 152, 263, 17)
$Label4 = GUICtrlCreateLabel("800x600 and enable windowed mode. Maximise WoW", 144, 168, 261, 17)
$Label5 = GUICtrlCreateLabel("as much as you can (dont disable Windowed mode)", 144, 184, 248, 17)
$Label6 = GUICtrlCreateLabel("And then find a location where you wich to grind mobs, and", 144, 200, 283, 17)
$Label7 = GUICtrlCreateLabel("then start the bot. ", 144, 216, 90, 17)
$win_title = "World of Warcraft"
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
          Togglepause()
    EndSwitch
WEnd

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
          Terminate();
          
    EndSwitch
WEnd


; Globals 
AutoItSetOption("MouseCoordMode", 0) 
AutoItSetOption("PixelCoordMode", 0) 
$win_title = "World of Warcraft" 

; Fires up WOW
WinActivate($win_title, "") 
WinSetOnTop($win_title, "", 0) 
Sleep(1000) 


   Start()
; ***** Combat function $coord = PixelSearch( 0, 0, 1152, 864, 0x32394A, 2 ) 0xBF0000
Func Start()
    While 1 
    Send("{TAB}")
    $coord = PixelSearch( 0, 0, 1152, 864, 0xCBC800 , 2 ) 
If @error Then 
    TrayTip("No mob found ", "Doing findmob routine", 5, 1)
sleep(1000)
Find_mob() 
Else
    TrayTip("Mob spotted! ", "Attacking Mob", 5, 1)
Battle()
EndIf
Wend 
EndFunc

; MAIN SCRIPT IS HERE

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

Func Terminate()
    Exit 0
EndFunc

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

Any help would be aprusiated

Link to comment
Share on other sites

  • Developers

Think a little bit longer about this section of code, I am sure you are able to figure out why Button2 and again Button2 (should be button3?) do not work.

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

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
          Togglepause()
    EndSwitch
WEnd

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
          Terminate();
          
    EndSwitch
WEnd

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Think a little bit longer about this section of code, I am sure you are able to figure out why Button2 and again Button2 (should be button3?) do not work.

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

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
          Togglepause()
    EndSwitch
WEnd

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
          Terminate();
          
    EndSwitch
WEnd
So I should change Button 2 to Button 3 and Button 3 to button 2?
Link to comment
Share on other sites

  • Developers

So I should change Button 2 to Button 3 and Button 3 to button 2?

Have you properly looked at the section I quoted?

There is a reference to Button2 twice and none to button3.

Also the whole logic is wrong because initially your script will be in the first While-Wend loop thus Button2 and button3 is never checked for.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Have you properly looked at the section I quoted?

There is a reference to Button2 twice and none to button3.

Also the whole logic is wrong because initially your script will be in the first While-Wend loop thus Button2 and button3 is never checked for.

Jos

Yea, I saw that you referred to button 2 two times. But It don't seem to work when I changed it :/
Link to comment
Share on other sites

  • Developers

Yea, I saw that you referred to button 2 two times. But It don't seem to work when I changed it :/

Also the whole logic is wrong because initially your script will be in the first While-Wend loop thus Button2 and button3 is never checked for.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

in other words...put it in the SAME while loop...

Link to comment
Share on other sites

I tried this now,

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

Start()

EndSwitch

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button2

Togglepause()

EndSwitch

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button3

Terminate();

EndSwitch

WEnd

But it still isnt working ;)

Apprusiating your help tho ^_^

Link to comment
Share on other sites

  • Moderators

kallblodig,

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Start()
        Case $Button2
            Togglepause()
        Case $Button3
            Terminate();
    EndSwitch
WEnd

M23

P.S. Sorry to butt in, but I cannot bear it any longer!

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Developers

P.S. Sorry to butt in, but I cannot bear it any longer!

^_^

Sometimes I wonder how peoples brains work. Don't get me wrong kallblodig, but you will have to try to understand what you are coding because else you are just trying things and that will not work when your script grows.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

Jos & Val,

That is why I apologised in advance.

I do not know if you ever saw the file "They Shoot Horses Don't They"......

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

kallblodig,

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Start()
        Case $Button2
            Togglepause()
        Case $Button3
            Terminate();
    EndSwitch
WEnd

M23

P.S. Sorry to butt in, but I cannot bear it any longer!

Still doesnt work :/ Tried everything I can :S
Link to comment
Share on other sites

  • Moderators

kallblodig,

The following is extracted from your original code with my While...WEnd loop:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
$Form3 = GUICreate("Darkangel Leveling bot Beta v1.9", 563, 356, 302, 218)
$Button1 = GUICtrlCreateButton("Button1", 176, 296, 49, 49, BitOR($BS_BITMAP,$WS_GROUP))
$Button2 = GUICtrlCreateButton("Button2", 256, 296, 57, 49, BitOR($BS_BITMAP,$WS_GROUP))
$Button3 = GUICtrlCreateButton("Button3", 344, 296, 57, 49, BitOR($BS_BITMAP,$WS_GROUP))
$win_title = "World of Warcraft"
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            ConsoleWrite("Start()" & @CRLF)
        Case $Button2
            ConsoleWrite("Togglepause()" & @CRLF)
        Case $Button3
            ConsoleWrite("Terminate()" & @CRLF);
    EndSwitch
WEnd

The buttons work for me!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Alright, well it works with this while loop,

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

Start()

Case $Button2

Togglepause()

Case $Button3

Exit

EndSwitch

WEnd

Tho the buttons only work when I havent started the bot. I want them to work while im running the bot after I have pressed Button 1 (Start). So basicly I want the script to be paused if its running when I press button 2, And Exit the bot if script is running and you have pressed Button 3.

Any ideas? Thx <33

Edited by kallblodig
Link to comment
Share on other sites

  • Moderators

kallblodig,

It sounds as though you never return to this loop after entering the Start() function. Do you have a While...WEnd loop in that function? If so, then you need to put the other key Cases in there. Pseudo-code:

Start of script
While
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Button1
        Start()
WEnd

Func Start()
Main function code
While
    Case $Button2
        Togglepause()
    Case $Button3
        Exit
WEnd
EndFunc

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

kallblodig,

It sounds as though you never return to this loop after entering the Start() function. Do you have a While...WEnd loop in that function? If so, then you need to put the other key Cases in there. Pseudo-code:

Start of script
While
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Button1
        Start()
WEnd

Func Start()
Main function code
While
    Case $Button2
        Togglepause()
    Case $Button3
        Exit
WEnd
EndFunc

M23

Alright, here is the whole start function, I sound soo naabish, but wich cases should I add to the function since Im already using a While loop in it. Thx <3

Start()

; ***** Combat function

Func Start()

WinActivate($win_title, "")

WinSetOnTop($win_title, "", 0)

Sleep(1000)

While 1

Send("{TAB}")

$coord = PixelSearch( 0, 0, 1152, 864, 0xBF0000 , 2 )

If @error Then

ToolTip('No mob found, doing Find Mob routine"',0,0)

sleep(1000)

Find_mob()

Else

ToolTip('Mob spotted, attacking"',0,0)

Battle()

EndIf

Wend

EndFunc

Link to comment
Share on other sites

  • Moderators

kallblodig,

This is the last time I offer any assistance unless you start showing some initiative and produce some code of your own! If you cannot manage to code a simple GUIGetMsg section by now.....

As I explained to you in my previous post, to have the "Pause" and "Exit" buttons active in the Start() function you need to poll GUIGetMsg in the While...WEnd loop of the function:

Func Start()
    WinActivate($win_title, "")
    WinSetOnTop($win_title, "", 0)
    Sleep(1000)
    While 1
        Send("{TAB}")
        $coord = PixelSearch(0, 0, 1152, 864, 0xBF0000, 2)
        If @error Then
            ToolTip('No mob found, doing Find Mob routine"', 0, 0)
            Sleep(1000)
            Find_mob()
        Else
            ToolTip('Mob spotted, attacking"', 0, 0)
            Battle()
        EndIf

    ; See if the buttons have been pressed
        Switch GUIGetMsg()
            Case $Button2
                Togglepause()
            Case $Button3
                Exit
        EndSwitch

    WEnd
EndFunc  ;==>Start

Now Buttons 2 & 3 will be active while Start() is running.

M23

P.S. Please use Code tags. Put [code ] before and [/code ] after your posted code (but omit the trailing space - it is only there so the tags display here).

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

kallblodig,

This is the last time I offer any assistance unless you start showing some initiative and produce some code of your own! If you cannot manage to code a simple GUIGetMsg section by now.....

As I explained to you in my previous post, to have the "Pause" and "Exit" buttons active in the Start() function you need to poll GUIGetMsg in the While...WEnd loop of the function:

Func Start()
    WinActivate($win_title, "")
    WinSetOnTop($win_title, "", 0)
    Sleep(1000)
    While 1
        Send("{TAB}")
        $coord = PixelSearch(0, 0, 1152, 864, 0xBF0000, 2)
        If @error Then
            ToolTip('No mob found, doing Find Mob routine"', 0, 0)
            Sleep(1000)
            Find_mob()
        Else
            ToolTip('Mob spotted, attacking"', 0, 0)
            Battle()
        EndIf

; See if the buttons have been pressed
        Switch GUIGetMsg()
            Case $Button2
                Togglepause()
            Case $Button3
                Exit
        EndSwitch

    WEnd
EndFunc ;==>Start

Now Buttons 2 & 3 will be active while Start() is running.

M23

P.S. Please use Code tags. Put [code ] before and [/code ] after your posted code (but omit the trailing space - it is only there so the tags display here).

Got it to work, Thx alot man ! =) And btw, I tried servral diffrent solutions but I didnt post them here since I didnt find it to be nessesary.
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...