LT2000 Posted August 26, 2015 Share Posted August 26, 2015 Totally new to AutoIt, but have created a few basic scripts.How can I resize the current window (or should I say most recently clicked window)? I am using a desktop shortcut to do this so as soon as I click it, I lose the focus of the window.Thanks Link to comment Share on other sites More sharing options...
guinness Posted August 26, 2015 Share Posted August 26, 2015 WinMove and 'ACTIVE'. See the help file for more details. 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...
AdmiralAlkex Posted August 26, 2015 Share Posted August 26, 2015 (edited) That would just return the desktop though. It would probably be easiest to let the script run in the background and use a hotkey to run your resize code. Look up HotKeySetAnd then use the code from guinness P.S. Welcome to the forum! Edited August 26, 2015 by AdmiralAlkex made it clearer (I hope) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
LT2000 Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) Yeah, that was the issue I originally had. I was using code from this link and it moved the desktop icons. I actually got WinMove to work if I first run a program since it is automatically active. But I can't do that in this case since the window already exists.I will have a look at the HotKeySet, but was really wanting to create an icon to handle. Edited August 26, 2015 by LT2000 Link to comment Share on other sites More sharing options...
LT2000 Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) Well since I am not a coder, I just hacked my way through it. This works. Basically I realized that the alt-tab structure always forces the most current window to the left of the list. So I used a send key to "activate" it and then applied the resize. Surely not best practice, but good enough for me.--Send("{ALTDOWN}{TAB}{LEFT}{ALTUP}")WinMove("", "", 0, 0, 900, 1367)---P.S. Not always 100% reliable (guess due to the alt-tab left and a timing issue) but usually works, so close enough for now at least. Edited August 26, 2015 by LT2000 Link to comment Share on other sites More sharing options...
LT2000 Posted August 26, 2015 Author Share Posted August 26, 2015 Definitely a reliability issue with the following command. Most of the time it finds the right window, but a lot of times it does not. Any idea why that is? Is that just asking too much from the string? I suspect if there was a delay between the alt-tab and left keys then it would be robust, but can't see how to make that happen.Send("{ALTDOWN}{TAB}{LEFT}{ALTUP}") Link to comment Share on other sites More sharing options...
l3ill Posted August 26, 2015 Share Posted August 26, 2015 Yup, very unreliable...consider using the suggestions given above.HotKeySet("{F2}", "_activate") While 1 Sleep(1000) WEnd Func _activate() WinMove("[ACTIVE]", "", 0, 0, 900, 1367) EndFunc LT2000 1 My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
LT2000 Posted August 26, 2015 Author Share Posted August 26, 2015 Thanks, that does work great! However, I am still wanting not quite ready to give up on the icon approach. This approach has some quirks, but works 100% so far. The major downside is the window has to be at the center of the screen. But not a terrible trade off.MouseClick("left",1280,720,1,0) ; selects window at center of screen WinMove("", "", 0, 0, 900, 1367) MouseClick("left",2300,1380,1,0) ; reposition mouse Link to comment Share on other sites More sharing options...
LT2000 Posted August 27, 2015 Author Share Posted August 27, 2015 At the end of the day, the hotkeys work really well and I can find some that will work for various window positioning.Thanks! 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