Last active
September 25, 2021 05:57
-
-
Save blood72/8cb9da4e87dde50acd2198c7e4725089 to your computer and use it in GitHub Desktop.
Default audio switcher temporarily for BlueStacks 4 (AHK script)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv | |
/* | |
* Variables | |
*/ | |
AUDIO_DEVICE_1 = __SOUND_DEVICE_WHAT_YOU_WANT_TO_SET_TEMPORARILY__ | |
AUDIO_DEVICE_2 = __SOUND_DEVICE_THE_ORIGINAL_ONE__ | |
;BLUESTACKS4_COMMAND = -json "{\"app_icon_url\":\"\",\"app_name\":\"Microsoft Launcher\",\"app_url\":\"\",\"app_pkg\":\"com.microsoft.launcher\"}" | |
global BLUESTACKS4_LAUNCHER_PATH := "__YOUR_BLUESTACKS4_PATH__\Bluestacks.exe " . BLUESTACKS4_COMMAND | |
global BLUESTACKS4_APP_PATH := "__YOUR_BLUESTACKS4_PATH__\HD-RunApp.exe " . BLUESTACKS4_COMMAND | |
global NIRCMD_PATH := "__YOUR_NIRCMD_PATH__\nircmdc.exe" | |
/* | |
* Scripts | |
*/ | |
; prevent duplicate process | |
if processExists("BlueStacks.exe") { | |
return | |
} | |
; set default sound device as what you want to set temporarily | |
changeAudioDevice(AUDIO_DEVICE_1) | |
; execute BlueStacks and wait | |
runEmulator() | |
; set default sound device as the original one | |
changeAudioDevice(AUDIO_DEVICE_2) | |
; run custom command if defined | |
if %BLUESTACKS4_COMMAND% { | |
runAppCommand() | |
} | |
/* | |
* Functions | |
*/ | |
runEmulator() { | |
Run %BLUESTACKS4_LAUNCHER_PATH% | |
Sleep, 5000 | |
} | |
runAppCommand() { | |
WinWait, ahk_exe HD-Player.exe, , 3 | |
Run %BLUESTACKS4_APP_PATH% | |
} | |
changeAudioDevice(device) { | |
i := 0 | |
Loop, 3 { | |
; loop i from 0 to 2 | |
Run %NIRCMD_PATH% setdefaultsounddevice `"%device%`" %i%, , Hide | |
i++ | |
} | |
} | |
processExists(app) { | |
Process, Exist, %app% | |
return ErrorLevel | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have to endure until BlueStacks 5 supports Hyper-V.
Requirement
Configuration
Fill strings to replace
__~~__
inVariables
.You can put a short cut command in the
BLUSTACKS4_COMMAND
refer to the BlueStacks Support page.If a command exists, the program will be opened when it is executed.
AHK supports .exe converter, so if you're interested, look for them.