Jump to content

How to click ok/Enter on Modal dialog windoe


Recommended Posts

Hi All, 

Could any one please help me to click ok button/ press keyboard button to enter when modal dialog appears.

Below is the code have written.

Opt("WinTitleMatchMode", 2)
WinWaitActive( "My title View:", " ", 10)
Send({ENTER})

 

Many Thanks,


regards,

Link to comment
Share on other sites

  1. try frequently asked questions faq 31. 
  2. You at least should read the help file on all the control* functions
  3. The help file is full of examples see just a copy/paste below
Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Send a mouse click to the edit control of Notepad using the handle returned by WinWait.
    ControlClick($hWnd, "", "Edit1")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example

 

Link to comment
Share on other sites

Hi Junkew, 

 

Thank you for the reply. 

Above code is for notepad, but I need for modal dialog box for which I have written above. Could you please tell me if my code is correct.

After going through help, above is the code I have come up with

 

Thanks,

Nagarjuna

Link to comment
Share on other sites

What application are you automating? 

you need to find the control and use a control function to click it.  Use the AutoIT Info tool to find the button  and paste that information back here for more help. just because your application goes active doesn't mean that control has focus so sending an Enter probably won't help.

 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

  • code is fine you should tell whats not working?
  • Search modal dialog in the forum and you will get some answers
  • If you cannot click directly from 1 script potentially you have to click from a 2nd script
  • Could be you need adlibregister function if your script is "waiting" for the modal dialog to dissapear. 
    From your description I cannot conclude what your full question is. Be more specific on what you see or what your requirements are.
  • Sending an enter by keyboard can be a fine solution but alternatives are there like controlclick or more complex ones involving the UIAutomation library

 

Link to comment
Share on other sites

Thank you for the comments.  Please find below detailed info

Am trying to automate Web based application, but I do get modal dialog box. Where I have click ok , else application cannot be active/cannot proceed.

Attached the screenshot of dialog box that i need to perform action using auto it

 

--------->AU Info data ---------------------<--

----Window----- 

Title : Accounts: Test123- Google Chrome
Class : Chrome_WidgetWin_1
Position : -8, -8
Size 1296,880
Style : 0x17CF0F00
Ex Style : 0x00000100
Handle : 0x0000000000010465

--Control----
Class: Chrome_WidgetHostHWND
Instance : 1
ClassnameNN : Chrome_WidgetHostHWND1
Name : 
Advanced Mode : [CLASS:Chrome_WidgetHostHWND; INSTANCE:1]
ID : 5612345
Text : Chrome Window
Position : 0,55
Size : 1280, 869
ControlClick Coords : 520, 108
Style : 0x56300000
ExStyle : 0x00000020


--Visible Text--
Chrome Window

--Hidden Text --
Chrome Window

--Status Bar--

 

My current Script :

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
WinWaitActive("[CLASS:Chrome_WidgetHostHWND]", "", 10)
Sleep(2000)
ControlClick("Chrome_WidgetWin_1", "", "[CLASS:Chrome_WidgetHostHWND: INSTANCE:1]")

 

Kindly help 


 

ModalDialog.jpg

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...