Skip to content

Commit

Permalink
+-
Browse files Browse the repository at this point in the history
  • Loading branch information
Ixiko committed Aug 18, 2023
1 parent e5e1666 commit e318e92
Show file tree
Hide file tree
Showing 26 changed files with 1,249 additions and 123,735 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion AHK_V2/Webview2.ahk2 → AHK_V2/Webview2.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ WebView2_Init(iGui){
WebView2ExecuteScriptCompletedHandler := WebView2() ; ICoreWebView2ExecuteScriptCompletedHandler
WebView2DocumentTitleChangedEventHandler := WebView2() ; ICoreWebView2DocumentTitleChangedEventHandler.

local dllPath := "c:\Program Files (x86)\AutoHotKey\JMM\WebView2\x64\WebView2Loader"
local dllPath := A_ScriptDir "\..\webview2\WebView2Loader"
DllCall dllPath "\CreateCoreWebView2Environment","ptr",WebView2Environment

If(A_LastError){
Expand Down
2 changes: 1 addition & 1 deletion AHK_V2/examples/QQ.ahk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Include '..\XCGUI.ahk'
#Include '..\class_XCGUI.ahk'
DllCall('LoadLibrary', 'str', '..\' (A_PtrSize * 8) 'bit\xcgui.dll')
XC.InitXCGUI()
bRes := XC.LoadResource('resource.res')
Expand Down
2 changes: 1 addition & 1 deletion AHK_V2/examples/Webview2-example 2.ahk2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include WebView2.ahk
#include %A_ScriptDir%\..\WebView2.ahk

HtmlSite := "https www.google.com " Broken Link for safety

Expand Down
7 changes: 4 additions & 3 deletions AHK_V2/examples/Webview2-example 3.ahk2
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include webview2.ahk
#include %A_ScriptDir%\..\webview2.ahk

NavUri := "https www.bing.com " ; Broken Link for safety

NavUri := "https www.bing.com " Broken Link for safety

win := Gui.New("-caption","WebView2 Testing")
win.BackColor := "Aqua"
Expand All @@ -15,7 +16,7 @@ win.Show "w" A_ScreenWidth " h" A_ScreenHeight
;Give some time to load Gui
sleep 600

NavUri := "https www.google.com " Broken Link for safety
NavUri := "https www.google.com " ; Broken Link for safety

wvtop := A_ScreenHeight/1.5
wvBottom := 1090
Expand Down
2 changes: 1 addition & 1 deletion AHK_V2/examples/Webview2-example 4.ahk2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include WebView2.ahk
#include %A_ScriptDir%\..\webview2.ahk

NavUri := "https://www.google.com"

Expand Down
4 changes: 2 additions & 2 deletions AHK_V2/examples/Webview2-example.ahk2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include WebView2.ahk
#include imagedata.ahk
#include %A_ScriptDir%\..\webview2.ahk
#include %A_ScriptDir%\..\imagedata.ahk

On_Click(iClick){
Switch(iClick){
Expand Down
90 changes: 45 additions & 45 deletions AHK_V2/examples/class_winsock_example.ahk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Include _socket.ahk
#Include %A_ScriptDir%\..\socket.ahk

#Requires AutoHotkey v2.0-beta ; 32-bit

Expand Down Expand Up @@ -36,70 +36,70 @@ F7::test_google_blocking()

test_error() {
sock := winsock("client-err",cb,"IPV4")

; sock.Connect("www.google.com",80) ; 127.0.0.1",27015 ; www.google.com",80
result := sock.Connect("localhost",5678) ; error is returned in callback
}

test_google() {
sock := winsock("client",cb,"IPV6")

sock.Connect("www.google.com",80) ; 127.0.0.1",27015 ; www.google.com",80
; sock.Connect("www.autohotkey.com",80) ; www.autohotkey.com/download/2.0/

print_gui("Client connecting...`r`n`r`n")
}

test_server() { ; server - uses async to accept sockets
sock := winsock("server",cb,"IPV4")
sock.Bind("0.0.0.0",27015) ; "0.0.0.0",27015

sock.Listen()

print_gui("Server listening...`r`n`r`n")
}

test_client() { ; client
sock := winsock("client",cb,"IPV4")

sock.Connect("127.0.0.1",27015) ; 127.0.0.1",27015 ; www.google.com",80

print_gui("Client connecting...`r`n`r`n")
}

test_google_blocking() { ; this uses no async at all
sock := winsock("client",cb,"IPV6")

domain := "www.autohotkey.com" ; www.google.com / www.autohotkey.com
port := 443 ; 443 / 80

If !(r1 := sock.Connect(domain,port,true)) { ; www.google.com
msgbox "Could not connect: " sock.err
return
}

get_req := "GET / HTTP/1.1`r`n"
. "Host: " domain "`r`n`r`n"

strbuf := Buffer(StrPut(get_req,"UTF-8"),0)
StrPut(get_req,strbuf,"UTF-8")

If !(r2 := sock.Send(strbuf)) {
Msgbox "Send failed."
return
}

While !(buf:=sock.Recv()).size ; wait for data
Sleep 10

result := ""
while buf.size {
result .= StrGet(buf,"UTF-8") ; collect data
buf:=sock.Recv()
}

sock.Close()

A_Clipboard := result
msgbox "Done. Check clipboard."
}
Expand All @@ -110,41 +110,41 @@ test_send() { ; the connecting client doesn't use async
msgbox "Could not connect."
return ; handle a failed connect properly
}

msg := "abc"
strbuf := Buffer(StrLen(msg) + 1) ; for UTF-8, take strLen() + 1 as the buffer size
StrPut(msg, strbuf, "UTF-8")

r := sock.Send(strbuf) ; check send result if necessary

sock.Close()
}

cb(sock, event, err) {
global client_data

dbg("sock.name: " sock.name " / event: " event " / err: " err " ===========================")

if (sock.name = "client") {

if (event = "close") {
msgbox "Address: " sock.addr "`n" "Port: " sock.port "`n`n" client_data
A_Clipboard := client_data
client_data := ""
sock.close()

} else if (event = "connect") { ; connection complete, if (err = 0) then it is a success
print_gui("Client...`r`nConnect Addr: " sock.addr "`r`nConnect Port: " sock.port "`r`n`r`n") ; this does not check for failure

} else if (event = "write") { ; client ready to send/write
get_req := "GET / HTTP/1.1`r`n"
. "Host: www.google.com`r`n`r`n"

strbuf := Buffer(StrPut(get_req,"UTF-8"),0)
StrPut(get_req,strbuf,"UTF-8")

sock.Send(strbuf)

print_gui("Client sends to server:`r`n"
. "======================`r`n"
. Trim(get_req,"`r`n") "`r`n"
Expand All @@ -154,45 +154,45 @@ cb(sock, event, err) {
buf := sock.Recv()
client_data .= StrGet(buf,"UTF-8")
}



} else if (sock.name = "server") || instr(sock.name,"serving-") {

if (event = "accept") {
sock.Accept(&addr,&newsock) ; pass &addr param to extract addr of connected machine

print_gui("======================`r`n"
. "Server processes client connection:`r`n"
. "address: " newsock.addr "`r`n"
. "======================`r`n`r`n" )

} else if (event = "close") {


} else if (event = "read") {

If !(buf := sock.Recv()).size ; get buffer, check size, return on zero-size buffer
return

dbg("buf size: " buf.size)

print_gui("======================`r`n"
. "Server recieved from client:`r`n"
. Trim(strget(buf,"UTF-8"),"`r`n") "`r`n"
. "======================`r`n`r`n")
}

} else if (sock.name = "client-err") { ; this is how you catch an error with async / non-blocking

if (event = "connect") && err
msgbox sock.name ": " event ": err: " err
msgbox sock.name ": " event ": err: " err

}

; dbg(sock.name ": " event ": err: " err) ; to make it easier to see all the events
}



; ==========================================================
Expand Down
Loading

0 comments on commit e318e92

Please sign in to comment.