Sign in to follow this  
Followers 0
GrizDoug

How to activate a dialog?

13 posts in this topic

I displayed a dialog through a link using the script I have been working on. I read in the help file that when using the ControlCommand() call, sometimes the window or dialog needs to be activated, and I think this is one of the cases, but I am having some problems getting the window to be active. Now the question becomes, "How do I make the dialog (window) active?" The dialog gets displayed and the script stops there waiting for the window to be active. I did a test with WinActive and the dialog (window) wasn't active. It needs to be active so the script will continue. I tried WinActivate() and that didn't help. I also tried:

$hWnd = WinGetHandle("Device advanced settings")
_WinAPI_SetFocus($hWnd)

This code didn't help either. Any ideas?

Thanks in advance.


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites



is it a windows dialog window or is it one that your script produces or is it from another application....and can we see some code?


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites

How about WinWaitActive?

Share this post


Link to post
Share on other sites

is it a windows dialog window or is it one that your script produces or is it from another application....and can we see some code?

It's a windows dialog, I think, activated by the Realtek HD Audio Manager dialog that comes from the tray in the lower right of the screen. I'll get you some code in a bit. I just got pre-empted to do an installation. I'll be back.

Thanks!


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

How about WinWaitActive?

I tried WinWaitActive() as well, but the script just sat there because the window never became active.

Thanks!


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

out of curiosity, what does the AutoIT window info tool have to say about this window?


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites

out of curiosity, what does the AutoIT window info tool have to say about this window?

It's a window and it's title is "Device advanced settings", just like the title shows on the window. The class is #32770, which is like other windows/dialogs. The controls on the window are standard buttons and the text on the buttons is the same as shown in the AutoIt window info tool. By all accounts, it's a standard window.


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

It's a window and it's title is "Device advanced settings", just like the title shows on the window. The class is #32770, which is like other windows/dialogs. The controls on the window are standard buttons and the text on the buttons is the same as shown in the AutoIt window info tool. By all accounts, it's a standard window.

can i see the part of the code that your talking about?


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites

can i see the part of the code that your talking about?

;*********************************************
Func AddHDAudio2ndOutput()
;*********************************************
;Show the Realtek Sound Manager dialog
    Run("control RTSndMgr.cpl","",@SW_HIDE)
    Opt("WinWaitDelay", 1000)
    WinWait("Realtek HD Audio Manager")
;*********************************************

;The HD Audio 2nd output tab should be displayed at the top of the dialog. Select the tab and select the Default Format tab,
;about one third down the page on the left. Set the Default Format in the dropdown as "16 Bits, 44100 Hz (CD Quality)."
    
;Add the HD Audio 2nd Output by clicking Device Advanced Settings in upper right corner of dialog,
;to display the Device advanced settings dialog
    $WM_LBUTTONDOWN = 0x0201
    $WM_LBUTTONUP = 0x0202
    $MK_LBUTTON = 0x0001
    $ilParam = _WinAPI_MakeDWord(34, 9)
    $hControl = ControlGetHandle("Realtek HD Audio Manager", "", "SysLink2")
    _SendMessageA($hControl, $WM_LBUTTONDOWN, $MK_LBUTTON, $ilParam)
    _SendMessageA($hControl, $WM_LBUTTONUP, $MK_LBUTTON, $ilParam)
;WinActivate("Device advanced settings", "")
    $hWnd = WinGetHandle("Device advanced settings")
    _WinAPI_SetFocus($hWnd)
    If WinActive("Device advanced settings") Then
        MsgBox(0, "", "Device advanced settings is active")
    EndIf
    Opt("WinWaitDelay", 1000)
    WinWait("Device advanced settings") 
;WinWaitActive("Device advanced settings")
    
