Script for multiple monitor window management

Post your working scripts, libraries and tools for AHK v1.1 and older
akbars
Posts: 8
Joined: 23 Jun 2014, 19:34

Script for multiple monitor window management

23 Jun 2014, 19:39

When a dialog pops up but you don't know where it is you can spend a good 5 seconds looking for it across your 2-6 screens.

I've created a script to shoot the most active window over to your mouse, and also shoot your mouse over to the window.

Move window to mouse:

Code: Select all

#w::
{
WinGetTitle, Title2, A
; Activate top window 
WinActivate, %Title2%
; This un-maximizes fullscreen things to prevent UI bug. 
WinRestore, %Title2%
; Mouse screen coords = mouse relative + win coords therefore..
WinGetPos, xtemp, ytemp,,, A ; get active windows location
MouseGetPos, X, Y   ; get mouse location 
;; Calculate actual position
;; -16 on x and y pos allows you to doubleclick and close window(most of the time) 
xpos:=X+xtemp-16
ypos:=Y+ytemp-16

WinMove, %Title2%, , %xpos%, %ypos%  ; move window to mouse 
} 
Move mouse to window:

Code: Select all

#q::
{
WinGetTitle, Title2, A
; Activate top window 
WinActivate, %Title2%
;WinGetPos, xtemp, ytemp,,, A
; 10 is speed, 16, 16 is a good place to doubleclick and close window. 
MouseMove, 16, 16, 10
Return
}
Hope this helps people save those 5 seconds.

I will be trying to have it do it automatically when it detects a new window under 600x600pxl. like a dialog box.

Best

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 143 guests