Hyflex Posted September 1, 2013 Share Posted September 1, 2013 (edited) Hey AutoIt Forums,I'm looking for some help creating a system tray minimiser...Currently my code is the following...If Not ProcessExists("fix1.exe") Then Run("fix1.exe") End If If ProcessExists("fix1.exe") Then $State = WinGetState(ink)") If $State = 23 Then WinSetState("ink)", "", @SW_HIDE) ElseIf $State = 21 Then WinSetState("ink)", "", @SW_SHOW) WinActivate("ink") EndIf Else Exit EndIfI need help with the following:On launch: If the program does not exist, run it. (Done)On launch: If the minimiser is already running then kill the older running minimiser...On launch: If the program exists and is minimised then it will hide it and make a system tray icon appear... (Partly done)On launch: If the program exists and is hidden then it will unhide it and remove the. (Partly done)On double click (when system tray is active): Unhide and activate the windowOn right click (when system tray is active): Give option to unhide + exit minimiser (also processcloses the program)Anyone able to help me achieve this?Thanks- HyflexEDIT: Anyone know why state 23 and 21 are different to what the docs say? Edited September 1, 2013 by Hyflex Link to comment Share on other sites More sharing options...
somdcomputerguy Posted September 1, 2013 Share Posted September 1, 2013 (edited) You need an EndIf statement for the second If loop, and the WinGetState line (in that loop) is missing the opening double quote ("). Just FYI, if an If loop has only one execute line, the whole loop can be on one line, and it doesn't need an EndIf. Here's an example:If Not ProcessExists("fix1.exe") Then Run("fix1.exe") EndIf ; can be like this instead If Not ProcessExists("fix1.exe") Then Run("fix1.exe") Edited September 1, 2013 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Hyflex Posted September 1, 2013 Author Share Posted September 1, 2013 Sorry yeah, that was an error in my example. I have a really basic minimiser working but none working with the icon part :/ Link to comment Share on other sites More sharing options...
Hyflex Posted September 1, 2013 Author Share Posted September 1, 2013 This is as far as I can get with the process closing part for older process...$ProcessList = ProcessList("mad.exe") For $i = 1 To $ProcessList[0][0] If $ProcessList[$i][1] <> @AutoItPID Then ProcessClose(@AutoItPID) EndIf NextSeems to be working fine in my examples... Link to comment Share on other sites More sharing options...
Hyflex Posted September 1, 2013 Author Share Posted September 1, 2013 Eventually after hours and hours of trying I got there... Someone else might find use for this too: expandcollapse popup#include <Constants.au3> Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) TraySetClick(8) TraySetIcon("\icon.ico") TraySetToolTip("Minimiser") $Exit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, '_Exit') TraySetState() TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "Double") If Not ProcessExists("fix1.exe") Then Run("C:\fix1.exe") ProcessWait("fix1.exe") EndIf $ProcessList = ProcessList("Minimiser.exe") For $i = 1 To $ProcessList[0][0] If $ProcessList[$i][1] <> @AutoItPID Then ProcessClose($ProcessList[$i][1]) EndIf Next If ProcessExists("fix1.exe") Then $State = WinGetState("ink") TraySetState(2) WinSetState("ink", "", @SW_SHOW) WinActivate("ink") Else Exit EndIf While 1 Sleep(200) If ProcessExists("fix1.exe") Then $State = WinGetState("ink") If $State = 23 Then WinSetState("ink", "", @SW_HIDE) TraySetState(1) EndIf Else Exit EndIf WEnd Func Double() If ProcessExists("fix1.exe") Then $State = WinGetState("ink") If $State = 23 Then WinSetState("ink", "", @SW_HIDE) TraySetState(1) ElseIf $State = 21 Then TraySetState(2) WinSetState("ink", "", @SW_SHOW) WinActivate("ink") EndIf Else Exit EndIf EndFunc Func _Exit() WinSetState("ink", "", @SW_SHOW) WinClose("ink") Exit EndFunc Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now