Please test AHK v2 with Win11 and two monitors

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
hendrikm
Posts: 9
Joined: 12 Nov 2017, 23:19

Please test AHK v2 with Win11 and two monitors

Post by hendrikm » 29 Apr 2024, 03:23

Hi,

I use AHK mainly for one script and with a computer with Win10 and two screens. This script (written in v1) doesn´t work anymore with Win11 and is not compatible to AHK v2. :o

I´d like to know wether rewriting the script in v2 is a viable way to use it with Win11. Therefore I´need someone to test only one function for me with v2 and Win11...

You need two screens with the same resolution (eg. 1920x1080) set up as extended screen. Now you need a program (eg. notepad) fullscreen on monitor A and move the window fullscreen to monitor B. Does it work and the program is visible on monitor B?


Last year I tested it with win11 and v1 and the program was not visible after moving. If it is now possible with v2 I´ll switch the operating system and the AutoHotKey version...

Thanks for testing and helping me out :clap: :clap: :clap:
Hendrik
niCode
Posts: 335
Joined: 17 Oct 2022, 22:09

Re: Please test AHK v2 with Win11 and two monitors

Post by niCode » 29 Apr 2024, 05:45

I don't see why your script wouldn't work unless you made a mistake in your code which you didn't provide.

Regardless, v1 is deprecated and v2 should be used.

Code: Select all

; example
$F1::Send('#+{Right}')
Rohwedder
Posts: 7895
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Please test AHK v2 with Win11 and two monitors

Post by Rohwedder » 29 Apr 2024, 05:59

Hallo,
works! Test it yourself:

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance force	; skips the dialog box and replaces the old instance of the script automatically
GroupAdd("Microsoft", "ahk_exe ONENOTE.EXE")	; Microsoft OneNote
GroupAdd("Microsoft", "ahk_exe OUTLOOK.EXE")	; Microsoft Outlook
GroupAdd("Microsoft", "ahk_exe EXCEL.EXE")		; Microsoft Excel
GroupAdd("Microsoft", "ahk_exe WINWORD.EXE")	; Microsoft Word
GroupAdd("Microsoft", "ahk_exe POWERPNT.EXE")	; Microsoft PowerPoint
GroupAdd("Microsoft", "ahk_exe VISIO.EXE")		; Microsoft Visio
GroupAdd("Microsoft", "ahk_exe PROJECT.EXE")	; Microsoft Project
GroupAdd("Microsoft", "ahk_exe PBIDesktop.EXE") ; Microsoft Power BI
;LEFT MONITOR (Win+Numpad)
#Numpad1::WinMove(X(&W,&H), 0, A_ScreenWidth//3+W, A_ScreenHeight-H, "A")						;Left 1//3
#Numpad3::WinMove(X(&W,&H)+A_ScreenWidth*2//3, 0, A_ScreenWidth//3+W, A_ScreenHeight-H, "A")	;Right 1//3
#Numpad4::WinMove(X(&W,&H), 0, A_ScreenWidth//2+W, A_ScreenHeight-H, "A")						;Left 1//2
#Numpad5::WinMove(X(&W,&H), 0, A_ScreenWidth+W, A_ScreenHeight-H, "A"), WinMaximize				;Left Fullscreen
#Numpad6::WinMove(X(&W,&H)+A_ScreenWidth//2, 0, A_ScreenWidth//2+W, A_ScreenHeight-H, "A")		;Right 1//2
#Numpad7::WinMove(X(&W,&H), 0, A_ScreenWidth*2//3+W, A_ScreenHeight-H, "A")						;Left 2//3
#Numpad9::WinMove(X(&W,&H)+A_ScreenWidth//3, 0, A_ScreenWidth*2//3+W, A_ScreenHeight-H, "A")	;Right 2//3
;RIGHT MONITOR (Win+Alt+Numpad)
#!Numpad1::WinMove(X(&W,&H)+A_ScreenWidth, 0, A_ScreenWidth//3+W, A_ScreenHeight-H, "A")		;Left 1//3
#!Numpad3::WinMove(X(&W,&H)+A_ScreenWidth*5//3, 0, A_ScreenWidth//3+W, A_ScreenHeight-H, "A")	;Right 1//3
#!Numpad4::WinMove(X(&W,&H)+A_ScreenWidth, 0, A_ScreenWidth//2+W, A_ScreenHeight-H, "A")		;Left 1//2
#!Numpad5::WinMove(X(&W,&H)+A_ScreenWidth, 0, A_ScreenWidth+W, A_ScreenHeight-H, "A"), WinMaximize ;Right Fullscreen
#!Numpad6::WinMove(X(&W,&H)+A_ScreenWidth*3//2, 0, A_ScreenWidth//2+W, A_ScreenHeight-H, "A")	;Right 1//2
#!Numpad7::WinMove(X(&W,&H)+A_ScreenWidth, 0, A_ScreenWidth*2//3+W, A_ScreenHeight-H, "A")		;Left 2//3
#!Numpad9::WinMove(X(&W,&H)+A_ScreenWidth*4//3, 0, A_ScreenWidth*2//3+W, A_ScreenHeight-H, "A")	;Right 2//3
X(&W,&H) {
	WinActive("ahk_group Microsoft")?(XX:=0, W:=0, H:=40):(XX:=-7, W:=14, H:=33)
	Return XX
}
The two fullscreen cases are #Numpad5:: and #!Numpad5::

Quixilvr: viewtopic.php?p=569394#p569394
hendrikm
Posts: 9
Joined: 12 Nov 2017, 23:19

Re: Please test AHK v2 with Win11 and two monitors

Post by hendrikm » 29 Apr 2024, 06:58

Thanks a lot to you both!

I tried both solutions and they work ;-)

@Rohwedder
I´ve used winmove and winmaximize and my scripts before but somehow it hadn´t worked in v1.
For your Info: If I use two screens with different resolutions (1600x1050 and 1600x1200), winmove works but somehow the window is not scaled to fullsize by winmaximize on the larger screen

@nicode
That´s far above my league...
I need to research why you used $F1:: as keybinding instead of just F1::
and I need to research why "Windows key" plus "Right key" works.
If I use my keyboard I need to press "Windows key" plus "Shift key" plus "Right key" to move a fullscreen window...

THANK YOU VERY MUCH
niCode
Posts: 335
Joined: 17 Oct 2022, 22:09

Re: Please test AHK v2 with Win11 and two monitors

Post by niCode » 29 Apr 2024, 17:57

hendrikm wrote:
29 Apr 2024, 06:58
@nicode
That´s far above my league...
I need to research why you used $F1:: as keybinding instead of just F1::
and I need to research why "Windows key" plus "Right key" works.
If I use my keyboard I need to press "Windows key" plus "Shift key" plus "Right key" to move a fullscreen window...
The plus sign +[/kbd ]is the modifier symbol for shift.

The dollar sign $ is the prefix for a hotkey that applies the keyboard hook. This just basically means that the hotkey can't be accidentally called by some Send somewhere else in the script (unless you use something like SendLevel or #InputLevel).
Post Reply

Return to “Ask for Help (v2)”