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

    • tentacole
      By tentacole
      Afternoon!
      This is my first post, so I apologize if this is in the wrong place. 
      I've created a while loop to click in a certain area of an application, and have the y axis change at the end of each loop. My loop continues to click at x:27, x:10, even though the $y is adding 15 at the end of each loop. I did a Send($x) and Send($y) into a Notepad to see if the $y had changed after each loop, and the 15 was being added to $y each loop. (If this makes sense)
       
      I'm unsure where I'm going wrong, and would be extremely grateful if someone can point me in the correct direction to fix this. 
      Local $rDirectory = "H:\oDemandProject\fList.txt" Local $rLine = _FileCountLines($rDirectory) Local $x = 27 Local $y = 10 While $rline > 0 WinActivate("OnDemand", "-> 1") WinWaitActive("OnDemand", "-> 1") ControlClick("OnDemand", "", "[CLASS:AfxFrameOrView120u; INSTANCE:1]", "left", 4, $x, $y) $y += 15 $rLine -= 1 WEnd  
    • careca
      By careca
      Hi, i feel im close to getting it to work, but there must be something im missing that's probably easy for you experts.
      #include <IE.au3> #include <File.au3> #include <MsgBoxConstants.au3> $Visible = 1 Local $oIE $oIE = _IECreate("https://beemp3s.net/mp3-download.html", 0, $Visible, 1, 1) _IELoadWait($oIE) If $oIE <> @error Then ;_ArrayText() _QuerySite('Finding Hope - Without You') ;_IEQuit($oIE) ;Exit Else MsgBox(64 + 262144, 'Fail', 'Could not create a new window') EndIf ;============================================================================= Func _QuerySite($Name) Local $oIE_ObjectToSearch = _IEGetObjById($oIE, 'query') _IEDocInsertText($oIE_ObjectToSearch, $Name) Local $oIE_ObjectToClick = _IEGetObjById($oIE, "search-action") _IEAction($oIE_ObjectToClick, 'click') _IELoadWait($oIE, 2000) ;============================================================================= Local $oSubmitClick = _IEGetObjById($oIE, "col-md-12") _IEAction($oSubmitClick, "click") _IELoadWait($oIE, 2000) ;============================================================================= Local $oBtns = _IETagNameGetCollection($oIE, "div") For $oBtn In $oBtns If String($oBtn.classname) = "col-md-12" Then If String($oBtn.innertext) = "Download / Play" Then ConsoleWrite($oBtn.innertext & @CRLF) _IEAction($oBtn, 'click') EndIf EndIf Next ;============================================================================= ;Local $oElements = _IETagNameAllGetCollection($oIE) ;For $oElement In $oElements ; If $oElement.id Then MsgBox($MB_SYSTEMMODAL, "Element Info", "Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText) ;Next ;============================================================================= ;_IEQuit($oIE) ;Exit ;============================================================================= EndFunc ;==>_QuerySite ;============================================================================= Func _ArrayText() If FileExists('Titles.txt') Then Local $FO = FileOpen('Titles.txt') Local $R2A = FileReadToArray($FO) Local $iLineCount = @extended FileClose($FO) For $f = 0 To $iLineCount - 1 ConsoleWrite($f & ' - ' & $R2A[$f] & @CRLF) _QuerySite($R2A[$f]) Next Else MsgBox(64 + 262144, 'Fail', 'Could not find the file Titles.txt') EndIf EndFunc ;==>_ArrayText ;============================================================================= The idea is to get into this site, write into the search and click, which i did, but now the problem is clicking in any of the buttons in the results page, im looking for a way to click the first one, it always matches to what i want, so no need to fiddle around.
      Site
      Thanks for help in advance.

    • yoschga
      By yoschga
      is there a possibility to let ie.au3 click into a form? i use on a project where i need to click into a form where items are loaded just writing it in or fill the form is no option
       

    • Yirrlaar
      By Yirrlaar
      #Include <WinAPI.au3> local $ClassName = _WinAPI_GetClassName(WinGetHandle(WinGetTitle("[ACTIVE]"))) ControlClick(WinGetTitle("[ACTIVE]"), "", "[CLASS:"&$ClassName&"; INSTANCE:1]", "primary") When I am running this script it just gives me a ConsoleWrite output of "0x001D04A8"
      When using "AutoIT v3 Window Info" all the info I need for the ControlClick is there and displayed perfectly as if I typed it in normally.
      Upon click the button it should be clicking it, I see the following inn the console window:
      If I replace the $ClassName with the actual ClassName of "WindowsForms10.BUTTON.app.0.3296db7_r14_ad1" it works just fine, any ideas???
    • RamaKrishna9
      By RamaKrishna9
      What are the minimum system requirements(like Windows OS version, IE browser version, etc,.) for IE.au3(3.3.14.2) to work properly?
×