now have two functions. a function and b function.
a function effect is reading png file data to a VarSetCapacity variable, and return .
b function effect is reception a function result, but There is a problem here. b function reading a function result don't agreement!!!!
Here is the main code!!!!
function a
Code: Select all
screenshot(pos_x, pos_y, w, h, ByRef len)
{
; 截图
;pos := pos_x "|" pos_y "|" w "|" h
;pToken := Gdip_Startup()
;snap := Gdip_BitmapFromScreen(pos)
;Gdip_SaveBitmapToFile(snap, "temp.png")
;Gdip_DisposeImage(snap)
;读取文件
file := FileOpen("temp.png", "r")
VarSetCapacity(content, 102400)
len := file.RawRead(content, 102400)
return content
}
function b
Code: Select all
F1::
len := 0
res := screenshot("50", "50", "1000", "1000", len)
index := 0
Loop, 5 {
num := NumGet(res, index, "UChar")
MsgBox, %num% - %index%
index := index + 1
}
;httpPost("http 10.1.3.63:8080 ", "/", res.data, res.len)
return
function b: variable res is inconsistent with A
all codes
Code: Select all
#Include ./AHKv2-Gdip/Gdip_All.ahk
memcpy()
{
}
httpGet(host, path)
{
; 参数1 char * host
VarSetCapacity(host_ptr, StrLen(host) * 2)
StrPut(host, &host_ptr)
; 参数2 char * path
VarSetCapacity(path_ptr, StrLen(path) * 2)
StrPut(path, &path_ptr)
; 参数4 int buff_len
buff_len := 10240
; 参数3 char * resBuff
VarSetCapacity(res_buff, buff_len)
; 调用dll
res := DllCall("httpClient.dll\post", "Str", host_ptr, "Str", path_ptr, "Str", res_buff, "Int", buff_len)
MsgBox, http接口返回的字节数 = %res% `n 返回内容 `n %res_buff%
return res_buff
}
httpPost(host, path, ByRef send_content, send_content_len)
{
; 参数1 char * host
VarSetCapacity(host_ptr, StrLen(host) * 2)
StrPut(host, &host_ptr)
; 参数2 char * path
VarSetCapacity(path_ptr, StrLen(path) * 2)
StrPut(path, &path_ptr)
; 参数4 int buff_len
buff_len := 10240
; 参数3 char * resBuff
VarSetCapacity(res_buff, buff_len)
;参数5 char * buff
VarSetCapacity(buff_ptr, send_content_len)
; 内存拷贝
index = 0
Loop, 30 {
num := NumGet(&send_content, index, "UChar")
;MsgBox, %num% - %index%
NumPut(num, buff_ptr, index, "UChar")
index := index + 1
}
;参数6 int send_len
send_len := send_content_len
; 调用dll
res := DllCall("httpClient.dll\post", "Str", host_ptr, "Str", path_ptr, "Str", res_buff, "Int", buff_len, "Str", send_content, "Int", send_len)
MsgBox, http接口返回的字节数 = %res% `n 返回内容 `n %res_buff%
return res_buff
}
screenshot(pos_x, pos_y, w, h, ByRef len)
{
; 截图
;pos := pos_x "|" pos_y "|" w "|" h
;pToken := Gdip_Startup()
;snap := Gdip_BitmapFromScreen(pos)
;Gdip_SaveBitmapToFile(snap, "temp.png")
;Gdip_DisposeImage(snap)
;读取文件
file := FileOpen("temp.png", "r")
VarSetCapacity(content, 102400)
len := file.RawRead(content, 102400)
return content
}
F1::
len := 0
res := screenshot("50", "50", "1000", "1000", len)
index := 0
Loop, 5 {
num := NumGet(res, index, "UChar")
MsgBox, %num% - %index%
index := index + 1
}
;httpPost("http 10.1.3.63:8080 ", Broken Link for safety "/", res.data, res.len)
return
t(){
s := "tttt213213"
return s
}
F2::
str := t()
len := StrLen(str)
MsgBox, %len%