the button I am trying to interact with isn't within any iFrame within the page but there are iFrames.
iWB2 is giving me:
<button title="" class="btn btn-inverse btn-icon" onclick="javascript: assignCSRFToken(); this.form.action='/main/location/hrsx/pinebluff/yard/carSearch';this.form.target='imain';this.form.submit(); return false;" type="submit" target="imain" value="search" <input="">
<i class="icon-search"></i>
</button>
Code: Select all
#singleinstance Force
Obj := ComObjActive("Excel.Application")
Cell := Obj.ActiveCell ; The cell to start at.
wb := ComObjCreate("InternetExplorer.Application")
wb.Visible := True
wb.Navigate("https://ey2.expressyard.com/main/login")
WinMaximize, % "ahk_id " WB.HWND
While wb.readyState!=4 || wb.document.readyState!="complete" || wb.busy
Sleep 50
;login
;================================================================================
wb.Document.All.cmp.Value := "company"
wb.Document.All.usr.Value := "username"
wb.Document.All.pwd.Value := "password"
wb.Document.All.btn1.click()
While wb.readyState!=4 || wb.document.readyState!="complete" || wb.busy
Sleep 50
;select Location
;============================================================================================
wb.document.All.location.selectedIndex := 14
While wb.readyState!=4 || wb.document.readyState!="complete" || wb.busy
Sleep 50
wb.Document.GetElementById("btn1").click()
sleep, 3000
wb.quit()
sleep, 500
;Make new Window Object
;========================================================================================
IEGet(Name="") ;Retrieve pointer to existing IE window/tab
{
IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame
Name := ( Name="ExpressYard - View Yard - Internet Explorer" ) ? "about:Tabs"
: RegExReplace( Name, " - (Windows|Microsoft) Internet Explorer" )
For Pwb in ComObjCreate( "Shell.Application" ).Windows
If ( Pwb.LocationName = Name ) && InStr( Pwb.FullName, "iexplore.exe" )
Return Pwb
}
WBGet(WinTitle="ahk_class IEFrame", Svr#=1)
{ ; based on ComObjQuery docs
static msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
, IID := "{0002DF05-0000-0000-C000-000000000046}" ; IID_IWebBrowserApp
; , IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ; IID_IHTMLWindow2
SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle%
if (ErrorLevel != "FAIL") {
lResult:=ErrorLevel, VarSetCapacity(GUID,16,0)
if DllCall("ole32\CLSIDFromString", "wstr","{332C4425-26CB-11D0-B483-00C04FD90119}", "ptr",&GUID) >= 0 {
DllCall("oleacc\ObjectFromLresult", "ptr",lResult, "ptr",&GUID, "ptr",0, "ptr*",pdoc)
return ComObj(9,ComObjQuery(pdoc,IID,IID),1), ObjRelease(pdoc)
}
}
}
; Jethrow's updated IEGet
IEGet2(Name="", HwndFilter="") {
if (Name = "") ;// Get active window name if no parameter
WinGetTitle, Name, % "ahk_id" HwndFilter:=WinExist("ahk_class IEFrame")
else if (HwndFilter="A" or HwndFilter="Active")
WinGet, HwndFilter, ID, ahk_class IEFrame
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")
if Not HwndFilter or (HwndFilter and wb.hwnd=HwndFilter)
return wb
}
wb2 := WBGet()
wb2.Visible := True
WinMaximize, % "ahk_id " Wb2.HWND
While wb2.readyState!=4 || wb2.document.readyState!="complete" || wb2.busy
Sleep 60000
; Use A_Index to calculate the curent cell's offset from the starting cell.
CurrentCell := Cell.Offset(0, 0)
Mark := CurrentCell.Offset(1, 0).Text
RepairDate := CurrentCell.Offset(2, 0).Text
Initial := CurrentCell.Offset(3, 0).Text
Numb := CurrentCell.Offset(4, 0).Text
Loc := CurrentCell.Offset(5, 0).Text
Qty := CurrentCell.Offset(6, 0).Text
CC := CurrentCell.Offset(7, 0).Text
AJC := CurrentCell.Offset(8, 0).Text
AQ := CurrentCell.Offset(9, 0).Text
AUQ := CurrentCell.Offset(10, 0).Text
WM := CurrentCell.Offset(11, 0).Text
RJC := CurrentCell.Offset(12, 0).Text
RQ := CurrentCell.Offset(13, 0).Text
Parts := CurrentCell.Offset(14, 0).Text
Description := CurrentCell.Offset(15, 0).Text
CID := CurrentCell.Offset(16, 0).Text
A_Mo := CurrentCell.Offset(17, 0).Text
A_Yr := CurrentCell.Offset(18, 0).Text
A_Mfr := CurrentCell.Offset(19, 0).Text
A_Class := CurrentCell.Offset(20, 0).Text
A_Scale := CurrentCell.Offset(21, 0).Text
A_Fng := CurrentCell.Offset(22, 0).Text
R_Mo := CurrentCell.Offset(23, 0).Text
R_Yr := CurrentCell.Offset(24, 0).Text
R_Mfr := CurrentCell.Offset(25, 0).Text
R_Class := CurrentCell.Offset(26, 0).Text
R_Scale := CurrentCell.Offset(27, 0).Text
R_Fng := CurrentCell.Offset(28, 0).Text
Labor := CurrentCell.Offset(29, 0).Text
if (CurrentCell.Value = "")
{
Msgbox, complete
exitapp
}
else
{
if (CurrentCell.Value = 1) ;New Car
;==========================================================================================
{
wb2.Document.All.sCriteria.text := Initial
wb2.Document.All.sCriteria.text := Numb
wb2.Document.All.getElementsByClass("btn btn-inverse btn-icon").Item.Click()
}
else
{
Msgbox, New Line
exitapp
}
}
esc::exitapp