Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Minimize GUI to tray fails with external minimize


  • Please log in to reply
5 replies to this topic

#1 JohnSAutoIt

JohnSAutoIt

    Seeker

  • Active Members
  • 35 posts

Posted 12 May 2012 - 05:35 AM

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.







#2 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 19,889 posts

Posted 12 May 2012 - 09:01 AM

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
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#3 JohnSAutoIt

JohnSAutoIt

    Seeker

  • Active Members
  • 35 posts

Posted 12 May 2012 - 12:09 PM

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 by JohnSAutoIt, 12 May 2012 - 12:13 PM.


#4 funkey

funkey

    New Dad

  • Active Members
  • PipPipPipPipPipPip
  • 602 posts

Posted 12 May 2012 - 02:54 PM

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 to

build bigger and better idiot-proof programs, and the Universe

trying to produce bigger and better idiots.

So far, the Universe is winning.


#5 JohnSAutoIt

JohnSAutoIt

    Seeker

  • Active Members
  • 35 posts

Posted 13 May 2012 - 01:14 AM

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 by JohnSAutoIt, 13 May 2012 - 01:19 AM.


#6 JohnSAutoIt

JohnSAutoIt

    Seeker

  • Active Members
  • 35 posts

Posted 28 June 2012 - 01:06 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users