thqby / ahk2_lib

MIT License
197 stars 26 forks source link

2 errors whenever i try to open any AHK with webview2. #12

Closed akselfoley closed 1 year ago

akselfoley commented 1 year ago

So WebView2.ahk gives me these errors:

Error: Parameter #1 of ObjAddRef is invalid.

▶ 060: DllCall('user32\GetClientRect', 'ptr', hwnd, 'ptr', RECT := Buffer(16)), ObjAddRef(createdController)

Error: Parameter #2 of ComCall is invalid.

▶ 169: Return A_PtrSize = 8 ? ComCall(6, this, 'ptr', Value) : ComCall(6, this, 'int64', NumGet(Value, 'int64'), 'int64', NumGet(Value, 8, 'int64'))

This version: /****

The code:

Requires AutoHotKey v2.0-

Include lib\WebView2.ahk

main := Gui() main.Show(Format('w{} h{}', A_ScreenWidth 0.6, A_ScreenHeight 0.6)) main.Show()

wvc := WebView2.create(main.hwnd) wv := wvc.CoreWebView2 wv.Navigate("https://www.vg.no")

thqby commented 1 year ago

It may be caused by the system environment.

akselfoley commented 1 year ago

I've checked on both computers I am testing.

The errors above is from the a computer running .ahk.

But I've also created an .exe to run together with \lib*

So get a new error there: image

▶ 072: If (R := DllCall(dllPath '\CreateCoreWebView2EnvironmentWithOptions', 'str', edgeruntime, 'str', datadir || RegExReplace(A_AppData, 'Roaming$', 'Local\Microsoft\Edge\User Data'), 'ptr', options, 'ptr', EnvironmentCompletedHandler, 'uint'))

Installation status is the same for both: image

thqby commented 1 year ago

Keep the default file tree structure, and #Include <WebView2\WebView2>. Or specify the corresponding version of WebView2Loader.dll.

akselfoley commented 1 year ago

Can you provide the best structure? :)

This is my current structure: image

image

thqby commented 1 year ago

The above directory should not have this error. My directory is consistent with this repository.

image

akselfoley commented 1 year ago

How does it know to use D:\Documents\Autohotkey\Lib to look for <Webview2\Webview2> ?

thqby commented 1 year ago

https://www.autohotkey.com/docs/v2/Scripts.htm#lib

This is User library.

akselfoley commented 1 year ago

But for this to work it should be enough to have:

Include WebView2\WebView2.ahk

Where the webview2 folder looks like this: image

I will create an .exe from the .ahk, and run it on a computer that dont have AHK installed.

Any suggestions?

thqby commented 1 year ago

Library location priority order, Local library > User library > Standard library.

After the script is compiled, A_LineFile will change and need to be adjusted according to the actual situation.

akselfoley commented 1 year ago

I am very sorry. I am a bit stupid at the moment.

Local Library in this case is the folder WebView2 that's next to .ahk/.exe and it would work to type <WebView2\WebView2> ?

thqby commented 1 year ago

yes

.ahk/../lib Local library .exe/../lib Standard library

akselfoley commented 1 year ago

So I tried to do the User Library, and it found the files. Still the same error: image image image

thqby commented 1 year ago

View the value of the function hresult parameter, and throw OSError(hresult) display error description

akselfoley commented 1 year ago

I don't understand. Sorry.

But I updated the code of WebView2.ahk.

image

thqby commented 1 year ago

What is the Edge Webview2 Runtime version?

My current version is 111.0.1661.51

akselfoley commented 1 year ago

I have the same version installed.

I guess I’ll have to walk away from this and keep the current ahi that opens a url in Edge kiosk mode.

Thanks for trying :)