marko001 Posted October 20, 2021 Posted October 20, 2021 Hi all guys, I have several GUIs and the classic $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit in my While cycle. How can I "just" close (i.e. hide) the GUI i'm focusing and not exiting? I know I can use Guiswitch() but sometimes I have many GUIs opened and I just would like to close the one I'm focusing. To clarify. I developed a tool to monitor stocks. Whenever I select one it opens a graph (i.e. a GUI containing the graph). So I could have up to 15 graphs. Let's say I want to close the 3rd. How can I give focus (I mean not just clicking on it) and "x" to close? Thanks, Marco
marko001 Posted October 20, 2021 Author Posted October 20, 2021 (edited) @Loc thanks, but it's not clear to me. I mean, Guisetstate() can let me change the state (show/hide for example) If I press [X] on GUI1 (thus I'm obviously focusing it) and $GUI_EVENT_CLOSE it's a general check, how can AutoIt knows i'm on that GUI? maybe I should first check which GUI is focused then kill/hide/delete that one EDIT: Hmmm... If Winactive() then [...] maybe this is the solution Edited October 20, 2021 by marko001
ad777 Posted December 4, 2021 Posted December 4, 2021 (edited) On 10/20/2021 at 11:52 AM, marko001 said: Hi all guys, I have several GUIs and the classic $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit in my While cycle. How can I "just" close (i.e. hide) the GUI i'm focusing and not exiting? I know I can use Guiswitch() but sometimes I have many GUIs opened and I just would like to close the one I'm focusing. To clarify. I developed a tool to monitor stocks. Whenever I select one it opens a graph (i.e. a GUI containing the graph). So I could have up to 15 graphs. Let's say I want to close the 3rd. How can I give focus (I mean not just clicking on it) and "x" to close? Thanks, Marco i hope this help's:☺️ expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <Misc.au3> #RequireAdmin Example() Func Example() Global $check2 = "" Local $sItems, $aItems, $idListBox;;;; $Form1 = GUICreate("Form1", 401, 297, 324, 233) $Input1 = GUICtrlCreateInput("Untitled - Notepad", 120, 256, 121, 21) $Button1 = GUICtrlCreateButton("Refresh", 8, 256, 75, 25) $Checkbox1 = GUICtrlCreateCheckbox("long Focus", 272, 256, 97, 17) $idListBox = GUICtrlCreateList("", 0, 0, 385, 240, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL)) GUISetState(@SW_SHOW) _GUICtrlListBox_BeginUpdate($idListBox) Global $Array = WinList(GUICtrlRead($Input1)) For $i = 1 To $Array[0][0] Step 1 _GUICtrlListBox_AddString($idListBox, StringFormat("F1:Focus|| F2:Close "&$Array[$i][0]&"-"&WinGetHandle($Array[$i][1]), Random(1, 100, 1))) Sleep(10) Next _GUICtrlListBox_EndUpdate($idListBox) Do If _IsChecked($Checkbox1 ) Then If $check2 = "loop" Then _WinAPI_SetFocus(0x&StringSplit($sItems,"-0",$STR_ENTIRESPLIT)[2]);;0x00000 EndIf EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 MsgBox(0,"Fwindow","Updated") for $i = 0 To $Array[0][0] Step 1 _GUICtrlListBox_DeleteString($idListBox,0) Next Sleep(100) Global $Array = WinList(GUICtrlRead($Input1)) For $i = 1 To $Array[0][0] Step 1 _GUICtrlListBox_AddString($idListBox, StringFormat("F1:Focus|| F2:Close "&$Array[$i][0]&"-"&WinGetHandle($Array[$i][1]), Random(1, 100, 1))) Sleep(10) Next EndSwitch $aItems = _GUICtrlListBox_GetSelItemsText($idListBox) For $iI = 1 To $aItems[0] $sItems = $aItems[$iI] Next if StringLeft($sItems,1)Then if _IsPressed("2D",DllOpen("user32.dll")) Then;;;F1 Key $check = "loop" _WinAPI_SetFocus(0x&StringSplit($sItems,"-0",$STR_ENTIRESPLIT)[2]);;0x00000 EndIf EndIf if _IsPressed("71",DllOpen("user32.dll")) Then;F2 Key WinKill(HWnd(0x&StringSplit($sItems,"-0",$STR_ENTIRESPLIT)[2])) EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Edited December 30, 2021 by ad777 none
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