thqby / ahk2_lib

MIT License
197 stars 26 forks source link

stuck on wait for response #50

Closed sousvideonlow closed 3 months ago

sousvideonlow commented 4 months ago

There is a certain site (can't share as it's a premium and you need subscription to view page) where if I use the console in chrome, I get the desired text when I querySelectorAll item [8].

However, in Chrome when I debug I get stuck at these lines

; Wait for the response this._responses[ID] := false while (this.readyState = 1 && !this._responses[ID]) Sleep(20)

I've ensured I'm using the right page and everything else is working by checking this

url := page.evaluate("window.location.href")["value"] msgbox url

thqby commented 4 months ago

Maybe in a different frame? image

sousvideonlow commented 4 months ago

sorry I meant that if I use the actual browser console it's fine but when using this AHK chrome I get stuck in that loop. Also there seems to be some weird characters in the text I'm retrieving. It just appears as spaces in Chrome's browser console.

thqby commented 3 months ago

Without reproducible code, I can't find the problem.

sousvideonlow commented 3 months ago

Thanks it might help if you could explain what response is this waiting for?

thqby commented 3 months ago

The method called through the cdp will have a unique id, usually a return value, marking this id this._responses[ID] := false. When receiving a message, the message will contain the call id. If the id is marked this._responses.Has(id := data.Get('id', 0)), it is set as the message object, wait for the end and return the result. There are also some methods that do not return a value and will never return if you wait for the result.