Web browser stops loading for a site

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Web browser stops loading for a site

Post by anhnha » 22 Nov 2022, 12:12

I have been used this and a more complex version and they worked very well.
However, the site stopped loading on IE.
Does anyone have a solution?

Code: Select all

#NoEnv
SetBatchLines, -1

#a::
    Clipboard := ""
    Send, ^c
    ClipWait, 2
    if ErrorLevel {
        MsgBox, 48,, The attempt to copy text onto the clipboard failed.
        return
    }

    WB.Navigate("https://korean.dict.naver.com/kovidict/vietnamese/#/search?query=" Clipboard)
    Gui, Show
return

_InitGUI() {
    static _ := _InitGUI()
    global WB

    w := 509
    h := 728
    x := A_ScreenWidth - w -20
    y := A_ScreenHeight/2 - h/2

    Gui, +AlwaysOnTop
    Gui, Margin, 0, 0
    Gui, Add, ActiveX, w%w% h%h% vWB, Shell.Explorer
    Gui, Show, Hide x%x% y%y% w%w% h%h%, KO-VI dictionary

    ComObjConnect(WB, "WB_")
    WB.Silent := true
    WB.Navigate("https://korean.dict.naver.com/kovidict/vietnamese/#/search?query=test")
    return

    GuiEscape:
        Gui, Hide
    return
}

WB_NavigateComplete2(pDisp, URL, WB) {
    divTags := WB.document.all.tags("div")
    Loop, % divTags.length
    {
        if (divTags[A_Index-1].ClassName = "mykeyword_wrap opened")
            return "", divTags[A_Index-1].OuterHtml := ""
    }
} 

RussF
Posts: 1229
Joined: 05 Aug 2021, 06:36

Re: Web browser stops loading for a site

Post by RussF » 22 Nov 2022, 12:32

Did you try manually loading the site in IE?

Since IE reached its end-of-life in June, It's possible the site was updated to a point that it no longer supports IE.

Russ

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Web browser stops loading for a site

Post by anhnha » 22 Nov 2022, 12:44

Yes, I did. It returns a black page. I read about other options like Chrome or Edge but they seem too complex.
image.png
image.png (55.39 KiB) Viewed 742 times

RussF
Posts: 1229
Joined: 05 Aug 2021, 06:36

Re: Web browser stops loading for a site

Post by RussF » 22 Nov 2022, 14:55

If the site will load in Chrome, you can find great information about Chrome.ahk here.

Russ

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Web browser stops loading for a site

Post by anhnha » 29 Nov 2022, 18:34

As there is no ActiveX in Google Chrome, how would you embeded this into a Gui using Chrome.ahk?

Code: Select all

 Gui, Add, ActiveX, w%w% h%h% vWB, Shell.Explorer

User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Web browser stops loading for a site

Post by Xeo786 » 30 Nov 2022, 03:38

anhnha wrote:
29 Nov 2022, 18:34
As there is no ActiveX in Google Chrome, how would you embeded this into a Gui using Chrome.ahk?

Code: Select all

 Gui, Add, ActiveX, w%w% h%h% vWB, Shell.Explorer
You can use Rufaydium to control chrome and open as an app, you can also do that using chrome.ahk

Code: Select all

#include Rufaydium.ahk 
w := 509
h := 728
x := A_ScreenWidth - w -20
y := A_ScreenHeight/2 - h/2

Chrome := new Rufaydium()
Chrome.capabilities.addArg("--app=https://korean.dict.naver.com/kovidict/vietnamese/#/search?query=test")
Chrome.capabilities.addArg("--window-position=" x "," y )
Chrome.capabilities.addArg("--window-size=" w "," h )
Page := Chrome.NewSession()

#a::
    Clipboard := ""
    Send, ^c
    ClipWait, 2
    if ErrorLevel {
        MsgBox, 48,, The attempt to copy text onto the clipboard failed.
        return
    }
Page.Url := "https://korean.dict.naver.com/kovidict/vietnamese/#/search?query=" clipboard
return

#f12:
Chrome.QuitAllSessions() ; close all session 
Chrome.Driver.Exit() ; then exits driver
exitapp
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Web browser stops loading for a site

Post by anhnha » 30 Nov 2022, 06:49

