Func ats_idactionpopup does attach to the correct dialogbox (I commented out the MsgBox, but this shows the correct url used in the dialogbox). The dialogbox is structured in the exact same way as the main jsp with the same name frame (AppWindow), but ControlSend doesn't send the {enter} to Button1.
Console output:
--> IE.au3 T3.0-1 Error from function _IEPropertyGet, $_IESTATUS_InvalidObjectType
Complete code:
#include <IE.au3>
#include <MsgBoxConstants.au3>
#RequireAdmin
Global $oIE = _IECreate("url_to_webpage")
Func ats_idactionmain($ats_id, $ats_action)
Local $oFrame = _IEFrameGetObjByName($oIE, "AppWindow")
Local $oSubmit = _IEGetObjByName($oFrame, $ats_id)
Local $hWnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($oSubmit, "focus")
ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $ats_action)
EndFunc
Func ats_idactionpopup($ats_popup, $ats_idpopup, $ats_actionpopup)
Local $oIEpopup = _IEAttach($ats_popup, "dialogbox")
;MsgBox($MB_SYSTEMMODAL, "The URL", _IEPropertyGet($oIEpopup, "locationurl"))
Local $oFramepopup = _IEFrameGetObjByName($oIEpopup, "AppWindow")
Local $oSubmitpopup = _IEGetObjByName($oFramepopup, $ats_idpopup)
Local $hWndpopup = _IEPropertyGet($oIEpopup, "hwnd")
_IEAction($oSubmitpopup, "focus")
ControlSend($hWndpopup, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $ats_actionpopup)
EndFunc
_IELoadWait($oIE)
ats_idactionmain("GEBRUIKER1", "username")
ats_idactionmain("WACHTWOORD1", "password")
ats_idactionmain("Pb_inloggen", "{enter}")
Sleep(4000)
ats_idactionpopup("afdelingskeuze", "Button1", "{enter}")
EDIT:
It is driving me nuts...
Using the following I found out for sure that it is attaching to the correct dialogbox:
Local $oFrames = _IEFrameGetCollection($oIEpopup)
Local $iNumFrames = @extended
Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
Local $oFramepopup = 0
For $i = 0 To ($iNumFrames - 1)
$oFramepopup = _IEFrameGetCollection($oIEpopup, $i)
$sTxt &= _IEPropertyGet($oFramepopup, "innertext") & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Frames Info", $sTxt)
It even gives me the text in the correct frame (name AppWindow).
Switched to debug-output and found the line it chokes on:
0047: 0-0: ats_idactionpopup("afdelingskeuze", "Button1", "{enter}")
0017: 0-0: Local $oIEpopup = _IEAttach($ats_popup, "dialogbox")
0018: 0-0: Local $oFramepopup = _IEFrameGetObjByName($oIEpopup, "AppWindow")
0019: 0-0: Local $oSubmitpopup = _IEGetObjByName($oIEpopup, $ats_idpopup)
--> IE.au3 T3.0-1 Warning from function _IEGetObjByName, $_IESTATUS_NoMatch (Name: Button1, Index: 0)
0020: 7-0: Local $hWndpopup = _IEPropertyGet($oFramepopup, "hwnd")
--> IE.au3 T3.0-1 Error from function _IEPropertyGet, $_IESTATUS_InvalidObjectType
0021: 4-1: _IEAction($oSubmitpopup, "focus")
--> IE.au3 T3.0-1 Error from function _IEAction(focus), $_IESTATUS_InvalidDataType
0022: 3-1: ControlSend($hWndpopup, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $ats_actionpopup)
0023: 0-0: EndFunc
but when looking at the source, using debugbar AND firebug, this should be the correct button...
Since the dialogbox and the main window have the exact same html (it just loads a different .html in a frame with the same name as the main frame in the main window) I figured I could use almost the same code (but with the addition of Local $oIEpopup = _IEAttach($ats_popup, "dialogbox")). Does _IEGetObjByName behave differently inside a dialogbox perhaps?