Hyflex Posted September 30, 2013 Share Posted September 30, 2013 (edited) Hey AutoIt Forums,Below is some code I created recently to make an unofficial minimise to tray / launcher but I have an issue with the closingOn Launch:1) If "Program" is running unhide window, hide/remove/delete/kill the tray icon, focus the window and either kill the previously ran minimizer (can the new minimiser instead tell the old minimiser to run a certain function then exit the new self? (keeps the old minimiser running?))2) If "Program" is not running, run it and focus the window.On Minimise:1) Minimise to tray by hiding the program and showing an iconOn Double Click of Icon (Only visible once minimise/hidden)1) Unhide and focus the window and also remove/delete/kill/hide the tray icon.Basically my problem at the moment is it's not killing the right minimiser so the issues are connected/about option 1 for the "On Launch" part. expandcollapse popup#include <Constants.au3> Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) $MinimiserName = "TLauncher.exe" $ProgramName = "Tfix1.exe" $WindowName = "ink)" $Icon = "\Tr.ico" $ToolTip = "T Minimiser" TraySetClick(8) TraySetIcon($Icon) TraySetToolTip($ToolTip) $Exit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, '_Exit') TraySetState() TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "Double") If Not ProcessExists($ProgramName) Then Run("\" & $ProgramName) ProcessWait($ProgramName) EndIf $ProcessList = ProcessList($MinimiserName) For $i = 1 To $ProcessList[0][0] If $ProcessList[$i][1] <> @AutoItPID Then ProcessClose($ProcessList[$i][1]) _RefreshSystemTray(1) EndIf Next If ProcessExists($ProgramName) Then $State = WinGetState($WindowName) TraySetState(2) WinSetState($WindowName, "", @SW_SHOW) WinActivate($WindowName) Else Exit EndIf While 1 Sleep(250) If ProcessExists($ProgramName) Then $State = WinGetState($WindowName) If $State = 23 Then WinSetState($WindowName, "", @SW_HIDE) TraySetState(1) EndIf Else Exit EndIf WEnd Func Double() If ProcessExists($ProgramName) Then $State = WinGetState($WindowName) If $State = 23 Then WinSetState($WindowName, "", @SW_HIDE) TraySetState(1) ElseIf $State = 21 Then TraySetState(2) WinSetState($WindowName, "", @SW_SHOW) WinActivate($WindowName) EndIf Else Exit EndIf EndFunc Func _Exit() WinSetState($WindowName, "", @SW_SHOW) WinClose($WindowName) Exit EndFunc ; =================================================================== ; _RefreshSystemTray($nDealy = 1000) ; ; Removes any dead icons from the notification area. ; Parameters: ; $nDelay - IN/OPTIONAL - The delay to wait for the notification area to expand with Windows XP's ; "Hide Inactive Icons" feature (In milliseconds). ; Returns: ; Sets @error on failure: ; 1 - Tray couldn't be found. ; 2 - DllCall error. ; =================================================================== Func _RefreshSystemTray($nDelay = 1000) ; Save Opt settings Local $oldMatchMode = Opt("WinTitleMatchMode", 4) Local $oldChildMode = Opt("WinSearchChildren", 1) Local $error = 0 Do; Pseudo loop Local $hWnd = WinGetHandle("classname=TrayNotifyWnd") If @error Then $error = 1 ExitLoop EndIf Local $hControl = ControlGetHandle($hWnd, "", "Button1") ; We're on XP and the Hide Inactive Icons button is there, so expand it If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then ControlClick($hWnd, "", $hControl) Sleep($nDelay) EndIf Local $posStart = MouseGetPos() Local $posWin = WinGetPos($hWnd) Local $y = $posWin[1] While $y < $posWin[3] + $posWin[1] Local $x = $posWin[0] While $x < $posWin[2] + $posWin[0] DllCall("user32.dll", "int", "SetCursorPos", "int", $x, "int", $y) If @error Then $error = 2 ExitLoop 3; Jump out of While/While/Do EndIf $x = $x + 8 WEnd $y = $y + 8 WEnd DllCall("user32.dll", "int", "SetCursorPos", "int", $posStart[0], "int", $posStart[1]) ; We're on XP so we need to hide the inactive icons again. If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then ControlClick($hWnd, "", $hControl) EndIf Until 1 ; Restore Opt settings Opt("WinTitleMatchMode", $oldMatchMode) Opt("WinSearchChildren", $oldChildMode) SetError($error) EndFunc; _RefreshSystemTray()Any help, suggestions and advice would be greatly appreciated- Hyflex Edited October 3, 2013 by Hyflex Link to comment Share on other sites More sharing options...
Hyflex Posted October 2, 2013 Author Share Posted October 2, 2013 Bump, anyone able to help with this? Link to comment Share on other sites More sharing options...
mrflibblehat Posted October 2, 2013 Share Posted October 2, 2013 I can see an error on line 64, Should be WinSetState($WindowName, "", @SW_HIDE) and not WinSetState($WindowName", "", @SW_HIDE) [font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font] Link to comment Share on other sites More sharing options...
Hyflex Posted October 3, 2013 Author Share Posted October 3, 2013 Sorry, that was a mistake where I was converting it so it's easier to read. Link to comment Share on other sites More sharing options...
Hyflex Posted October 5, 2013 Author Share Posted October 5, 2013 Bump, anyone ;( Link to comment Share on other sites More sharing options...
Hyflex Posted October 6, 2013 Author Share Posted October 6, 2013 Up :/ Link to comment Share on other sites More sharing options...
JohnOne Posted October 7, 2013 Share Posted October 7, 2013 I cannot make heads nor tails of what anything you wrote means. I suspect that it all makes perfect sense to yourself though, and that's because you made it and know what it's supposed to do. What I'm saying is, it's likely that you have not had much help because of the effort that would need to go into finding out what exactly, this script is supposed to do. I suggest you re-write your original post in understandable terms, that someone who knows nothing about it can understand, and not have to follow your unformatted code. Oh and format (indent) your code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Hyflex Posted October 8, 2013 Author Share Posted October 8, 2013 I cannot make heads nor tails of what anything you wrote means.I suspect that it all makes perfect sense to yourself though, and that's because you made it and know what it's supposed to do. What I'm saying is, it's likely that you have not had much help because of the effort that would need to go into finding out what exactly, this script is supposed to do. I suggest you re-write your original post in understandable terms, that someone who knows nothing about it can understand, and not have to follow your unformatted code. Oh and format (indent) your code.I shall do just that in the morning, also the code was formatted when I posted it, I don't know why it's stripped my formatting. 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