Is it possible to create this kind of data in AutoHoktey?

I need to create a function that will take a window and resize it or restore its initial size. I am stuck on the part of recording the windows initial position and size, so I can restore its initial position later on.

Here is what I have:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>win_snapToMonitor(winTitle := "a", subCommand := ""){
static history := []
hwnd := winExist(winTitle)
monNo := coord_OnMonitor(hwnd) ;this function simply return a monitor No, such as "1" or "2"
SysGet, mon, Monitor,% monNo
WinGetPos(winX, winY, winW, winH, winTitle)
;if (history has hwnd in it){ ;this block is pseudo code
; restore window
; remove it from the "history" array
; return
;}
;else{
; history.push(hwnd:{x:winX, y:winY, w:winW, h:winH})
;}
if (subCommand = "toLeft")
WinMove("ahk_id" hwnd,, monLeft) ;only move to left
else if (subCommand = "toTop")
WinMove("ahk_id" hwnd,,, monTop) ;only move to top
else if (subCommand = "toRight")
WinMove("ahk_id" hwnd,, monRight - winH) ;only move to right
else if (subCommand = "toBottom")
WinMove("ahk_id" hwnd,,, monBottom - winW) ;only move to bottom
else if (subCommand = "Horiz")
WinMove("ahk_id" hwnd,, monLeft,, monRight) ;fill all horizontal
else if (subCommand = "Vert")
WinMove("ahk_id" hwnd,,, monTop,, (montop - monBottom) * -1) ;fill all vertical
}
</code>
<code>win_snapToMonitor(winTitle := "a", subCommand := ""){ static history := [] hwnd := winExist(winTitle) monNo := coord_OnMonitor(hwnd) ;this function simply return a monitor No, such as "1" or "2" SysGet, mon, Monitor,% monNo WinGetPos(winX, winY, winW, winH, winTitle) ;if (history has hwnd in it){ ;this block is pseudo code ; restore window ; remove it from the "history" array ; return ;} ;else{ ; history.push(hwnd:{x:winX, y:winY, w:winW, h:winH}) ;} if (subCommand = "toLeft") WinMove("ahk_id" hwnd,, monLeft) ;only move to left else if (subCommand = "toTop") WinMove("ahk_id" hwnd,,, monTop) ;only move to top else if (subCommand = "toRight") WinMove("ahk_id" hwnd,, monRight - winH) ;only move to right else if (subCommand = "toBottom") WinMove("ahk_id" hwnd,,, monBottom - winW) ;only move to bottom else if (subCommand = "Horiz") WinMove("ahk_id" hwnd,, monLeft,, monRight) ;fill all horizontal else if (subCommand = "Vert") WinMove("ahk_id" hwnd,,, monTop,, (montop - monBottom) * -1) ;fill all vertical } </code>
win_snapToMonitor(winTitle := "a", subCommand := ""){
    
    static history := []
    hwnd := winExist(winTitle)
    monNo   := coord_OnMonitor(hwnd)                                                            ;this function simply return a monitor No, such as "1" or "2"
    SysGet, mon, Monitor,% monNo
    WinGetPos(winX, winY, winW, winH, winTitle)
    
    ;if (history has hwnd in it){                                                           ;this block is pseudo code
    ;   restore window
    ;   remove it from the "history" array                                      
    ;   return
    ;}
    ;else{
    ;   history.push(hwnd:{x:winX, y:winY, w:winW, h:winH})
    ;}

    if (subCommand = "toLeft")
        WinMove("ahk_id" hwnd,, monLeft)                                                    ;only move to left
    else if (subCommand = "toTop")
        WinMove("ahk_id" hwnd,,, monTop)                                                ;only move to top
    else if (subCommand = "toRight")
        WinMove("ahk_id" hwnd,, monRight - winH)                                        ;only move to right
    else if (subCommand = "toBottom")
        WinMove("ahk_id" hwnd,,, monBottom - winW)                                  ;only move to bottom
    else if (subCommand = "Horiz")
        WinMove("ahk_id" hwnd,, monLeft,, monRight)                                 ;fill all horizontal
    else if (subCommand = "Vert")
        WinMove("ahk_id" hwnd,,, monTop,, (montop - monBottom) * -1)            ;fill all vertical
}

The line history.push(hwnd:{x:winX, y:winY, w:winW, h:winH}) keeps throwing an ==> Unexpected "{" error.

