Sign in to follow this  
Followers 0
sebsabul

GUICtrlSetOnEvent

8 posts in this topic

Hey guys, need some help!

Why don´t run the item: exit? (or the function myevent2())?

What did I worog with the command GUICtrlSetOnEvent??

Here is my script:

#include <GUIConstants.au3>

#Include <Constants.au3>

#include <GUIConstants.au3>

#Include <Constants.au3>

#NoTrayIcon

Opt("TrayMenuMode",1)

Opt("GUIOnEventMode", 1)

$trayitem1 = TrayCreateItem("Anzeigen")

TraySetItemState($trayitem1, $TRAY_DEFAULT);just need to click the tray icon to select item

$starten = TrayCreateItem("Nachrichtendienst starten")

$beenden = TrayCreateItem("Nachrichtendienst beenden")

$exititem = TrayCreateItem("Exit")

TraySetClick(8); only show tray menu on right-click

$InfoGui = GUICreate("Info", 900, 500)

$textlabel = GUICtrlCreateLabel ("", 5, 5, 895, 150)

$textlabel2 = GUICtrlCreateLabel ("", 5, 170, 895, 150)

$textlabel3 = GUICtrlCreateLabel ("", 5, 340, 895, 150)

GUISetState (@SW_SHOW)

AdlibEnable("myadlib", 1000)

GUISetOnEvent ( $GUI_EVENT_CLOSE, "myevent")

GUICtrlSetOnEvent ( $starten, "myevent2")

local $info = 0

local $wait = 1000

local $timer = 0

TraySetIcon("Shell32.dll",130)

While 1

WinWait("Nachrichtendienst", "")

If WinWait("Nachrichtendienst", "") then

$info = $info + 1

$text = WinGetText("Nachrichtendienst")

ControlSetText($InfoGui, "", $textlabel, $text)

TrayTip ( "Info", "Meldung eingegangen", 86400000)

winclose("Nachrichtendienst")

endif

If $info = 10 then

Run("C:\Windows\System\meldung.bat")

sleep(2000)

Run("net stop nachrichtendienst")

TrayTip ( "Info", "Nachrichtendienst beendet", 86400000)

$info = 0

endif

WinWait("Nachrichtendienst", "")

If WinWait("Nachrichtendienst", "") then

$info = $info + 1

$text = WinGetText("Nachrichtendienst")

ControlSetText($InfoGui, "", $textlabel2, $text)

TrayTip ( "Info", "Meldung eingegangen", 86400000)

winclose("Nachrichtendienst")

endif

If $info = 10 then

Run("C:\Windows\System\meldung.bat")

sleep(2000)

Run("net stop nachrichtendienst")

TrayTip ( "Info", "Nachrichtendienst beendet", 86400000)

$info = 0

endif

WinWait("Nachrichtendienst", "")

If WinWait("Nachrichtendienst", "") then

$info = $info + 1

$text = WinGetText("Nachrichtendienst")

ControlSetText($InfoGui, "", $textlabel3, $text)

TrayTip ( "Info", "Meldung eingegangen", 86400000)

winclose("Nachrichtendienst")

endif

If $info = 10 then

Run("C:\Windows\System\meldung.bat")

sleep(2000)

Run("net stop nachrichtendienst")

TrayTip ( "Info", "Nachrichtendienst beendet", 86400000)

$info = 0

endif

Wend

Func myadlib()

$timer = $timer + 1

If $timer = 60 Then $info = 0

If $timer = 60 then $timer = 0

EndFunc

Func myevent()

exit

EndFunc

Func myevent2()

Runwait("net start nachrichtendienst")

EndFunc

Thank you for help.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Your missing the file extension.

The name of the executable (EXE, BAT, COM, PIF) to run.

eg.

Runwait("net start nachrichtendienst.exe")
Edited by burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

I don't think tray functions can have onevent functions.

Holger will confirm

Basically they don't use GuiGetMsg but TrayGetMsg

The return of GUICtrlSetOnEvent ( $starten, "myevent2")

is 0 which means no success :):D

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

mhmm and what can i do now? is there any solution?

thank you for help..

Edited by sebsabul

Share this post


Link to post
Share on other sites

yeah thanks, there is a option called Opt("TrayOnEventMode", 1) .. anybody knows how to use it (with my script) generally..

thanks..

Share this post


Link to post
Share on other sites

It works fine thank you very much !

! ! ! T H A N K S ! ! !

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