Jump to content

set on event problem


Recommended Posts

Once i press start... the stop button and the exit button do not function...

but the tray icon button does??

Example script

#include <GUIConstants.au3>

$Quit=""

GUICreate("my GUI")

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode 

$Start= GUICtrlCreateButton("Start", 30, 55, 120, 25)
GUICtrlSetOnEvent(-1, "Set_Start")
$Stop= GUICtrlCreateButton("Stop", 30, 100, 120, 25)
GUICtrlSetOnEvent(-1, "Set_Stop")
$Exit= GUICtrlCreateButton("Exit", 30, 155, 120, 25)
GUICtrlSetOnEvent(-1, "Set_Exit2")

$Notice=GUICtrlCreateLabel(" Information Label", 20, 325, 540, 30)

GUISetState()

opt("TrayMenuMode", 1)  ; Default tray menu items (Script Paused/Exit) will not be shown.
opt("TrayOnEventMode", 1)


$exit_tray = TrayCreateItem ("Exit Program")
TrayItemSetOnEvent (-1, "Set_Exit")
TraySetState ()


While 1
    Sleep(200)
WEnd


;---------------- Functions--------------

Func Set_Exit()
    GUICtrlSetData($Notice, "  Tray - Exit Working")
    Sleep(2000)
    Exit
EndFunc  

Func Set_Exit2()
    GUICtrlSetData($Notice, "  Button - Exit Working")
    Sleep(1000)
    Exit
EndFunc 

Func Set_Stop()
    GUICtrlSetData($Notice, "  Stop Button - Working")
    $Quit="stop"
    Sleep(1000)

EndFunc 

Func Set_Start()
    GUICtrlSetData($Notice, "  Start Button - Working")
    Sleep(1000)
    
    While 2
        GUICtrlSetData($Notice, "  Start Button - Still Working")
        Sleep(1000)
        
        If $QUIT <>"" then 
            $Quit=""
            ExitLoop
        EndIf
        
        GUICtrlSetData($Notice, "  Start Button - Recycling")
        Sleep(1000)
    WEnd
    
    
EndFunc

any way to re-poll the stop and exit buttons while the start process is running?

thanks

NEWHeader1.png

Link to comment
Share on other sites

#include <GUIConstants.au3>

$Quit=""

GUICreate("my GUI")

Opt("GUIOnEventMode", 1); Change to OnEvent mode 

$Start= GUICtrlCreateButton("Start", 30, 55, 120, 25)
GUICtrlSetOnEvent($Start, "Set_Start")
$Stop= GUICtrlCreateButton("Stop", 30, 100, 120, 25)
GUICtrlSetOnEvent($Stop, "Set_Stop")
$Exit= GUICtrlCreateButton("Exit", 30, 155, 120, 25)
GUICtrlSetOnEvent($Exit, "Set_Exit2")

$Notice=GUICtrlCreateLabel(" Information Label", 20, 325, 540, 30)
$Loop = 0
GUISetState()

opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown.
opt("TrayOnEventMode", 1)

$exit_tray = TrayCreateItem ("Exit Program")
TrayItemSetOnEvent ($exit_tray, "Set_Exit")
TraySetState ()


While 1
    Sleep(200)
     If ($Loop) Then _Start_Loop()
        
WEnd


;---------------- Functions--------------

Func Set_Exit()
     $Loop = 0
    GUICtrlSetData($Notice, "  Tray - Exit Working")
    Sleep(2000)
    Exit
EndFunc  

Func Set_Exit2()
     $Loop = 0
    GUICtrlSetData($Notice, "  Button - Exit Working")
    Sleep(1000)
    Exit
EndFunc 

Func Set_Stop()
     $Loop = 0
    GUICtrlSetData($Notice, "  Stop Button - Working")
    $Quit="stop"
    Sleep(1000)
EndFunc 

Func Set_Start()
    GUICtrlSetData($Notice, "  Start Button - Working")
    Sleep(1000)
     $Loop = 1
EndFunc 

Func _Start_Loop()
    While $Loop
        GUICtrlSetData($Notice, "  Start Button - Still Working")
        Sleep(1000)
        
        If $QUIT <>"" then 
            $Quit=""
            ExitLoop
        EndIf
        
        GUICtrlSetData($Notice, "  Start Button - Recycling")
        Sleep(1000)
    WEnd
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

These are not like vb events where multiple events can be fired, I would think of it more like a function being assigned to a button, and until that function returns control to the main routine, no other functions "events" can be fired.

