Jump to content
Sign in to follow this  
experience

Cant Exit Script when its running

Recommended Posts

experience

I can exit the script before i click the start button, but as soon as it starts running it wont respond to any of the exit commands.

I've set Esc, the stop button and the cross on the the window to make it close which work fine except when its running.

I've tried everything i can think of to make it work but have ran out of ideas :)

#include <GUIConstants.au3>
GUICreate("title", 300, 120) ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)    ; will display an empty dialog box
Opt("GUICoordMode",2)
Opt("GUIOnEventMode",1)
$Button_1 = GUICtrlCreateButton ("Start",  50, 90, 100)
$Button_2 = GUICtrlCreateButton ( "Stop / Exit",  0, -1)
$progressbar1 = GUICtrlCreateProgress (-150, -80,100,20)
$Label = GUICtrlCreateLabel("", -170, 10, 250, 20)
$Label2 = GUICtrlCreateLabel("Will put some Text here when i get a chance", -240, -70, 250, 20)
$nMsg = GUIGetMsg()
GUISetState ()
GuICtrlSetOnEvent($Button_2,"Quit")
GuiCtrlSetOnEvent($Button_1,"DoScript")
GUICtrlSetOnEvent($progressbar1,"Doscript")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
HotKeySet("Esc","close")

Func close()
Exit
EndFunc 

While 1
    Sleep(100)
WEnd

Func Quit()
    Exit
EndFunc

Func _Exit()
    Exit
EndFunc

Func DoScript()

GUICtrlSetData ($progressbar1,(0))

MouseMove(1200, 400)
sleep(4000)
GUICtrlSetData ($progressbar1,(25)) 
sleep(4000)
MouseMove(600, 400)
GUICtrlSetData ($progressbar1,(50)) 
sleep(4000)
MouseMove(1200, 400)
GUICtrlSetData ($progressbar1,(75)) 
sleep(4000)
MouseMove(600, 400)
GUICtrlSetData ($progressbar1,(100)) 
EndFunc

Share this post


Link to post
Share on other sites
AlmarM

Will this works:

#include <GUIConstants.au3>
GUICreate("title", 300, 120) ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)    ; will display an empty dialog box
Opt("GUICoordMode",2)
Opt("GUIOnEventMode",1)
$Button_1 = GUICtrlCreateButton ("Start",  50, 90, 100)
$Button_2 = GUICtrlCreateButton ( "Stop / Exit",  0, -1)
$progressbar1 = GUICtrlCreateProgress (-150, -80,100,20)
$Label = GUICtrlCreateLabel("", -170, 10, 250, 20)
$Label2 = GUICtrlCreateLabel("Will put some Text here when i get a chance", -240, -70, 250, 20)
$nMsg = GUIGetMsg()
GUISetState ()
GuICtrlSetOnEvent($Button_2,"Quit")
GuiCtrlSetOnEvent($Button_1,"DoScript")
GUICtrlSetOnEvent($progressbar1,"Doscript")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
HotKeySet('{ESC}', '_Exit')

Func close()
Exit
EndFunc 

While 1
    Sleep(100)
WEnd

Func _Exit()
;ToolTip(' '&@CRLF&' EXITING '&@CRLF&' ')
Sleep(500)
Exit
EndFunc

Func DoScript()

GUICtrlSetData ($progressbar1,(0))

MouseMove(1200, 400)
sleep(4000)
GUICtrlSetData ($progressbar1,(25)) 
sleep(4000)
MouseMove(600, 400)
GUICtrlSetData ($progressbar1,(50)) 
sleep(4000)
MouseMove(1200, 400)
GUICtrlSetData ($progressbar1,(75)) 
sleep(4000)
MouseMove(600, 400)
GUICtrlSetData ($progressbar1,(100)) 
EndFunc
Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites
experience

Will this works:

#include <GUIConstants.au3>
GUICreate("title", 300, 120) ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)    ; will display an empty dialog box
Opt("GUICoordMode",2)
Opt("GUIOnEventMode",1)
$Button_1 = GUICtrlCreateButton ("Start",  50, 90, 100)
$Button_2 = GUICtrlCreateButton ( "Stop / Exit",  0, -1)
$progressbar1 = GUICtrlCreateProgress (-150, -80,100,20)
$Label = GUICtrlCreateLabel("", -170, 10, 250, 20)
$Label2 = GUICtrlCreateLabel("Will put some Text here when i get a chance", -240, -70, 250, 20)
$nMsg = GUIGetMsg()
GUISetState ()
GuICtrlSetOnEvent($Button_2,"Quit")
GuiCtrlSetOnEvent($Button_1,"DoScript")
GUICtrlSetOnEvent($progressbar1,"Doscript")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
HotKeySet('{ESC}', '_Exit')

Func close()
Exit
EndFunc 

While 1
    Sleep(100)
WEnd

Func _Exit()
;ToolTip(' '&@CRLF&' EXITING '&@CRLF&' ')
Sleep(500)
Exit
EndFunc

Func DoScript()

GUICtrlSetData ($progressbar1,(0))

