Facing a strange problem in Internet Explorer while using WBGet function. Please help!

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

Facing a strange problem in Internet Explorer while using WBGet function. Please help!

Post by Sabestian Caine » 16 Apr 2021, 10:15

When I navigate to https://translate.google.com/ and put some santance to convert it into desired language by using following codes-

Code: Select all

WinGet, hWnd, ID, A
oWB := WBGet("ahk_id " hWnd)
oWB.document.getelementsByClassName("er8xn")[0].value:= "how are you"
return


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)
      }
   }
}
then it does not show anything in the right box. please see this image-
16_04_21 @8_47_02.PNG
16_04_21 @8_47_02.PNG (103.04 KiB) Viewed 374 times

But when i click in the left box and press enter key or space key then it imminently shows that sentence's translated meaning.
I think this is the problem of some even listener.

Please help me to solve this problem... Thanks a lot..
I don't normally code as I don't code normally.


User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

Re: Facing a strange problem in Internet Explorer while using WBGet function. Please help!

Post by Sabestian Caine » 17 Apr 2021, 08:08

Thanks dear malcev for your good reply, but sir, I am not able to understand how to solve this issue by reading the answers in your above mentioned links. I tried the codes like this-

Code: Select all

WinGet, hWnd, ID, A
oWB := WBGet("ahk_id " hWnd)
oWB.document.getelementsByClassName("er8xn")[0].value:= "how are you"
target := oWB.document.querySelector("#yDmH0d > c-wiz > div > div.WFnNle > c-wiz > div.OlSOob > c-wiz > div.ccvoYb > div.AxqVh > div.OPPzxe > c-wiz.rm1UF.dHeVVb.UnxENd > span > span > div > textarea")

event := oWB.document.createEvent("Event")
event.initEvent("change", true, true)

target.dispatchEvent(event)

But the above codes are not working. Sir, i request you to elaborate the things and help me to solve this issue.
Thank you sir..
I don't normally code as I don't code normally.

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Facing a strange problem in Internet Explorer while using WBGet function. Please help!

Post by malcev » 17 Apr 2021, 12:22

Links have enough information to do it by Yourself.
You have to monitor events and detect what exact event do You need.
Also I think that Your target is wrong.
Try the same as You use to set value.
For me it is not interesting to do this kind of work by myself. Sorry.

Post Reply

Return to “Ask for Help (v1)”