Sign in to follow this  
Followers 0
JohnnyDepth

Move Window Down One Pixel

6 posts in this topic

Hi all,

 

Is there a way to store a window's coordinates in a variable, subtract one from each coordinate, and then move the window to the new coordinates?  I want the window to move slightly.

I am thinking i will need to use the wingetpos, somehow store it in a variable, then winmove with the new coordinates after subtracting one from the variable and applying it to the winmove.

 

Any help? I am not sure how to store the coordinates in a variable from the wingetpos.

 

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Yes you can.  The WinGetPos function returrn an Array with the X, Y, Width and Height values of a desired "window".  You can then reference the appropriate Array element for the coordinate values and provide them to the WinMove function.

;pseudo-code
$aWinPos = WinGetPos("title")

;                   X Pos      Y Pos + 1
WinMove("title",$aWinPos[0],$aWinPos[1]+1)

 

Edited by spudw2k

Share this post


Link to post
Share on other sites
32 minutes ago, spudw2k said:

Yes you can.  The WinGetPos function returrn an Array with the X, Y, Width and Height values of a desired "window".  You can then reference the appropriate Array element for the coordinate values and provide them to the WinMove function.

;pseudo-code
$aWinPos = WinGetPos("title")

;                   X Pos      Y Pos + 1
WinMove("title",$aWinPos[0],$aWinPos[1]+1)

 

Thank you for the help! I didn't know you could do that.  How would you do this if you wanted it to do this for which ever window is active, regardless of what the title is? 

Share this post


Link to post
Share on other sites

There is another function which will give you the "active" window...namely WinGetHandle("").  Proving an empty string ("") to the function returns the handle of the active window.  

Keep in mind the logic will be different to keep all windows "below a line" for example.  You wouldn't want to just continuously add to the window position, but set a limit/threshold or finite position value(s).  Also be aware of window size to compensate for a window position that might cause a window to overhang the desktop.

Share this post


Link to post
Share on other sites

Thanks for all the help! 

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  
Followers 0