moonlight-qt icon indicating copy to clipboard operation
moonlight-qt copied to clipboard

(Not an "issue") AHK Script to help you switch (alt/tab) between windows with a hotkey

Open efraimip opened this issue 3 years ago • 1 comments

This is not a bug report. This is not an "issue" with the app at all... Just wanted to share this, if anyone else thinks its useful.

What is this?

Quick AHK script that lets you use 1 hotkey (configurable, just edit the script) to switch between windows. You just have to rename the title of the window on your client PC with whatever you switch between. This is useful if you are playing a game on your client PC while streaming another game on your host PC, which I believe is a frequent usage of this app. The script below for example is for when I play ESO with my daughter. She is on my gaming laptop, I stream her desktop via moonlight so I can help her sometimes as needed.

Where to get AHK?

Free-ware scripting program, download here: https://www.autohotkey.com/

Configure the script

F1:: = the hotkey I use. Change to whatever hotkey you want. https://www.autohotkey.com/docs/KeyList.htm if WinExist("

") = title of the window of your game/app MouseMove = cursor position (relative to that monitor/window) that you want the cursor to move to. Otherwise you'll focus another window, but your cursor will still be where it was... Click = some games/apps require cursor-locking by actually activating the mouse in the window. Un-comment this line if yours does. <h1>How to use?</h1> <p>Copy/paste the below script in a raw-text editor. Save it as an .ahk file. Download/install AHK above. Run the .ahk file. Use "PAUSE" button to pause the script</p> <pre><code>#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. $Pause::Suspend ; You can pause this script using the k/b "Pause" button F1:: If (Toggle := !Toggle){ if WinExist("Elder Scrolls Online") ; Change this to whatever the title of your game/app-window is WinActivate ; Use the window found by WinExist. MouseMove, 1720, 720 ; I have 3 monitors: 1920x1080 (left), 3440x1440 (middle), 1920x1080 (right) - so this sets mouse position to middle of my game screen where I play my game (middle monitor) ; Sleep, 100 ; Click ; If you need to activate the window somehow - ESO requires this or it doesnt "lock" the cursor to the window }else{ if WinExist("Moonlight") WinActivate MouseMove, 960, 540 ; This sets mouse to middle of the screen on my left monitor where moonlight is streaming ; Sleep, 100 ; Click ; like above, enable this line if you need to activate cursor-lock in the window } return </code></pre>

efraimip avatar Jan 19 '22 15:01 efraimip

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Apr 28 '22 02:04 stale[bot]