herbert4789

Selection of Items (and keyboard action)

3 posts in this topic

I have a bluetooth device at home and this disconnects itself after approx 1hour. After this time it selects my laptops loudspeakers as default.  Since I'm fed up with this manual activation I wanna have a mechanism to activate my bluetooth loudspeaker automatically (or set it as default in some additional cases). What I did up till now is the following

 

#NoTrayIcon
;Playback Controlpanel aufrufen
Run("C:\Windows\system32\rundll32.exe Shell32.dll,Control_RunDLL mmsys.cpl,,playback")
WinWait("Sound")
WinActivate("Sound")
;Index des Sound-Devices von Oben gesehen (0-basiert)
$eintragIndex = 1
; Eintrag auswählen
ControlListView("Sound","","SysListView321","Select",$eintragIndex)

;Kontextmenü aufrufen
Send("^+{F10}")

; hier die Prozedur zum Click auf "Verbinden
; um z.B zwei Einträge im Kontextmenü runter zu gehen und dann Enter drücken (im Moment noch auskommentiert)
;-----
;Send("{DOWN 2}")
;Send("{ENTER}")

; select the connection key (in German = 'V' in English ?)
Send("V")
; using the key 'V' prevents me to select the second item which is - when already connected - Testing ==> but I don't wanna have a testing function => so if 'V' is not available then already connected and everything fine ;-)
;------

; Select item
ControlListView("Sound","","SysListView321","Select",$eintragIndex)
Sleep(500)
; and than set it as default
Send("{ALT}+a")

 

So my MAIN problem here now is at the ending: Cuz I thought I select the second item and then press ALT+A (German keyboard shortcut to set as default). When I do the keyboard action manually this worx. But here in the script it does NOT work. Question:

  1. How to send the keyboard action properly after the second item is selected? Or is there another way to select the combobox and 'click' onto?
  2. Connecting to the bluetooth might take some time until its properly established. Is there an 'easy' way to check it and than proceed with the script? E.g. the 'default combo' is deselected until it has a connection. I can only think about 'Sleep' - alternatives?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Did you try:

; and than set it as default
Send("!a")

If that doesn't work, you might try changing the a to an uppercase A.

Edited by MuffinMan

Share this post


Link to post
Share on other sites

No, thx this worx :) Although I don't understand why the {ALT} doesn't work. Anyway this worx.

Any ideas how to check the combo if already enabled? (Cuz this will be enabled automatically when the bluetooth connection is established.)

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now