Jump to content
Sign in to follow this  

WinMove Google Chrome

Recommended Posts


Hey Guys:

I'm attempting to run Chrome and bring it over to my first monitor (of three) for performing my automated task.  

I've tried several of the sample scripts for opening calc or notepad but can't seem to get anything to work.  The most I can get is for the script to open notepad or move my current window on monitor 2 to monitor 1.

I've tried this - https://www.autoitscript.com/autoit3/docs/functions/WinMove.htm

and this - http://ahkscript.org/docs/commands/WinMove.htm 

neither work.

Can anyone help?

Share this post

Link to post
Share on other sites

Your first link is AutoIT and it should work.  I would assume your not using the function properly.

Can you post an example of the code you have tried so we can possibly surmount where you went wrong?

I just tried this and have it working for me, very generic.  I would put the specific window title or even use the Chrome.udf for more finite control.

If multiple windows I would incorporate WinList()

WinWait("", "Chrome Legacy Window")
WinActivate("", "Chrome Legacy Window")
WinSetState("", "Chrome Legacy Window", @SW_RESTORE)
WinMove("", "Chrome Legacy Window", -1000, 0)
WinSetState("", "Chrome Legacy Window", @SW_MAXIMIZE)


Edited by ViciousXUSMC

Share this post

Link to post
Share on other sites

I just tried the notepad script in a new file and it worked.  What class should I use for Chrome?



Func TestFunction() ;temp function for testing
    ; Run Notepad
    Run("C:\Program Files (x86)\Google\Chrome\Application\Chrome.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Chrome]", "", 10) ;what class should ii use here?

    ; Retrieve the position as well as the height and width of the Notepad window. We will use this when we have to move the window back to the original position.
    Local $aPos = WinGetPos($hWnd)

    ; Move the Notepad to the x, y position of 0, 0 and set the height and width at 200, 200.
    WinMove($hWnd, "", 0, 0, 200, 200)

    ; Wait for 2 seconds to display the new position of the Notepad window.

    ; Move the Notepad window back to the original position by using the array returned by WinGetPos.
    ;WinMove($hWnd, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])

    ; Wait for 2 seconds to display the original position of the Notepad window.

    ; Close the Notepad window using the handle returned by WinWait.

Share this post

Link to post
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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.