-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControls.ahk
More file actions
130 lines (98 loc) · 4.09 KB
/
Copy pathControls.ahk
File metadata and controls
130 lines (98 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
AddTab(TabText, ControlHwnd, Pos := GetTabCount(ControlHwnd) + 1) {
static TCIF_TEXT := 0x0001
, TCM_INSERTITEMW := 0x133E
OffTxP := (3 * 4) + (A_PtrSize - 4)
Size := (5 * 4) + (2 * A_PtrSize) + (A_PtrSize - 4)
TCITEM := Buffer(Size, 0)
NumPut("UInt", TCIF_TEXT, TCITEM, 0)
NumPut("Ptr", StrPtr(TabText), TCITEM, OffTxP)
SendMessage(TCM_INSERTITEMW, Pos - 1, TCITEM, , "ahk_id " ControlHwnd)
}
RemoveTab(ControlHwnd, Item) {
static TCM_DELETEITEM := 0x1308
SendMessage(TCM_DELETEITEM, Item -1, 0, , "ahk_id " ControlHwnd)
}
GetTabCount(ControlHwnd) {
static TCM_GETITEMCOUNT := 0x1304
return SendMessage(TCM_GETITEMCOUNT, 0, 0, , "ahk_id " ControlHwnd)
}
GetSelTabIndex(ControlHwnd) {
static TCM_GETCURSEL := 0x130B
return SendMessage(TCM_GETCURSEL, 0, 0, , "ahk_id " ControlHwnd) + 1
}
SetTabSelection(ControlHwnd, Index := 0) {
static TCM_SETCURFOCUS := 0x1330
, TCM_SETCURSEL := 0x130C
SendMessage(TCM_SETCURFOCUS, Index, 0, , ControlHwnd)
SendMessage(TCM_SETCURSEL, Index, 0, , ControlHwnd)
}
GetTabCaption(ControlHwnd, Index) {
static TCM_GETITEM := 0x133C
, TCIF_TEXT := 1
, MAX_TEXT_LENGTH := 260
, MAX_TEXT_SIZE := MAX_TEXT_LENGTH * 2
pid := WinGetPID("ahk_id " ControlHwnd)
static PROCESS_VM_OPERATION := 0x8
, PROCESS_VM_READ := 0x10
, PROCESS_VM_WRITE := 0x20
, READ_WRITE_ACCESS := PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION
, PROCESS_QUERY_INFORMATION := 0x400
, MEM_COMMIT := 0x1000
, MEM_RELEASE := 0x8000
, PAGE_READWRITE := 4
hproc := DllCall("OpenProcess", "uint", READ_WRITE_ACCESS | PROCESS_QUERY_INFORMATION, "int", false, "uint", pid, "ptr")
if !hproc
return ""
if A_Is64bitOS {
try DllCall("IsWow64Process", "ptr", hproc, "int*", &is32bit := true)
} else {
is32bit := true
}
RPtrSize := is32bit ? 4 : 8
TCITEM_SIZE := 16 + RPtrSize * 3
remote_item := DllCall("VirtualAllocEx", "ptr", hproc, "ptr", 0, "uptr", TCITEM_SIZE + MAX_TEXT_SIZE, "uint", MEM_COMMIT, "uint", PAGE_READWRITE, "ptr")
remote_text := remote_item + TCITEM_SIZE
local_item := Buffer(TCITEM_SIZE, 0)
NumPut("uint", TCIF_TEXT, local_item, 0)
NumPut("UPtr", remote_text, local_item, 8 + RPtrSize)
NumPut("int", MAX_TEXT_LENGTH, local_item, 8 + RPtrSize * 2)
VarSetStrCapacity(&local_text, MAX_TEXT_SIZE)
DllCall("WriteProcessMemory", "ptr", hproc, "ptr", remote_item, "ptr", local_item, "uptr", TCITEM_SIZE, "ptr", 0)
SendMessage(TCM_GETITEM, Index, remote_item,, "ahk_id " ControlHwnd)
DllCall("ReadProcessMemory", "ptr", hproc, "ptr", remote_text, "ptr", StrPtr(local_text), "uptr", MAX_TEXT_SIZE, "ptr", 0)
VarSetStrCapacity(&local_text, -1)
DllCall("VirtualFreeEx", "ptr", hproc, "ptr", remote_item, "uptr", 0, "uint", MEM_RELEASE)
DllCall("CloseHandle", "ptr", hproc)
return local_text
}
IsListViewCheckboxChecked(ControlHwnd, RowIndex) {
static LVM_GETITEMSTATE := 0x102C
, LVIS_STATEIMAGEMASK := 0xF000
ItemState := SendMessage(LVM_GETITEMSTATE, RowIndex, LVIS_STATEIMAGEMASK, , "ahk_id " ControlHwnd)
CheckboxState := (ItemState & LVIS_STATEIMAGEMASK) >> 12
return CheckboxState = 2
}
SetTreeViewRowHeight(ControlHwnd, RowHeight) {
static TVM_SETITEMHEIGHT := 0x111B
SendMessage(TVM_SETITEMHEIGHT, RowHeight, 0, , "ahk_id " ControlHwnd)
}
SetReadOnly(ControlHwnd, ReadOnly := true) {
static EM_SETREADONLY := 0xCF
ReadOnlyFlag := ReadOnly ? 1 : 0
SendMessage(EM_SETREADONLY, ReadOnlyFlag, 0, ControlHwnd)
}
GetListViewItemCount(ControlHwnd) {
static LVM_GETITEMCOUNT := 0x1004
return SendMessage(LVM_GETITEMCOUNT, 0, 0, , "ahk_id " ControlHwnd)
}
ControlExists(Control, WinTitle := "", WinText := "", ExcludeTitle := "", ExcludeText := "") {
try {
return ControlGetHwnd(Control, WinTitle, WinText, ExcludeTitle, ExcludeText)
} catch {
return false
}
}
GetCharLimit(ControlHwnd) {
static EM_GETLIMITTEXT := 0xD5
return SendMessage(EM_GETLIMITTEXT, 0, 0, , "ahk_id " ControlHwnd)
}