How do I wait for Google Chrome to load a webpage before continuing in AutoHotkey?

后端 未结 6 815
南方客
南方客 2020-12-10 12:30

I am working on a AutoHotkey script that does a repetitive job in Google Chrome. Every time that I click a link from the script, I have to tell my script to sleep while the

6条回答
  •  悲哀的现实
    2020-12-10 12:57

    I've had some success looking for a control to be present on the target page. Depends on the contents of the page of course. I used WinSpy to figure out a suitable target.

    Here's the code that worked for me:

    loaded := false
    check_count := 0
    MAX_CHECKS := 20
    
    while !loaded {
        Sleep, 100
        ControlGetPos, x, y, ,,Chrome Legacy Window
        if x == ""
            loaded := false
        else
            loaded := true
    
        check_count++
        if (check_count >= MAX_CHECKS) {
            Exit
        }
    }
    

提交回复
热议问题