;Select the radio button titled "Make front and rear output devices playback
;two different audio streams simultaneously."
;WinActivate("Device advanced settings", "")
;ControlClick("Device advanced settings", "", 1212)
;ControlFocus("Device advanced settings", "", "Button5")
;WinActivate("Device advanced settings", "")
;ControlClick("Device advanced settings", "", 1212, "left", 1, 11, 11)
;$ilParam = _WinAPI_MakeDWord(11, 11)
;$hControl = ControlGetHandle("Device advanced settings", "", "Button5")
;_SendMessage($hControl, $WM_LBUTTONDOWN, $MK_LBUTTON, $ilParam)
;_SendMessage($hControl, $WM_LBUTTONUP, $MK_LBUTTON, $ilParam)
;ControlCommand("Device advanced settings", "", "[CLASS:Button; INSTANCE:4]", "UnCheck", "")
;ControlCommand("Device advanced settings", "", "[CLASS:Button; INSTANCE:5]", "Check", "")
    ControlCommand("Device advanced settings", "", 1212, "Check", "")
    Opt("WinWaitDelay", 1000)
    WinWait("Device advanced settings")
    
;Click the Ok button to close the Device advanced settings dialog
    ControlClick("Device advanced settings", "", 1)
;WinWaitNotActive("Device advanced settings")
    Opt("WinWaitDelay", 5000)
    WinWait("Realtek HD Audio Manager")
    
    Dim $tab
    $tab = ControlCommand("Realtek HD Audio Manager", "", "[CLASS:SysTabControl32; INSTANCE:8]", "CurrentTab", "")
    MsgBox(4096, "Information", "Tab = " & $tab)
    
;Need to tab left the proper amount of tabs to get to beginning
    ControlCommand("Realtek HD Audio Manager", "", "[CLASS:SysTabControl32; INSTANCE:8]", "TabLeft", "")
    Opt("WinWaitDelay", 1000)
    WinWait("Realtek HD Audio Manager")
    
;Get the text of the tab
    $tab_str = ControlGetText("Realtek HD Audio Manager", "", "[CLASS:SysTabControl32; INSTANCE:8]")
    MsgBox(0, "tab_str", $tab_str)
    
;*********************************************
;Click the Ok button to close the dialog
    ControlClick("Realtek HD Audio Manager", "", 1)
    WinWaitNotActive("Realtek HD Audio Manager")
;*********************************************
EndFunc
;*********************************************

The code after the comment "Add the HD Audio 2nd Output by..." causes the child dialog to display and then it has some code that checks to see if the window is active. You will see that I have tried several things and some of those are commented out. I need to get the window active before I can select the radio button using the script.

Please let me know if you have any ideas.

Thanks!


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

;*********************************************
Func AddHDAudio2ndOutput()
;*********************************************
;Show the Realtek Sound Manager dialog
    Run("control RTSndMgr.cpl","",@SW_HIDE)
    Opt("WinWaitDelay", 1000)
    WinWait("Realtek HD Audio Manager")
;*********************************************

;The HD Audio 2nd output tab should be displayed at the top of the dialog. Select the tab and select the Default Format tab,
;about one third down the page on the left. Set the Default Format in the dropdown as "16 Bits, 44100 Hz (CD Quality)."
    
;Add the HD Audio 2nd Output by clicking Device Advanced Settings in upper right corner of dialog,
;to display the Device advanced settings dialog
    $WM_LBUTTONDOWN = 0x0201
    $WM_LBUTTONUP = 0x0202
    $MK_LBUTTON = 0x0001
    $ilParam = _WinAPI_MakeDWord(34, 9)
    $hControl = ControlGetHandle("Realtek HD Audio Manager", "", "SysLink2")
    _SendMessageA($hControl, $WM_LBUTTONDOWN, $MK_LBUTTON, $ilParam)
    _SendMessageA($hControl, $WM_LBUTTONUP, $MK_LBUTTON, $ilParam)
;WinActivate("Device advanced settings", "")
    $hWnd = WinGetHandle("Device advanced settings")
    _WinAPI_SetFocus($hWnd)
    If WinActive("Device advanced settings") Then
        MsgBox(0, "", "Device advanced settings is active")
    EndIf
    Opt("WinWaitDelay", 1000)
    WinWait("Device advanced settings") 
;WinWaitActive("Device advanced settings")
    
