#include <Constants.au3>
#include <GUIConstantsEx.au3>
Global $sysini = @WorkingDir & "\system.ini"
Opt('TrayMenuMode', 3)
Opt("GUIOnEventMode", 1)
Global $hGUI
Select
Case IniRead ($sysini,"RUN","RunPID", Null) <> ""
Select
Case ProcessExists ( IniRead ($sysini,"RUN","RunPID", Null) )
WinSetState ( IniRead ($sysini,"RUN","RunGUI", Null), Null, @SW_SHOW )
WinActivate ( IniRead ($sysini,"RUN","RunGUI", Null), Null )
Exit
EndSelect
EndSelect
TraySetState(1)
_Main()
Func _Main()
$nGUI = "GUI 0.1"
$hGUI = GUICreate($nGUI, 250, 250)
IniWrite($sysini, "RUN", "RunPID", WinGetProcess ( $hGUI ))
IniWrite($sysini, "RUN", "RunGUI", '"' & $nGUI &'"')
GUISetOnEvent($GUI_EVENT_CLOSE, '_exit', $hGUI)
GUISetOnEvent($GUI_EVENT_MINIMIZE, '_hide', $hGUI)
GUISetState(@SW_SHOW)
While 1
Switch TrayGetMsg()
Case $TRAY_EVENT_PRIMARYUP
WinSetState ( $hGUI, Null, @SW_SHOW )
WinActivate ( $hGUI, Null )
EndSwitch
Sleep(10)
WEnd
EndFunc ;==>_Main
Func _exit()
IniDelete ( $sysini, "RUN" )
Exit
EndFunc
Func _hide()
WinSetState ( $hGUI, Null, @SW_HIDE )
EndFunc