goldenix Posted July 22, 2007 Posted July 22, 2007 several hours of forum & hepl file search did not result in any progress at all....so let me ask you guys:I have 3 GUIs & i want to minimize to tray only the gui I click $GUI_EVENT_MINIMIZE on, Note that prog is written in Opt("GUIOnEventMode", 1) Basically this works, but The problem is, that the GUIs are are just being minimized (I see the guis on my taskbar) instead of being minimizsed to tray:I hope someone can give me a hand hire.#include <GUIConstants.au3> AutoItSetOption("WinTitleMatchMode", 4) ; Change into the WinTitleMatchMode that supports classnames and handles Opt("GUIOnEventMode", 1) ; Change to OnEvent mode ;~ Gui ;~ ------------------------------------------------------------------------------------------------------- $GUI1 = GUICreate("GUI1", 400, 100) GUISetState(@SW_SHOW) ; makes Gui Visible $GUI2 = GUICreate("GUI2", 440, 100,) GUISetState(@SW_SHOW) $GUI3 = GUICreate("GUI3", 440, 100,) GUISetState(@SW_SHOW) ;~ GUI Events ;~ --------------------------------------------------------------------------------------------------------- GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Minimize") func _Minimize() ; Get the handle of a window $handle = WinGetHandle("GUI1") If $handle = $GUI1 Then GUISetState(@SW_HIDE,$GUI1) ; Hide GUI1 $handle2 = WinGetHandle("GUI2") If $handle2 = $GUI2 Then GUISetState(@SW_HIDE,$GUI2) $handle3 = WinGetHandle("GUI3") If $handle3 = $GUI2 Then GUISetState(@SW_HIDE,$GUI3) EndFunc While 1 ; Keep prog alive Sleep(100) WEnd My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
martin Posted July 22, 2007 Posted July 22, 2007 several hours of forum & hepl file search did not result in any progress at all....so let me ask you guys: I have 3 GUIs & i want to minimize to tray only the gui I click $GUI_EVENT_MINIMIZE on, Note that prog is written in Opt("GUIOnEventMode", 1) Basically this works, but The problem is, that the GUIs are are just being minimized (I see the guis on my taskbar) instead of being minimizsed to tray: I hope someone can give me a hand hire. #include <GUIConstants.au3> AutoItSetOption("WinTitleMatchMode", 4) ; Change into the WinTitleMatchMode that supports classnames and handles Opt("GUIOnEventMode", 1) ; Change to OnEvent mode ;~ Gui ;~ ------------------------------------------------------------------------------------------------------- $GUI1 = GUICreate("GUI1", 400, 100) GUISetState(@SW_SHOW) ; makes Gui Visible $GUI2 = GUICreate("GUI2", 440, 100,) GUISetState(@SW_SHOW) $GUI3 = GUICreate("GUI3", 440, 100,) GUISetState(@SW_SHOW) ;~ GUI Events ;~ --------------------------------------------------------------------------------------------------------- GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Minimize") func _Minimize() ; Get the handle of a window $handle = WinGetHandle("GUI1") If $handle = $GUI1 Then GUISetState(@SW_HIDE,$GUI1) ; Hide GUI1 $handle2 = WinGetHandle("GUI2") If $handle2 = $GUI2 Then GUISetState(@SW_HIDE,$GUI2) $handle3 = WinGetHandle("GUI3") If $handle3 = $GUI2 Then GUISetState(@SW_HIDE,$GUI3) EndFunc While 1 ; Keep prog alive Sleep(100) WEnd First you have an errors which are not causing your problem but need to be corrected. $GUI2 = GUICreate("GUI2", 440, 100,);<--------comma to be removed $GUI3 = GUICreate("GUI3", 440, 100,);<--------do If $handle3 = $GUI2 Then GUISetState(@SW_HIDE,$GUI3);<------------ should be = $GUI3 You don't need the wingethandle, you can just say GUISetSTate(@SW_HIDE,$GUI3) The problem with gui icons on the task bar is when, as you say, they have been minimised. If you set an event for $GUI_EVENT_CLOSE and then set the gui to @SW_HIDE it won't be on the task bar. So one way round it is to say if the state is minimized then restore it and hide it. The other way I've read that this can be done is to first create a dummy form which is always hidden. Make the new forms be children of the dummy form and then when they are minimized they won't appear on the task bar. If I ever tried this I can't remember if it works. But I prefer to say that if someone mnimizes an application they should be able to see it on the task bar. If they close it they expect it to be gone, and if I don't want it to close then I just hide it. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
goldenix Posted July 22, 2007 Author Posted July 22, 2007 Thank you. thanx to your post I found really easy way, how to manipulate with your Gui GUISetOnEvent`s: Hire is the working sample & explanations in the comments:#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode ;~ Gui 1 ;~ ------------------------------------------------------------------------------------------------------- $GUI1 = GUICreate("GUI1", 400, 100) GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Minimize") ; must be set separately for each GUI GUISetState(@SW_SHOW) ; makes Gui Visible ;~ Gui 2 $GUI2 = GUICreate("GUI2", 440, 100) GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Minimize") GUISetState(@SW_SHOW) ;~ Gui 3 $GUI3 = GUICreate("GUI3", 440, 100) GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Minimize") GUISetState(@SW_SHOW) ;~ GUI Events ;~ --------------------------------------------------------------------------------------------------------- func _Minimize() ; @GUI_WINHANDLE checks where (GUI) the action came from If @GUI_WINHANDLE = $GUI1 Then GUISetState(@SW_HIDE,$GUI1) If @GUI_WINHANDLE = $GUI2 Then GUISetState(@SW_HIDE,$GUI2) If @GUI_WINHANDLE = $GUI3 Then GUISetState(@SW_HIDE,$GUI3) EndFunc While 1 ; Keep prog alive Sleep(100) WEnd My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
martin Posted July 22, 2007 Posted July 22, 2007 (edited) goldenix, that's much better than what I said. You can make the _Minimize function simpler too func _Minimize() GUISetState(@SW_HIDE,@GUI_WINHANDLE) EndFunc Edited July 22, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
smashly Posted July 24, 2007 Posted July 24, 2007 You may want to use this as wellOpt("GUIEventOptions",1) This way the window wont minimise or maximise or close from the title bar controls, but it will still send the message when the controls are clicked. This way when you show the window it will not need to be restored after minimize/hide. Cheers
martin Posted July 24, 2007 Posted July 24, 2007 You may want to use this as wellOpt("GUIEventOptions",1) CheersAs well?? all the earlier posts do just that. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
smashly Posted July 24, 2007 Posted July 24, 2007 (edited) The reason for my suggestion.. Using the function as it currently, when you Click the minimize window button then the GUI will still be in a minimized hidden state. If you show the gui window again then it will still be minimized.. So you'll also have to restore the window after showing it. When you use Opt("GUIEventOptions",1) and you use the function as it is the window would be hidden and not minimized.. So when you show the window again it wont need to be restored. Cheers Edit: Example without Opt("GUIEventOptions",1) :expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) #NoTrayIcon Global $TrayItem[6] ;~ Gui 1 ;~ ------------------------------------------------------------------------------------------------------- $GUI1 = GUICreate("GUI1", 400, 100) GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Minimize") ; must be set separately for each GUI GUISetState(@SW_SHOW) ; makes Gui Visible ;~ Gui 2 $GUI2 = GUICreate("GUI2", 440, 100) GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Minimize") GUISetState(@SW_SHOW) ;~ Gui 3 $GUI3 = GUICreate("GUI3", 440, 100) GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Minimize") GUISetState(@SW_SHOW) ;- Tray Menu $spTiName = StringSplit("Show GUI 1|Show GUI 2|Show GUI 3||Exit", "|") For $i = 1 To 5 $TrayItem[$i] = TrayCreateItem($spTiName[$i]) TrayItemSetOnEvent(-1, "_TrayMenu") Next TraySetState() While 1 ; Keep prog alive Sleep(100) WEnd ;~ GUI Events ;~ --------------------------------------------------------------------------------------------------------- func _Minimize() ; @GUI_WINHANDLE checks where (GUI) the action came from If @GUI_WINHANDLE = $GUI1 Then GUISetState(@SW_HIDE,$GUI1) If @GUI_WINHANDLE = $GUI2 Then GUISetState(@SW_HIDE,$GUI2) If @GUI_WINHANDLE = $GUI3 Then GUISetState(@SW_HIDE,$GUI3) EndFunc ;- Tray Events ;~ --------------------------------------------------------------- Func _TrayMenu() Select Case @TRAY_ID = $TrayItem[1] GUISetState(@SW_SHOW,$GUI1) Case @TRAY_ID = $TrayItem[2] GUISetState(@SW_SHOW,$GUI2) Case @TRAY_ID = $TrayItem[3] GUISetState(@SW_SHOW,$GUI3) Case @TRAY_ID = $TrayItem[5] Exit EndSelect EndFuncoÝ÷ Ù&¦yìZ^Â+a:jºFP/z{N¦Ø¨Ê®¢ÝZºÚ"µÍÚ[ÛYH ÑÕRPÛÛÝ[Ë]LÉÝÂÜ ][ÝÑÕRSÛ][[ÙI][ÝËJHÈÚ[ÙHÈÛ][[ÙBÜ ][ÝÑÕRQ][Ü[ÛÉ][ÝËJBÜ ][ÝÕ^SÛ][[ÙI][ÝËJBÜ ][ÝÕ^SY[S[ÙI][ÝËJBÓÕ^RXÛÛÛØ[ ÌÍÕ^R][VÍBßÝZHBßKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKBÌÍÑÕRLHHÕRPÜX]J ][ÝÑÕRLI][ÝË L BÕRTÙ]Û][ ÌÍÑÕRWÑUSÓRSSRVK ][Ý×ÓZ[[Z^I][ÝÊHÈ]ÝHÙ]Ù][HÜXXÚÕRBÕRTÙ]Ý]JÕ×ÔÒÕÊHÈXZÙÈÝZHÚXBßÝZHÌÍÑÕRLHÕRPÜX]J ][ÝÑÕRL][ÝË L BÕRTÙ]Û][ ÌÍÑÕRWÑUSÓRSSRVK ][Ý×ÓZ[[Z^I][ÝÊBÕRTÙ]Ý]JÕ×ÔÒÕÊBßÝZHÂÌÍÑÕRLÈHÕRPÜX]J ][ÝÑÕRLÉ][ÝË L BÕRTÙ]Û][ ÌÍÑÕRWÑUSÓRSSRVK ][Ý×ÓZ[[Z^I][ÝÊBÕRTÙ]Ý]JÕ×ÔÒÕÊBËH^HY[BÌÍÜÜS[YHHÝ[ÔÜ] ][ÝÔÚÝÈÕRH_ÚÝÈÕRHÚÝÈÕRHß^] ][ÝË ][Ýß ][ÝÊBÜ ÌÍÚHHHÈ BIÌÍÕ^R][VÉÌÍÚWHH^PÜX]R][J ÌÍÜÜS[YVÉÌÍÚWJBU^R][TÙ]Û][ LK ][Ý×Õ^SY[I][ÝÊB^^TÙ]Ý]J BÚ[HHÈÙYÙÈ[]BÛY L BÑ[ßÕRH][ÂßKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKB[ÈÓZ[[Z^J BNÈÕRWÕÒSSHÚXÚÜÈÚH ÕRJHHXÝ[ÛØ[YHÛBYÕRWÕÒSSHH ÌÍÑÕRLH[ÕRTÙ]Ý]JÕ×ÒQK ÌÍÑÕRLJBYÕRWÕÒSSHH ÌÍÑÕRL[ÕRTÙ]Ý]JÕ×ÒQK ÌÍÑÕRLBRYÕRWÕÒSSHH ÌÍÑÕRLÈ[ÕRTÙ]Ý]JÕ×ÒQK ÌÍÑÕRLÊH[[ÂËH^H][ÂßKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKB[ÈÕ^SY[J BTÙ[XÝBPØÙHVWÒQH ÌÍÕ^R][VÌWBBBQÕRTÙ]Ý]JÕ×ÔÒÕË ÌÍÑÕRLJBBPØÙHVWÒQH ÌÍÕ^R][VÌBÕRTÙ]Ý]JÕ×ÔÒÕË ÌÍÑÕRLBBPØÙHVWÒQH ÌÍÕ^R][VÌ×BBBQÕRTÙ]Ý]JÕ×ÔÒÕË ÌÍÑÕRLÊBBPØÙHVWÒQH ÌÍÕ^R][VÍWBBBQ^]Q[Ù[XÝ[[ Edited July 24, 2007 by smashly
GEOSoft Posted July 24, 2007 Posted July 24, 2007 Here is a piece of code that I use. Modify it for your own use. Func Hide_GUI() Global $Tr_Disp = 1 GuiSetState(@SW_HIDE,$Frm_Main ) TraySetOnEvent(-8,"Restore_GUI") TraySetOnEvent(-10,"_Exit") TrayTip($Ttl,'Left click to restore' & @CRLF & 'Right click to Exit',5,1) Opt("TrayIconHide", 0) EndFunc ;<===> Hide_GUI() Func Restore_GUI() GuiSetState(@SW_Show,$Frm_Main ) WinActivate ($Frm_Main) TraySetState ( 2 ) Opt("TrayIconHide", 1) EndFunc ;<===> Restore_GUI() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
smashly Posted July 24, 2007 Posted July 24, 2007 A smashlified example of the original code with tray menu to control the hide n show.expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt("GUIEventOptions",1) Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) #NoTrayIcon Global $GUI[4], $TrayItem[6], $x = 400, $MinState[4] ;~ Gui 1 To 3 For $g = 1 To 3 $GUI[$g] = GUICreate("GUI" & $g, $x, 100) GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Minimize") GUISetState(@SW_SHOW, $GUI[$g]) $x = 440 Next ;- Tray Menu $spTiName = StringSplit("Minimize GUI1|Minimize GUI2|Minimize GUI3||Exit", "|") For $i = 1 To 5 $TrayItem[$i] = TrayCreateItem($spTiName[$i]) TrayItemSetOnEvent(-1, "_TrayMenu") Next $spTiName = 0 TraySetState() While 1 ; Keep prog alive Sleep(100) WEnd ;~ GUI Events func _Minimize() For $s = 1 To 3 If @GUI_WINHANDLE = $GUI[$s] Then GUISetState(@SW_HIDE, $GUI[$s]) TrayItemSetText($TrayItem[$s], "Restore GUI" & $s) $MinState[$s] = 1 EndIf Next EndFunc ;- Tray Events Func _TrayMenu() For $t = 1 To 5 If $t = 4 Then ContinueLoop If @TRAY_ID = $TrayItem[$t] And $t < 4 And $MinState[$t] = 1 Then GUISetState(@SW_SHOW, $GUI[$t]) TrayItemSetText($TrayItem[$t], "Minimize GUI" & $t) $MinState[$t] = 0 ElseIf @TRAY_ID = $TrayItem[$t] And $t < 4 And $MinState[$t] = 0 Then GUISetState(@SW_HIDE, $GUI[$t]) TrayItemSetText($TrayItem[$t], "Restore GUI" & $t) $MinState[$t] = 1 ElseIf @TRAY_ID = $TrayItem[5] Then Exit EndIf Next EndFunc
martin Posted July 24, 2007 Posted July 24, 2007 The reason for my suggestion..Using the function as it currently, when you Click the minimize window button then the GUI will still be in a minimized hidden state.If you show the gui window again then it will still be minimized..So you'll also have to restore the window after showing it.When you use Opt("GUIEventOptions",1) and you use the function as it is the window would be hidden and not minimized..So when you show the window again it wont need to be restored.Oh I see what you were saying smashly. I misread GUIEventOptions as GUIOnEvent. Writing programs can be hard work when you're duckslegsmix. Thanks for pointing that out, I'd never noticed it before. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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