有个私活,把一个 ahk 函数转成 rust 函数,预算 500

下面是 ahk 函数,用到了一个 ahk 库 Gdip.ahk ,要求用 rust 和 windows-rs 库实现一个相同功能的函数。
实现出来了可以加我微信私聊,WX:bHgxMDc2OTg4OTQ0

```ahk
可视化(var0 := "0", var1 := "0", var2 := "0")
{ ;显示坐标
if !pToken := Gdip_Startup()
{
MsgBox, % 4096+262208, , Gdiplus 错误!, Gdiplus 无法启动.请确保系统中有 gdiplus.dll
return
}

Gui, GUILX: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, GUILX: Show, NA
Width := A_ScreenWidth
Height := A_ScreenHeight
hwnd1 := WinExist()
hbm := CreateDIBSection(Width, Height)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
pBrush1 := Gdip_CreatePen(0xFFFF0000, 1)
pBrush2 := Gdip_CreatePen(0xFF00FFFF, 1)
pBrush3 := Gdip_CreatePen(0xFFFFFF00, 1)

for k, v in var0
{
Gdip_DrawRectangle(G, pBrush1, v.x, v.y, v.w, v.h)
}

if var1
{
x := "", y := "", c := ""
For k, v in var1
{
if (y = "")
{
N := StrSplit(v,",")
x := N[1],y := N[2]
c .= "`n" . k . " : " . v
}
tx:=x
ty:=y-20
Gdip_TextToGraphics(G, k, "x" tx "y" ty "h20 Centre cFF00FF00 r4 s12 Left")
Gdip_DrawLine(G, pBrush2, x - 5, y, x - 1 , y)
Gdip_DrawLine(G, pBrush2, x + 5, y, x + 1 , y)
Gdip_DrawLine(G, pBrush2, x, y - 5, x, y - 1)
Gdip_DrawLine(G, pBrush2, x, y + 5, x, y + 1)
}
}
if var2
{
Gdip_DrawRectangle(G, pBrush3, var2.x - 5, var2.y - 5, var2.w + 10, var2.h + 10)
}
Gdip_DeleteBrush(pBrush1)
Gdip_DeleteBrush(pBrush2)
Gdip_DeleteBrush(pBrush3)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, Width, Height)
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)
MsgBox, 4096, , % "点击确认关闭显示" c
Gui, GUILX: Destroy
return
}
```

来源:https://v2ex.com/t/1064263