rix Posted November 19, 2021 Share Posted November 19, 2021 I'm a newbie. i need a script to minimize an active windows Can you teach/help me? Thanks in advance... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 19, 2021 Moderators Share Posted November 19, 2021 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team 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...
Moderators Melba23 Posted November 19, 2021 Moderators Share Posted November 19, 2021 rix, Welcome to the AutoIt forums. I would suggest looking at WinSetState in the Help file. 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...
Comatose Posted November 19, 2021 Share Posted November 19, 2021 This is actually a bit complicated. Minimizing the window is the easy part. Being on the correct window will take a bit of coding. WinList will show the open windows. Then you'll have to compare to see if the window you're looking for is open. If so make it the active window then minimize it. OR ... if you know the windows exact name you could just try to make it active. If that works then you can minimize it. If not the window couldn't be found. There is a tool called: AutoIt v3 Window Information. You can use that to find the exact window text you can use (It's basically the name of the window and/or any text you added). Raw commands would be: WinActivate ( "title" [, "text"] ) and WinSetState ( "title", "text", @SW_MINIMIZE)Without anymore context in your question this is just a generic answer for you. Link to comment Share on other sites More sharing options...
SkysLastChance Posted November 19, 2021 Share Posted November 19, 2021 (edited) Here is an example with notepad. OpenNotepad () Func OpenNotepad () Local $iNotePad = Run("notepad.exe", "", @SW_MAXIMIZE) WinWait("[CLASS:Notepad]", "", 5) Sleep(5000) WinSetState($iNotePad,"",@SW_MINIMIZE) ProcessClose($iNotePad) EndFunc Edited November 19, 2021 by SkysLastChance You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott Link to comment Share on other sites More sharing options...
Musashi Posted November 19, 2021 Share Posted November 19, 2021 3 hours ago, rix said: i need a script to minimize an active windows Can you teach/help me? Thanks in advance... To get the title or handle of the active window : HotKeySet("{ESC}", "_Terminate") HotKeySet("+!1", "_ActiveWindow") ; Shift-Alt-1 Global $sTitleActive, $hHandleActive ; Title or Handle While True Sleep(100) WEnd Func _ActiveWindow() $sTitleActive = WinGetTitle("[active]") $hHandleActive = WinGetHandle("[active]") MsgBox(BitOR(4096, 64), "Minimize :", "Title : " & @CRLF & $sTitleActive & @CRLF & _ "Handle : " & @CRLF & $hHandleActive & @CRLF) EndFunc Func _Terminate() MsgBox(BitOR(4096, 64), "Message :", "Script terminated" & @CRLF) Exit EndFunc Use WinSetState (with title or handle) to minimize the active window for example. SkysLastChance and rix 2 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
rix Posted November 21, 2021 Author Share Posted November 21, 2021 I've an idea ( i'm juist a newbie): is it possible to simulate this sequence: alt+space and then i? Link to comment Share on other sites More sharing options...
Danp2 Posted November 21, 2021 Share Posted November 21, 2021 @rixYes, I'm sure it's possible. But it would be way less reliable than using WinSetState("[ACTIVE]","",@SW_MINIMIZE) SkysLastChance 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
rix Posted November 23, 2021 Author Share Posted November 23, 2021 On 11/19/2021 at 11:31 PM, Musashi said: To get the title or handle of the active window : HotKeySet("{ESC}", "_Terminate") HotKeySet("+!1", "_ActiveWindow") ; Shift-Alt-1 Global $sTitleActive, $hHandleActive ; Title or Handle While True Sleep(100) WEnd Func _ActiveWindow() $sTitleActive = WinGetTitle("[active]") $hHandleActive = WinGetHandle("[active]") MsgBox(BitOR(4096, 64), "Minimize :", "Title : " & @CRLF & $sTitleActive & @CRLF & _ "Handle : " & @CRLF & $hHandleActive & @CRLF) EndFunc Func _Terminate() MsgBox(BitOR(4096, 64), "Message :", "Script terminated" & @CRLF) Exit EndFunc Use WinSetState (with title or handle) to minimize the active window for example. I've got a doubt: but is the script uncomplete? or do I have to change it? if I run it I get nothing. I apologize for the obvious, but I am not an expert. I tried to simulate win +down but it closes all the windows .... if I really press the keys it closes the active window Link to comment Share on other sites More sharing options...
Musashi Posted November 23, 2021 Share Posted November 23, 2021 54 minutes ago, rix said: I've got a doubt: but is the script uncomplete? or do I have to change it? if I run it I get nothing. The script runs in the background (until you press ESC). It does not minimize anything, but shows you the title and handle of the currently active window. You can use this information to e.g. minimize the active window. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
rix Posted November 27, 2021 Author Share Posted November 27, 2021 Yeap but i don't obtain a title, just the message script terminated when i press esc... Link to comment Share on other sites More sharing options...
Musashi Posted November 27, 2021 Share Posted November 27, 2021 45 minutes ago, rix said: Yeap but i don't obtain a title, just the message script terminated when i press esc... Please perform a test : #include <MsgBoxConstants.au3> HotKeySet("{ESC}", "_Terminate") HotKeySet("+!1", "_ContolHasFocus") ; Shift-Alt-1 Run("notepad.exe") Global $sControl, $hHandle, $sTitle Global $hWnd = WinWait("[CLASS:Notepad]", "", 10) While True Sleep(100) WEnd Func _ContolHasFocus() $hHandle = WinGetHandle("[active]") $sTitle = WinGetTitle("[active]") $sControl = ControlGetFocus($hWnd) MsgBox(BitOR(4096, 64), "Focus :", _ "Handle : " & @CRLF & $hHandle & @CRLF & _ "Titel : " & @CRLF & $sTitle & @CRLF & _ "Focus : " & @CRLF & $sControl & @CRLF) EndFunc Func _Terminate() MsgBox(BitOR(4096, 64), "Message :", "Script terminated" & @CRLF) Exit EndFunc Run the script. After Notepad is launched, then open whatever text file you want. Now press Shift Alt 1 Use the 1 from the keyboard, not the 1 from the Numpad. What happens now? "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
rix Posted November 28, 2021 Author Share Posted November 28, 2021 This one, it works fine...i've got handle and title Link to comment Share on other sites More sharing options...
Musashi Posted November 28, 2021 Share Posted November 28, 2021 52 minutes ago, rix said: This one, it works fine...i've got handle and title OK ! Another test : Start your application (may not be minimized). Now run the following script within the SciTE editor (F5). (from @Subz : getting-list-of-all-normal-windows ) #include <Array.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Local $hWindow, $vWinStyle, $aWinNormal[1][2] Local $aWinList = WinList("[REGEXPTITLE:(?i)(.+)]") For $i = $aWinList[0][0] To 1 Step -1 If $aWinList[$i][0] = "" Then ContinueLoop $hWindow = WinGetHandle($aWinList[$i][1], "") If Not $hWindow Then ContinueLoop $vWinStyle = _WinAPI_GetWindowLong($hWindow, $GWL_STYLE) If BitAND(WinGetState($aWinList[$i][1]), 4) = 4 _ And BitAND($vWinStyle, $WS_VISIBLE) = $WS_VISIBLE _ And BitAND($vWinStyle, $WS_MINIMIZE) <> $WS_MINIMIZE _ And BitAND($vWinStyle, $WS_MINIMIZEBOX) = $WS_MINIMIZEBOX _ And BitAND($vWinStyle, $WS_MAXIMIZEBOX) = $WS_MAXIMIZEBOX Then _ArrayAdd($aWinNormal, $aWinList[$i][0] & "|" & $aWinList[$i][1]) Next $aWinNormal[0][0] = UBound($aWinNormal) - 1 _ArrayDisplay($aWinNormal) Does your application appear in the list? "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
rix Posted November 30, 2021 Author Share Posted November 30, 2021 (edited) Yeap at the end of the list, i've got my application name. Sorry my english isn't perfect Edited December 4, 2021 by rix 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