Jump to content
LaunchBox Community Forums

[Partial solution] AutoHotKey and checking which display is being used


Recommended Posts

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 by darthopus
Partially Solved
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...