darthopus Posted July 11, 2018 Share Posted July 11, 2018 (edited) I am using a wonderful script, written by ChadMondo on this forum, for using the Home button on an Xbox One Controller to launch and close BigBox. It works perfectly. The code can be found here: https://forums.launchbox-app.com/topic/42319-ahk-script-for-windows-10-use-center-guide-button-to-open-big-box-hold-button-down-to-turn-off-controller/ I am trying to adapt it to change between two monitors. It works for switching to the second monitor, but will not work for switching back. Here is the code. I'm pretty sure it is the #IfWinNotExist and #ifWinActive lines that are giving me the trouble since they look to see if a window exists/not exists. I've looked at the documentation and cannot seem to find how to have autohotkey determine which monitor is being used. Any ideas? #IfWinNotExist, LaunchBox Big Box $vk07sc000:: aDown:=A_TickCount While GetKeyState("vk07sc000") Duration:=(A_TickCount-aDown) If (Duration<300) run %windir%\System32\DisplaySwitch.exe /external Else {} Return #IfWinActive, LaunchBox Big Box $vk07sc000:: aDown:=A_TickCount While GetKeyState("vk07sc000") Duration:=(A_TickCount-aDown) If (Duration<300) run %windir%\System32\DisplaySwitch.exe /internal Else {} Return Edited July 13, 2018 by darthopus Partially Solved Quote Link to comment Share on other sites More sharing options...
darthopus Posted July 12, 2018 Author Share Posted July 12, 2018 I was able to get something together that works for me. There is probably a better way to do it, but this works. #IfWinNotActive, LaunchBox Big Box $vk07sc000:: run %windir%\System32\DisplaySwitch.exe /external Run, mmsys.cpl WinWait,Sound ; Change "Sound" to the name of the window in your local language ControlSend,SysListView321,{Down 3} ; This number selects the matching audio device in the list, change it accordingly ControlClick,&Set Default ; Change "&Set Default" to the name of the button in your local language ControlClick,OK Send, ^!o aDown:=A_TickCount While GetKeyState("vk07sc000") Duration:=(A_TickCount-aDown) If (Duration<300) run "G:\LaunchBox\BigBox.exe" Else {} Return #IfWinActive, LaunchBox Big Box $vk07sc000:: aDown:=A_TickCount While GetKeyState("vk07sc000") Duration:=(A_TickCount-aDown) If (Duration<300) send, x Else {} run %windir%\System32\DisplaySwitch.exe /internal Run, mmsys.cpl WinWait,Sound ; Change "Sound" to the name of the window in your local language ControlSend,SysListView321,{Down 1} ; This number selects the matching audio device in the list, change it accordingly ControlClick,&Set Default ; Change "&Set Default" to the name of the button in your local language ControlClick,OK Send, ^!o Process, Close, Bigbox.exe Return Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.