;Select the radio button titled "Make front and rear output devices playback
;two different audio streams simultaneously."
;WinActivate("Device advanced settings", "")
;ControlClick("Device advanced settings", "", 1212)
;ControlFocus("Device advanced settings", "", "Button5")
;WinActivate("Device advanced settings", "")
;ControlClick("Device advanced settings", "", 1212, "left", 1, 11, 11)
;$ilParam = _WinAPI_MakeDWord(11, 11)
;$hControl = ControlGetHandle("Device advanced settings", "", "Button5")
;_SendMessage($hControl, $WM_LBUTTONDOWN, $MK_LBUTTON, $ilParam)
;_SendMessage($hControl, $WM_LBUTTONUP, $MK_LBUTTON, $ilParam)
;ControlCommand("Device advanced settings", "", "[CLASS:Button; INSTANCE:4]", "UnCheck", "")
;ControlCommand("Device advanced settings", "", "[CLASS:Button; INSTANCE:5]", "Check", "")
    ControlCommand("Device advanced settings", "", 1212, "Check", "")
    Opt("WinWaitDelay", 1000)
    WinWait("Device advanced settings")
    
;Click the Ok button to close the Device advanced settings dialog
    ControlClick("Device advanced settings", "", 1)
;WinWaitNotActive("Device advanced settings")
    Opt("WinWaitDelay", 5000)
    WinWait("Realtek HD Audio Manager")
    
    Dim $tab
    $tab = ControlCommand("Realtek HD Audio Manager", "", "[CLASS:SysTabControl32; INSTANCE:8]", "CurrentTab", "")
    MsgBox(4096, "Information", "Tab = " & $tab)
    
;Need to tab left the proper amount of tabs to get to beginning
    ControlCommand("Realtek HD Audio Manager", "", "[CLASS:SysTabControl32; INSTANCE:8]", "TabLeft", "")
    Opt("WinWaitDelay", 1000)
    WinWait("Realtek HD Audio Manager")
    
;Get the text of the tab
    $tab_str = ControlGetText("Realtek HD Audio Manager", "", "[CLASS:SysTabControl32; INSTANCE:8]")
    MsgBox(0, "tab_str", $tab_str)
    
;*********************************************
;Click the Ok button to close the dialog
    ControlClick("Realtek HD Audio Manager", "", 1)
    WinWaitNotActive("Realtek HD Audio Manager")
;*********************************************
EndFunc
;*********************************************

The code after the comment "Add the HD Audio 2nd Output by..." causes the child dialog to display and then it has some code that checks to see if the window is active. You will see that I have tried several things and some of those are commented out. I need to get the window active before I can select the radio button using the script.

Please let me know if you have any ideas.

Thanks!

Bump!

Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

Bump!

I added the code to display the window from the link. You will also see some of the code that I tried, which are commented out or not, to activate the displayed window. Please take a look and see if you have some additional ideas. I appreciate any help.

Thanks for all suggestions!!


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

I added the code to display the window from the link. You will also see some of the code that I tried, which are commented out or not, to activate the displayed window. Please take a look and see if you have some additional ideas. I appreciate any help.

Thanks for all suggestions!!

I Googled this issue on the net and found a suggestion to add a WinWait() to wait for the window to be displayed, then add a WinActivate() to activate the window once it is displayed. I tried that. but it didn't work.

Something I learned in researching this issue, when the script hangs or gets stuck, I click the cancel button on the child dialog and click the link again, and the script continues on right from the point where it was waiting for the active window. I'm not sure what the link is doing that I am missing. I thought my _SendMessageA() would work the same way as a button click on the link.

Help please!


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

I Googled this issue on the net and found a suggestion to add a WinWait() to wait for the window to be displayed, then add a WinActivate() to activate the window once it is displayed. I tried that. but it didn't work.

Something I learned in researching this issue, when the script hangs or gets stuck, I click the cancel button on the child dialog and click the link again, and the script continues on right from the point where it was waiting for the active window. I'm not sure what the link is doing that I am missing. I thought my _SendMessageA() would work the same way as a button click on the link.

Help please!

Bump, I need help and Thanks in advance!!


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

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