Sign in to follow this  
Followers 0
SumTingWong

ControlCommand and modal dialog

2 posts in this topic

#1 ·  Posted (edited)

Hi,

This is the code I am trying to run:

AutoItSetOption("WinSearchChildren", 1)

AdlibEnable("_NoSaveScheme")
_SetNoSound()
AdlibDisable()

Func _SetNoSound()
   Local $sWork
   
   $sWork = @SystemDir & "\RUNDLL32.EXE shell32.dll,Control_RunDLL mmsys.cpl,,1"
   Run($sWork)
   If WinWaitActive("Sounds and Audio Devices Properties", "", 10) Then      
      ControlCommand("Sounds and Audio Devices Properties", "", "ComboBox1", "SelectString", "No Sounds")
   ;ControlClick("Sounds and Audio Devices Properties", "", "Button5")
   EndIf
EndFunc

Func _NoSaveScheme()
   If WinExists("Save Scheme") Then 
      MsgBox(4096,'debug:' , 'WinExists:');### Debug MSGBOX 
      ControlClick("Save Scheme", "", "Button2")
   EndIf
EndFunc

Basically, it opens the Sounds and Audio Devices Properties control applet and sets the sound scheme to No Sounds. However, if the active sound scheme has been modified, a modal dialog box pops up prompting you to save the existing scheme. The problem is that this modal dialog box stops even Adlib from working so I can't automatically click on the No button to dismiss it. Could anyone offer a way round this problem please?

Many thanks

Edited by pacman

Share this post


Link to post
Share on other sites



AdlibEnable("_NoSaveScheme")
_SetNoSound()
AdlibDisable()

I think the above code causes the AdlibDisable() to be called sooner than you think...

Try adding the following to the last line of your _SetNoSound() function:

While WinExists("Sounds and Audio Devices Properties")
sleep(100)
WEnd

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

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
Sign in to follow this  
Followers 0