AHK COM id changes, to raise an if ID exists to raise a function else

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
doanathan
Posts: 1
Joined: 15 Mar 2018, 22:38

AHK COM id changes, to raise an if ID exists to raise a function else

15 Mar 2018, 22:45

Hello, I am a beginner when it comes to coding. I have a website that has an COM ID that changes every now and then. I am having a hard time raising an event if ID exists or not so that I can create a function.

Using facebook as an example, the COM ID "pass" exist, but if I navigate away, I should get an error message because ID no longer exists.

Code: Select all

    ^a::
    wb := ComObjCreate("InternetExplorer.Application")
    wb.Visible := true
    wb.Navigate("www.facebook.com")
    return
    
    ^q::
    If wb.document.GetElementById("pass") {
    	MsgBox, ID Exist
    	return
    }
    else
    {
    MsgBox, ID does not exist
    return
    }
I have also tried an example from youtube, but that isn't working either

Code: Select all

^z::
 wb.document.GetElementById("pass") := false
    while(wb.document.GetElementById("pass") := False) {
    	if wb.document.GetElementById("pass") 
    	{
    		wb.document.GetElementById("pass") := true
    		break
    	}
    	Sleep, 500
    }
    MsgBox, it worked
    return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: fiendhunter and 229 guests