tantony Posted July 30, 2019 Posted July 30, 2019 This is my first post. I'm using the below script in my PowerShell script to resize and move some windows. My question is, when I move the window to 0,0 it doesn't go all the way to the top left corner. It leaves a small gap. What's the reason for that? I'm new to AutoIT, and so far, I found it very helpful in working with GUI. https://www.autoitscript.com/autoit3/docs/functions/WinMove.htm MoveWindow() Func MoveWindow() Run("notepad.exe") Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) WinMove($hWnd, "", 0, 0, 200, 200) EndFunc Thanks, Tony
Subz Posted July 30, 2019 Posted July 30, 2019 It's a known issue on Windows 10 seems there is padding, the easiest way is to use something like: MoveWindow() Func MoveWindow() Run("notepad.exe", "", @SW_MAXIMIZE) Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) Local $aWndPos = WinGetPos($hWnd, "") WinMove($hWnd, "", $aWndPos[0], $aWndPos[1], 200, 200) EndFunc
tantony Posted July 31, 2019 Author Posted July 31, 2019 When I run the script, I get an error on EndFunc
Subz Posted July 31, 2019 Posted July 31, 2019 Unfortunately sometimes when you copy the code from the forum it contains some hidden text, paste it in NotePadd++ or delete the EndFunc line and write it manually.
tantony Posted August 1, 2019 Author Posted August 1, 2019 I figured it out. Apparently, if you do -7 it will snap all the way to 0,0. I found this info from another Windows forum.
Subz Posted August 1, 2019 Posted August 1, 2019 On my machine it's -8 which is why I use the WinGetPos
tantony Posted August 1, 2019 Author Posted August 1, 2019 It could be -8 also (too small to notice). I just went with -7 because someone mentioned it in a tech forum. I don't remember where exactly.
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