qwert Posted February 29, 2012 Share Posted February 29, 2012 (edited) My script runs an external application, which I retrieve the window handle for (the application) so I can move/size the window. That all works fine.Now I need to be able to minimize that same window ... so I issue a WinSetState($handle, "", @SW_MINIMIZE)It minimizes ... but it minimizes within the workspace of my script's GUI (apparently). A taskbar-like entry shows up at the bottom of my GUI and not on the Windows Taskbar.How can I minimize that external application so that it appears on the Taskbar and works like any other? When I exit my script, I want to leave the application running — and have the user be able to control it normally, as if they had started it. I never knew there were two levels of Minimize.Thanks for any help. Edited February 29, 2012 by qwert Link to comment Share on other sites More sharing options...
guinness Posted February 29, 2012 Share Posted February 29, 2012 Search the forum (specifically the examples section) for an application called Minime, this will give you an idea of how to achieve this. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
KaFu Posted February 29, 2012 Share Posted February 29, 2012 From your description it sounds like you've set your open gui as the parent window for the external app. Set the parent window to desktop and minimization to taskbar should work fine. Otherwise post some sample code ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
qwert Posted February 29, 2012 Author Share Posted February 29, 2012 Set the parent window to desktop and minimization to taskbar should work fine. ...That sounds perfect!Er ... how do I do that? The only option I see for the Run command is $RUN_CREATE_NEW_CONSOLE. Is that it? Or do I have to run command prompt and "type" the start command with a Send?(Thanks for your help with this.) Link to comment Share on other sites More sharing options...
KaFu Posted February 29, 2012 Share Posted February 29, 2012 Maybe this works for you, otherwise... show the code. #include <WinAPI.au3> _WinAPI_SetParent($handle, _WinAPI_GetDesktopWindow()) WinSetState($handle, "", @SW_MINIMIZE) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
qwert Posted February 29, 2012 Author Share Posted February 29, 2012 Well, it looked promising, but it didn't change anything. Here are the essential steps of my start sequence. Note that the delays are ones that I have found necessary for the actual application I'm starting. My experience is that the Process starts and can be tested, but that the corresponding window doesn't exist for some moments ... hence the delays. $1stWin = Run( "C:\Windows\Notepad.exe", "", @SW_HIDE) ProcessWait($1stWin) Sleep(1000) ; give process time to open a window $Data = _WinAPI_EnumProcessWindows($1stWin) If @error Then MsgBox(0, 'ERROR', 'Failed to find window to PID: ' & $1stWin) Else $hWnd1 = $Data[1][0] $state = WinGetState ( $hWnd1) WinSetState($hWnd1, "", @SW_HIDE) Sleep(1000) ; pause before moving window WinMove($hWnd1, "", 100, 100, 500, 600) $res = _WinAPI_SetParent($hWnd1,_WinAPI_GetDesktopWindow()) Any suggestions you can make will be appreciated (especially if you know how to eliminate the delays). Link to comment Share on other sites More sharing options...
BrewManNH Posted February 29, 2012 Share Posted February 29, 2012 (edited) You're hiding the notepad window, so even if it's working, you're never going to know because you can't see it. EDIT: Also, you never use the @SW_MINIMIZE macro, so I'm not sure what it is you're trying to accomplish other than having a hidden notepad window. Edited February 29, 2012 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
UEZ Posted February 29, 2012 Share Posted February 29, 2012 Try this: #include <Misc.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $hDLL = DllOpen("user32.dll") HotKeySet("{ESC}", "_Exit") OnAutoItExitRegister("_Exit") While Sleep(50) ToolTip("Click on a window to minimize it!", MouseGetPos(0) + 10, MouseGetPos(1) + 10) If _IsPressed("01", $hDLL) Then Min_Win() WEnd Func Min_Win() Local $aRet = DllCall("user32.dll", "int", "WindowFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1)) Local $hWnd = _WinAPI_GetAncestor(HWnd($aRet[0]), $GA_ROOT) WinSetState($hWnd, "", @SW_MINIMIZE) EndFunc Func _Exit() ToolTip("") DllClose($hDLL) Exit EndFunc Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
qwert Posted February 29, 2012 Author Share Posted February 29, 2012 (edited) You're hiding the notepad window, so even if it's working, you're never going to know because you can't see it.Also, you never use the @SW_MINIMIZE macro, so I'm not sure what it is you're trying to accomplish other than having a hidden notepad window.Both true, of course. But both are the result of me pulling steps out of my real script in order to represent the problem in a simpler way. Indeed, a later part of my script Shows the notepad and Minimizes it. I regret the confusion I injected.@UEZ: I can't follow how your suggestion will fit my particular need. Here is the key point:When I exit my script, I want to leave the application running — and have the user be able to control it normally, as if they had started it.So, KaFu's original line of reasoning was on the right track. It is unfortunate it didn't exactly work.Thanks for your responses.(One more clarification: The Run Notepad statement is one of the first actions my script takes. The script hasn't performed a CreateGUI at that point, although it does, later. However, there is a Splash up at the point of the Run Notepad, if that counts as a GUI.) Edited February 29, 2012 by qwert Link to comment Share on other sites More sharing options...
BrewManNH Posted February 29, 2012 Share Posted February 29, 2012 Try changing this line: $Data = _WinAPI_EnumProcessWindows($1stWin, False) ; Add the false parameter to find hidden windows If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
UEZ Posted February 29, 2012 Share Posted February 29, 2012 (edited) @qwert: I showed a way how to minimize any GUI and also the desktop . This more or less what I understood. You never posted any example so what do you expect? I would suggest to post a demonstration code and we can try to help you better. Br, UEZ Edited February 29, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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