mmikeww / AHK-v2-script-converter

AHK v1 -> v2 script converter
https://autohotkey.com/boards/viewtopic.php?f=6&t=25100
The Unlicense
487 stars 38 forks source link

An error conversion #210

Open lazulkia opened 1 week ago

lazulkia commented 1 week ago

V1:

NumPut(VarSetCapacity(WINDOWPLACEMENT, 44, 0), WINDOWPLACEMENT, 0, "UInt")

V2 (Converted):

 NumPut("UInt", WINDOWPLACEMENT := Buffer(44, 0), WINDOWPLACEMENT, 0) ; V1toV2: if 'WINDOWPLACEMENT' is a UTF-16 string, use 'VarSetStrCapacity(&WINDOWPLACEMENT, 44)'

V2 (Expected):

    WINDOWPLACEMENT := Buffer(44, 0)
    NumPut("UInt", 44, WINDOWPLACEMENT, 0)
Banaanae commented 6 days ago

Could you send the full v1 script? NumPut and co is very confusing for me so having the full script to test would be appreciated :)

lazulkia commented 5 days ago

The full script is from the forum:

GetWindowPlacement(hWnd) {
    NumPut(VarSetCapacity(WINDOWPLACEMENT, 44, 0), WINDOWPLACEMENT, 0, "UInt")
    DllCall("GetWindowPlacement", "Ptr", hWnd, "Ptr", &WINDOWPLACEMENT)
    Result := {}
    Result.x := NumGet(WINDOWPLACEMENT, 28, "Int")
    Result.y := NumGet(WINDOWPLACEMENT, 32, "Int")
    Result.w := NumGet(WINDOWPLACEMENT, 36, "Int") - Result.x
    Result.h := NumGet(WINDOWPLACEMENT, 40, "Int") - Result.y
    Result.showCmd := NumGet(WINDOWPLACEMENT, 8, "UInt") ; 1 = normal, 2 = minimized, 3 = maximized
    Return Result
}

SetWindowPlacement(hWnd, x, y, w, h, showCmd) {
    NumPut(VarSetCapacity(WINDOWPLACEMENT, 44, 0), WINDOWPLACEMENT, 0, "UInt")
    NumPut(x, WINDOWPLACEMENT, 28, "Int")
    NumPut(y, WINDOWPLACEMENT, 32, "Int")
    NumPut(w + x, WINDOWPLACEMENT, 36, "Int")
    NumPut(h + y, WINDOWPLACEMENT, 40, "Int")
    NumPut(showCmd, WINDOWPLACEMENT, 8, "UInt")
    Return DllCall("SetWindowPlacement", "Ptr", hWnd, "ptr", &WINDOWPLACEMENT)
}