Jump to content
Ubermensch

Help: ControlClick/Send/MouseClick ActiveX Prompt/Popup Message Button

Recommended Posts

Ubermensch

Hello,

I am currently trying to automatically click the "Yes" button in the ActiveX prompt/popup message after opening the IE (html).

At 1st, I encounter the "Allow Blocked Content". I already resolve it just by changing settings in the IE Options. But after resolving the "Allow Blocked Content", there's a popup message appear.

I have attached the ActiveX Prompt.

Here is the 1st code that I try to use.

#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

_IECreate("C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\sampleAWD10.html",0,1,0)
Local $oIE = _IEAttach("", "instance", 1)
_IELoadWait($oIE)

AdlibRegister("_ActiveXRun",250)


Local $oLastName = _IEGetObjByName($oIE, "Text4")
Local $oGetItem = _IEGetObjByName($oIE, "getitem")

_IEAction($oGetItem, "click")

MsgBox($MB_SYSTEMMODAL, "Form Element Value", _IEFormElementGetValue($oGetItem))



Func _ActiveXRun()

$retWin = WinGetHandle("[Class:Button]","")
$winTitle = "[HANDLE:" & $retWin &"]"
$ctrlHandle = ControlGetHandle($winTitle,"", "[CLASS:Button; INSTANCE:2]")
$ctrlTitle = "HANDLE:" & $ctrlHandle &"]"
WinWaitActive($ctrlTitle,"[CLASS:Button; INSTANCE:2]",10)

$k = ControlGetPos($winTitle, "","[CLASS:Button; INSTANCE:2]")
$x = $k[0]
$y = $k[1]

WinActivate ($winTitle,"An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?")
ControlFocus($winTitle,"An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?","[CLASS:Button; INSTANCE:2]")
ControlClick($winTitle, "","[CLASS:Button; INSTANCE:2]","primary",1,$x,$y)
ControlSend($winTitle, "", "[CLASS:Button; INSTANCE:2]", "{ENTER}", 0)

EndFunc

Here is the console output.

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3" /UserParams    
+>12:44:11 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0   Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\april\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\april\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.2)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3
+>12:44:11 AU3Check ended.rc:0
>Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3" (31) : ==> Subscript used on non-accessible variable.:
$x = $k[0]
$x = $k^ ERROR
->12:44:24 AutoIt3.exe ended.rc:1
+>12:44:24 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 13.76

I also tried a simpler code.

include <IE.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

_IECreate("C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\sampleAWD10.html",0,1,0)
Local $oIE = _IEAttach("", "instance", 1)
_IELoadWait($oIE)

$k = ControlGetPos("[CLASS:#32770]", "","[CLASS:Button; INSTANCE:2]")
$x = $k[0]
$y = $k[1]

ControlClick("[CLASS:#32770]", "","[CLASS:Button; INSTANCE:2]","primary",1,$x,$y)

Local $oLastName = _IEGetObjByName($oIE, "Text4")
Local $oGetItem = _IEGetObjByName($oIE, "getitem")

_IEAction($oGetItem, "click")

MsgBox($MB_SYSTEMMODAL, "Form Element Value", _IEFormElementGetValue($oGetItem))

There's no error in the console output for the 2nd code I have tried.

And here is the Window Info for the ActiveX prompt.

>>>> Window <<<<
Title:  Internet Explorer
Class:  #32770
Position:   580, 338
Size:   376, 146
Style:  0x94C808C4
ExStyle:    0x00010101
Handle: 0x00000000001516FA

>>>> Control <<<<
Class:  Button
Instance:   2
ClassnameNN:    Button2
Name:   
Advanced (Class):   [CLASS:Button; INSTANCE:2]
ID: 1
Text:   &Yes
Position:   184, 77
Size:   80, 22
ControlClick Coords:    37, 12
Style:  0x50010000
ExStyle:    0x00000004
Handle: 0x00000000001215DE

>>>> Mouse <<<<
Position:   228, 120
Cursor ID:  0
Color:  0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
&No
An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?
&Yes


>>>> Hidden Text <<<<

 

ActiveX Prompt.png

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

  • Similar Content

    • Skysnake
      By Skysnake
      I need to automate a specific GUI from a legacy system written in C.
      The spy tool gives me this

      I use this code
      Local $swintit = WinGetTitle("[active]") ConsoleWrite("active Window " & $swintit & @CRLF) If $swintit = "FILES NOTES" Then ; If $swintit = "FILES NOTES" Then ; got Window, now atomate ConsoleWrite("got Window " & @CRLF) ; now focus, then click :) ;EditPaste ;ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(404, $GUI_Focus) ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(401, $GUI_Focus) ControlClick("FILES NOTES", "", 401, $acno) ; click okay EndIf ; If $swintit = "FILES NOTES" Then The idea is to paste the acno value into the edit box, then click an Okay button.
      I get a console write that the active Window is as expected, but my loop completes without ever writing anything into the GUI.
      I also tried the control ID as text "404" - same result
      What am I missing?
      Skysnake
       
    • JNutt
      By JNutt
       

       
       
      I'm trying to use mouseclick in a panel above.  I want to click on a list item, such as 'Estimated'.  (I've given up on trying to use control click for this).  I'm using window info coordinates from 'Control' tab.

      ; click 'Columns' WinActivate("Innovaya Studio with Sage (Archtectural 2017_V1.invx") MouseClick("primary", 292, 88, 1, 1) WinActivate("Select Browsing Properties") Sleep(1000) MouseClick("primary", 27, 70, 0,0) Sleep(2000) Send("{TAB}{TAB}{TAB}{TAB}{TAB}") Sleep(1000) Send("{ENTER}") ControlClick( But when I used the code Autoit doesn't click where the coordinates are.  In the scipts it is the second MouseClick that won't work.  Any ideas?
    • dadalt
      By dadalt
      Hi!
      I have a button where I need to close it!
      I was doing through  clicking same position in screen but there are some id's that have different sizes.
      What are the possible ways to click this closable button?
      Is there a way to close it through id? Is there a way to get it's position through it's ID?  
      Thanks in advance!


    • Miliardsto
      By Miliardsto
      Hello I got this script works below and I want to do not move cursor on screen when action is performed.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then MouseMove($x, $y,0) MouseClick("right", $x, $y)) MouseMove($xMiddle, $yMiddle,0) MouseClick("left", $xMiddle, $yMiddle) EndIf I changed this above to this below and what happen is. It clicks right button and then left button but not move mouse to $x $y and then to $xMiddle $yMiddle.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then ControlClick("","",0,"secondary",1,$x,$y) ControlClick("","",0,"primary",1,$xMiddle,$yMiddle) EndIf If needed I got handle in var $hwnd
      Please tell me how parameters in ControlClick would like be
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.