Thanks, it's nice to know that there is another way to do this other than chrome.ahk.
(as I couldn't make it work with that library)
How can I hide it?

Code: Select all

#1::
Chrome.Driver.visible := false
I tried this and it works but then I want to unhide it when I press

Code: Select all

#a
so I put

Code: Select all

Chrome.Driver.visible := true
below

Code: Select all

#a
to unhide it but it triggers an error.

User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Web browser stops loading for a site

Post by Xeo786 » 30 Nov 2022, 08:22

anhnha wrote:
30 Nov 2022, 06:49
Thanks, it's nice to know that there is another way to do this other than chrome.ahk.
(as I couldn't make it work with that library)
How can I hide it?

Code: Select all

#1::
Chrome.Driver.visible := false
I tried this and it works but then I want to unhide it when I press

Code: Select all

#a
so I put

Code: Select all

Chrome.Driver.visible := true
below

Code: Select all

#a
to unhide it but it triggers an error.
Make sure chromedriver.exe is running, Rufaydium download and run web driver hidden, closes/exits with Chrome.Driver.Exit()
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Web browser stops loading for a site

Post by anhnha » 30 Nov 2022, 09:15

I think you misunderstood my question above. It works well but now I wanted to improve it a bit. So instead of press Window + F12 to close the page, I want to just hide the window and unhide it when I consult a new word.
Here is my modification version:

Code: Select all

#include Rufaydium.ahk 
w := 509
h := 728
x := A_ScreenWidth - w -20
y := A_ScreenHeight/2 - h/2

Chrome := new Rufaydium()
Chrome.capabilities.addArg("--app=https://korean.dict.naver.com/kovidict/vietnamese/#/search?query=test")
Chrome.capabilities.addArg("--window-position=" x "," y )
Chrome.capabilities.addArg("--window-size=" w "," h )
Page := Chrome.NewSession()

#a::
Chrome.Driver.visible := true

    Clipboard := ""
    Send, ^c
    ClipWait, 2
    if ErrorLevel {
        MsgBox, 48,, The attempt to copy text onto the clipboard failed.
        return
    }
Page.Url := "https://korean.dict.naver.com/kovidict/vietnamese/#/search?query=" clipboard
return

#1::
Chrome.Driver.visible := false

#f12:
Chrome.QuitAllSessions() ; close all session 
Chrome.Driver.Exit() ; then exits driver
exitapp
The hide part with window + 1 works well but I couldn't unhide it with Chrome.Driver.visible := true.

User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Web browser stops loading for a site

Post by Xeo786 » 01 Dec 2022, 03:36

anhnha wrote:
30 Nov 2022, 09:15
I think you misunderstood my question above. It works well but now I wanted to improve it a bit. So instead of press Window + F12 to close the page, I want to just hide the window and unhide it when I consult a new word.
Here is my modification version:
Your code is not working as expected try this

Code: Select all

#Include, %A_ScriptDir%\..\Rufaydium-Webdriver
#include Rufaydium.ahk 
w := 509
h := 728
x := A_ScreenWidth - w -20
y := A_ScreenHeight/2 - h/2
Toggle := 0
Chrome := new Rufaydium()
Chrome.capabilities.addArg("--app=https://korean.dict.naver.com/kovidict/vietnamese/#/search?query=test")
Chrome.capabilities.addArg("--window-position=" x "," y )
Chrome.capabilities.addArg("--window-size=" w "," h )
Page := Chrome.NewSession()
Page.setrect(x,y,w,h)
return
#a::
Chrome.Driver.visible := true

    Clipboard := ""
    Send, ^c
    ClipWait, 2
    if ErrorLevel {
        MsgBox, 48,, The attempt to copy text onto the clipboard failed.
        return
    }
Page.Url := "https://korean.dict.naver.com/kovidict/vietnamese/#/search?query=" clipboard
return

f1:: ; hide unhide
Toggle := !Toggle
if toggle
    Page.setrect(x + 600 ,x + 600,10,10)
else
    Page.setrect(x,y,w,h)        
return

#f12:
Chrome.QuitAllSessions() ; close all session 
Chrome.Driver.Exit() ; then exits driver
exitapp
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Web browser stops loading for a site

Post by anhnha » 01 Dec 2022, 05:52

This also doesn't work.
It just hides the app whenever Page.setrect(x,y,w,h) is called.
There probably some problems with the setrect.

User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Web browser stops loading for a site

Post by Xeo786 » 01 Dec 2022, 08:03

anhnha wrote:
01 Dec 2022, 05:52
This also doesn't work.
It just hides the app whenever Page.setrect(x,y,w,h) is called.
There probably some problems with the setrect.
you need to find out the correct Coord/Rect for Chrome, according to your display,as I have two monitors and don;t know how webdriver Rect() works
Run Rufaydium, Manually set up the window area on the desktop display. then use the following code to get those coordinates,

Code: Select all

f5:: ; include following code to the main code
msgbox, % json.load(Page.getrect(),1)
return
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

anhnha
Posts: 116
Joined: 08 Aug 2018, 02:46

Re: Web browser stops loading for a site

Post by anhnha » 27 Dec 2022, 02:35

The getrect gives me this error.
I don't understand why setrect doesn't move the window to the desired position (as obtained from Window Spy).
image.png
image.png (35.91 KiB) Viewed 408 times
This does not move the window to the middle of the screen (not any coordinate is correct).

w := 509
h := 728
x := A_ScreenWidth/2 ;
y := A_ScreenHeight/2 ;

Page.setrect(x,y,w,h)

Post Reply

Return to “Ask for Help (v1)”