Make a autohotkey script that will wingetpos of GeForce NOW and left click twice
- User
Make a autohotkey script that will wingetpos of GeForce NOW and left click twice
- Assistant
Certainly! To create an AutoHotkey script that obtains the position of the "GeForce NOW" window and simulates two left mouse clicks at that position, you can use the following script:
#Persistent ; Keep the script running SetTitleMatchMode, 2 ; Allow partial match of window titles ^g:: ; Hotkey to trigger the action (Ctrl + G) { ; Retrieve GeForce NOW window position and size WinGetPos, x, y, width, height, GeForce NOW ; Check if the window was found if (ErrorLevel) { MsgBox, The GeForce NOW window was not found. return } ; Move the mouse to the center of the GeForce NOW window centerX := x + (width / 2) centerY := y + (height / 2) MouseMove, centerX, centerY ; Simulate two left clicks Click Click return } - User
make that script work when i click f7
- Assistant
Certainly! To modify the script so that it triggers when you press
F7, simply change the hotkey definition in the script from^gtoF7. Here's the updated script:#Persistent ; Keep the script running SetTitleMatchMode, 2 ; Allow partial match of window titles F7:: ; Hotkey to trigger the action (F7) { ; Retrieve GeForce NOW window position and size WinGetPos, x, y, width, height, GeForce NOW ; Check if the window was found if (ErrorLevel) { MsgBox, The GeForce NOW window was not found. return } ; Move the mouse to the center of the GeForce NOW window centerX := x + (width / 2) centerY := y + (height / 2) MouseMove, centerX, centerY ; Simulate two left clicks Click Click return }Instructions:
-
Use the same process as before: copy the script into a file, and run it by double-clicking the file after ensuring AutoHotkey is installed.
-
- User
name the function metal farm
- Assistant
Certainly! Here's how you can encapsulate the logic within a function called
MetalFarmand then call this function when you pressF7:#Persistent ; Keep the script running SetTitleMatchMode, 2 ; Allow partial match of window titles F7:: ; Hotkey to trigger the action (F7) { MetalFarm() return } MetalFarm() { ; Retrieve GeForce NOW window position and size WinGetPos, x, y, width, height, GeForce NOW ; Check if the window was found if (ErrorLevel) { MsgBox, The GeForce NOW window was not found. return } ; Move the mouse to the center of the GeForce NOW window centerX := x + (width / 2) centerY := y + (height / 2) MouseMove, centerX, centerY ; Simulate two left clicks Click Click }Instructions:
-
Save and run the script: Copy the updated script into a file with the extension and run it by double-clicking the file. Ensure AutoHotkey is installed.
-
- User
function is to work on monitor 2
- Assistant
Certainly! To ensure the function works specifically on monitor 2, you can adjust the script to get the coordinates related to that monitor. Here's how you can modify the function:
#Persistent ; Keep the script running SetTitleMatchMode, 2 ; Allow partial match of window titles F7:: ; Hotkey to trigger the action when F7 is pressed { MetalFarm() return } MetalFarm() { ; Retrieve all monitors' information SysGet, MonitorCount, MonitorCount SysGet, Monitor2, Monitor, 2 if (MonitorCount < 2) { MsgBox, Monitor 2 not found. Please make sure you have multiple monitors. return } ; Get info about GeForce NOW window WinGetPos, wx, wy, width, height, GeForce NOW ; Check if the GeForce NOW window was found if (ErrorLevel) { MsgBox, The GeForce NOW window was not found. return } ; Check if the window is on monitor 2, if not, move it there if (wx < Monitor2Left || wx > Monitor2Right || wy < Monitor2Top || wy > Monitor2Bottom) { ; Move the window to monitor 2 WinMove, GeForce NOW, , Monitor2Left, Monitor2Top, width, height ; Update the window position for new coordinates WinGetPos, wx, wy, width, height, GeForce NOW } ; Move the mouse to the center of the window on monitor 2 centerX := wx + (width / 2) centerY := wy + (height / 2) MouseMove, centerX, centerY ; Simulate two left clicks Click Click } - User
Edit the script so that the mouse moves from monitor 1 to monitor 2 that is located to the left first.
- Assistant
- User
clean the script
- Assistant
Certainly! Here's the script with a cleaner structure and essential elements for moving the mouse from monitor 1 to monitor 2, simulating the clicks: