Skip to content

Commit

Permalink
Update ahk version
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBestPessimist committed Nov 7, 2023
1 parent f563dc1 commit 42060eb
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 133 deletions.
Binary file modified AutoHotkey64.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions UX/WindowSpy.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ WinSpyGui() {
oGui.OnEvent("Close",WinSpyClose)
oGui.OnEvent("Size",WinSpySize)

oGui.SetFont('s9', "Segoe UI")

oGui.Add("Text",,"Window Title, Class and Process:")
oGui.Add("Checkbox","yp xp+200 w120 Right vCtrl_FollowMouse","Follow Mouse").Value := 1
oGui.Add("Edit","xm w320 r5 ReadOnly -Wrap vCtrl_Title")
Expand Down
2 changes: 1 addition & 1 deletion UX/inc/identify_regex.ahk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
get_identify_regex() => '
(
(?(DEFINE)(?<line_comment>(?<![^ `t`r`n]);.*)(?<block_comment>(?m:^[ `t]*/\*(?:.*\R?)+?(?:[ `t]*\*/|.*\Z)))(?<eol>(?=[ `t]*+(?&line_comment)?(?m:$)))(?<tosol>(?:(?&eol).*\R|(?&block_comment))++)(?<toeol>(?:[^ `t`r`n]++|[ `t]*+(?!(?&eol)))*+)(?<contsec>[ `t]*+\((?i:Join[^ `t`r`n]*+|(?&line_comment)|[^ `t`r`n()]++|[ `t]++)*+\R(?:[ `t]*+(?!\)).*\R)*+[ `t]*+\))(?<solcont>[ `t]*+(?:,(?!::| +& )|[<>=/|^,?:\.+\-*&!~](?![^"'`r`n]*?(?:".*?::(?!.*?")|'.*?::(?!.*?')|::))|(?i:AND|OR)(?=[ `t])))(?<eolcont>(?&eol)(?:(?<ec_bad>(?<=:=)|(?<=[:,]))|(?<=[<>=/|^,?:\.+\-*&!~](?<!\+\+|--))|(?<=(?<![\w[:^ascii:]\.])(?i:OR|IS|AS|IN))|(?<=(?<![\w[:^ascii:]\.])(?i:AND|NOT))|(?<=(?<![\w[:^ascii:]\.])(?i:CONTAINS)))(?&tosol)(?:(?&contsec)|(?(ec_bad)|(*:v2-cle))))(?<v1_cont>(?&tosol)(?:(?&solcont)(?&subexp)|[ `t]*+,[ `t]*+(?=%)(?&pct)|(?&contsec)(?&ambig)))(?<v1_fin>(?:.*+(?&v1_cont))*.*+)(?<ambig>(?:(?&exp)|(?&v1_cont)|.*+)++(*:~))(?<pct>(?=%[ `t])(?:(?&subexp)(?&exp)|(?&v1_fin)(*:v1-pct)))(?<expm>(*:exp)(?&exp))(?<v1_lines>(?&toeol)(?:(?&tosol)(?:(?&solcont)|(?&contsec))(?&v1_lines))?)(?<otb>(?<![<>=/|^,?:\.*&!~])(?<!(?<!\+)\+)(?<!(?<!\-)\-)[ `t]*+\{(?&eol))(?<enclf>\R(?:(?&contsec)|(?!(?&solcont))(*:v2-cbe)|))(?<encex>(?:[, `t]++|(?&enclf)|(?&subexp)|(?&line_comment))*+)(?<v2_exm>%(?:[^,`r`n;\[\]{}()"%']*+|,(?![ `t]*+%)|(?&subexp))*+%(*:v2-pct)|=>(*:v2-fat))(?<subexp>(?:(?!(?&otb))(?&eolcont)?[ `t]*+(?:[^ `t;,`r`n=\[\]{}()"%']++|\((?&encex)\)|\[(?&encex)\]|\{(?&encex)\}|(?>"(?>[^"``\r\n]|``["'``])*+"|'(?>[^'``\r\n]|``["'``])*+'(*:v2-sq))|'(?&tosol)(?&contsec)'(*:v2-sq)|(?<!\.)%[\w[:^ascii:]]++%|(?&v2_exm)|=|(?&v1_cont)))++)(?<exp>(?:(?&subexp)|[ `t]*+,|(?&eol))++(?&otb)?))(?:[ `t]*+(?&line_comment)(*SKIP)(?!)|(?m:^)[ `t{}]*(?:(?m:^[ `t]*/\*(?:.*\R?)+?(?:[ `t]*\*/|.*\Z))(*SKIP)(?!)|(?:[<>*~$!^+#]*(?>\w+|[^ `t`r`n])|~?(?>\w+|[^ `t`r`n]) & ~?(?>\w+|[^ `t`r`n]))(?i:[ `t]+up)?::(?:[<>*~$!^+#]*(?>\w+|[^ `t`r`n])(?&eol)(*:remap?)|(?&eol)(?!(?&tosol)[ `t]*+(?:[\{#]|.*?::|[\w[:^ascii:]]++\())(*:v1-hk)|(*:hotkey))|(?(?=:[^\:`r`n]*[xX]):[[:alnum:]\?\*\- ]*:.*(?<!``)::|:[[:alnum:]\?\*\- ]*:.*(?<!``)::.*)(*:hotstring)|[\w[:^ascii:]]++:(?=[ `t]*+(?:(?<![^ `t`r`n]);.*)?(?m:$))(*:label)|[^ ,```r`n]+(?<!:):(?=[ `t]*+(?:(?<![^ `t`r`n]);.*)?(?m:$))(*:v1-lbl)|#(?:\w+,|(?i:NoEnv|If|CommentFlag|Delimiter|DerefChar|EscapeChar))(?&v1_fin)(*:v1-dir)|#(?i:HotIf)(*:v2-dir)(?&exp)?|#(?i:Include(?:Again)?)[ `t]+(?&v1_fin)(*:dir)|#\w+(?![^ `t`r`n])(?&ambig)(*:dir?)|(?<=[{}])(*SKIP)(?!))|[ `t]*+(?:(?!(?:[\w[:^ascii:]<>=/|^,?:\.+\-*&!~ `t()\[\]{}%]++|(?>"(?>[^"``\r\n]|``["'``])*+"|'(?>[^'``\r\n]|``["'``])*+'(*:v2-sq))|['"].*)*+(?=[ `t]*+(?:(?<![^ `t`r`n]);.*)?(?m:$)))(?&v1_fin)(*:v1-char)|(?i:else|try|finally)(?![^ `t`r`n])[ `t]*+\{?(*SKIP)(?!)|(?i:return|for|while|until|throw|switch)[ `t]++(?&expm)|(?i:local|global|static)(?![\w[:^ascii:]#@$])(?:[ `t]++[\w[:^ascii:]]++(?:(?=\()(?&exp)(*:v2-kw)|[ `t]*+\{(?&eol)(*:v2-kw)|(?![ `t]*+=)(?&expm))|(?&eol)(*:assume)|(?&v1_fin)(*:v1-kw))|(?i:if)[ `t]++(?:(?>[\w[:^ascii:]#@$]++|%[\w[:^ascii:]#@$]++%)++(?:[ `t]++(?i:not[ `t]++)?(?i:in|contains|between)[ `t]++(?&v1_fin)(*:v1-if)|[ `t]*+(?:[<>]=?|!?=)(?&ambig))|(?&expm))|[\w[:^ascii:]]++(?:[ `t]*+=(?:>(?&ambig)|.*?\?.+?:.*(?&ambig)|(?&v1_fin)(*:v1-ass))|[\(\[](?=.*[\)\]][ `t`r`n]*\{)(?:[ `t]*+[\w[:^ascii:]]++[ `t]*+(?::=(?&subexp))?[ `t]*+,)*+[ `t]*+(?:(?i:ByRef)[ `t]++[\w[:^ascii:]](*:v1-ref)|&(*:v2-ref)|[\w[:^ascii:]]++[ `t]*+=(*:v1-def)|\*[ `t]*+[\)\]](*:v2-vfn)).*|(?=[\(\[\.\?]|[ `t]*+(?>[\:\+\-\*/\.\|&\^]|<<|>>|//)=)(?&expm)|,(?&v1_fin)(*:v1-cmd)|(?&eol)(?&ambig)|[ `t]++(?:[ `t]*+(?:\^|(?:(?!\{)[\w[:^ascii:]<>=/|^,?:\.+\-*&!~ `t()\[\]{}%]|(?>"(?>[^"``\r\n]|``["'``])*+"|'(?>[^'``\r\n]|``["'``])*+'(*:v2-sq)))*+\{[ `t]*+(?:\w+|.)(?:[ `t]++\w+)?[ `t]*+\})(?&v1_fin)(*:v1-send)|(?:[^`r`n,\[\]{}()"%']*+,[ `t]*+)*+(?&pct)|(?&ambig)(*:cmd?)))|(?:\+\+|--)(?&expm)|.(?&ambig)(*:!!)))
(?(DEFINE)(?<line_comment>(?<![^ `t`r`n]);.*)(?<block_comment>(?m:^[ `t]*/\*(?:.*\R?)+?(?:[ `t]*\*/|.*\Z)))(?<eol>(?=[ `t]*+(?&line_comment)?(?m:$)))(?<tosol>(?:(?&eol).*\R|(?&block_comment))++)(?<toeol>(?:[^ `t`r`n]++|[ `t]*+(?!(?&eol)))*+)(?<contsec>[ `t]*+\((?i:Join[^ `t`r`n]*+|(?&line_comment)|[^ `t`r`n()]++|[ `t]++)*+\R(?:[ `t]*+(?!\)).*\R)*+[ `t]*+\))(?<solcont>[ `t]*+(?:,(?!::| +& )|[<>=/|^,?:\.+\-*&!~](?![^"'`r`n]*?(?:".*?::(?!.*?")|'.*?::(?!.*?')|::))|(?i:AND|OR)(?=[ `t])))(?<eolcont>(?&eol)(?:(?<ec_bad>(?<=:=)|(?<=[:,]))|(?<=[<>=/|^,?:\.+\-*&!~](?<!\+\+|--))|(?<=(?<![\w[:^ascii:]\.])(?i:OR|IS|AS|IN))|(?<=(?<![\w[:^ascii:]\.])(?i:AND|NOT))|(?<=(?<![\w[:^ascii:]\.])(?i:CONTAINS)))(?&tosol)(?:(?&contsec)|(?(ec_bad)|(*:v2-cle))))(?<v1_cont>(?&tosol)(?:(?&solcont)(?&subexp)|[ `t]*+,[ `t]*+(?=%)(?&pct)|(?&contsec)(?&ambig)))(?<v1_fin>(?:.*+(?&v1_cont))*.*+)(?<ambig>(?:(?&exp)|(?&v1_cont)|.*+)++(*:~))(?<pct>(?=%[ `t])(?:(?&subexp)(?&exp)|(?&v1_fin)(*:v1-pct)))(?<expm>(*:exp)(?&exp))(?<v1_lines>(?&toeol)(?:(?&tosol)(?:(?&solcont)|(?&contsec))(?&v1_lines))?)(?<otb>(?<![<>=/|^,?:\.*&!~])(?<!(?<!\+)\+)(?<!(?<!\-)\-)[ `t]*+\{(?&eol))(?<enclf>\R(?:(?&contsec)|(?!(?&solcont))(*:v2-cbe)|))(?<encex>(?:[, `t]++|(?&enclf)|(?&subexp)|(?&line_comment))*+)(?<v2_exm>%(?:[^,`r`n;\[\]{}()"%']*+|,(?![ `t]*+%)|(?&subexp))*+%(*:v2-pct)|=>(*:v2-fat))(?<subexp>(?:(?!(?&otb))(?&eolcont)?[ `t]*+(?:[^ `t;,`r`n=\[\]{}()"%']++|\((?&encex)\)|\[(?&encex)\]|\{(?&encex)\}|(?>"(?>[^"``\r\n]|``["'``])*+"|'(?>[^'``\r\n]|``["'``])*+'(*:v2-sq))|'(?&tosol)(?&contsec)'(*:v2-sq)|(?<!\.)%[\w[:^ascii:]]++%|(?&v2_exm)|=|(?&v1_cont)))++)(?<exp>(?:(?&subexp)|[ `t]*+,|(?&eol))++(?&otb)?))(?:[ `t]*+(?&line_comment)(*SKIP)(?!)|(?m:^)[ `t{}]*(?:(?m:^[ `t]*/\*(?:.*\R?)+?(?:[ `t]*\*/|.*\Z))(*SKIP)(?!)|(?:[<>*~$!^+#]*(?>\w+|[^ `t`r`n])|~?(?>\w+|[^ `t`r`n]) & ~?(?>\w+|[^ `t`r`n]))(?i:[ `t]+up)?::(?:[<>*~$!^+#]*(?>\w+|[^ `t`r`n])(?&eol)(*:remap?)|(?&eol)(?!(?&tosol)[ `t]*+(?:[\{#]|.*?::|[\w[:^ascii:]]++\())(*:v1-hk)|(*:hotkey))|(?(?=:[^\:`r`n]*[xX]):[[:alnum:]\?\*\- ]*:.*(?<!``)::|:[[:alnum:]\?\*\- ]*:.*(?<!``)::(?:(?&v1_cont)|.*))(*:hotstring)|[\w[:^ascii:]]++:(?=[ `t]*+(?:(?<![^ `t`r`n]);.*)?(?m:$))(*:label)|[^ ,```r`n]+(?<!:):(?=[ `t]*+(?:(?<![^ `t`r`n]);.*)?(?m:$))(*:v1-lbl)|#(?:\w+,|(?i:NoEnv|If|CommentFlag|Delimiter|DerefChar|EscapeChar))(?&v1_fin)(*:v1-dir)|#(?i:HotIf)(*:v2-dir)(?&exp)?|#(?i:Include(?:Again)?)[ `t]+(?&v1_fin)(*:dir)|#\w+(?![^ `t`r`n])(?&ambig)(*:dir?)|(?<=[{}])(*SKIP)(?!))|[ `t]*+(?:(?!(?:[\w[:^ascii:]<>=/|^,?:\.+\-*&!~ `t()\[\]{}%]++|(?>"(?>[^"``\r\n]|``["'``])*+"|'(?>[^'``\r\n]|``["'``])*+'(*:v2-sq))|['"].*)*+(?=[ `t]*+(?:(?<![^ `t`r`n]);.*)?(?m:$)))(?&v1_fin)(*:v1-char)|(?i:else|try|finally)(?![^ `t`r`n])[ `t]*+\{?(*SKIP)(?!)|(?i:return|for|while|until|throw|switch)[ `t]++(?&expm)|(?i:if|while|return|until|loop|goto)(?=\()(?&expm)|(?i:local|global|static)(?![\w[:^ascii:]#@$])(?:[ `t]++[\w[:^ascii:]]++(?:(?=\()(?&exp)(*:v2-kw)|[ `t]*+\{(?&eol)(*:v2-kw)|(?![ `t]*+=)(?&expm))|(?&eol)(*:assume)|(?&v1_fin)(*:v1-kw))|(?i:if)[ `t]++(?:(?>[\w[:^ascii:]#@$]++|%[\w[:^ascii:]#@$]++%)++(?:[ `t]++(?i:not[ `t]++)?(?i:in|contains|between)[ `t]++(?&v1_fin)(*:v1-if)|[ `t]*+(?:[<>]=?|!?=)(?&ambig))|(?&expm))|[\w[:^ascii:]]++(?:[ `t]*+=(?:>(?&ambig)|.*?\?.+?:.*(?&ambig)|(?&v1_fin)(*:v1-ass))|[\(\[](?=.*[\)\]][ `t`r`n]*\{)(?:[ `t]*+[\w[:^ascii:]]++[ `t]*+(?::=(?&subexp))?[ `t]*+,)*+[ `t]*+(?:(?i:ByRef)[ `t]++[\w[:^ascii:]](*:v1-ref)|&(*:v2-ref)|[\w[:^ascii:]]++[ `t]*+=(*:v1-def)|\*[ `t]*+[\)\]](*:v2-vfn)).*|(?=[\(\[\.\?]|[ `t]*+(?>[\:\+\-\*/\.\|&\^]|<<|>>|//)=)(?&expm)|,(?&v1_fin)(*:v1-cmd)|(?&eol)(?&ambig)|[ `t]++(?:[ `t]*+(?:\^|(?:(?!\{)[\w[:^ascii:]<>=/|^,?:\.+\-*&!~ `t()\[\]{}%]|(?>"(?>[^"``\r\n]|``["'``])*+"|'(?>[^'``\r\n]|``["'``])*+'(*:v2-sq)))*+\{[ `t]*+(?:\w+|.)(?:[ `t]++\w+)?[ `t]*+\})(?&v1_fin)(*:v1-send)|(?:[^`r`n,\[\]{}()"%']*+,[ `t]*+)*+(?&pct)|(?&ambig)(*:cmd?)))|(?:\+\+|--)(?&expm)|.(?&ambig)(*:!!)))
)'
256 changes: 128 additions & 128 deletions UX/inc/ui-base.ahk
Original file line number Diff line number Diff line change
@@ -1,129 +1,129 @@
class AutoHotkeyUxGui extends Gui {
__new(title, opt:='') {
super.__new(opt, title, this)
this.SetFont('s9', "Segoe UI")
this.OnEvent('Escape', 'Destroy')
this.OnEvent('Close', 'Destroy')
}

AddListMenu(options:='', columns:=unset) {
IsSet(columns) || columns := []
c := this.AddListView(UxListMenu.DefaultOptions ' ' options, columns)
if !InStr(options, 'Theme')
DllCall("uxtheme\SetWindowTheme", "ptr", c.hwnd, "wstr", "Explorer", "ptr", 0)
static LVTVIM_TILESIZE := 1, LVTVIM_COLUMNS := 2, LVTVIM_LABELMARGIN := 4
static LVTVIF_AUTOSIZE := 0, LVTVIF_EXTENDED := 4, LVTVIF_FIXEDHEIGHT := 2
, LVTVIF_FIXEDSIZE := 3, LVTVIF_FIXEDWIDTH := 1
static LVM_SETTILEVIEWINFO := 0x10A2
tileviewinfo := Buffer(40, 0)
ControlGetPos(,, &w,, c)
pad := 2 * A_ScreenDPI // 96
NumPut(
'uint', 40, ; cbSize
'uint', LVTVIM_LABELMARGIN | LVTVIM_TILESIZE, ; dwMask
'uint', LVTVIF_FIXEDWIDTH, ; dwFlags
'int', w, 'int', 0, ; sizeTile
'int', 0, ; cLines
'int', pad, 'int', pad, 'int', pad, 'int', pad, ; rcLabelMargin
tileviewinfo
)
SendMessage LVM_SETTILEVIEWINFO,, tileviewinfo, c
c.base := UxListMenu.Prototype
return c
}

AddIconButton(options, iconHandle, hiddenText:="") {
static BS_ICON := 0x40
static BS_CENTER := 0x300
static BS_VCENTER := 0xC00
btn := this.AddButton((BS_ICON | BS_CENTER | BS_VCENTER) ' ' options, hiddenText)
static BM_SETIMAGE := 0xF7
SendMessage(BM_SETIMAGE, 1, iconHandle, btn)
return btn
}

FileSelect(p*) {
this.Opt '+OwnDialogs'
try
return FileSelect(p*)
finally
this.Opt '-OwnDialogs'
}

static Show(p*) {
for w in WinGetList('ahk_pid ' ProcessExist())
if (g := GuiFromHwnd(w)) && g.base = this.Prototype
return g.Show()
inst := this(p*)
inst.Show()
}
}

