Liquid5n0w Posted June 5, 2019 Share Posted June 5, 2019 I have found a script that will minimize the currently focused window when a hotkey is pressed, but I don't know AutiIt very well. I'm thinking of a loop checking if an exe has focus or not, and if it's minimized or not. If it's not focused and not minimized, I want to send a command to minimize it. Can anyone advise the right commands to lookup for that kind of thing? Func _MinimizeActive() Local $v_Wnd, $w_Wnd ;declare variables $v_Wnd = _WinAPI_GetFocus() ;get focused window $w_Wnd = WinGetHandle($v_Wnd) ;get handle of focused window WinSetState($w_Wnd,"",@SW_MINIMIZE) ;minimize focused window EndFunc Link to comment Share on other sites More sharing options...
Earthshine Posted June 5, 2019 Share Posted June 5, 2019 (edited) snip... is this so you can hide your gaming from your boss or something? Edited June 5, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Liquid5n0w Posted June 5, 2019 Author Share Posted June 5, 2019 1 hour ago, Earthshine said: snip... is this so you can hide your gaming from your boss or something? I would never inappropriately use work resources and time! Especially not time I have free because I'm good at my job. Link to comment Share on other sites More sharing options...
Earthshine Posted June 5, 2019 Share Posted June 5, 2019 good to know. if you look at the help file included with AutoIt or online help you will see all kinds of built in Windows functions to use also, you can auto minimize everything on your desktop with a windows key shortcut My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Developers Jos Posted June 5, 2019 Developers Share Posted June 5, 2019 1 hour ago, Earthshine said: snip... is this so you can hide your gaming from your boss or something? How do you say in English: "It takes one to know one" ? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Earthshine Posted June 5, 2019 Share Posted June 5, 2019 (edited) nah, I got caught a very long time ago and learned my lesson. was too thick to hide the windows. Edited June 5, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Liquid5n0w Posted June 5, 2019 Author Share Posted June 5, 2019 1 hour ago, Earthshine said: good to know. if you look at the help file included with AutoIt or online help you will see all kinds of built in Windows functions to use also, you can auto minimize everything on your desktop with a windows key shortcut Yeah the shortcut key is what I use now, but I have gotten use to one program that has this behavior built in(Factorio), and I want to add it to others. I have found WinWaitNotActive in the help file, which solved one of the problems. I can use WinActive to look for the window on a delay loop, then on another loop check if it's not active? Then other loop check if it's not minimized? Then use WinSetState to minimize it. When it says it returns the handle, thats the parameter to pass to WinSetState right(hWnd)? Link to comment Share on other sites More sharing options...
Earthshine Posted June 5, 2019 Share Posted June 5, 2019 (edited) just use WinExists to find windows, then see what their state is. Read the helpfile more. https://www.autoitscript.com/autoit3/docs/functions/WinExists.htm https://www.autoitscript.com/autoit3/docs/functions/WinSetState.htm notice the helpfile information regarding the paramerters, you can pass title, handle or class of the window Parameters title The title/hWnd/class of the window to change the state. See Title special definition. text The text of the window to change the state. See Text special definition. flag The "show" flag of the executed program: @SW_HIDE = Hide window @SW_SHOW = Shows a previously hidden window @SW_MINIMIZE = Minimize window @SW_MAXIMIZE = Maximize window @SW_RESTORE = Undoes a window minimization or maximization @SW_DISABLE = Disables the window @SW_ENABLE = Enables the window use the helpfile and run the samples in it to learn how to use each function. Edited June 5, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Nine Posted June 5, 2019 Share Posted June 5, 2019 Here something you can build on : #include <MsgBoxConstants.au3> #include <WinAPISysWin.au3> HotKeySet ("{ESC}","_Exit") WinMinimizeAll() Sleep (500) Const $hDesktop = _WinAPI_GetForegroundWindow () Local $hWinPrec = $hDesktop While True Sleep (100) $hWin = _WinAPI_GetForegroundWindow () If $hWin = $hWinPrec Then ContinueLoop ConsoleWrite ($hWin & "/" & $hWinPrec & @CRLF) If $hWinPrec And $hWinPrec <> $hDesktop And WinGetTitle ($hWinPrec) <> "" And Not BitAnd(WinGetState ($hWinPrec), $WIN_STATE_MINIMIZED) Then ConsoleWrite ("Minimizing " & $hWinPrec & @CRLF) WinSetState ($hWinPrec, "", @SW_MINIMIZE) EndIf $hWinPrec = $hWin WEnd Func _Exit () Exit EndFunc It is not perfect, if you play with window's task bar, it will get somewhat defective. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Liquid5n0w Posted June 6, 2019 Author Share Posted June 6, 2019 I did this and it seems to work, but it seems to have an error sometimes with a flashing X on the icon. Where do I get the log to figure out the error? While 1 ;loop to keep alive WinWaitNotActive("[CLASS:HaemimontGamesWindowClass]") WinSetState("[CLASS:HaemimontGamesWindowClass]", "", @SW_MINIMIZE) WinWaitActive("[CLASS:HaemimontGamesWindowClass]") WEnd Link to comment Share on other sites More sharing options...
Earthshine Posted June 6, 2019 Share Posted June 6, 2019 (edited) snip Edited June 6, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Nine Posted June 6, 2019 Share Posted June 6, 2019 41 minutes ago, Liquid5n0w said: CLASS:HaemimontGamesWindowClass You should read about forum rules, especially the part of game automation ! Earthshine 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Earthshine Posted June 6, 2019 Share Posted June 6, 2019 (edited) oops, i didn't even notice that. just focused on function calls. so it's about games, and somehow I could feel it from my first post. LOL. Edited June 6, 2019 by Earthshine Nine and FrancescoDiMuro 2 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 6, 2019 Moderators Share Posted June 6, 2019 (edited) Welcome to the AutoIt forum. Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. The Moderation team Edit: To other forum members, earlier in the thread perhaps you should have pointed to the forum rules if you had suspicions, a simple - "Check out the forum rules, make sure you're adhering to them". We may have gotten to this point a whole lot more quickly. Edited June 6, 2019 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts