setting variable in array IE

Get help with using AutoHotkey and its commands and hotkeys
Ernestas
Posts: 19
Joined: 16 Apr 2018, 02:07

setting variable in array IE

Post by Ernestas » 18 Apr 2018, 06:20

hello guys,

I have faced with one more problem. I need to set var_index variable's value in the pwb.document.GetElementsByTagName("A")[var_index].click to activate click function. Does anyone know how to do it, thank you !!!

Code: Select all

if (pwb.document.getElementsByClassName("xxx").length > 1 ){
      var_length := pwb.document.getElementsByClassName("xxx").length
      msgbox, % var_length
      loop, % var_length {
         var := pwb.document.getElementsByClassName("xxx")[A_Index-1].InnerText  
         var_index := 79 + A_Index 
         msgbox, % var
         If RegExMatch(var, "V") and RegExMatch(var, "A"){
            msgbox, % var_index
            pwb.document.GetElementsByTagName("A")[var_index].click
            break
         }   
         else If RegExMatch(var, "E") and RegExMatch(var, "A|I")
               sleep, 50
         else If RegExMatch(var, "V") and RegExMatch(var, "I|P")
               sleep, 50
         else,
            sleep, 50
      }
   } 
suoabb
Posts: 29
Joined: 17 Jul 2016, 10:40

Re: setting variable in array IE

Post by suoabb » 18 Apr 2018, 08:14

i think you are missing the "()" after click and pwb := WBGet() at the beginning of the script

try putting this at beginning of script:

Code: Select all

pwb := WBGet()
then add the () after the click:

Code: Select all

pwb.document.GetElementsByTagName("A")[var_index].click()
make sure you have the WBGet method somewhere in your script:

Code: Select all

; WBGet: Access an IE object by WinTitle and Internet Explorer_Server Number 

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)
      }
   }
}
Return
Ernestas
Posts: 19
Joined: 16 Apr 2018, 02:07

Re: setting variable in array IE

Post by Ernestas » 18 Apr 2018, 23:22

hey,

thank you! my silly mistake with the brackets..
Post Reply

Return to “Ask For Help”