However, script doesn't wait till page load and as a result I am getting btn.click() executed twice and script behaves strangely. I have also tried below snippet for page load wait but same result.
Could someone please help? I have tried to increase sleep to 1000 as well but no change.
Code: Select all
while pwb.busy or pwb.ReadyState != 4 ;Wait for page to load
Sleep, 100
Code: Select all
... ;some lines not shown
pwb.document.all.btn.click() ;Click
while (pwb.busy or pwb.readystate <> 4) ; waits for the page to be loaded
sleep, 200
replace := {sqlcode:"sqlcode100"}
For k, v in replace
StringReplace, String, String, %k%, %v%, All
pwb.document.all.TextBar.Value :=String
pwb.document.all.btn.click() ;Click
;************Pointer to Open IE Window******************
WBGet(WinTitle="ahk_class IEFrame", Svr#=1) {
static msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
, IID := "{0002DF05-0000-0000-C000-000000000046}"
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)
}
}
}