I am trying to store a dictionary (map?) whose name is a window handle. Looking at it on its own, it looks like this

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>hwnd := winExist("code")
WinGetPos(winX, winY, winW, winH, winTitle) ;1:1 wrapper for the winGetPos command
history := []
history.push(hwnd{x:winX, y:winY, w:winW, h:winH}) ;keeps throwing an ==> Unexpected "{" error.
history.push(%hwnd%:{x:winX, y:winY, w:winW, h:winH}) ;this does not work either
history.push((%hwnd%):{x:winX, y:winY, w:winW, h:winH}) ;this does not work either
history.push((hwnd):{x:winX, y:winY, w:winW, h:winH}) ;this does not work either
print(history) ;prints a stringified json of the AHK object
</code>
<code>hwnd := winExist("code") WinGetPos(winX, winY, winW, winH, winTitle) ;1:1 wrapper for the winGetPos command history := [] history.push(hwnd{x:winX, y:winY, w:winW, h:winH}) ;keeps throwing an ==> Unexpected "{" error. history.push(%hwnd%:{x:winX, y:winY, w:winW, h:winH}) ;this does not work either history.push((%hwnd%):{x:winX, y:winY, w:winW, h:winH}) ;this does not work either history.push((hwnd):{x:winX, y:winY, w:winW, h:winH}) ;this does not work either print(history) ;prints a stringified json of the AHK object </code>
hwnd := winExist("code")
WinGetPos(winX, winY, winW, winH, winTitle)         ;1:1 wrapper for the winGetPos command
history := []
history.push(hwnd{x:winX, y:winY, w:winW, h:winH})      ;keeps throwing an ==> Unexpected "{" error.
history.push(%hwnd%:{x:winX, y:winY, w:winW, h:winH})      ;this does not work either
history.push((%hwnd%):{x:winX, y:winY, w:winW, h:winH})    ;this does not work either
history.push((hwnd):{x:winX, y:winY, w:winW, h:winH})      ;this does not work either
print(history)                                  ;prints a stringified json of the AHK object

I am trying to create data like this

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>[
"0x13f11" : {
"x" : 100,
"y" : 100,
"w" : 1000,
"w" : 1000,
}
"0x13f722" : {
"x" : 200,
"y" : 200,
"w" : 2000,
"w" : 2000,
}
...
]
</code>
<code>[ "0x13f11" : { "x" : 100, "y" : 100, "w" : 1000, "w" : 1000, } "0x13f722" : { "x" : 200, "y" : 200, "w" : 2000, "w" : 2000, } ... ] </code>
[
    "0x13f11" : {
        "x"     : 100, 
        "y"     : 100,
        "w" : 1000,
        "w" : 1000,
    }
    "0x13f722" : {
        "x"     : 200, 
        "y"     : 200,
        "w" : 2000,
        "w" : 2000,
    }
...
]

I decided to have the data in this structure, because I am thinking I can query history and return a matching handle in a list of handles it has, doing arrayMatch(history, hwnd) should return a array element

The code for arrayMatch

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>;Match a value in a array using case-insensitive string matching, with the option to return first or all matches and value or index
arrayMatch(array, match, all := 0, index := 0){
out := []
loop,% array.Length()
{
if (index){
if (array[A_Index] = match){
return A_Index
}
}
else{
if (array[A_Index] == match){
if (all)
out.push((array[A_Index]))
else
return (array[A_Index])
}
}
}
return out
}
</code>
<code>;Match a value in a array using case-insensitive string matching, with the option to return first or all matches and value or index arrayMatch(array, match, all := 0, index := 0){ out := [] loop,% array.Length() { if (index){ if (array[A_Index] = match){ return A_Index } } else{ if (array[A_Index] == match){ if (all) out.push((array[A_Index])) else return (array[A_Index]) } } } return out } </code>
;Match a value in a array using case-insensitive string matching, with the option to return first or all matches and value or index
arrayMatch(array, match, all := 0, index := 0){
    out := []
    loop,% array.Length()
        {
            if (index){
                if (array[A_Index] = match){
                        return A_Index
                    }   
                }
            else{
                if (array[A_Index] == match){
                    if (all)
                        out.push((array[A_Index]))
                    else
                        return (array[A_Index])
                    }   
                }
        }
    return out
}

I am a very novice programmer, so any suggestions for a better data structure would be most welcome.

PS: I know windows kind of does this feature, but this is a programming project for me.

Any help would be greatly appreciated!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật