How to bypass or press ok to javascript popup using COM

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ddougal
Posts: 52
Joined: 09 Nov 2015, 14:26

How to bypass or press ok to javascript popup using COM

18 Mar 2016, 17:27

Can I rewrite the javascript code to not ask me if I am sure I want to lock this order using COM or click ok on the popup box that asks this question.

Here is the HTML/Javascript code:

Code: Select all

<body><div id="container"><form id="queryForm" name="queryForm" method="post" action="/npsgui/jsp/query.jsf" enctype="application/x-www-form-urlencoded"><div id="header" class="pageQuery"><div id="navigation">

 </td><td class="borderQuery fieldLabelRight" style="width: 130px;"><div><a href="#" onclick="if (!confirm('Are you sure you want to lock this order?')) { return false; };return oamSubmitForm('queryForm','queryForm:_idJsp20');" id="queryForm:_idJsp20" class="btnCommand">Lock</a><div style="clear: right;"/></div></td></tr><tr><td colspan="3">
Autohotkey code:

Code: Select all

wb := WBGet("NPS GUI") ;IE instance already open 
if (wb) 
{
 ;click lock order
  wb.document.getElementById("queryForm:_idJsp20").click()  ;lock order which bring up the annoying popup window where I have to click ok
send {enter}   ;fail

wb.document.getElementsByName("oamSubmitForm")[0].setAttribute("onClick").value = ""   ;fail

sleep 1000
IfWinActive, ahk_class #32770
SetControlDelay -1
ControlClick, Button1, ahk_class #32770   ;failed

}
SifJar
Posts: 398
Joined: 11 Jan 2016, 17:52

Re: How to bypass or press ok to javascript popup using COM

18 Mar 2016, 19:09

Try this:

Code: Select all

wb := IEGet("NPS GUI")
if (wb)
{
	wb.document.getElementById("queryForm:_idJsp20").setAttribute("onclick", "return oamSubmitForm('queryForm','queryForm:_idJsp20');") ;remove the annoying popup
	wb.document.getElementById("queryForm:_idJsp20").click()
}

IEGet(name="") {
   IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame     ;// Get active window if no parameter
   Name := (Name="New Tab - Windows Internet Explorer")? "about:Tabs":RegExReplace(Name, " - (Windows|Microsoft)? ?Internet Explorer$")
   for wb in ComObjCreate("Shell.Application").Windows()
      if wb.LocationName=Name and InStr(wb.FullName, "iexplore.exe")
         return wb
}
I couldn't get WBGet to work so I went for IEGet instead, this seemed to work in a similar sample I performed on another site.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CrowexBR, doodles333, vysmaty and 240 guests