Move Window between monitors

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
TomT
Posts: 32
Joined: 21 Feb 2017, 06:32

Move Window between monitors

Post by TomT » 21 Feb 2022, 03:33

Hi.

I'm looking for a way to add 3 icons to the active windows title bar.
Then when the one the icons is pressed the window will move the the associated monitor.

I have two questions.
1. Is this possible with AHK ?
2. Is there already something that does similar to this ? If there is a link would be helpful.

Thanks

TomT
Posts: 32
Joined: 21 Feb 2017, 06:32

Re: Move Window between monitors

Post by TomT » 21 Feb 2022, 04:04

I seen to have go this working using:

Code: Select all

^1::
	SysGet, Mon1, Monitor, 1
    WinGetPos, , , WW, WH, A
    WinGetClass, class, A
    if class != Shell_TrayWnd
    if class != Progman
    if class != DV2ControlHost
        WinMove, A, , (( Mon1Right-Mon1Left - WW ) / 2) +Mon1Left, (Mon1Bottom - 30 - WH ) / 2
return
I've added ^2 & ^3 for the other 2 screens.
However I have a slight problem.

Screen 1 is 1080p
Screens 2 & 3 are 1440p

So moving a window from 2 or 3 to 1 the scaling is wrong, often the window is larger than the screen.
Can anyone advise how I shrink the window by 25% as it is moved to screen 1, but back to normal on 2 or 3 ?

Thanks

RussF
Posts: 1260
Joined: 05 Aug 2021, 06:36

Re: Move Window between monitors

Post by RussF » 21 Feb 2022, 07:20

I know this is a forum for solving problems with AHK, but you DID ask if there was anything else that would solve your problem.

Check out DisplayFusion. (https://www.displayfusion.com/) It can put the buttons you want onto each window's title bar and has the option to switch a window from one monitor to another and resize proportionately. That and a whole host of other features too numerous to mention. You can install a trial version which is fully function for 30 days, then reverts to the "free" version and some features stop, but the license is not that expensive (and perhaps everything you want works in the free version.)

Disclaimer - I am not affiliated with Binary Fortress (DisplayFusion) and receive no compensation for the shout-out. I just use their product and love it. IMHO, there's no reason to reinvent the wheel, unless you can make it better.

Russ

TomT
Posts: 32
Joined: 21 Feb 2017, 06:32

Re: Move Window between monitors

Post by TomT » 21 Feb 2022, 08:45

Thanks, Display Fusion does offer a lot of functionality but most of it I don't need.

I can add buttons to move a window to the next or previous screen, but I can't see anyway to send a window to a specific screen.

I've been having a look around and have found this:

Code: Select all

sysget n, monitorcount
loop % n {
	sysget m_, monitorworkarea, % a_index
	fn := func("swapfs").bind(m_left, m_top, m_right - m_left, m_bottom - m_top)
	hotkey ^numpad%a_index%, % fn
}

swapfs(x, y, w, h) {
	winmove a,, x, y, w, h
}
This works using CTRL + Monitor number and seems to work quite well.
Only issue I can see is it forces full screen on each monitor, not adjusting the size to match the screen resolution.

Thanks

TomT
Posts: 32
Joined: 21 Feb 2017, 06:32

Re: Move Window between monitors

Post by TomT » 22 Feb 2022, 12:09

Any one have any ideas how I can get the window that is moved resized proportionally to the monitor size ?

Thanks

nate1021
Posts: 3
Joined: 31 Jul 2021, 16:58

Re: Move Window between monitors

Post by nate1021 » 10 Aug 2022, 05:15

Code: Select all

/*
I binded F21 to one of my side mouse buttons--use any key combination you want

Sends input "Windows Key + Shift + Left arrow"

My windows automatically resize themselves via this method, I hope it works for you!
*/ 
F21::
Send #+{Left}
return

wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Move Window between monitors

Post by wetware05 » 10 Aug 2022, 14:18

Hi :wave:
TomT wrote:
22 Feb 2022, 12:09
Any one have any ideas how I can get the window that is moved resized proportionally to the monitor size ?
I imagine asking the system for the name of the application, and when it is in the target monitor, telling it to restore the window in the first step, and in a second case to maximize it. (If you want to restore the window to the size of the previous monitor, you have to use the WinGetPos command to know its size, and restore it later.)

Microsoft Windows has resident change an application to another monitor with the keyboard shortcut Shift+Windows key+right key. Paradoxically, if you have "hooked" an application (by holding down the left mouse button on the title) and you make a script that changes the monitor cursor, the effect is the mouse will drag to the other monitor to the application. You can create a script for an application to stay "hooked" and drag it to other monitors, I do not know how it will behave. Whether that "effect" will cause it to change in size.

I've used a second script that you've shared, but it doesn't do "anything", maybe you have it next to another script. Can you share what you've been researching? I am interested in this topic, but in my case, having only two monitors and the same plot, I have no problems.

You may be interested in this page: https://icode.best/i/07486944505119, and this one: viewtopic.php?t=81731

Post Reply

Return to “Ask for Help (v1)”