MouseMove(1200, 400)
sleep(4000)
GUICtrlSetData ($progressbar1,(25)) 
sleep(4000)
MouseMove(600, 400)
GUICtrlSetData ($progressbar1,(50)) 
sleep(4000)
MouseMove(1200, 400)
GUICtrlSetData ($progressbar1,(75)) 
sleep(4000)
MouseMove(600, 400)
GUICtrlSetData ($progressbar1,(100)) 
EndFunc
No that gives an error when you execute it

Share this post


Link to post
Share on other sites
AlmarM

What error ??

EDIT: ah... i know what you mean... the code is:

#include <GUIConstants.au3>
GUICreate("title", 300, 120); will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)   ; will display an empty dialog box
Opt("GUICoordMode",2)
Opt("GUIOnEventMode",1)
$Button_1 = GUICtrlCreateButton ("Start",  50, 90, 100)
$Button_2 = GUICtrlCreateButton ( "Stop / Exit",  0, -1)
$progressbar1 = GUICtrlCreateProgress (-150, -80,100,20)
$Label = GUICtrlCreateLabel("", -170, 10, 250, 20)
$Label2 = GUICtrlCreateLabel("Will put some Text here when i get a chance", -240, -70, 250, 20)
$nMsg = GUIGetMsg()
GUISetState ()
GuICtrlSetOnEvent($Button_2,"Quit")
GuiCtrlSetOnEvent($Button_1,"DoScript")
GUICtrlSetOnEvent($progressbar1,"Doscript")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
HotKeySet('{ESC}', '_Exit')

Func Quit()
Exit
EndFunc

Func close()
Exit
EndFunc 

While 1
    Sleep(100)
WEnd

Func _Exit()
;ToolTip(' '&@CRLF&' EXITING '&@CRLF&' ')
Sleep(500)
Exit
EndFunc

Func DoScript()

GUICtrlSetData ($progressbar1,(0))

MouseMove(1200, 400)
sleep(4000)
GUICtrlSetData ($progressbar1,(25)) 
sleep(4000)
MouseMove(600, 400)
GUICtrlSetData ($progressbar1,(50)) 
sleep(4000)
MouseMove(1200, 400)
GUICtrlSetData ($progressbar1,(75)) 
sleep(4000)
MouseMove(600, 400)
GUICtrlSetData ($progressbar1,(100)) 
EndFunc

Good Enough ^^ ?

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites
experience

What error ??

EDIT: ah... i know what you mean... the code is:

#include <GUIConstants.au3>
GUICreate("title", 300, 120); will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW) ; will display an empty dialog box
Opt("GUICoordMode",2)
Opt("GUIOnEventMode",1)
$Button_1 = GUICtrlCreateButton ("Start",  50, 90, 100)
$Button_2 = GUICtrlCreateButton ( "Stop / Exit",  0, -1)
$progressbar1 = GUICtrlCreateProgress (-150, -80,100,20)
$Label = GUICtrlCreateLabel("", -170, 10, 250, 20)
$Label2 = GUICtrlCreateLabel("Will put some Text here when i get a chance", -240, -70, 250, 20)
$nMsg = GUIGetMsg()
GUISetState ()
GuICtrlSetOnEvent($Button_2,"Quit")
GuiCtrlSetOnEvent($Button_1,"DoScript")
GUICtrlSetOnEvent($progressbar1,"Doscript")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
HotKeySet('{ESC}', '_Exit')

Func Quit()
Exit
EndFunc

Func close()
Exit
EndFunc 

While 1
    Sleep(100)
WEnd

Func _Exit()
;ToolTip(' '&@CRLF&' EXITING '&@CRLF&' ')
Sleep(500)
Exit
EndFunc

Func DoScript()

GUICtrlSetData ($progressbar1,(0))

MouseMove(1200, 400)
sleep(4000)
GUICtrlSetData ($progressbar1,(25)) 
sleep(4000)
MouseMove(600, 400)
GUICtrlSetData ($progressbar1,(50)) 
sleep(4000)
MouseMove(1200, 400)
GUICtrlSetData ($progressbar1,(75)) 
sleep(4000)
MouseMove(600, 400)
GUICtrlSetData ($progressbar1,(100)) 
EndFunc

Good Enough ^^ ?

Ah ha yeh thats good the Esc key exits! the exit button & window close still doesnt work tho Edited by experience

Share this post


Link to post
Share on other sites
AlmarM

Ah ha yeh thats good the Esc key exits! the exit button & window close still doesnt work tho

Uhm...

window close still doesnt work tho

???

What you mean :) ??


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites
SmOke_N

Uhm...

window close still doesnt work tho

???

What you mean :) ??

When you are doing a "Sleep()", nothing is interpreted from the GUI during that sleep, so when you are clicking on the close option for the GUI, it's not getting the message.

You'll have to re-think what you are doing a bit more clearly.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
AlmarM

When you are doing a "Sleep()", nothing is interpreted from the GUI during that sleep, so when you are clicking on the close option for the GUI, it's not getting the message.

You'll have to re-think what you are doing a bit more clearly.

Lol im just a newbie who did know that about the HotKeySet...

Buy i still dont know anything about the GUI things :)


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.