Jump to content
Sign in to follow this  
sebsabul

GUICtrlSetOnEvent

Recommended Posts

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

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

qq

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

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

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...