Jump to content

Resize Current Window


 Share

Recommended Posts

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

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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 

HotKeySet

And then use the code from guinness

 

P.S. Welcome to the forum!

 

Edited by AdmiralAlkex
made it clearer (I hope)
Link to comment
Share on other sites

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 by LT2000
Link to comment
Share on other sites

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 by LT2000
Link to comment
Share on other sites

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

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

 

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...