PPRuNe Forums - View Single Post - Another for the "team that can"...
View Single Post
Old 25th February 2013 | 22:21
  #8 (permalink)  
Keef

Official PPRuNe Chaplain
 
Joined: Apr 2001
Posts: 3,498
Likes: 0
From: Witnesham, Suffolk
I simplified the source code to this, which when compiled works OK from a CMD line or from clicking on the .exe - but doesn't work from Task Scheduler.

Code:
; This is the "on" version


	$windowName = "Sound"
	$altPlusKey = "s"
	$numDevices = 2
	

	; Set device position to switch to 2 = Speaker
	$ItemNumber = 2

	; Run the sound control applet
 Run("control mmsys.cpl") 
	
	; Wait a second for it to be active before sending keystrokes
 Sleep (1000)

	; Put the focus on the list
 Send("{TAB}{TAB}{TAB}{TAB}")

	; Tab down to the device position.
 For $i = 1 to $ItemNumber Step 1
 Send("{DOWN}")
 Next

	; Press shortkey to set the selected device as the default
 Send("!"&$altPlusKey) 

	; Close the window.
 WinClose($windowName)
I tried running that via a batch file - same result!

Last edited by Keef; 25th February 2013 at 22:23.
Keef is offline  
Reply