Jump to content

Minimize GUI to tray fails with external minimize


Recommended Posts

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 1 month later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...