class UxListMenu extends Gui.ListView {
static DefaultOptions := '-Multi Tile'
. ' R1'
. ' -E0x200' ; -WS_EX_CLIENTEDGE (remove border)
. ' LV0x14000'
. Format(' Background{:x}', DllCall("GetSysColor", "int", 15, "int")) ; COLOR_3DFACE

Add(p*) {
i := super.Add(p*)
static LVM_SETTILEINFO := 0x10A4
static LVCFMT_FILL := 0x200000
static LVCFMT_WRAP := 0x400000
tileinfo := Buffer(8 + 3*A_PtrSize, 0)
col := Buffer(4)
colf := Buffer(4)
NumPut("int", 1, col)
NumPut("int", LVCFMT_FILL | LVCFMT_WRAP, colf)
NumPut("int", tileinfo.size, "int", i-1, "uptr", 1, "ptr", col.ptr, "ptr", colf.ptr, tileinfo)
SendMessage(LVM_SETTILEINFO, 0, tileinfo, this)
return i
}

_SetTileWidth(w) {
static LVTVIM_TILESIZE := 1, LVTVIM_COLUMNS := 2, LVTVIM_LABELMARGIN := 4
static LVTVIF_AUTOSIZE := 0, LVTVIF_EXTENDED := 4, LVTVIF_FIXEDHEIGHT := 2
, LVTVIF_FIXEDSIZE := 3, LVTVIF_FIXEDWIDTH := 1
static LVM_SETTILEVIEWINFO := 0x10A2
tileviewinfo := Buffer(40, 0)
pad := 2 * A_ScreenDPI // 96
NumPut(
'uint', 40, ; cbSize
'uint', LVTVIM_LABELMARGIN | LVTVIM_TILESIZE, ; dwMask
'uint', LVTVIF_FIXEDWIDTH, ; dwFlags
'int', w, 'int', 0, ; sizeTile
'int', 0, ; cLines
'int', pad, 'int', pad, 'int', pad, 'int', pad, ; rcLabelMargin
tileviewinfo
)
SendMessage LVM_SETTILEVIEWINFO,, tileviewinfo, this
}

AutoSize(maxItems:=20) {
static LVM_GETITEMRECT := 0x100E, LVIR_BOUNDS := 0
static SM_CXVSCROLL := 2

itemCount := this.GetCount()

; Keep control width and adjust tile width to avoid horizontal scrollbar.
ControlGetPos(,, &w,, this)
if itemCount > maxItems
w -= SysGet(SM_CXVSCROLL)
this._SetTileWidth(w)

; Adjust control height to fit content.
rect := Buffer(16, 0)
NumPut('int', LVIR_BOUNDS, rect)
SendMessage(LVM_GETITEMRECT, Min(itemCount, maxItems) - 1, rect.ptr, this)
iy := NumGet(rect, 4, 'int')
iw := NumGet(rect, 8, 'int')
ih := NumGet(rect, 12, 'int') - iy
; Result needs additional padding. Testing showed the width returned was less
; than what we set with LVM_SETTILEVIEWINFO. The amount of padding needed to
; avoid scrollbars appeared to be exactly the amount to bring it up to the size
; we specified, so perhaps something similar is happening with the height.
h := NumGet(rect, 12, 'int') + 4
ControlMove(,,, h, this)
}
class AutoHotkeyUxGui extends Gui {
__new(title, opt:='') {
super.__new(opt, title, this)
this.SetFont('s9', "Segoe UI")
this.OnEvent('Escape', 'Destroy')
this.OnEvent('Close', 'Destroy')
}

AddListMenu(options:='', columns:=unset) {
IsSet(columns) || columns := []
c := this.AddListView(UxListMenu.DefaultOptions ' ' options, columns)
if !InStr(options, 'Theme')
DllCall("uxtheme\SetWindowTheme", "ptr", c.hwnd, "wstr", "Explorer", "ptr", 0)
static LVTVIM_TILESIZE := 1, LVTVIM_COLUMNS := 2, LVTVIM_LABELMARGIN := 4
static LVTVIF_AUTOSIZE := 0, LVTVIF_EXTENDED := 4, LVTVIF_FIXEDHEIGHT := 2
, LVTVIF_FIXEDSIZE := 3, LVTVIF_FIXEDWIDTH := 1
static LVM_SETTILEVIEWINFO := 0x10A2
tileviewinfo := Buffer(40, 0)
ControlGetPos(,, &w,, c)
pad := 2 * A_ScreenDPI // 96
NumPut(
'uint', 40, ; cbSize
'uint', LVTVIM_LABELMARGIN | LVTVIM_TILESIZE, ; dwMask
'uint', LVTVIF_FIXEDWIDTH, ; dwFlags
'int', w, 'int', 0, ; sizeTile
'int', 0, ; cLines
'int', pad, 'int', pad, 'int', pad, 'int', pad, ; rcLabelMargin
tileviewinfo
)
SendMessage LVM_SETTILEVIEWINFO,, tileviewinfo, c
c.base := UxListMenu.Prototype
return c
}

AddIconButton(options, iconHandle, hiddenText:="") {
static BS_ICON := 0x40
static BS_CENTER := 0x300
static BS_VCENTER := 0xC00
btn := this.AddButton((BS_ICON | BS_CENTER | BS_VCENTER) ' ' options, hiddenText)
static BM_SETIMAGE := 0xF7
SendMessage(BM_SETIMAGE, 1, iconHandle, btn)
return btn
}

FileSelect(p*) {
this.Opt '+OwnDialogs'
try
return FileSelect(p*)
finally
this.Opt '-OwnDialogs'
}

static Show(p*) {
for w in WinGetList('ahk_pid ' ProcessExist())
if (g := GuiFromHwnd(w)) && g.base = this.Prototype
return g.Show()
inst := this(p*)
inst.Show()
}
}

class UxListMenu extends Gui.ListView {
static DefaultOptions := '-Multi Tile'
. ' R1'
. ' -E0x200' ; -WS_EX_CLIENTEDGE (remove border)
. ' LV0x14000'
. Format(' Background{:x}', DllCall("GetSysColor", "int", 15, "int")) ; COLOR_3DFACE

Add(p*) {
i := super.Add(p*)
static LVM_SETTILEINFO := 0x10A4
static LVCFMT_FILL := 0x200000
static LVCFMT_WRAP := 0x400000
tileinfo := Buffer(8 + 3*A_PtrSize, 0)
col := Buffer(4)
colf := Buffer(4)
NumPut("int", 1, col)
NumPut("int", LVCFMT_FILL | LVCFMT_WRAP, colf)
NumPut("int", tileinfo.size, "int", i-1, "uptr", 1, "ptr", col.ptr, "ptr", colf.ptr, tileinfo)
SendMessage(LVM_SETTILEINFO, 0, tileinfo, this)
return i
}

_SetTileWidth(w) {
static LVTVIM_TILESIZE := 1, LVTVIM_COLUMNS := 2, LVTVIM_LABELMARGIN := 4
static LVTVIF_AUTOSIZE := 0, LVTVIF_EXTENDED := 4, LVTVIF_FIXEDHEIGHT := 2
, LVTVIF_FIXEDSIZE := 3, LVTVIF_FIXEDWIDTH := 1
static LVM_SETTILEVIEWINFO := 0x10A2
tileviewinfo := Buffer(40, 0)
pad := 2 * A_ScreenDPI // 96
NumPut(
'uint', 40, ; cbSize
'uint', LVTVIM_LABELMARGIN | LVTVIM_TILESIZE, ; dwMask
'uint', LVTVIF_FIXEDWIDTH, ; dwFlags
'int', w, 'int', 0, ; sizeTile
'int', 0, ; cLines
'int', pad, 'int', pad, 'int', pad, 'int', pad, ; rcLabelMargin
tileviewinfo
)
SendMessage LVM_SETTILEVIEWINFO,, tileviewinfo, this
}

AutoSize(maxItems:=20) {
static LVM_GETITEMRECT := 0x100E, LVIR_BOUNDS := 0
static SM_CXVSCROLL := 2

itemCount := this.GetCount()

; Keep control width and adjust tile width to avoid horizontal scrollbar.
ControlGetPos(,, &w,, this)
if itemCount > maxItems
w -= SysGet(SM_CXVSCROLL)
this._SetTileWidth(w)

; Adjust control height to fit content.
rect := Buffer(16, 0)
NumPut('int', LVIR_BOUNDS, rect)
SendMessage(LVM_GETITEMRECT, Min(itemCount, maxItems) - 1, rect.ptr, this)
iy := NumGet(rect, 4, 'int')
iw := NumGet(rect, 8, 'int')
ih := NumGet(rect, 12, 'int') - iy
; Result needs additional padding. Testing showed the width returned was less
; than what we set with LVM_SETTILEVIEWINFO. The amount of padding needed to
; avoid scrollbars appeared to be exactly the amount to bring it up to the size
; we specified, so perhaps something similar is happening with the height.
h := NumGet(rect, 12, 'int') + 4
ControlMove(,,, h, this)
}
}
2 changes: 1 addition & 1 deletion UX/install-version.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ InstallAutoHotkey(version) {
if req.status != 200
throw Error(req.status ' - ' req.statusText, -1)
currentVersion := req.responseText
if VerCompare(currentVersion, baseVersion) < 0 || VerCompare(currentVersion, Round(baseVersion + 1)) >= 0
if !(currentVersion ~= '^\Q' baseVersion '\E\b')
abort "An error occurred while trying to identify the latest available version. The downloaded version.txt was invalid.", currentVersion
version := currentVersion
}
Expand Down
Loading

0 comments on commit 42060eb

Please sign in to comment.