That's my thought on how these work.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Func _Start_Loop()
    While $Loop
        GUICtrlSetData($Notice, "  Start Button - Still Working")
        Sleep(1000)
        
        If $QUIT <>"" then 
            $Quit=""
            ExitLoop
        EndIf
        
        GUICtrlSetData($Notice, "  Start Button - Recycling")
        Sleep(1000)
    WEnd
EndFunc

<{POST_SNAPBACK}>

Thanks ... gafrost

I'm really not sure if i could have figured that one out

btw

Your Codewizard is Great

Thanks again

NEWHeader1.png

Link to comment
Share on other sites

These are not like vb events where multiple events can be fired, I would think of it more like a function being assigned to a button, and until that function returns control to the main routine, no other functions "events" can be fired.

That's my thought on how these work.

<{POST_SNAPBACK}>

But. if thats true, then why do the tray functions continue to "fire"???

NEWHeader1.png

Link to comment
Share on other sites

Forgot about those still working, might be something to post for possible bug?

TrayEvents still work, but GuiCtrlEvents don't once GuiCtrlEvent occurs until "Event" returns control.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

That creates another question/problem

I dont want to work this direction unless it is possible

i will try to include my questiojn in your example

Func _Start_Loop()

While $Loop

GUICtrlSetData($Notice, " Start Button - Still Working")

Sleep(1000)

If $QUIT <>"" then

$Quit=""

ExitLoop

EndIf

If $1x = "go" then call("program1")

If $2x = "go" Then Call("program2")

;If $3x=............. and on and on ???

GUICtrlSetData($Notice, " Start Button - Recycling")

Sleep(1000)

WEnd

EndFunc

Is this possible????

Thanks

NEWHeader1.png

Link to comment
Share on other sites

Here's another thing to look at, start using the start in the tray

the stop button works, but the tray exit doesn't, not until you use the stop

button then you'll see the tray exit.

#include <GUIConstants.au3>

$Quit=""

GUICreate("my GUI")

Opt("GUIOnEventMode", 1); Change to OnEvent mode 

$Start= GUICtrlCreateButton("Start", 30, 55, 120, 25)
GUICtrlSetOnEvent($Start, "Set_Start")
$Stop= GUICtrlCreateButton("Stop", 30, 100, 120, 25)
GUICtrlSetOnEvent($Stop, "Set_Stop")
$Exit= GUICtrlCreateButton("Exit", 30, 155, 120, 25)
GUICtrlSetOnEvent($Exit, "Set_Exit2")

$Notice=GUICtrlCreateLabel(" Information Label", 20, 325, 540, 30)
GUISetState()

opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown.
opt("TrayOnEventMode", 1)

$start_tray = TrayCreateItem ("Start")
TrayItemSetOnEvent ($start_tray, "Set_Start")

$exit_tray = TrayCreateItem ("Exit Program")
TrayItemSetOnEvent ($exit_tray, "Set_Exit")
TraySetState ()


While 1
    Sleep(200)
WEnd


;---------------- Functions--------------

Func Set_Exit()
    GUICtrlSetData($Notice, "  Tray - Exit Working")
    Sleep(2000)
    Exit
EndFunc  

Func Set_Exit2()
    GUICtrlSetData($Notice, "  Button - Exit Working")
    Sleep(1000)
    Exit
EndFunc 

Func Set_Stop()
    GUICtrlSetData($Notice, "  Stop Button - Working")
    $Quit="stop"
    Sleep(1000)
EndFunc 

Func Set_Start()
    GUICtrlSetData($Notice, "  Start Button - Working")
    Sleep(1000)
    While 1
        GUICtrlSetData($Notice, "  Start Button - Still Working")
        Sleep(1000)
        
        If $QUIT <>"" then 
            $Quit=""
            ExitLoop
        EndIf
        
        GUICtrlSetData($Notice, "  Start Button - Recycling")
        Sleep(1000)
    WEnd
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Thanks again gafrost.... but thats a difficult key combination for other users of my program

could you or someone reply on this question below

That creates another question/problem

I dont want to work this direction unless it is possible

i will try to include my questiojn in your example

Func _Start_Loop()

    While $Loop

        GUICtrlSetData($Notice, "  Start Button - Still Working")

        Sleep(1000)

       

        If $QUIT <>"" then

            $Quit=""

            ExitLoop

        EndIf

       

  If $1x = "go" then call("program1")

 

  If $2x = "go" Then Call("program2")

 

  ;If $3x=............. and on and on ???

 

        GUICtrlSetData($Notice, "  Start Button - Recycling")

        Sleep(1000)

    WEnd

EndFunc

Is this possible????

Thanks

<{POST_SNAPBACK}>

Just want to know what direction to go now

thanks

NEWHeader1.png

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...