Make a autohotkey script that will active the "GeforceNOW" window on monitor 2 when i…
- User
Make a autohotkey script that will active the "GeforceNOW" window on monitor 2 when i click F1 and open "ArkAscended" window on monitor 1 when i click F2
- Assistant
To create an AutoHotkey script that activates specific applications on designated monitors when you press F1 or F2, you need to identify the window titles or classes of the applications you want to control (in this case, "GeforceNOW" and "ArkAscended"). The script will utilize the
WinActivatefunction to focus the appropriate window. Here's a sample script to achieve this functionality:#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetTitleMatchMode, 2 ; Allows partial matching of window titles. ; Hotkey for F1 to activate "GeforceNOW" on Monitor 2 F1:: ; Adjust the window title according to the actual title of the GeforceNOW window WinActivate, GeforceNOW ; You may need additional lines to ensure it's on the correct monitor if necessary ; For instance, you might need to move the window or specify exact position return ; Hotkey for F2 to activate "ArkAscended" on Monitor 1 F2:: ; Adjust the window title according to the actual title of the ArkAscended window WinActivate, ArkAscended ; As with GeforceNOW, additional handling for monitor positioning might be needed returnNotes:
-
Window Title: Ensure that the window titles ("GeforceNOW" and "ArkAscended") match the exact titles or partial titles of the application windows as they appear in your system. You can use tools like "Window Spy," which comes with AutoHotkey, to get the exact window title or class.
-
Monitor Management: The script assumes that both applications remember their last positions or that they are manually arranged correctly on their respective monitors. If needed, you might need to employ additional logic to move windows between monitors using the
WinMovefunction. -
Testing & Customization: It's a good idea to run the script and fine-tune the window titles or additional logic based on how the applications behave on your system. Different setups might require different approaches to window management beyond just activating.
-
Installation & Running: Save the above script in a file with a
.ahkextension, then run it with AutoHotkey. You can stop the script from the tray icon if required.
This basic script setup is quite flexible, so feel free to make modifications based on your specific needs or further integrate additional functionality.
-
- User
monitor two is to the left and both monitors are 1920x1080. With that information write full script.
- Assistant
To handle a dual-monitor setup where monitor two is to the left of the primary monitor, you can utilize the
WinMovefunction to position windows correctly. The left monitor has negative values on the x-coordinate axis since it is placed to the left. Here's how you can modify the script to account for this:#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetTitleMatchMode, 2 ; Allows partial matching of window titles. ; Hotkey for F1 to activate "GeforceNOW" and move it to Monitor 2 (to the left) F1:: ; Replace with the appropriate window title or class for the "GeforceNOW" app WinActivate, GeforceNOW ; Move the window to the left (monitor 2) WinMove, GeforceNOW, , -1920, 0, 1920, 1080 return ; Hotkey for F2 to activate "ArkAscended" and move it to Monitor 1 (to the right) F2:: ; Replace with the appropriate window title or class for the "ArkAscended" app WinActivate, ArkAscended ; Move the window to the right (primary monitor) WinMove, ArkAscended, , 0, 0, 1920, 1080 returnExplanation
#NoEnvandSendMode Input: These directives improve script performance and reliability.SetTitleMatchMode, 2: Allows partial matching of window titles, making it easier to match windows without needing the full title.WinActivate: Brings the window with the specified title to the front.WinMove: Moves and resizes the specified window. The parameters specify the position and size:-1920, 0, 1920, 1080: Positions the window on monitor 2 to the left, assuming monitor 2 resolution is 1920x1080.0, 0, 1920, 1080: Positions the window on the primary monitor (monitor 1) to the right, also with a resolution of 1920x1080.
Notes
- You must ensure that the window titles ("GeforceNOW" and "ArkAscended") match exactly as they appear. Use AutoHotkey's Window Spy to confirm the titles or class names of the windows if needed.
- If the windows don't recognize title changes (like dynamic titles), consider using
ahk_classwithWinActivateandWinMovefor more precise control. - Save this script as a
.ahkfile and run it to activate it, making sure AutoHotkey is installed on your system.