JohnSAutoIt Posted May 12, 2012 Share Posted May 12, 2012 I have a GUI that minimizes to the tray. I used some code found in the forum that works fine with the GUI. However, if the GUI is minimized by other scripts or by Win+D, it minimizes to the Task Bar and does not respond other than right-click/close. The minimize and restore parts of the GUI are: Case $GUI_EVENT_MINIMIZE GUISetState(@SW_MINIMIZE) GUISetState(@SW_HIDE) TraySetState(1) ; show TraySetToolTip("AutoIt Scripts") Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func SpecialEvent() ; restore from tray GUISetState(@SW_RESTORE) GUISetState(@SW_SHOW) TraySetState(2) ; hide EndFunc ;==>SpecialEvent Clearly it needs some lines to cope with these external/Windows instructions but I have no idea how to define them. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 12, 2012 Moderators Share Posted May 12, 2012 JohnSAutoIt, Try making your GUI a child of the everpresent, but invisible, AutoIt GUI - then it does not have a taskbar button to display: $iParent_Win = WinGetHandle(AutoItWinGetTitle()) $hMain_Win = GUICreate("MyGUI", 200, 120, -1, -1, Default, Default, $iParent_Win) Any help? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnSAutoIt Posted May 12, 2012 Author Share Posted May 12, 2012 (edited) Thanks for the tip on AutoItWinGetTitle which I've never heard of! Your edit did what you described . Perhaps I was not specific enough - when I noted it minimized to the taskbar, that was it, no tray icon. With no presence on the GUI I have to close the process. Edit: The original GUI Create was as follows: $Input1 = GUICreate("AutoIt Scripts", 300, 630, 100, 60, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) Edited May 12, 2012 by JohnSAutoIt Link to comment Share on other sites More sharing options...
funkey Posted May 12, 2012 Share Posted May 12, 2012 I remember that if I had minimized some GUIs from external application, I had to use WinSetState instead of GuiSetState, to get everything working like expected. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
JohnSAutoIt Posted May 13, 2012 Author Share Posted May 13, 2012 (edited) I think I see the intent of using WinSetState. I tried it but still had the problem that the task bar item was unresponsive. I added a Function so I could monitor the window state. It seemed to follow what one would expect when Win+D activated, WinGetState was 23 so it was being seen as minimized, enabled etc. I resolved the problem by adding the WinGetState line: Case $GUI_EVENT_MINIMIZE GUISetState(@SW_MINIMIZE) GUISetState(@SW_HIDE) TraySetState(1) ; show TraySetToolTip("AutoIt Scripts") Case $GUI_EVENT_CLOSE Exit EndSwitch If BitAND(WinGetState("AutoIt Scripts"), 16) Then TraySetState(1) ; show WEnd Func SpecialEvent() ; restore from tray GUISetState(@SW_RESTORE) GUISetState(@SW_SHOW) TraySetState(2) ; hide EndFunc ;==>SpecialEvent That ensures the tray icon is visible when the GUI is minimized by whatever means. If externally minimized, the task bar item appeared as well as the tray icon but I can live with that (not a normal situation). I tried Melba23's lines on top of that addition - it did not immediately improve things so I called it a day. It's now usable. Thanks all. Edited May 13, 2012 by JohnSAutoIt Link to comment Share on other sites More sharing options...
JohnSAutoIt Posted June 28, 2012 Author Share Posted June 28, 2012 A belated resolution FYI based on Funkey's suggestion: Case $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) TraySetState(1) ; show TraySetToolTip("AutoIt Scripts") Case $GUI_EVENT_CLOSE Exit EndSwitch If BitAND(WinGetState("AutoIt Scripts"), 16) Then GUISetState(@SW_HIDE) ; hide TraySetState(1) ; show EndIf I found that the GUISetState and the TraySetState lines had to be in that order. Now the window minimizes to tray even when it's by an external operation such as Win+D 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