├── .gitignore ├── .vscode └── settings.json ├── AppInfo.ini ├── README.md ├── array.ahk ├── cmd ├── 7z.dll ├── 7z.exe ├── Everything.ini ├── Everything.lng ├── Everything64.dll ├── ahklib.ahk ├── ahklib安装程序v0.5.exe ├── ahklib安装程序v0.6.exe ├── build.cmd ├── config.txt └── everything.exe ├── en ├── array.d.ahk ├── number.d.ahk ├── object.d.ahk ├── path.d.ahk ├── string.d.ahk ├── time.d.ahk └── utils.d.ahk ├── env.ahk ├── map.ahk ├── number.ahk ├── object.ahk ├── package.json ├── path.ahk ├── stdlib.ahk ├── string.ahk ├── time.ahk ├── utils.ahk └── zh ├── array.d.ahk ├── number.d.ahk ├── object.d.ahk ├── path.d.ahk ├── string.d.ahk ├── time.d.ahk └── utils.d.ahk /.gitignore: -------------------------------------------------------------------------------- 1 | demo/ 2 | cmd/ 3 | .vscode/ 4 | .idea/ -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "liveServer.settings.port": 5526 3 | } -------------------------------------------------------------------------------- /AppInfo.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autumn-one/ahk-standard-lib/8c6ac06cfcbb1515981d23fda7422421c34646aa/AppInfo.ini -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ahk-standard-lib 2 | 3 | autohotkey语言的标准库,目标是提供更好的数据结构操作体验.项目开源,欢迎参与. 4 | 5 | ## 字符串相关方法 6 | 7 | - Split 切割字符串返回一个数组 8 | - Length 返回字符串的长度,这是一个属性 9 | - StartsWith 判断字符串是否以某个子字符串开头 10 | - EndsWith 判断某个字符串是否以某个子字符串结尾 11 | - Includes 判断字符串是否包含某个子字符串 12 | - IndexOf 从字符串中搜索某个子字符串的位置,如果搜索不到返回0 13 | - IndexOfAll 获取所有子字符串的位置,返回一个数组 14 | - lastIndexOf 从右边开始搜索 15 | - Trim 删除字符串两边的空白或自定义字符集 16 | - TrimLeft 删除字符串左边 17 | - TrimRight 删除字符串右边 18 | - CharCodeAt 获取字符串某个字符的code码 19 | - CodeAt CharCodeAt的别名 20 | - Wrap 使用某个字符串包裹另一个字符串 21 | - ToString 打印字符串的表示 22 | - Replace 字符串替换 23 | - ToCode 返回整个字符串的编码表示,这是将所有字符编码拼接之后的数字表示 24 | - ToCodes 返回对应字符串的字符编码数组 25 | - ToLower 返回小写 26 | - ToUpper 返回大写 27 | - ToTitle 返回标题形式 28 | - Format 字符串模板 {1} 29 | - Templ 字符串模板 {变量名} 30 | - Reverse 翻转字符串 31 | - Remove 从字符串中删除子字符串 32 | - RemoveLeft 从左边删除 33 | - RemoveRight 从右边删除 34 | - PadStart 同js 35 | - PadEnd 同js 36 | 37 | ## 字符串相关操作 38 | 39 | ### 取值操作 40 | 41 | `str[index]` 取字符串索引 42 | 43 | `str[start, end]` 取字符串范围 44 | 45 | ### 循环操作 46 | 47 | ``` 48 | for char in str { 49 | ; char 50 | } 51 | ``` 52 | 53 | ## 数组相关方法 54 | 55 | - Join 将一个数组连接成字符串,默认以逗号连接 56 | - Map 遍历数组并返回一个新数组,可用来修改数组的每一项 57 | - Filter 过滤数组,返回一个过滤后的新数组 58 | - ForEach 遍历数组返回数组自身 59 | - Shift 删除数组的第一个元素或从第一个开始的多个元素, 如果只删除一个元素则返回该元素, 删除多个则返回被删除元素组成的数组,该函数改变数组自身 60 | - UnShift 向数组头部添加多个元素,并返回原数组,该方法改变自身 61 | - Concat 将多个数组连接成一个新数组并返回 62 | - Every 传入一个函数, 数组每一项带入执行, 返回值全部为真则返回真, 否则为假 63 | - Some 传入一个函数, 数组的每一项带入执行, 有一个返回值为真则返回真, 否则为假 64 | - Remove 删除数组的某项一次或多次, 并返回原数组, 该函数改变自身 65 | - RemoveAll 传入一个待删除元素组成的数组, 从原数组中删除这些项, 返回原数组 66 | - Find 传入一个函数, 找到结果为真的第一个数组项并返回 67 | - FindAll 传入一个函数, 返回结果为真的所有项组成的新数组 68 | - Includes 查看value是否在数组内部 69 | - IndexOf 查看value在数组中的位置 70 | - IndexOfAll 传入一个值或函数返回匹配到的项对应索引组成的新数组 71 | - Flat 数组扁平化 72 | - Unique 数组去重 73 | - Sort 数组排序 74 | - Intersect 取多个数组的交集 75 | - Union 数组并集 76 | - Xor 排除所有数组共有元素, 剩余元素组成新的数组 77 | 78 | ## 对象相关方法 79 | 80 | * Keys 获取对象的key组成的数组 81 | * Values 获取对象的Value组成的数组 82 | * Items 获取对象的key value对组成的数组 `[ { key: "a", value: 1 }, { key: "b", value: 2 }, { key: "c", value: 3 } ]` 83 | * ToString 对象字符串表示形式 84 | * Length 对象长度,这是一个属性 85 | * Has 查看是否有某个属性 86 | * Contains 查看是否有某个属性 87 | * Merge 合并多个对象 88 | -------------------------------------------------------------------------------- /array.ahk: -------------------------------------------------------------------------------- 1 | ;@include en\array.d.ahk 2 | ;@include zh\array.d.ahk 3 | ;todo 还差mapx 和 filterx 没实现 4 | ([].Base).DefineProp("ToString", { Call: __ArrayToString}) 5 | 6 | __OriginArrayItem := ObjGetBase([]).GetOwnPropDesc("__Item") 7 | ([]).Base.DefineProp("RawGet", { Call: (arr, index) => __OriginArrayItem.get.bind(arr)(index) }) 8 | ([]).Base.DefineProp("RawSet", { Call: (arr, value, index) => ( __OriginArrayItem.set.bind(arr)(value, index)) }) 9 | if !IsSet(UIA){ 10 | ([]).Base.DefineProp("__Item", { get: __ArrayItemGet, set: __ArrayItemSet}) 11 | } 12 | 13 | ([].Base).DefineProp("Join", { Call: __ArrayJoin}) 14 | ([].Base).DefineProp("Map", { Call: __ArrayMap}) 15 | ([].Base).DefineProp("ForEach", { Call: __ArrayForEach}) 16 | ([].Base).DefineProp("Filter", { Call: __ArrayFilter}) 17 | ([].Base).DefineProp("Shift", { Call: __ArrayShift}) 18 | ([].Base).DefineProp("UnShift", { Call: __ArrayUnShift}) 19 | ([].Base).DefineProp("Concat", { Call: __ArrayConcat}) 20 | ([].Base).DefineProp("Every", { Call: __ArrayEvery}) 21 | ([].Base).DefineProp("Some", { Call: __ArraySome}) 22 | ([].Base).DefineProp("Remove", { Call: __ArrayRemove}) 23 | ([].Base).DefineProp("RemoveAll", { Call: __ArrayRemoveAll}) 24 | ([].Base).DefineProp("Find", { Call: __ArrayFind}) 25 | ([].Base).DefineProp("FindAll", { Call: __ArrayFindAll}) 26 | ([].Base).DefineProp("Includes", { Call: __ArrayIncludes}) 27 | ([].Base).DefineProp("IncludeSome", { Call: __ArrayIncludeSome}) 28 | ([].Base).DefineProp("IncludeEvery", { Call: __ArrayIncludeEvery}) 29 | ([].Base).DefineProp("IndexOf", { Call: __ArrayIndexOf}) 30 | ([].Base).DefineProp("IndexOfAll", { Call: __ArrayIndexOfAll}) 31 | ([].Base).DefineProp("Flat", { Call: __ArrayFlat}) 32 | ([].Base).DefineProp("Unique", { Call: __ArrayUnique}) 33 | ([].Base).DefineProp("Sort", { Call: __ArraySort}) 34 | ([].Base).DefineProp("Reverse", { Call: __ArrayReverse}) 35 | ([].Base).DefineProp("Intersect", { Call: __ArrayIntersect}) 36 | ([].Base).DefineProp("Union", { Call: __ArrayUnion}) 37 | ([].Base).DefineProp("Xor", { Call: __ArrayXor}) 38 | ([].Base).DefineProp("Sum", { Call: __ArraySum}) 39 | ([].Base).DefineProp("Reduce", { Call: __ArrayReduce}) 40 | ([].Base).DefineProp("ReduceRight", { Call: __ArrayReduceRight}) 41 | 42 | __ArraySum(arr) { 43 | return arr.Reduce((m, i) => i + m) 44 | } 45 | 46 | __ArrayReduce(arr, ReduceFunc, initial?){ 47 | if !IsSet(initial) { 48 | reduceArr := arr[2, -1] 49 | memo := arr[1] 50 | }else{ 51 | reduceArr := arr[] 52 | memo := initial 53 | } 54 | 55 | for item in reduceArr { 56 | memo := ReduceFunc(memo, item) 57 | } 58 | return memo 59 | } 60 | 61 | __ArrayReduceRight(arr, ReduceFunc, initial?){ 62 | if !IsSet(initial) { 63 | reduceArr := arr[1, -2] 64 | memo := arr[-1] 65 | }else{ 66 | reduceArr := arr[] 67 | memo := initial 68 | } 69 | 70 | loop reduceArr.Length { 71 | memo := ReduceFunc(memo, reduceArr[-A_Index]) 72 | } 73 | return memo 74 | } 75 | 76 | 77 | __ArrayJoin(arr, separator := ","){ 78 | output := "" 79 | for item in arr { 80 | output := output String(item) . separator 81 | } 82 | if separator.Length >= 1 && output[-1, 0 - separator.length] == separator{ 83 | output := output[1, -1 - separator.length] 84 | } 85 | return output 86 | } 87 | 88 | __ArrayUnion(arr, params*) { 89 | newArr := [arr*] 90 | params.forEach(item => item.forEach(i => !newArr.Includes(i) && newArr.Push(i))) 91 | return newArr 92 | } 93 | 94 | __ArrayXor(arr, params*) { 95 | newArr := [] 96 | iArr := arr.Intersect(params*) 97 | arr.Union(params*).forEach(i => !iArr.Includes(i) && newArr.Push(i)) 98 | return newArr 99 | } 100 | 101 | __ArrayIntersect(arr, params*){ 102 | newArr := [] 103 | for item in arr { 104 | value := item 105 | if params.Every((i) => i.Includes(value), true) { 106 | newArr.Push(value) 107 | } 108 | } 109 | return newArr 110 | } 111 | 112 | 113 | __ArrayForEach(arr, eachfn){ 114 | for item in arr { 115 | eachfn(item) 116 | } 117 | } 118 | 119 | __ArrayMap(arr, mapfn){ 120 | newArr := [] 121 | for item in arr { 122 | newArr.Push(mapfn(item)) 123 | } 124 | return newArr 125 | } 126 | 127 | 128 | __ArrayFilter(arr, filterfn){ 129 | newArr := [] 130 | for item in Arr { 131 | if filterfn(item) { 132 | newArr.Push(item) 133 | } 134 | } 135 | return newArr 136 | } 137 | 138 | 139 | __ArrayShift(arr, count := 1){ ; 默认删除头部一个元素 140 | ret := arr[1, count] 141 | arr[1, count] := [] 142 | return ret.Length == 1 ? ret[1] : ret 143 | } 144 | 145 | __ArrayUnShift(arr, params*){ ; 向头部添加若干个元素 146 | arr.InsertAt(1, params*) 147 | return arr 148 | } 149 | 150 | __ArrayConcat(arr, params*){ 151 | for item in params { 152 | arr.Push(item*) 153 | } 154 | return arr 155 | } 156 | 157 | __ArrayEvery(arr, everyfn, short := false){ ; 默认不短路 158 | flag := true 159 | for item in arr { 160 | if !everyfn(item){ 161 | flag := false 162 | if short { 163 | break 164 | } 165 | } 166 | } 167 | return flag 168 | } 169 | 170 | __ArraySome(arr, somefn, short := false){ ; 默认不短路 171 | flag := false 172 | for item in arr { 173 | if somefn(item) { 174 | flag := true 175 | if short { 176 | break 177 | } 178 | } 179 | } 180 | return flag 181 | } 182 | 183 | __ArrayRemove(arr, value, count := 1){ ; 默认删除一个 184 | i := 0 185 | loop arr.length { 186 | if A_Index > arr.length { 187 | break 188 | } 189 | if arr[A_Index] == value { 190 | arr.RemoveAt(A_Index) 191 | i++ 192 | A_Index-- 193 | if count == 0 { 194 | continue 195 | } else if i == count { 196 | break 197 | } 198 | } 199 | } 200 | return arr 201 | } 202 | 203 | __ArrayRemoveAll(arr, delArr, count := 1){ 204 | delArr.forEach(i => arr.remove(i, count)) 205 | return arr 206 | } 207 | 208 | __ArrayFind(arr, findfn, dv := ""){ 209 | for item in arr { 210 | if findfn(item) { 211 | return item 212 | } 213 | } 214 | return dv 215 | } 216 | 217 | __ArrayFindAll(arr, findallfn){ 218 | newArr := [] 219 | for item in arr { 220 | if findallfn(item) { 221 | newArr.Push(item) 222 | } 223 | } 224 | return newArr 225 | } 226 | 227 | __ArrayIncludes(arr, value){ 228 | for item in arr { 229 | if item == value { 230 | return true 231 | } 232 | } 233 | return false 234 | } 235 | 236 | __ArrayIncludeSome(arr, params*){ 237 | return params.Some(item => arr.Includes(item), true) 238 | } 239 | 240 | __ArrayIncludeEvery(arr, params*){ 241 | return params.Every(item => arr.Includes(item), true) 242 | } 243 | 244 | __ArrayIndexOf(arr, value){ 245 | for index, item in arr { 246 | if item == value { 247 | return index 248 | } 249 | } 250 | return 0 251 | } 252 | 253 | __ArrayIndexOfAll(arr, fn){ 254 | newArr := [] 255 | if type(fn) != "Func"{ 256 | checkfn := (item) => item == fn 257 | }else{ 258 | checkfn := fn 259 | } 260 | for index, item in arr { 261 | if checkfn(item) { 262 | newArr.Push(index) 263 | } 264 | } 265 | return newArr 266 | } 267 | 268 | __ArrayFlat(arr, depth := 0, count := 0){ 269 | newArr := [] 270 | for item in arr { 271 | if type(item) == "Array" && ( depth == 0 || depth != count){ 272 | newArr.Push(__ArrayFlat(item, depth, count + 1)*) 273 | }else{ 274 | newArr.Push(item) 275 | } 276 | } 277 | return newArr 278 | } 279 | 280 | __ArraySort(arr, sortfn := (a,b) => a - b){ 281 | if arr.length < 1 { 282 | return [] 283 | } 284 | left := [] 285 | right := [] 286 | middle := [] 287 | base := arr[1] 288 | for item in arr { 289 | cond := sortfn(item, base) 290 | if cond < 0 { 291 | left.push(item) 292 | }else if cond > 0{ 293 | right.push(item) 294 | }else{ 295 | middle.push(item) 296 | } 297 | } 298 | 299 | return [].Concat(__ArraySort(left, sortfn), middle, __ArraySort(right, sortfn)) 300 | 301 | } 302 | 303 | __ArrayReverse(arr){ 304 | newArr := [] 305 | loop arr.Length { 306 | newArr.Push(arr[-A_Index]) 307 | } 308 | return newArr 309 | } 310 | 311 | __ArrayUnique(arr){ 312 | newArr := [] 313 | for item in arr { 314 | if !newArr.Includes(item){ 315 | newArr.Push(item) 316 | } 317 | } 318 | return newArr 319 | } 320 | 321 | __ArrayItemGet(arr, params*){ 322 | if params.Length == 0{ 323 | return arr.Clone() 324 | }else if params.Length == 1 { 325 | return arr.RawGet(params.RawGet(1)) 326 | }else if params.Length == 2{ 327 | outArr := [] 328 | for index, item in params { 329 | if item < 0 { 330 | params.RawSet(item + arr.Length + 1, index) 331 | } 332 | } 333 | 334 | index := params.RawGet(1) 335 | end := params.RawGet(2) 336 | loop{ 337 | outArr.Push(arr.RawGet(index)) 338 | index++ 339 | } until index > end 340 | return outArr 341 | 342 | } 343 | } 344 | 345 | __ArrayItemSet(arr, value, params*){ 346 | if params.length == 1{ 347 | arr.RawSet(value, params.RawGet(1)) 348 | }else if params.length == 2 { 349 | for index, item in params { 350 | if item < 0 { 351 | params.RawSet(item + arr.length + 1, index) 352 | } 353 | } 354 | arr.RemoveAt(params.RawGet(1), params.RawGet(2) - params.RawGet(1) + 1) 355 | if type(value) == "Array"{ 356 | if value.Length != 0 { 357 | arr.InsertAt(params.RawGet(1), value*) 358 | } 359 | }else{ 360 | arr.insertAt(params.RawGet(1), value) 361 | } 362 | } 363 | } 364 | 365 | __ArrayToString(arr){ 366 | output := "[" 367 | for item in arr { 368 | output := output.Concat( 369 | " ", 370 | type(item) == "String" ? item.ToString() : String(item), 371 | "," 372 | ) 373 | } 374 | if output[-1] == "," { 375 | output := output[1, -2] 376 | } 377 | output := output . " ]" 378 | return output 379 | } 380 | 381 | 382 | -------------------------------------------------------------------------------- /cmd/7z.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autumn-one/ahk-standard-lib/8c6ac06cfcbb1515981d23fda7422421c34646aa/cmd/7z.dll -------------------------------------------------------------------------------- /cmd/7z.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autumn-one/ahk-standard-lib/8c6ac06cfcbb1515981d23fda7422421c34646aa/cmd/7z.exe -------------------------------------------------------------------------------- /cmd/Everything.ini: -------------------------------------------------------------------------------- 1 | ; Please make sure Everything is not running before modifying this file. 2 | [Everything] 3 | run_as_admin=1 4 | allow_http_server=1 5 | allow_etp_server=1 6 | window_x=-3154 7 | window_y=1341 8 | window_wide=1582 9 | window_high=1320 10 | maximized=0 11 | minimized=0 12 | fullscreen=0 13 | ontop=0 14 | bring_into_view=1 15 | alpha=255 16 | match_whole_word=0 17 | match_path=0 18 | match_case=0 19 | match_diacritics=0 20 | match_regex=0 21 | view=0 22 | thumbnail_size=64 23 | thumbnail_fill=0 24 | min_thumbnail_size=32 25 | max_thumbnail_size=256 26 | medium_thumbnail_size=64 27 | large_thumbnail_size=128 28 | extra_large_thumbnail_size=256 29 | thumbnail_load_size=0 30 | thumbnail_overlay_icon=1 31 | shell_max_path=0 32 | allow_multiple_windows=0 33 | allow_multiple_instances=0 34 | run_in_background=1 35 | show_in_taskbar=1 36 | show_tray_icon=1 37 | minimize_to_tray=0 38 | toggle_window_from_tray_icon=0 39 | alternate_row_color=0 40 | show_mouseover=0 41 | check_for_updates_on_startup=0 42 | beta_updates=0 43 | show_highlighted_search_terms=1 44 | text_size=0 45 | hide_empty_search_results=0 46 | clear_selection_on_search=1 47 | show_focus_on_search=0 48 | new_window_key=0 49 | show_window_key=0 50 | toggle_window_key=0 51 | language=0 52 | show_selected_item_in_statusbar=1 53 | statusbar_selected_item_format= 54 | show_size_in_statusbar=0 55 | statusbar_size_format=0 56 | open_folder_command2= 57 | open_file_command2= 58 | open_path_command2= 59 | explore_command2= 60 | explore_path_command2= 61 | window_title_format= 62 | taskbar_notification_title_format= 63 | instance_name= 64 | translucent_selection_rectangle_alpha=70 65 | min_zoom=-6 66 | max_zoom=27 67 | context_menu_type=0 68 | context_menu_shell_extensions=1 69 | auto_include_fixed_volumes=1 70 | auto_include_removable_volumes=0 71 | auto_remove_offline_ntfs_volumes=1 72 | auto_remove_moved_ntfs_volumes=1 73 | auto_include_fixed_refs_volumes=1 74 | auto_include_removable_refs_volumes=0 75 | auto_remove_offline_refs_volumes=1 76 | auto_remove_moved_refs_volumes=1 77 | find_mount_points_on_removable_volumes=0 78 | scan_volume_drive_letters=1 79 | last_export_type=0 80 | max_threads=0 81 | reuse_threads=1 82 | find_subfolders_and_files_max_threads=0 83 | single_parent_context_menu=0 84 | auto_size_1=512 85 | auto_size_2=640 86 | auto_size_3=768 87 | auto_size_aspect_ratio_x=9 88 | auto_size_aspect_ratio_y=7 89 | auto_size_width_only=0 90 | auto_size_path_x=1 91 | auto_size_path_y=2 92 | sticky_vscroll_bottom=1 93 | last_options_page=4 94 | draw_focus_rect=1 95 | date_format= 96 | time_format= 97 | listview_item_high=0 98 | single_click_open=0 99 | underline_icon_titles=0 100 | icons_only=0 101 | icon_shell_extensions=1 102 | auto_scroll_repeat_delay=250 103 | auto_scroll_repeat_rate=50 104 | open_many_files_warning_threshold=16 105 | set_foreground_window_attach_thread_input=0 106 | debug=0 107 | debug_log=0 108 | verbose=0 109 | lvm=1 110 | ipc=1 111 | home_match_case=0 112 | home_match_whole_word=0 113 | home_match_path=0 114 | home_match_diacritics=0 115 | home_regex=0 116 | home_search=1 117 | home_filter=0 118 | home_sort=0 119 | home_view=0 120 | home_index=1 121 | allow_multiple_windows_from_tray=0 122 | single_click_tray=0 123 | close_on_execute=0 124 | double_click_path=0 125 | update_display_after_scroll=0 126 | update_display_after_mask=1 127 | auto_scroll_view=0 128 | double_quote_copy_as_path=0 129 | snap=0 130 | snaplen=10 131 | rename_select_filepart_only=1 132 | rename_move_caret_to_selection_end=0 133 | rename_nav=0 134 | search_edit_move_caret_to_selection_end=0 135 | search_edit_drag_accept_files=0 136 | select_search_on_mouse_click=0 137 | focus_search_on_activate=0 138 | reset_vscroll_on_search=1 139 | wrap_focus=0 140 | load_icon_priority=0 141 | load_thumbnail_priority=0 142 | load_fileinfo_priority=0 143 | always_request_all_fileinfo=0 144 | header_high=0 145 | hide_on_close=0 146 | max_hidden_windows=0 147 | winmm=0 148 | menu_escape_amp=1 149 | menu_folders=0 150 | menu_folder_separator= 151 | menu_items_per_column=0 152 | new_inherit=1 153 | full_row_select=0 154 | tray_show_command_line= 155 | dpi=96 156 | ctrl_mouse_wheel_action=1 157 | lvm_scroll=1 158 | allow_open=1 159 | allow_context_menu=1 160 | allow_delete=1 161 | allow_rename=1 162 | allow_cut=1 163 | allow_copy=1 164 | allow_paste=1 165 | allow_drag_drop=1 166 | allow_window_message_filter_dragdrop=0 167 | auto_column_widths=0 168 | hotkey_explorer_path_search=0 169 | hotkey_user_notification_state=0 170 | get_key_name_text=1 171 | paste_new_line_op=0 172 | esc_cancel_action=1 173 | fast_ascii_search=1 174 | match_path_when_search_contains_path_separator=1 175 | allow_literal_operators=0 176 | allow_round_bracket_parenthesis=0 177 | expand_environment_variables=0 178 | search_as_you_type=1 179 | always_update_query_on_search_parameter_change=0 180 | convert_forward_slash_to_backslash=0 181 | match_whole_filename_when_using_wildcards=1 182 | operator_precedence=0 183 | replace_exact_trailing_star_dot_star_with_star=1 184 | allow_exclamation_point_not=1 185 | search_command_prefix= 186 | auto_complete_search_command=1 187 | double_buffer=1 188 | search= 189 | show_number_of_results_with_selection=0 190 | date_descending_first=1 191 | size_descending_first=1 192 | size_format=2 193 | alpha_select=0 194 | tooltips=1 195 | listview_tooltips=1 196 | show_detailed_listview_tooltips=1 197 | rtl_listview_edit=0 198 | force_path_ltr_order=1 199 | force_path_left_align=1 200 | date_time_order=0 201 | date_time_align=1 202 | size_align=3 203 | invert_layout=0 204 | update_layout_on_input_language_change=0 205 | control_shift_action=3 206 | change_search_rtl_reading_action=3 207 | invert_layout_action=3 208 | bookmark_remember_case=1 209 | bookmark_remember_wholeword=1 210 | bookmark_remember_path=1 211 | bookmark_remember_diacritic=1 212 | bookmark_remember_regex=1 213 | bookmark_remember_sort=1 214 | bookmark_remember_view=1 215 | bookmark_remember_filter=1 216 | bookmark_remember_index=1 217 | bookmark_remember_search=1 218 | bookmark_organize_x=0 219 | bookmark_organize_y=0 220 | bookmark_organize_wide=0 221 | bookmark_organize_high=0 222 | exclude_list_enabled=1 223 | exclude_hidden_files_and_folders=0 224 | exclude_system_files_and_folders=0 225 | include_only_files= 226 | exclude_files= 227 | db_location= 228 | db_multi_user_filename=0 229 | db_compress=0 230 | index_size=1 231 | fast_size_sort=1 232 | index_date_created=0 233 | fast_date_created_sort=0 234 | index_date_modified=1 235 | fast_date_modified_sort=1 236 | index_date_accessed=0 237 | fast_date_accessed_sort=0 238 | index_attributes=0 239 | fast_attributes_sort=0 240 | index_folder_size=0 241 | fast_path_sort=1 242 | fast_extension_sort=0 243 | extended_information_cache_monitor=1 244 | db_update_thread_priority=-15 245 | index_recent_changes=1 246 | refs_file_id_extd_directory_info_buffer_size=0 247 | folder_update_thread_mode_background=0 248 | folder_update_rescan_asap=1 249 | monitor_thread_mode_background=1 250 | monitor_retry_delay=30000 251 | monitor_update_delay=1000 252 | monitor_pause=0 253 | usn_record_filter=0xffffffff 254 | cancel_delay=0x000003e8 255 | allow_ntfs_open_file_by_id=1 256 | always_update_folder_recent_change=0 257 | editor_x=0 258 | editor_y=0 259 | editor_wide=0 260 | editor_high=0 261 | editor_maximized=0 262 | file_list_relative_paths=0 263 | rename_x=0 264 | rename_y=0 265 | rename_wide=0 266 | rename_high=0 267 | rename_match_case=0 268 | rename_regex=0 269 | advanced_copy_to_x=0 270 | advanced_copy_to_y=0 271 | advanced_copy_to_wide=0 272 | advanced_copy_to_high=0 273 | advanced_copy_to_match_case=0 274 | advanced_copy_to_regex=0 275 | advanced_move_to_x=0 276 | advanced_move_to_y=0 277 | advanced_move_to_wide=0 278 | advanced_move_to_high=0 279 | advanced_move_to_match_case=0 280 | advanced_move_to_regex=0 281 | advanced_search_x=0 282 | advanced_search_y=0 283 | advanced_search_wide=0 284 | advanced_search_high=0 285 | advanced_search_page_y_offset=0 286 | advanced_search_focus_id=0 287 | advanced_search_warnings=1 288 | max_recv_size=8388608 289 | display_full_path_name=0 290 | size_tiny=10240 291 | size_small=102400 292 | size_medium=1048576 293 | size_large=16777216 294 | size_huge=134217728 295 | themed_toolbar=1 296 | show_copy_name=2 297 | show_copy_path=2 298 | show_copy_full_name=2 299 | show_open_path=2 300 | show_explore=2 301 | show_explore_path=2 302 | copy_path_folder_append_backslash=0 303 | custom_verb01= 304 | custom_verb02= 305 | custom_verb03= 306 | custom_verb04= 307 | custom_verb05= 308 | custom_verb06= 309 | custom_verb07= 310 | custom_verb08= 311 | custom_verb09= 312 | custom_verb10= 313 | custom_verb11= 314 | custom_verb12= 315 | filters_visible=0 316 | filters_wide=128 317 | filters_right_align=1 318 | filters_tab_stop=0 319 | filter= 320 | filter_everything_name= 321 | filter_organize_x=0 322 | filter_organize_y=0 323 | filter_organize_wide=0 324 | filter_organize_high=0 325 | preview_visible=0 326 | preview_x=640 327 | preview_tab_stop=0 328 | preview_mag_filter=0 329 | preview_min_filter=0 330 | preview_fill=0 331 | show_preview_handlers_in_preview_pane=0 332 | preview_load_size=0 333 | preview_context=0x00000000 334 | preview_release_handler_on_clear=0 335 | sort=Run Count 336 | sort_ascending=0 337 | always_keep_sort=0 338 | index=0 339 | index_file_list= 340 | index_etp_server= 341 | index_link_type=1 342 | status_bar_visible=1 343 | select_search_on_focus_mode=1 344 | select_search_on_set_mode=2 345 | search_history_enabled=0 346 | run_history_enabled=1 347 | search_history_days_to_keep=90 348 | run_history_days_to_keep=90 349 | search_history_keep_forever=1 350 | run_history_keep_forever=1 351 | search_history_always_suggest=0 352 | search_history_always_suggest_extend_toolbar=0 353 | search_history_visible_count_max=12 354 | search_history_always_suggest_visible_count_max=1 355 | search_history_show_all_max=256 356 | search_history_suggestion_max=256 357 | search_history_show_all_sort=2 358 | search_history_suggestion_sort=1 359 | search_history_show_above=0 360 | search_history_sort=2 361 | search_history_sort_ascending=0 362 | search_history_x=0 363 | search_history_y=0 364 | search_history_wide=0 365 | search_history_high=0 366 | search_history_column_search_wide=208 367 | search_history_column_search_order=0 368 | search_history_column_count_wide=128 369 | search_history_column_count_order=1 370 | search_history_column_date_wide=128 371 | search_history_column_date_order=2 372 | etp_server_enabled=0 373 | etp_server_bindings= 374 | etp_server_port=21 375 | etp_server_username= 376 | etp_server_password= 377 | etp_server_welcome_message= 378 | etp_server_log_file_name= 379 | etp_server_logging_enabled=0 380 | etp_server_log_max_size=4194304 381 | etp_server_log_delta_size=524288 382 | etp_server_allow_file_download=1 383 | ftp_allow_port=1 384 | ftp_check_data_connection_ip=1 385 | http_server_enabled=0 386 | http_server_bindings= 387 | http_title_format= 388 | http_server_port=80 389 | http_server_username= 390 | http_server_password= 391 | http_server_home= 392 | http_server_default_page= 393 | http_server_log_file_name= 394 | http_server_logging_enabled=0 395 | http_server_log_max_size=4194304 396 | http_server_log_delta_size=524288 397 | http_server_allow_file_download=1 398 | http_server_items_per_page=32 399 | http_server_show_drive_labels=0 400 | http_server_strings= 401 | http_server_header= 402 | service_pipe_name= 403 | name_column_pos=0 404 | name_column_width=512 405 | path_column_visible=1 406 | path_column_pos=1 407 | path_column_width=512 408 | size_column_visible=1 409 | size_column_pos=2 410 | size_column_width=192 411 | extension_column_visible=0 412 | extension_column_pos=3 413 | extension_column_width=192 414 | type_column_visible=0 415 | type_column_pos=4 416 | type_column_width=192 417 | last_write_time_column_visible=1 418 | last_write_time_column_pos=3 419 | last_write_time_column_width=306 420 | creation_time_column_visible=0 421 | creation_time_column_pos=6 422 | creation_time_column_width=306 423 | date_accessed_column_visible=0 424 | date_accessed_column_pos=7 425 | date_accessed_column_width=306 426 | attribute_column_visible=0 427 | attribute_column_pos=8 428 | attribute_column_width=140 429 | date_recently_changed_column_visible=0 430 | date_recently_changed_column_pos=9 431 | date_recently_changed_column_width=306 432 | run_count_column_visible=0 433 | run_count_column_pos=10 434 | run_count_column_width=192 435 | date_run_column_visible=0 436 | date_run_column_pos=11 437 | date_run_column_width=306 438 | file_list_filename_column_visible=0 439 | file_list_filename_column_pos=12 440 | file_list_filename_column_width=192 441 | translucent_selection_rectangle_background_color= 442 | translucent_selection_rectangle_border_color= 443 | thumbnail_mouseover_border_color= 444 | preview_background_color= 445 | ntfs_volume_guids="\\\\?\\Volume{4c2b8ac2-0020-4977-a0e1-a4c9f86112c6}","\\\\?\\Volume{cddf085a-ae10-4815-845c-f67f5bb4dfcf}","\\\\?\\Volume{db94516b-57a1-47b0-af00-041169ea8abb}","\\\\?\\Volume{9151d978-4f75-4c10-8516-c13cc730314e}" 446 | ntfs_volume_paths="C:","D:","E:","F:" 447 | ntfs_volume_roots="","","","" 448 | ntfs_volume_includes=1,1,1,1 449 | ntfs_volume_load_recent_changes=0,0,0,0 450 | ntfs_volume_include_onlys="","","","" 451 | ntfs_volume_monitors=1,1,1,1 452 | refs_volume_guids= 453 | refs_volume_paths= 454 | refs_volume_roots= 455 | refs_volume_includes= 456 | refs_volume_load_recent_changes= 457 | refs_volume_include_onlys= 458 | refs_volume_monitors= 459 | filelists= 460 | filelist_monitor_changes= 461 | folders= 462 | folder_monitor_changes= 463 | folder_buffer_size_list= 464 | folder_rescan_if_full_list= 465 | folder_update_types= 466 | folder_update_days= 467 | folder_update_ats= 468 | folder_update_intervals= 469 | folder_update_interval_types= 470 | exclude_folders= 471 | connect_history_hosts= 472 | connect_history_ports= 473 | connect_history_usernames= 474 | connect_history_link_types= 475 | etp_client_rewrite_patterns= 476 | etp_client_rewrite_substitutions= 477 | file_new_search_window_keys=334 478 | file_open_file_list_keys=335 479 | file_close_file_list_keys= 480 | file_close_keys=343,27 481 | file_export_keys=339 482 | file_copy_full_name_to_clipboard_keys=9539 483 | file_copy_path_to_clipboard_keys= 484 | file_set_run_count_keys= 485 | file_create_shortcut_keys= 486 | file_delete_keys=8238 487 | file_delete_permanently_keys=9262 488 | file_edit_keys= 489 | file_open_keys=8205 490 | file_open_selection_and_close_everything_keys= 491 | file_explore_path_keys= 492 | file_open_new_keys= 493 | file_open_path_keys=8461 494 | file_open_with_keys= 495 | file_open_with_default_verb_keys= 496 | file_play_keys= 497 | file_preview_keys= 498 | file_print_keys= 499 | file_print_to_keys= 500 | file_properties_keys=8717 501 | file_read_extended_information_keys=8517 502 | file_rename_keys=8305 503 | file_run_as_keys= 504 | file_exit_keys=337 505 | file_copy_name_to_clipboard_keys= 506 | file_open_selection_and_do_not_close_everything_keys= 507 | file_open_most_run_keys= 508 | file_open_last_run_keys= 509 | file_custom_verb_1_keys= 510 | file_custom_verb_2_keys= 511 | file_custom_verb_3_keys= 512 | file_custom_verb_4_keys= 513 | file_custom_verb_5_keys= 514 | file_custom_verb_6_keys= 515 | file_custom_verb_7_keys= 516 | file_custom_verb_8_keys= 517 | file_custom_verb_9_keys= 518 | file_custom_verb_10_keys= 519 | file_custom_verb_11_keys= 520 | file_custom_verb_12_keys= 521 | indexes_folders_rescan_all_now_keys= 522 | indexes_force_rebuild_keys= 523 | edit_cut_keys=8536 524 | edit_copy_keys=8515,8493 525 | edit_paste_keys=8534,9261 526 | edit_select_all_keys=8513 527 | edit_invert_selection_keys= 528 | edit_copy_to_folder_keys= 529 | edit_move_to_folder_keys= 530 | edit_advanced_advanced_copy_to_folder_keys= 531 | edit_advanced_advanced_move_to_folder_keys= 532 | view_filters_keys= 533 | view_preview_keys=592 534 | view_status_bar_keys= 535 | view_details_keys=1334 536 | view_medium_thumbnails_keys=1331 537 | view_large_thumbnails_keys=1330 538 | view_extra_large_thumbnails_keys=1329 539 | view_increase_thumbnail_size_keys=1467 540 | view_decrease_thumbnail_size_keys=1469 541 | view_window_size_small_keys=561 542 | view_window_size_medium_keys=562 543 | view_window_size_large_keys=563 544 | view_window_size_auto_fit_keys=564 545 | view_zoom_zoom_in_keys=443 546 | view_zoom_zoom_out_keys=445 547 | view_zoom_reset_keys=304,352 548 | view_go_to_back_keys=549,166 549 | view_go_to_forward_keys=551,167 550 | view_go_to_home_keys=548 551 | view_go_to_show_all_history_keys=1352,328 552 | view_sort_by_name_keys=305 553 | view_sort_by_path_keys=306 554 | view_sort_by_size_keys=307 555 | view_sort_by_extension_keys=308 556 | view_sort_by_type_keys=309 557 | view_sort_by_date_modified_keys=310 558 | view_sort_by_date_created_keys=311 559 | view_sort_by_attributes_keys=312 560 | view_sort_by_file_list_filename_keys= 561 | view_sort_by_run_count_keys= 562 | view_sort_by_date_run_keys= 563 | view_sort_by_date_recently_changed_keys=313 564 | view_sort_by_date_accessed_keys= 565 | view_sort_by_ascending_keys= 566 | view_sort_by_descending_keys= 567 | view_refresh_keys=116 568 | view_fullscreen_keys=122 569 | view_toggle_ltrrtl_direction_keys= 570 | view_on_top_never_keys= 571 | view_on_top_always_keys= 572 | view_on_top_while_searching_keys= 573 | search_match_case_keys=329 574 | search_match_whole_word_keys=322 575 | search_match_path_keys=341 576 | search_match_diacritics_keys=333 577 | search_enable_regex_keys=338 578 | search_advanced_search_keys= 579 | search_add_to_filters_keys= 580 | search_organize_filters_keys=1350 581 | bookmarks_add_to_bookmarks_keys=324 582 | bookmarks_organize_bookmarks_keys=1346 583 | tools_options_keys=336 584 | tools_console_keys=448 585 | tools_file_list_editor_keys= 586 | tools_connect_to_etp_server_keys= 587 | tools_disconnect_from_etp_server_keys= 588 | help_everything_help_keys=112 589 | help_search_syntax_keys= 590 | help_regex_syntax_keys= 591 | help_command_line_options_keys= 592 | help_everything_website_keys= 593 | help_check_for_updates_keys= 594 | help_about_everything_keys=368 595 | help_donate_keys= 596 | search_edit_focus_search_edit_keys=326,114,580 597 | search_edit_delete_previous_word_keys=4360 598 | search_edit_auto_complete_search_keys=4384 599 | search_edit_show_search_history_keys= 600 | search_edit_show_all_search_history_keys=4646,4648 601 | result_list_item_up_keys=8230,4134 602 | result_list_item_down_keys=8232,4136 603 | result_list_page_up_keys=8225,4129 604 | result_list_page_down_keys=8226,4130 605 | result_list_start_of_list_keys=8228 606 | result_list_end_of_list_keys=8227 607 | result_list_item_up_extend_keys=9254,5158 608 | result_list_item_down_extend_keys=9256,5160 609 | result_list_page_up_extend_keys=9249,5153 610 | result_list_page_down_extend_keys=9250,5154 611 | result_list_start_of_list_extend_keys=9252 612 | result_list_end_of_list_extend_keys=9251 613 | result_list_focus_up_keys=8486,4390 614 | result_list_focus_down_keys=8488,4392 615 | result_list_focus_page_up_keys=8481,4385 616 | result_list_focus_page_down_keys=8482,4386 617 | result_list_focus_start_of_list_keys=8484 618 | result_list_focus_end_of_list_keys=8483 619 | result_list_focus_up_extend_keys=9510,5414 620 | result_list_focus_down_extend_keys=9512,5416 621 | result_list_focus_page_up_extend_keys=9505,5409 622 | result_list_focus_page_down_extend_keys=9506,5410 623 | result_list_focus_start_of_list_extend_keys=9508 624 | result_list_focus_end_of_list_extend_keys=9507 625 | result_list_focus_result_list_keys= 626 | result_list_focus_highest_run_count_result_keys= 627 | result_list_focus_last_run_result_keys= 628 | result_list_toggle_path_column_keys= 629 | result_list_toggle_size_column_keys= 630 | result_list_toggle_extension_column_keys= 631 | result_list_toggle_type_column_keys= 632 | result_list_toggle_date_modified_column_keys= 633 | result_list_toggle_date_created_column_keys= 634 | result_list_toggle_attributes_column_keys= 635 | result_list_toggle_file_list_filename_column_keys= 636 | result_list_toggle_run_count_column_keys= 637 | result_list_toggle_date_recently_changed_column_keys= 638 | result_list_toggle_date_accessed_column_keys= 639 | result_list_toggle_date_run_column_keys= 640 | result_list_size_all_columns_to_fit_keys=8555 641 | result_list_size_result_list_to_fit_keys= 642 | result_list_context_menu_keys=9337 643 | result_list_scroll_left_or_thumbnail_left_keys=8229 644 | result_list_scroll_right_or_thumbnail_right_keys=8231 645 | result_list_scroll_page_left_or_thumbnail_focus_left_keys=8485 646 | result_list_scroll_page_right_or_thumbnail_focus_right_keys=8487 647 | result_list_left_extend_keys=9253 648 | result_list_right_extend_keys=9255 649 | result_list_focus_left_extend_keys=9509 650 | result_list_focus_right_extend_keys=9511 651 | result_list_select_focus_keys=8224 652 | result_list_toggle_focus_selection_keys=8480 653 | result_list_copy_as_csv_keys= 654 | preview_focus_preview_keys= 655 | result_list_font= 656 | result_list_font_size= 657 | search_edit_font= 658 | search_edit_font_size= 659 | status_bar_font= 660 | status_bar_font_size= 661 | header_font= 662 | header_font_size= 663 | normal_background_color= 664 | normal_foreground_color= 665 | normal_bold= 666 | highlighted_background_color= 667 | highlighted_foreground_color= 668 | highlighted_bold= 669 | current_sort_background_color= 670 | current_sort_foreground_color= 671 | current_sort_bold= 672 | current_sort_highlighted_background_color= 673 | current_sort_highlighted_foreground_color= 674 | current_sort_highlighted_bold= 675 | selected_background_color= 676 | selected_foreground_color= 677 | selected_bold= 678 | selected_highlighted_background_color= 679 | selected_highlighted_foreground_color= 680 | selected_highlighted_bold= 681 | selected_inactive_background_color= 682 | selected_inactive_foreground_color= 683 | selected_inactive_bold= 684 | selected_inactive_highlighted_background_color= 685 | selected_inactive_highlighted_foreground_color= 686 | selected_inactive_highlighted_bold= 687 | drop_target_background_color= 688 | drop_target_foreground_color= 689 | drop_target_bold= 690 | drop_target_highlighted_background_color= 691 | drop_target_highlighted_foreground_color= 692 | drop_target_highlighted_bold= 693 | mouseover_background_color= 694 | mouseover_foreground_color= 695 | mouseover_bold= 696 | mouseover_highlighted_background_color= 697 | mouseover_highlighted_foreground_color= 698 | mouseover_highlighted_bold= 699 | mouseover_current_sort_background_color= 700 | mouseover_current_sort_foreground_color= 701 | mouseover_current_sort_bold= 702 | mouseover_current_sort_highlighted_background_color= 703 | mouseover_current_sort_highlighted_foreground_color= 704 | mouseover_current_sort_highlighted_bold= 705 | alternate_row_background_color= 706 | alternate_row_foreground_color= 707 | alternate_row_bold= 708 | alternate_row_highlighted_background_color= 709 | alternate_row_highlighted_foreground_color= 710 | alternate_row_highlighted_bold= 711 | current_sort_alternate_row_background_color= 712 | current_sort_alternate_row_foreground_color= 713 | current_sort_alternate_row_bold= 714 | current_sort_alternate_row_highlighted_background_color= 715 | current_sort_alternate_row_highlighted_foreground_color= 716 | current_sort_alternate_row_highlighted_bold= 717 | hot_background_color= 718 | hot_foreground_color= 719 | hot_bold= 720 | hot_highlighted_background_color= 721 | hot_highlighted_foreground_color= 722 | hot_highlighted_bold= 723 | selected_hot_background_color= 724 | selected_hot_foreground_color= 725 | selected_hot_bold= 726 | selected_hot_highlighted_background_color= 727 | selected_hot_highlighted_foreground_color= 728 | selected_hot_highlighted_bold= 729 | selected_inactive_hot_background_color= 730 | selected_inactive_hot_foreground_color= 731 | selected_inactive_hot_bold= 732 | selected_inactive_hot_highlighted_background_color= 733 | selected_inactive_hot_highlighted_foreground_color= 734 | selected_inactive_hot_highlighted_bold= 735 | thumbnail_mouseover_background_color= 736 | thumbnail_mouseover_foreground_color= 737 | thumbnail_mouseover_bold= 738 | thumbnail_mouseover_highlighted_background_color= 739 | thumbnail_mouseover_highlighted_foreground_color= 740 | thumbnail_mouseover_highlighted_bold= 741 | -------------------------------------------------------------------------------- /cmd/Everything.lng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autumn-one/ahk-standard-lib/8c6ac06cfcbb1515981d23fda7422421c34646aa/cmd/Everything.lng -------------------------------------------------------------------------------- /cmd/Everything64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autumn-one/ahk-standard-lib/8c6ac06cfcbb1515981d23fda7422421c34646aa/cmd/Everything64.dll -------------------------------------------------------------------------------- /cmd/ahklib.ahk: -------------------------------------------------------------------------------- 1 | ;@Ahk2Exe-ConsoleApp 2 | #SingleInstance Force 3 | SetWorkingDir A_ScriptDir 4 | #Include ../stdlib.ahk 5 | 6 | ; 定义管理器的版本 7 | ahklib_version := "v0.6" 8 | 9 | isChinese := GetLocaleLanguage() = "zh-CN" 10 | 11 | full_command_line := DllCall("GetCommandLine", "str") 12 | 13 | if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)")) 14 | { 15 | try 16 | { 17 | args_str := "" 18 | for index, item in A_Args { 19 | if index == 1 { 20 | args_str := item 21 | } 22 | args_str := args_str . " " . item 23 | } 24 | if A_IsCompiled 25 | Run '*RunAs "' A_ScriptFullPath '" ' args_str ' /restart' 26 | else 27 | Run '*RunAs "' A_AhkPath '" /restart "' A_ScriptFullPath '" ' args_str 28 | } 29 | ExitApp 30 | } 31 | 32 | ; 检查编码 33 | if (encode := DllCall("GetConsoleOutputCP")) != 0 && encode != 65001{ 34 | DllCall("SetConsoleOutputCP", "UInt", 65001) 35 | } 36 | ; 如果当前运行的目录不是system32目录那么就复制一份过去 37 | if !A_ScriptDir.Includes("C:\Windows\System32") { 38 | FileCopy A_ScriptFullPath, "C:\Windows\System32\",1 39 | FileCopy A_ScriptDir "\7z.exe", "C:\Windows\System32\",1 40 | FileCopy A_ScriptDir "\Everything64.dll", "C:\Windows\System32\",1 41 | FileCopy A_ScriptDir "\7z.dll", "C:\Windows\System32\",1 42 | FileCopy A_ScriptDir "\Everything.exe", "C:\Windows\System32\",1 43 | ; FileCopy A_ScriptDir "\Everything.ini", "C:\Windows\System32\",1 44 | } 45 | 46 | ; 检查everything是否初始化完毕 47 | builtInEverything := false 48 | try { 49 | if !Everything.IsDBLoaded() && Everything.GetLastError() == 2 && !Everything.HasEverythingProcess() { 50 | builtInEverything := true 51 | Everything.RunEverything() 52 | Everything.GetAllDir("123") 53 | println(isChinese ? "正在初始化Everything" : "Initializing Everything") 54 | Sleep(1000) 55 | if !Everything.IsDBLoaded() { 56 | count := 0 57 | while Everything.ReBuildDB() = 0 { 58 | if count >= 3{ 59 | break 60 | } 61 | count++ 62 | Sleep(100) 63 | } 64 | Everything.GetAllDir("123") 65 | if !Everything.IsDBLoaded(){ 66 | msgbox isChinese ? "everything初始化失败,请自行安装并重启软件" : "everything initialization failed. Please install and restart the software yourself" 67 | return 68 | } 69 | 70 | Everything.SaveDB() 71 | } 72 | 73 | } 74 | 75 | ; 先 76 | ; 下载压缩包 77 | dir1Arr := Everything.GetAllDir("wfn:AutoHotkey.exe") 78 | dir2Arr := Everything.GetAllDir("wfn:AutoHotkey32.exe") 79 | dir3Arr := Everything.GetAllDir("wfn:AutoHotkey64.exe") 80 | dirArr := dir1Arr.Intersect(dir2Arr, dir3Arr) 81 | } 82 | 83 | if builtInEverything { 84 | if Everything.Exit() = 0 && ProcessExist("everything.exe") { 85 | ProcessClose("everything.exe") 86 | } 87 | } 88 | 89 | dirPath := "" 90 | if(dirArr.Length != 1){ 91 | _r := msgbox(isChinese ? "我们不能确认你ahk的安装位置,请手动选择AutoHotKey.exe所在目录" : "We cannot confirm your ahk installation location, please manually select the AutoHotKey.exe directory", isChinese ? "选择目录" : "Select Folder", "1") 92 | if _r == "Cancel"{ ; 如果取消了就算了 93 | return 94 | } 95 | dirPath := DirSelect(,2) 96 | if !dirPath{ 97 | return 98 | } 99 | }else{ 100 | dirPath := dirArr[1] 101 | } 102 | if FileExist(dirPath "\ahklib.zip") { 103 | FileDelete dirPath "\ahklib.zip" 104 | } 105 | 106 | ; 如果有之前没清楚的压缩包就先清楚 107 | if FileExist(dirPath "\ahklib.zip"){ 108 | FileDelete dirPath "\ahklib.zip" 109 | } 110 | 111 | println(isChinese ? "ahk标准库下载中..." : "ahk standard library download...") 112 | try{ 113 | Download("https://codeload.github.com/Autumn-one/ahk-standard-lib/zip/refs/heads/main", dirPath "\ahklib.zip") 114 | }catch { 115 | msgbox isChinese ? "包更新失败,请检查网络!或重试." : "Package update failed, please check the network! Or try again." 116 | return 117 | } 118 | 119 | ; 通过7zip解压到Lib目录即可 120 | ret := StdoutToVar("7z x ".Concat( 121 | '"', 122 | dirPath, 123 | '\ahklib.zip" -o', 124 | '"', 125 | dirPath, 126 | '\" -aoa' 127 | )) 128 | if ret.ExitCode != 0 { 129 | msgbox ret.Output 130 | } 131 | 132 | if FileExist(dirPath "\Lib"){ 133 | DirDelete dirPath "\Lib", 1 134 | } 135 | 136 | DirMove(dirPath "\ahk-standard-lib-main", dirPath "\Lib", 1) 137 | 138 | if FileExist(dirPath "\ahklib.zip") { 139 | FileDelete dirPath "\ahklib.zip" 140 | } 141 | 142 | if GetLocaleLanguage() = "zh-CN" { 143 | try DirDelete(path.Concat(dirPath, "Lib\en"), true) 144 | }else{ 145 | try DirDelete(path.Concat(dirPath, "Lib\zh"), true) 146 | } 147 | if ret.ExitCode == 0{ 148 | msgbox (isChinese ? "ahklib@{1}更新成功" : "ahklib@{1}Update succeeded").format(ahklib_version) 149 | }else{ 150 | msgbox (isChinese ? "ahklib{1}更新失败:" : "ahklib@{1}Update failed:").format(ahklib_version) ret.Output 151 | } 152 | 153 | 154 | 155 | class Everything { 156 | static EvDll := "" 157 | static __New(){ 158 | this.EvDll := DllCall("LoadLibrary", "Str", "Everything64.dll", "Ptr") 159 | } 160 | static GetCount(keyword){ 161 | try { 162 | DllCall("Everything64.dll\Everything_SetSearch", "Str", keyword) 163 | } catch Error as e { 164 | ExitApp 165 | } 166 | DllCall("Everything64.dll\Everything_Query", "int64", 1) 167 | return DllCall("Everything64.dll\Everything_GetNumResults") 168 | } 169 | static GetAllDir(keyword){ 170 | arr := [] 171 | Loop this.GetCount(keyword) 172 | { 173 | dirPath := DllCall("Everything64.dll\Everything_GetResultPath", "Int", A_index - 1, "Str") 174 | arr.Push(dirPath) 175 | } 176 | return arr 177 | } 178 | static HasEverythingProcess(){ 179 | DetectHiddenWindows 1 180 | ret := ProcessExist("everything.exe") 181 | DetectHiddenWindows 0 182 | return ret 183 | } 184 | static RunEverything(){ 185 | cmdstr := "everything.exe -startup " 186 | if FileExist(A_ScriptDir "\Everything.db") { 187 | cmdStr := cmdStr "-db " '"' A_ScriptDir "\Everything.db" '"' 188 | } 189 | Run cmdStr 190 | ProcessWait "everything.exe", 2 191 | } 192 | static IsDBLoaded(){ 193 | return DllCall("Everything64.dll\Everything_IsDBLoaded", "Int") 194 | } 195 | static ReBuildDB(){ 196 | return DllCall("Everything64.dll\Everything_RebuildDB", "Int") 197 | } 198 | static Exit(){ 199 | return DllCall("Everything64.dll\Everything_Exit", "Int") 200 | } 201 | static GetLastError(){ 202 | return DllCall("Everything64.dll\Everything_GetLastError", "Int") 203 | } 204 | static SaveDB(){ 205 | return DllCall("Everything64.dll\Everything_SaveDB", "Int") 206 | } 207 | } 208 | 209 | 210 | ; ---------------------------------------------------------------------------------------------------------------------- 211 | ; Function .....: StdoutToVar 212 | ; Description ..: Runs a command line program and returns its output. 213 | ; Parameters ...: sCmd - Commandline to be executed. 214 | ; ..............: sDir - Working directory. 215 | ; ..............: sEnc - Encoding used by the target process. Look at StrGet() for possible values. 216 | ; Return .......: Command output as a string on success, empty string on error. 217 | ; AHK Version ..: AHK v2 x32/64 Unicode 218 | ; Author .......: Sean (http://goo.gl/o3VCO8), modified by nfl and by Cyruz 219 | ; License ......: WTFPL - http://www.wtfpl.net/txt/copying/ 220 | ; Changelog ....: Feb. 20, 2007 - Sean version. 221 | ; ..............: Sep. 21, 2011 - nfl version. 222 | ; ..............: Nov. 27, 2013 - Cyruz version (code refactored and exit code). 223 | ; ..............: Mar. 09, 2014 - Removed input, doesn't seem reliable. Some code improvements. 224 | ; ..............: Mar. 16, 2014 - Added encoding parameter as pointed out by lexikos. 225 | ; ..............: Jun. 02, 2014 - Corrected exit code error. 226 | ; ..............: Nov. 02, 2016 - Fixed blocking behavior due to ReadFile thanks to PeekNamedPipe. 227 | ; ..............: Apr. 13, 2021 - Code restyling. Fixed deprecated DllCall types. 228 | ; ..............: Oct. 06, 2022 - AHK v2 version. Throw exceptions on failure. 229 | ; ..............: Oct. 08, 2022 - Exceptions management and handles closure fix. Thanks to lexikos and iseahound. 230 | ; ---------------------------------------------------------------------------------------------------------------------- 231 | StdoutToVar(sCmd, sDir:=A_ScriptDir, sEnc:="CP0") { 232 | ; Create 2 buffer-like objects to wrap the handles to take advantage of the __Delete meta-function. 233 | oHndStdoutRd := { Ptr: 0, __Delete: delete(this) => DllCall("CloseHandle", "Ptr", this) } 234 | oHndStdoutWr := { Base: oHndStdoutRd } 235 | 236 | If !DllCall( "CreatePipe" 237 | , "PtrP" , oHndStdoutRd 238 | , "PtrP" , oHndStdoutWr 239 | , "Ptr" , 0 240 | , "UInt" , 0 ) 241 | Throw OSError(,, "Error creating pipe.") 242 | If !DllCall( "SetHandleInformation" 243 | , "Ptr" , oHndStdoutWr 244 | , "UInt" , 1 245 | , "UInt" , 1 ) 246 | Throw OSError(,, "Error setting handle information.") 247 | 248 | PI := Buffer(A_PtrSize == 4 ? 16 : 24, 0) 249 | SI := Buffer(A_PtrSize == 4 ? 68 : 104, 0) 250 | NumPut( "UInt", SI.Size, SI, 0 ) 251 | NumPut( "UInt", 0x100, SI, A_PtrSize == 4 ? 44 : 60 ) 252 | NumPut( "Ptr", oHndStdoutWr.Ptr, SI, A_PtrSize == 4 ? 60 : 88 ) 253 | NumPut( "Ptr", oHndStdoutWr.Ptr, SI, A_PtrSize == 4 ? 64 : 96 ) 254 | 255 | If !DllCall( "CreateProcess" 256 | , "Ptr" , 0 257 | , "Str" , sCmd 258 | , "Ptr" , 0 259 | , "Ptr" , 0 260 | , "Int" , True 261 | , "UInt" , 0x08000000 262 | , "Ptr" , 0 263 | , "Ptr" , sDir ? StrPtr(sDir) : 0 264 | , "Ptr" , SI 265 | , "Ptr" , PI ) 266 | Throw OSError(,, "Error creating process.") 267 | 268 | ; The write pipe must be closed before reading the stdout so we release the object. 269 | ; The reading pipe will be released automatically on function return. 270 | oHndStdOutWr := "" 271 | 272 | ; Before reading, we check if the pipe has been written to, so we avoid freezings. 273 | nAvail := 0, nLen := 0 274 | While DllCall( "PeekNamedPipe" 275 | , "Ptr" , oHndStdoutRd 276 | , "Ptr" , 0 277 | , "UInt" , 0 278 | , "Ptr" , 0 279 | , "UIntP" , &nAvail 280 | , "Ptr" , 0 ) != 0 281 | { 282 | ; If the pipe buffer is empty, sleep and continue checking. 283 | If !nAvail && Sleep(100) 284 | Continue 285 | cBuf := Buffer(nAvail+1) 286 | DllCall( "ReadFile" 287 | , "Ptr" , oHndStdoutRd 288 | , "Ptr" , cBuf 289 | , "UInt" , nAvail 290 | , "PtrP" , &nLen 291 | , "Ptr" , 0 ) 292 | sOutput .= StrGet(cBuf, nLen, sEnc) 293 | } 294 | 295 | ; Get the exit code, close all process handles and return the output object. 296 | DllCall( "GetExitCodeProcess" 297 | , "Ptr" , NumGet(PI, 0, "Ptr") 298 | , "UIntP" , &nExitCode:=0 ) 299 | DllCall( "CloseHandle", "Ptr", NumGet(PI, 0, "Ptr") ) 300 | DllCall( "CloseHandle", "Ptr", NumGet(PI, A_PtrSize, "Ptr") ) 301 | Return { Output: sOutput, ExitCode: nExitCode } 302 | } -------------------------------------------------------------------------------- /cmd/ahklib安装程序v0.5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autumn-one/ahk-standard-lib/8c6ac06cfcbb1515981d23fda7422421c34646aa/cmd/ahklib安装程序v0.5.exe -------------------------------------------------------------------------------- /cmd/ahklib安装程序v0.6.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autumn-one/ahk-standard-lib/8c6ac06cfcbb1515981d23fda7422421c34646aa/cmd/ahklib安装程序v0.6.exe -------------------------------------------------------------------------------- /cmd/build.cmd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autumn-one/ahk-standard-lib/8c6ac06cfcbb1515981d23fda7422421c34646aa/cmd/build.cmd -------------------------------------------------------------------------------- /cmd/config.txt: -------------------------------------------------------------------------------- 1 | ;下面的注释包含自解压脚本命令 2 | 3 | Setup=ahklib.exe 4 | TempMode 5 | Silent=1 6 | Overwrite=1 7 | -------------------------------------------------------------------------------- /cmd/everything.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autumn-one/ahk-standard-lib/8c6ac06cfcbb1515981d23fda7422421c34646aa/cmd/everything.exe -------------------------------------------------------------------------------- /en/array.d.ahk: -------------------------------------------------------------------------------- 1 | /** @extends {#Array} */ 2 | class Array { 3 | /** 4 | * Determines whether an array contains an item and returns a Boolean value of 0 or 1 5 | * 6 | * - arr := ["hello", "autumn", "one"] 7 | * 8 | * arr.Includes("hello") // 1 9 | * 10 | * arr.Includes("hello2") // 0 11 | */ 12 | Includes(item) => Integer 13 | /** 14 | * Concatenate an array as a string, by default concatenated with commas 15 | * 16 | * arr := ["金", "木", "水", "火", "土"] 17 | * 18 | * arr.Join(",") // "金,木,水,火,土" 19 | */ 20 | Join(separator) => String 21 | /** 22 | * Converts an array to a string representation 23 | * 24 | * arr := [1,2,3] 25 | * 26 | * arr.ToString() // "123" 27 | * 28 | * String(arr) // "123" 29 | */ 30 | ToString() => String 31 | /** 32 | * Walk through the array and return a new array that can be used to modify each item in the array 33 | * 34 | * arr := [1,2,3] 35 | * 36 | * arr.Map(i => i * 2) // [2, 4, 6] 37 | */ 38 | Map(MapFunc) => Array 39 | /** 40 | * Simply traverses the array, returning the array itself 41 | * 42 | * arr := [1,2,3] 43 | * 44 | * arr.ForEach(i => msgbox(i)) // [1,2,3] 45 | */ 46 | /** 47 | * Filter array, returns a new filtered array 48 | * 49 | * arr := [1,2,3,4,5,6] 50 | * 51 | * arr.Filter(i => Mod(i, 2)) // [1,3,5] 52 | */ 53 | Filter(FilterFunc) => Array 54 | /** 55 | * Delete the first element of an array or multiple elements starting from the first, return the element if you delete only one element, and return the array of deleted elements if you delete multiple elements. This function changes the array itself 56 | * 57 | * arr := [1,2,3] 58 | * 59 | * arr.Shift(arr) // 1 60 | * 61 | * arr // [2,3] 62 | */ 63 | Shift(count := 1) => T | Array 64 | /** 65 | * Add multiple elements to the header of the array and return the original array, the method changes itself 66 | * 67 | * arr := [1,2,3] 68 | * 69 | * arr.UnShift(6,7,8) // [6,7,8,1,2,3] 70 | */ 71 | UnShift(items*) => Array 72 | /** 73 | * Concatenates multiple arrays into a new array and returns 74 | * 75 | * arr := [1,2,3] 76 | * 77 | * arr.Concat([4,5,6], [7,8,9]) // [1,2,3,4,5,6,7,8,9] 78 | */ 79 | Concat(arr*) => Array 80 | /** 81 | * A function is passed in, each item of the array is carried into execution, and true is returned if all the returned values are true, false otherwise 82 | * @param short The default value is false. No short circuit 83 | * 84 | * arr := [true, true] 85 | * 86 | * arr.Every(i => i) // 1 87 | */ 88 | Every(EveryFunc, short := false) => Integer 89 | /** 90 | * A function is passed, each item of the array is carried into execution, and if one return value is true, it is returned true, otherwise it is false 91 | * @param short The default value is false. No short circuit 92 | * 93 | * arr := [true, false] 94 | * 95 | * arr.Some(i => i) // 1 96 | */ 97 | Some(SomeFunc, short := false) => Integer 98 | /** 99 | * Delete an item of an array one or more times, and return the original array, the function changes itself 100 | * @param count By default, an item is deleted once. 0 indicates that all the same items are deleted 101 | * 102 | * arr := ["金", "木", "水", "火", "土", "土"] 103 | * 104 | * arr.Remove("土") // ["金", "木", "水", "火", "土"] 105 | * 106 | * arr.Remove("土", 2) // ["金", "木", "水", "火"] 107 | * 108 | * arr.Remove("土", 0) // ["金", "木", "水", "火"] 109 | */ 110 | Remove(item, count := 1) => Array 111 | /** 112 | * Pass in an array of elements to be deleted, remove the items from the original array, return the original array, the function changes the array itself 113 | * @param delArr An array containing the elements to be deleted 114 | * @param count The number of times each element to be deleted can be deleted, with 0 indicating that all are deleted 115 | * 116 | * arr := ["金", "木", "水", "火", "土", "土"] 117 | * 118 | * arr.RemoveAll(["水", "土"]) // ["金", "木", "火", "土"] 119 | * 120 | * arr.RemoveAll(["水", "土"], 0) // ["金", "木", "火"] 121 | */ 122 | RemoveAll(delArr, count := 1) => Array 123 | 124 | /** 125 | * Pass a function that finds the first array item whose result is true and returns it 126 | * @param FindFunc Function to find 127 | * @param DefaultValue The value returned if not found 128 | * 129 | * arr := ["木瓜", "西瓜", "土豆", "甜瓜"] 130 | * 131 | * arr.Find(i => i.Includes("甜")) // "甜瓜" 132 | * 133 | * arr.Find(i => i.Includes("黄瓜"), "Null") // "Null" 134 | */ 135 | Find(FindFunc, DefaultValue := "") => Any 136 | 137 | /** 138 | * Pass in a function that returns a new array of all the items whose result is true 139 | * 140 | * arr := ["木瓜", "西瓜", "土豆", "甜瓜"] 141 | * 142 | * arr.FindAll(i => i.Includes("瓜")) // ["木瓜", "西瓜", "甜瓜"] 143 | */ 144 | FindAll(FindFunc) => Array 145 | 146 | 147 | /** 148 | * Check whether the value is inside the array 149 | * @param value An array item 150 | * 151 | * arr := ["哈哈", "嘿嘿"] 152 | * 153 | * arr.Includes("哈哈") // 1 154 | * @returns {Integer} A Boolean value 155 | */ 156 | Includes(value) => Integer 157 | 158 | /** 159 | * View the position of value in the array 160 | * @param value View the index position of value in the array 161 | * 162 | * arr := ["哈哈", "嘿嘿"] 163 | * 164 | * arr.IndexOf("嘿嘿") // 2 165 | * @returns {Integer} If an index is returned in an array, 0 indicates absence 166 | */ 167 | IndexOf(value) => Integer 168 | 169 | /** 170 | * A value passed in or a function returned to a new array of matched items corresponding to the index 171 | * @param ValueOrFunc A value to look for or a function to look for, which returns true to indicate a successful match 172 | * 173 | * arr := ["木瓜", "西瓜", "土豆", "草莓", "葡萄", "甜瓜", "西瓜"] 174 | * 175 | * arr.IndexOfAll("西瓜") // [2, 7] 176 | * 177 | * arr.IndexOfAll(i => i.Includes("瓜")) // [1, 2, 6, 7] 178 | * @returns {Array} Returns an array containing all found indexes 179 | */ 180 | IndexOfAll(ValueOrFunc) => Array 181 | 182 | /** 183 | * Flatten the array 184 | * @param depth The number of layers to smooth the array 0 indicates infinite flatness 185 | * 186 | * arr := [1, 2, [3, [4, 5]]] 187 | * 188 | * arr.Flat() // [1,2,3,4,5] 189 | * 190 | * arr.Flat(1) // [1,2,3,[4,5]] 191 | * @returns {Array} 192 | */ 193 | Flat(depth := 0) => Array 194 | 195 | /** 196 | * Array deduplication 197 | * 198 | * arr := [1,1,1,2,2,2] 199 | * 200 | * arr.Unique() // [1,2] 201 | * @returns {Array} 202 | */ 203 | Unique() => Array 204 | 205 | /** 206 | * Array sorting, this method does not change the array itself, returns a new array 207 | * @param SortFunc a function for sorting, default (a,b) => a - b 208 | * 209 | * arr := [8, 2, 1, 9] 210 | * 211 | * arr.Sort() // [1,2,8,9] 212 | * 213 | * arr.Sort((a,b) => b-a) // [9,8,2,1] 214 | * @returns {Array} 215 | */ 216 | Sort(SortFunc) => Array 217 | 218 | /** 219 | * Take the intersection of all arrays and return a new array 220 | * @param arr* Pass in several arrays 221 | * 222 | * arr := [1,2,3] 223 | * 224 | * arr.Intersect([2, 3]) // [2, 3] 225 | * @returns {Array} 226 | */ 227 | Intersect(arr*) => Array 228 | 229 | /** 230 | * Take the array union, return a new array 231 | * @param arr* Multiple array 232 | * 233 | * arr := [1,2,3] 234 | * 235 | * arr.Union([2,3,4,5]) // [1,2,3,4,5] 236 | * @returns {Array} 237 | */ 238 | Union(arr*) => Array 239 | 240 | /** 241 | * All elements common to the array are excluded, and the remaining elements form a new array 242 | * @param arr* Array of several 243 | * 244 | * arr := [1, 2, 3] 245 | * 246 | * arr.Xor([2, 3, 6]) // [1, 6] 247 | * @returns {Array} 248 | */ 249 | Xor(arr*) => Array 250 | /** 251 | * Flipping the array returns a new array 252 | * @returns {Array} 253 | */ 254 | Reverse() => Array 255 | 256 | /** 257 | * Sum an array containing only numbers 258 | * @returns {Integer} 259 | */ 260 | Sum() => Integer 261 | 262 | /** 263 | * An imitation of the Reduce method in javascript 264 | * @param ReduceFunc 265 | * @param initial 266 | * 267 | * [1,2,3].Reduce((memo, item) => memo + item) // 1 + 2 + 3 = 6 268 | * 269 | * [1,2,3].Reduce((memo, item) => memo + item, 6) // 6 + 1 + 2 + 3 = 12 270 | * @returns {Any} 271 | */ 272 | Reduce(ReduceFunc, initial?) => Any 273 | 274 | /** 275 | * An imitation of the ReduceRight method in javascript 276 | * @param ReduceFunc 277 | * @param initial 278 | * 279 | * [1,2,3].ReduceRight((memo, item) => memo + item) // 3 + 2 + 1 = 6 280 | * 281 | * [1,2,3].ReduceRight((memo, item) => memo + item, 6) // 6 + 3 + 2 + 1 = 12 282 | * @returns {Any} 283 | */ 284 | ReduceRight(ReduceFunc, initial?) => Any 285 | 286 | /** 287 | * Return True if the array contains an item of the passed argument, False otherwise 288 | * @param params* 289 | * 290 | * [1,2,3].IncludeSome(2, 6) // True 291 | * 292 | * [1,2,3].IncludeSome(8, 9) // False 293 | * 294 | * @returns {Integer} Boolean 295 | */ 296 | IncludeSome(params*) => Integer 297 | 298 | /** 299 | * Return True if the array contains all the items in the passed argument, False otherwise 300 | * @param params* 301 | * 302 | * [1,2,3].IncludeEvery(1,2) // True 303 | * 304 | * [1,2,3].IncludeEvery(1,6) // False 305 | * 306 | * @returns {Integer} Boolean 307 | */ 308 | IncludeEvery(params*) => Integer 309 | } -------------------------------------------------------------------------------- /en/number.d.ahk: -------------------------------------------------------------------------------- 1 | /** @extends {#Number} */ 2 | class Number { 3 | /** 4 | * Returns the character corresponding to the number 5 | * 6 | * 66.ToChar() // "B" 7 | * @returns {String} 8 | */ 9 | ToChar() => String 10 | } -------------------------------------------------------------------------------- /en/object.d.ahk: -------------------------------------------------------------------------------- 1 | /** @extends {#Object} */ 2 | class Object{ 3 | /** 4 | * Gets an array of keys for an object 5 | * 6 | * obj := {a: 1, b: 2} 7 | * 8 | * obj.Keys() // ["a", "b"] 9 | * @returns {Array} 10 | */ 11 | Keys() => Array 12 | 13 | /** 14 | * Gets an array of the object's values 15 | * 16 | * obj := {a: 1, b: 2} 17 | * 18 | * obj.Values() // [1, 2] 19 | * @returns {Array} 20 | */ 21 | Values() => Array 22 | /** 23 | * Gets an array of key value pairs for an object 24 | * 25 | * obj := {a: 1, b: 2, c: 3} 26 | * 27 | * obj.Items() // [ { key: "a", value: 1 }, { key: "b", value: 2 }, { key: "c", value: 3 } ] 28 | * @returns {Array} 29 | */ 30 | Items() => Array 31 | /** 32 | * Returns a string representation of an object 33 | * 34 | * obj := {a: 1, b: 2, c: 3} 35 | * 36 | * obj.ToString() // "{ a: 1, b: 2, c: 3 }" 37 | * @returns {String} 38 | */ 39 | ToString() => String 40 | /** 41 | * An attribute that gets the length of the object 42 | * 43 | * obj := {a: 1, b: 2} 44 | * 45 | * obj.Length // 2 46 | */ 47 | Length { 48 | get => Integer 49 | } 50 | /** 51 | * Determines whether an object contains a property 52 | * 53 | * obj := {a: 1, b: 2, c: 3} 54 | * 55 | * obj.Has("d") // 0 56 | * 57 | * obj.Has("c") // 1 58 | * @returns {Integer} 59 | */ 60 | Has(prop) => Integer 61 | /** 62 | * Determines whether an object contains a property 63 | * 64 | * obj := {a: 1, b: 2, c: 3} 65 | * 66 | * obj.Contains("d") // 0 67 | * 68 | * obj.Contains("c") // 1 69 | * @returns {Integer} 70 | */ 71 | Contains() => Integer 72 | /** 73 | * Merge multiple objects 74 | * 75 | * obj := {a: 1, b: 2, c: 3} 76 | * 77 | * obj.Merge({c: 8, d: 9}) // { a: 1, b: 2, c: 8, d: 9 } 78 | * @returns {Object} 79 | */ 80 | Merge(objs*) => Object 81 | 82 | } -------------------------------------------------------------------------------- /en/path.d.ahk: -------------------------------------------------------------------------------- 1 | class path{ 2 | /** 3 | * Join the path, this function will handle some troublesome cases, the path must not contain \ at the end 4 | * @param {Array} params* 5 | * 6 | * path.Concat("c:\cbs\", "\dds") // "c:\cbs\dds" 7 | * 8 | * path.Concat("c:\cbs\", "\dds\") // "c:\cbs\dds" 9 | * @returns {String} 10 | */ 11 | static Concat(params*: Array) => String 12 | 13 | /** 14 | * Obtain path Folder path 15 | * @param {String} pathStr 16 | * 17 | * path.DirName("c:\abc\ddd\efs.txt") // "c:\abc\ddd" 18 | * @returns {String} 19 | */ 20 | static DirName(pathStr: String) => String 21 | 22 | /** 23 | * Gets the file name extension in the path 24 | * @param {String} pathStr 25 | * 26 | * path.ExtName("c:\abc\ddd\efs.txt") // "txt" 27 | * @returns {String} 28 | */ 29 | static ExtName(pathStr: String) => String 30 | 31 | /** 32 | * Gets the name of the file or folder in the path 33 | * @param {String} PathStr 34 | * @param {String} suffix Optional content to remove from the end of the result 35 | * 36 | * path.BaseName("c:\abc\ddd\efs.txt") // "efs.exe" 37 | * 38 | * path.BaseName("c:\abc\ddd\efs.txt", ".txt") // "efs" 39 | * @returns {String} 40 | */ 41 | static BaseName(PathStr: String, suffix?: String := "") => String 42 | } -------------------------------------------------------------------------------- /en/string.d.ahk: -------------------------------------------------------------------------------- 1 | /** @extends {#string} */ 2 | class String extends Primitive{ 3 | /** 4 | * Cut a string into an array 5 | * @param {Array, String} Delimiters A delimiter or array of delimiters that is not passed is cut into a single character 6 | * @param SplitCount Number of cuts -1 indicates an unlimited number of cuts, and 0 indicates no cuts 7 | * 8 | * 9 | * "木瓜".Split() // ["木", "瓜"] 10 | * 11 | * "金 木 水土 火".Split([A_Space, A_Tab]) // ["金", "木", "水土", "火"] 12 | * 13 | * "abc.bbc.ddd".Split(".", 1) // ["abc", "bbc.ddd"] 14 | * 15 | * "fff".Split() // ["fff"] 16 | * 17 | * "abc.".Split(".", 0) // ["abc."] 18 | * 19 | * "abc.".Split(".", 1) // ["abc", ""] 20 | * 21 | * ".abc".Split(".", 1) // ["", "abc"] 22 | * 23 | * @returns {Array} 24 | */ 25 | Split(Delimiters?: String, SplitCount?: -1) => Array 26 | /** 27 | * Cut the string into an array starting from the right 28 | * @param {Array, String} Delimiters A delimiter or array of delimiters that is not passed is cut into a single character 29 | * @param SplitCount Number of cuts -1 indicates an unlimited number of cuts, and 0 indicates no cuts 30 | * 31 | * 32 | * "木瓜".SplitRight() // ["木", "瓜"] 33 | * 34 | * "金 木 水土 火".SplitRight([A_Space, A_Tab]) // ["金", "木", "水土", "火"] 35 | * 36 | * "abc.bbc.ddd".SplitRight(".", 1) // ["abc.bbc", "ddd"] 37 | * 38 | * @returns {Array} 39 | */ 40 | SplitRight(Delimiters?: String, SplitCount?: -1) => Array 41 | 42 | /** 43 | * Return True if the string contains an item of the passed argument, False otherwise 44 | * @param params* 45 | * 46 | * "金木水火土".IncludeSome("金", "银") // True 47 | * 48 | * "木瓜".IncludeSome("大", "天", "子") // False 49 | * 50 | * @returns {Integer} Boolean 51 | */ 52 | IncludeSome(params*) => Integer 53 | 54 | /** 55 | * Return True if the string contains all the items in the passed argument, False otherwise 56 | * @param params* 57 | * 58 | * "金木水火土".IncludeEvery("金", "火") // True 59 | * 60 | * "西瓜".IncludeEvery("瓜", "白") // False 61 | * 62 | * @returns {Integer} Boolean 63 | */ 64 | IncludeEvery(params*) => Integer 65 | 66 | /** 67 | * Gets the length of the string 68 | */ 69 | Length { 70 | get => Integer 71 | } 72 | /** 73 | * Determines whether the string begins with a substring 74 | * @param startStr 75 | * @param caseSense Case sensitive: Case sensitive by default 76 | * 77 | * str := "木瓜" 78 | * 79 | * str.StartsWith("木") // 1 80 | * @returns {Integer} Boolean value 0 or 1 81 | */ 82 | StartsWith(startStr, caseSense := true) => Integer 83 | /** 84 | * Determines whether the string ends with a substring 85 | * @param endStr 86 | * @param caseSense Case sensitive: Case sensitive by default 87 | * 88 | * str := "大西瓜" 89 | * 90 | * str.EndsWith("西瓜") // 1 91 | * @returns {Integer} Boolean value 0 or 1 92 | */ 93 | EndsWith(endStr, caseSense := true) => Integer 94 | /** 95 | * Determines whether the string contains substrings 96 | * @param subStr 97 | * @param caseSense Case sensitive: Case sensitive by default 98 | * 99 | * str := "金木水火土" 100 | * 101 | * str.Includes("火") // 1 102 | * @returns {Integer} Boolean 103 | */ 104 | Includes(subStr, caseSense := true) => Integer 105 | /** 106 | * Gets the position of the substring in the string 107 | * @param subStr 108 | * @param caseSense Case sensitive: Case sensitive by default 109 | * 110 | * str := "木瓜西瓜" 111 | * 112 | * str.IndexOf("西") // 3 113 | * @returns {Integer} 114 | */ 115 | IndexOf(subStr, caseSense := true) => Integer 116 | /** 117 | * Gets the position of the substring in the string, searching from right to left 118 | * @param subStr 119 | * @param caseSense Case sensitive: Case sensitive by default 120 | * 121 | * str := "木瓜西瓜西" 122 | * 123 | * str.LastIndexOf("西") // 5 124 | * @returns {Integer} 125 | */ 126 | LastIndexOf(subStr, caseSense := true) => Integer 127 | /** 128 | * Gets all positions of the substring in the string and returns an array containing all positions 129 | * @param subStr 130 | * @param caseSense Case sensitive: Case sensitive by default 131 | * 132 | * str := "木瓜木有木哈哈木tutu" 133 | * 134 | * str.IndexOfAll("木") // [ 1, 3, 5, 8 ] 135 | * @returns {Array} 136 | */ 137 | IndexOfAll(subStr, caseSense := true) => Array 138 | /** 139 | * Deletes the specified characters on both sides of the string. By default, whitespace is deleted 140 | * @param {String} omitChars Specify multiple characters to delete 141 | * @returns {String} 142 | */ 143 | Trim(omitChars?: String) => String 144 | /** 145 | * Removes the specified character to the left of the string. By default, whitespace is removed 146 | * @param {String} omitChars 147 | * @returns {String} 148 | */ 149 | TrimLeft(omitChars?: String) => String 150 | /** 151 | * Removes the specified character to the right of the string. By default, whitespace is removed 152 | * @param {String} omitChars 153 | * @returns {String} 154 | */ 155 | TrimRight(omitChars?: String) => String 156 | /** 157 | * Gets the character encoding for the specified index position of the string 158 | * @param {Integer} index 159 | * 160 | * str := "西瓜" 161 | * 162 | * str.CharCodeAt(2) // 29916 163 | * @returns {Integer} 164 | */ 165 | CharCodeAt(index: Integer) => Integer 166 | /** 167 | * Gets the character encoding for the specified index position of the string 168 | * @param {Integer} index 169 | * 170 | * str := "西瓜" 171 | * 172 | * str.CodeAt(2) // 29916 173 | * @returns {Integer} 174 | */ 175 | CodeAt(index: Integer) => Integer 176 | /** 177 | * Concatenate multiple strings 178 | * @param params* 179 | * 180 | * str := "金" 181 | * 182 | * str.Concat("木", "水") // "金木水" 183 | * @returns {String} 184 | */ 185 | Concat(params*) => String 186 | /** 187 | * Wrap a string around another string 188 | * @param wrapStr 189 | * 190 | * str := "鸡蛋" 191 | * 192 | * str.Wrap("**") // "**鸡蛋**" 193 | * @returns {String} 194 | */ 195 | Wrap(wrapStr) => String 196 | /** 197 | * The String representation of a string, with one more double quotation mark than the ordinary print, is generally used for the call of the string method 198 | * But it seems that String doesn't call the custom ToString, other types do 199 | * @returns {String} 200 | */ 201 | ToString() => String 202 | /** 203 | * Concatenates all the character encodings of a string and returns the final number, which can generally be used for sorting 204 | * @returns {Integer} 205 | */ 206 | ToCode() => Integer 207 | /** 208 | * Returns an array of character encodings for the corresponding string 209 | * @returns {Array} 210 | */ 211 | ToCodes() => Array 212 | /** 213 | * Returns the lowercase form of a string 214 | * @returns {String} 215 | */ 216 | ToLower() => String 217 | /** 218 | * Returns the uppercase form of a string 219 | * @returns {String} 220 | */ 221 | ToUpper() => String 222 | /** 223 | * Returns the title form of the character 224 | * @returns {String} 225 | */ 226 | ToTitle() => String 227 | /** 228 | * String template, which is an alias for the Format method 229 | * @param values 230 | * 231 | * "我的名字叫:{1}".Format("木瓜") // "我的名字叫:木瓜" 232 | * @returns {String} 233 | */ 234 | Format(values*) => String 235 | /** 236 | * String template 237 | * @param values 238 | * 239 | * name := "木瓜" 240 | * "我的名字叫:{name}".Format(&name) // "我的名字叫:木瓜" 241 | * @returns {String} 242 | */ 243 | Templ(&values*) => String 244 | /** 245 | * Replaces some substrings in a string 246 | * @param {String} Needle The substring to search for 247 | * @param {String} ReplaceText The replacement character is replaced with blank if not passed 248 | * @param {String | Integer} CaseSense Case sensitive: Case sensitive by default 249 | * @param {VarRef} OutputVarCount The pointer stores the number of substitutions 250 | * @param {Integer} Limit The default value is -1, indicating the maximum number of replacements 251 | * 252 | * ret := "我是木瓜木木".Replace("木", "金", true, &cc, 2) 253 | * 254 | * println("ret:",ret) // ret: 我是金瓜金木 255 | * 256 | * println("cc:",cc) // cc: 2 257 | * @returns {String} 258 | */ 259 | Replace(Needle: String, ReplaceText?: String, CaseSense?: String | Integer := true, &OutputVarCount?: VarRef, Limit?: Integer) => String 260 | /** 261 | * Flip string 262 | * @returns {String} 263 | */ 264 | Reverse() => String 265 | /** 266 | * Returns the length of the specified string, if it is long enough to return as is, if it is not long enough to fill from the beginning, the filling process may truncate strFill 267 | * @param {Integer} num Specifies the length of the string to return 268 | * @param {String} strFill A string to fill if it is not long enough 269 | * 270 | * 'x'.padStart(5, 'ab') // 'ababx' 271 | * 272 | * 'x'.padStart(4, 'ab') // 'abax' 273 | * 274 | * '12'.padStart(10, 'YYYY-MM-DD') // "YYYY-MM-12" 275 | * 276 | * '09-12'.padStart(10, 'YYYY-MM-DD') // "YYYY-09-12" 277 | * @returns {String} 278 | */ 279 | PadStart(num: Integer, strFill: String := " ") => String 280 | 281 | /** 282 | * Returns the length of the specified string, if it is long enough to return as is, if it is not long enough to fill from the end, the filling process may truncate strFill 283 | * @param {Integer} num Specifies the length of the string to return 284 | * @param {String} strFill A string to fill if it is not long enough 285 | * 286 | * 'xxx'.padEnd(2, 'ab') // 'xxx' 287 | * 288 | * 'x'.padEnd(4) // 'x ' 289 | * @returns {String} 290 | */ 291 | PadEnd(num: Integer, strFill: String := " ") => String 292 | 293 | /** 294 | * Return duplicate string 295 | * @param {Integer} num times of repetition 296 | * 297 | * 'x'.repeat(3) // "xxx" 298 | * 299 | * 'hello'.repeat(2) // "hellohello" 300 | * @returns {String} 301 | */ 302 | Repeat(num: Integer) => String 303 | 304 | /** 305 | * Removes a substring from a string 306 | * @param {String} value The string to remove 307 | * 308 | * "西瓜太大".Remove("西瓜") // "太大" 309 | * 310 | * @returns {String} 311 | */ 312 | Remove(value: String) => String 313 | 314 | /** 315 | * Remove the substring to the left of the string. If the left side does not match, leave it alone 316 | * @param {String} value The left string to remove 317 | * 318 | * "西瓜太大".RemoveLeft("西瓜") // "太大" 319 | * 320 | * "大西瓜太大".RemoveLeft("西瓜") // "大西瓜太大" 321 | * @returns {String} 322 | */ 323 | RemoveLeft(value: String) => String 324 | 325 | /** 326 | * Remove the substring to the right of the string. If the right side does not match, leave it alone 327 | * @param {String} value 328 | * 329 | * "西瓜太甜".RemoveRight("太甜") // "西瓜" 330 | * @returns {String} 331 | */ 332 | RemoveRight(value: String) => String 333 | 334 | /** 335 | * Path.concat alias, join path, this function will handle some troublesome cases, the path must not contain \ at the end 336 | * @param params 337 | * 338 | * "c:\cbs\".ConcatP("\dds") // "c:\cbs\dds" 339 | * 340 | * "c:\cbs\".ConcatP("\dds\") // "c:\cbs\dds" 341 | * @returns {String} 342 | */ 343 | ConcatP(params*) => String 344 | 345 | /** 346 | * The alias of path.DirName, the path to the folder where the path is obtained 347 | * 348 | * "c:\abc\ddd\efs.txt".DirName() // "c:\abc\ddd" 349 | * @returns {String} 350 | */ 351 | DirName() => String 352 | 353 | /** 354 | * ExtName alias of path.ExtName, which is the file name extension in the path 355 | * @param dot 356 | * 357 | * "c:\abc\ddd\efs.txt".ExtName() // "txt" 358 | * 359 | * "c:\abc\ddd\efs.txt".ExtName(true) // ".txt" 360 | * @returns {String} 361 | */ 362 | ExtName(dot := false) => String 363 | 364 | /** 365 | * BaseName alias to get the name of the file or folder in the path 366 | * @param HasSuffix Whether the suffix is included 367 | * 368 | * "c:\abc\ddd\efs.txt".BaseName() // "efs.txt" 369 | * 370 | * "c:\abc\ddd\efs.txt".BaseName(false) // "efs" 371 | * @returns {String} 372 | */ 373 | BaseName(HasSuffix := true) => String 374 | } -------------------------------------------------------------------------------- /en/time.d.ahk: -------------------------------------------------------------------------------- 1 | class time { 2 | /** 3 | * Gets the number of the current time composition, accurate to milliseconds 4 | * @returns {Integer} 5 | */ 6 | static time() => Integer 7 | } -------------------------------------------------------------------------------- /en/utils.d.ahk: -------------------------------------------------------------------------------- 1 | /** 2 | * Pass in several parameters, print them and wrap them, separated by Spaces 3 | * @param params* 4 | */ 5 | println(params*) => void 6 | 7 | /** 8 | * Pass in several arguments, print them, separated by Spaces, and the function does not wrap lines 9 | * @param params 10 | */ 11 | print(params*) => void -------------------------------------------------------------------------------- /env.ahk: -------------------------------------------------------------------------------- 1 | ; Script Environment.ahk 2 | ; License: MIT License 3 | ; Author: Edison Hua (iseahound) 4 | ; Github: https://github.com/iseahound/Environment.ahk 5 | ; Date 2023-11-04 6 | ; Version 1.3.1 7 | ; 8 | ; ExpandEnvironmentStrings(), RefreshEnvironment() by NoobSawce + DavidBiesack (modified by BatRamboZPM) 9 | ; https://autohotkey.com/board/topic/63312-reload-systemuser-environment-variables/ 10 | ; 11 | ; Global Error Values 12 | ; 0 - Success. 13 | ; The error value "-1" is never returned in v2, instead an OSError is thrown. 14 | ; -2 - Value already added or value already deleted. 15 | ; -3 - Need to Run As Administrator. 16 | ; 17 | ; Notes 18 | ; SendMessage 0x1A, 0, "Environment",, ahk_id 0xFFFF ; 0x1A is WM_SETTINGCHANGE 19 | ; - The above code will broadcast a message stating there has been a change of environment variables. 20 | ; - Some programs have not implemented this message. 21 | ; - v1.00 replaces this with a powershell command using asyncronous execution providing 10x speedup. 22 | ; RefreshEnvironment() 23 | ; - This function will update the environment variables within AutoHotkey. 24 | ; - Command prompts launched by AutoHotkey inherit AutoHotkey's environment. 25 | ; Any command prompts currently open will not have their environment variables changed. 26 | ; - Please use the RefreshEnv.cmd batch script found at: 27 | ; https://github.com/chocolatey-archive/chocolatey/blob/master/src/redirects/RefreshEnv.cmd 28 | 29 | #Requires AutoHotkey v2.0-beta.3+ 30 | 31 | Env_UserAdd(name, value, regType := "", location := "", top := False){ 32 | value := (value ~= "^\.(\.)?\\") ? GetFullPathName(value) : value 33 | location := (location == "") ? "HKCU\Environment" : location 34 | 35 | ; Check if key exists. 36 | try registry := RegRead(location, name) 37 | if IsSet(registry) { 38 | Loop Parse, registry, ";" 39 | if (A_LoopField == value) 40 | return -2 41 | registry := RTrim(registry, ";") 42 | if top 43 | value := value ";" registry 44 | else 45 | value := registry ";" value 46 | } 47 | 48 | ; Create a new registry key. 49 | regType := (regType) ? regType : (value ~= "%") ? "REG_EXPAND_SZ" : "REG_SZ" 50 | RegWrite value, regType, location, name 51 | SettingChange() 52 | RefreshEnvironment() 53 | return 0 54 | } 55 | 56 | Env_SystemAdd(name, value, regType := ""){ 57 | return (A_IsAdmin) ? Env_UserAdd(name, value, regType, "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment") : -3 58 | } 59 | 60 | Env_UserAddTop(name, value, regType := "", location := ""){ 61 | return Env_UserAdd(name, value, regType, location, True) 62 | } 63 | 64 | Env_SystemAddTop(name, value, regType := ""){ 65 | return (A_IsAdmin) ? Env_UserAddTop(name, value, regType, "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment") : -3 66 | } 67 | 68 | Env_UserSub(name, value, regType := "", location := ""){ 69 | value := (value ~= "^\.(\.)?\\") ? GetFullPathName(value) : value 70 | location := (location == "") ? "HKCU\Environment" : location 71 | 72 | registry := RegRead(location, name) 73 | output := "" 74 | 75 | 76 | Loop Parse, registry, ";" 77 | if (A_LoopField != value) { 78 | output .= (A_Index > 1 && output != "") ? ";" : "" 79 | output .= A_LoopField 80 | } 81 | 82 | if (output == registry) 83 | return -2 84 | 85 | if (output != "") { 86 | regType := (regType) ? regType : (output ~= "%") ? "REG_EXPAND_SZ" : "REG_SZ" 87 | RegWrite output, regType, location, name 88 | } 89 | else 90 | RegDelete location, name 91 | SettingChange() 92 | RefreshEnvironment() 93 | return 0 94 | } 95 | 96 | Env_SystemSub(name, value, regType := ""){ 97 | return (A_IsAdmin) ? Env_UserSub(name, value, regType, "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment") : -3 98 | } 99 | 100 | Env_UserNew(name, value := "", regType := "", location := ""){ 101 | value := (value ~= "^\.(\.)?\\") ? GetFullPathName(value) : value 102 | regType := (regType) ? regType : (value ~= "%") ? "REG_EXPAND_SZ" : "REG_SZ" 103 | RegWrite value, regType, (location == "") ? "HKCU\Environment" : location, name 104 | SettingChange() 105 | RefreshEnvironment() 106 | return 0 107 | } 108 | 109 | Env_SystemNew(name, value := "", regType := ""){ 110 | return (A_IsAdmin) ? Env_UserNew(name, value, regType, "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment") : -3 111 | } 112 | 113 | ; Value does nothing except let me easily change between functions. 114 | Env_UserDel(name, value := "", location := ""){ 115 | RegDelete (location == "") ? "HKCU\Environment" : location, name 116 | SettingChange() 117 | RefreshEnvironment() 118 | return 0 119 | } 120 | 121 | Env_SystemDel(name, value := ""){ 122 | return (A_IsAdmin) ? Env_UserDel(name, value, "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment") : -3 123 | } 124 | 125 | Env_UserRead(name, value := "", location := ""){ 126 | registry := RegRead((location == "") ? "HKCU\Environment" : location, name) 127 | if (value != "") { 128 | Loop Parse, registry, ";" 129 | if (A_LoopField = value) 130 | return A_LoopField 131 | return ; Value not found 132 | } 133 | return registry 134 | } 135 | 136 | Env_SystemRead(name, value := ""){ 137 | return Env_UserRead(name, value, "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment") 138 | } 139 | 140 | ; Value does nothing except let me easily change between functions. 141 | Env_UserSort(name, value := "", location := ""){ 142 | registry := RegRead((location == "") ? "HKCU\Environment" : location, name) 143 | registry := Sort(registry, "D;") 144 | regType := (registry ~= "%") ? "REG_EXPAND_SZ" : "REG_SZ" 145 | RegWrite registry, regType, (location == "") ? "HKCU\Environment" : location, name 146 | return 0 147 | } 148 | 149 | Env_SystemSort(name, value := ""){ 150 | return (A_IsAdmin) ? Env_UserSort(name, value, "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment") : -3 151 | } 152 | 153 | ; Value does nothing except let me easily change between functions. 154 | Env_UserRemoveDuplicates(name, value := "", location := ""){ 155 | registry := RegRead((location == "") ? "HKCU\Environment" : location, name) 156 | registry := Sort(registry, "U D;") 157 | regType := (regType) ? regType : (registry ~= "%") ? "REG_EXPAND_SZ" : "REG_SZ" 158 | RegWrite registry, regType, (location == "") ? "HKCU\Environment" : location, name 159 | return 0 160 | } 161 | 162 | Env_SystemRemoveDuplicates(name, value := ""){ 163 | return (A_IsAdmin) ? Env_UserRemoveDuplicates(name, value, "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment") : -3 164 | } 165 | 166 | Env_UserBackup(fileName := "UserEnvironment.reg", location := ""){ 167 | _cmd .= (A_Is64bitOS != A_PtrSize >> 3) ? A_WinDir "\SysNative\cmd.exe" : A_ComSpec 168 | _cmd .= " /K " Chr(0x22) "reg export " Chr(0x22) 169 | _cmd .= (location == "") ? "HKCU\Environment" : location 170 | _cmd .= Chr(0x22) " " Chr(0x22) 171 | _cmd .= fileName 172 | _cmd .= Chr(0x22) . Chr(0x22) . " && pause && exit" 173 | try RunWait _cmd 174 | catch 175 | return "FAIL" 176 | return "SUCCESS" 177 | } 178 | 179 | Env_SystemBackup(fileName := "SystemEnvironment.reg"){ 180 | return Env_UserBackup(fileName, "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment") 181 | } 182 | 183 | Env_UserRestore(fileName := "UserEnvironment.reg"){ 184 | try RunWait fileName 185 | catch 186 | return "FAIL" 187 | return "SUCCESS" 188 | } 189 | 190 | Env_SystemRestore(fileName := "SystemEnvironment.reg"){ 191 | try RunWait fileName 192 | catch 193 | return "FAIL" 194 | return "SUCCESS" 195 | } 196 | 197 | 198 | RefreshEnvironment() 199 | { 200 | Path := "" 201 | PathExt := "" 202 | RegKeys := "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment,HKCU\Environment" 203 | Loop Parse, RegKeys, "CSV" 204 | { 205 | Loop Reg, A_LoopField, "V" 206 | { 207 | Value := RegRead() 208 | If (A_LoopRegType == "REG_EXPAND_SZ" && !ExpandEnvironmentStrings(&Value)) 209 | Continue 210 | If (A_LoopRegName = "PATH") 211 | Path .= Value . ";" 212 | Else If (A_LoopRegName = "PATHEXT") 213 | PathExt .= Value . ";" 214 | Else 215 | EnvSet A_LoopRegName, Value 216 | } 217 | } 218 | EnvSet "PATH", Path 219 | EnvSet "PATHEXT", PathExt 220 | } 221 | 222 | ExpandEnvironmentStrings(&vInputString) 223 | { 224 | ; get the required size for the expanded string 225 | vSizeNeeded := DllCall("ExpandEnvironmentStrings", "Str", vInputString, "Int", 0, "Int", 0) 226 | If (vSizeNeeded == "" || vSizeNeeded <= 0) 227 | return False ; unable to get the size for the expanded string for some reason 228 | 229 | vByteSize := vSizeNeeded + 1 230 | VarSetStrCapacity(&vTempValue, vByteSize) 231 | 232 | ; attempt to expand the environment string 233 | If (!DllCall("ExpandEnvironmentStrings", "Str", vInputString, "Str", vTempValue, "Int", vSizeNeeded)) 234 | return False ; unable to expand the environment string 235 | vInputString := vTempValue 236 | 237 | ; return success 238 | Return True 239 | } 240 | 241 | GetFullPathName(path) { 242 | cc := DllCall("GetFullPathName", "str", path, "uint", 0, "ptr", 0, "ptr", 0, "uint") 243 | VarSetStrCapacity(&buf, cc) 244 | DllCall("GetFullPathName", "str", path, "uint", cc, "str", buf, "ptr", 0, "uint") 245 | return buf 246 | } 247 | 248 | 249 | ; Source: https://gist.github.com/alphp/78fffb6d69e5bb863c76bbfc767effda 250 | /* 251 | $Script = @' 252 | Add-Type -Namespace Win32 -Name NativeMethods -MemberDefinition @" 253 | [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] 254 | public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam, uint fuFlags, uint uTimeout, out UIntPtr lpdwResult); 255 | "@ 256 | 257 | function Send-SettingChange { 258 | $HWND_BROADCAST = [IntPtr] 0xffff; 259 | $WM_SETTINGCHANGE = 0x1a; 260 | $result = [UIntPtr]::Zero 261 | 262 | [void] ([Win32.Nativemethods]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [UIntPtr]::Zero, "Environment", 2, 5000, [ref] $result)) 263 | } 264 | 265 | Send-SettingChange; 266 | '@ 267 | 268 | $ByteScript = [System.Text.Encoding]::Unicode.GetBytes($Script) 269 | [System.Convert]::ToBase64String($ByteScript) 270 | */ 271 | 272 | ; To verify the encoded command, start a powershell terminal and paste the script above. 273 | ; 10x faster than SendMessage 0x1A, 0, "Environment",, ahk_id 0xFFFF ; 0x1A is WM_SETTINGCHANGE 274 | SettingChange() { 275 | 276 | static _cmd := " 277 | ( LTrim 278 | QQBkAGQALQBUAHkAcABlACAALQBOAGEAbQBlAHMAcABhAGMAZQAgAFcAaQBuADMA 279 | MgAgAC0ATgBhAG0AZQAgAE4AYQB0AGkAdgBlAE0AZQB0AGgAbwBkAHMAIAAtAE0A 280 | ZQBtAGIAZQByAEQAZQBmAGkAbgBpAHQAaQBvAG4AIABAACIACgAgACAAWwBEAGwA 281 | bABJAG0AcABvAHIAdAAoACIAdQBzAGUAcgAzADIALgBkAGwAbAAiACwAIABTAGUA 282 | dABMAGEAcwB0AEUAcgByAG8AcgAgAD0AIAB0AHIAdQBlACwAIABDAGgAYQByAFMA 283 | ZQB0ACAAPQAgAEMAaABhAHIAUwBlAHQALgBBAHUAdABvACkAXQAKACAAIABwAHUA 284 | YgBsAGkAYwAgAHMAdABhAHQAaQBjACAAZQB4AHQAZQByAG4AIABJAG4AdABQAHQA 285 | cgAgAFMAZQBuAGQATQBlAHMAcwBhAGcAZQBUAGkAbQBlAG8AdQB0ACgASQBuAHQA 286 | UAB0AHIAIABoAFcAbgBkACwAIAB1AGkAbgB0ACAATQBzAGcALAAgAFUASQBuAHQA 287 | UAB0AHIAIAB3AFAAYQByAGEAbQAsACAAcwB0AHIAaQBuAGcAIABsAFAAYQByAGEA 288 | bQAsACAAdQBpAG4AdAAgAGYAdQBGAGwAYQBnAHMALAAgAHUAaQBuAHQAIAB1AFQA 289 | aQBtAGUAbwB1AHQALAAgAG8AdQB0ACAAVQBJAG4AdABQAHQAcgAgAGwAcABkAHcA 290 | UgBlAHMAdQBsAHQAKQA7AAoAIgBAAAoACgBmAHUAbgBjAHQAaQBvAG4AIABTAGUA 291 | bgBkAC0AUwBlAHQAdABpAG4AZwBDAGgAYQBuAGcAZQAgAHsACgAgACAAJABIAFcA 292 | TgBEAF8AQgBSAE8AQQBEAEMAQQBTAFQAIAA9ACAAWwBJAG4AdABQAHQAcgBdACAA 293 | MAB4AGYAZgBmAGYAOwAKACAAIAAkAFcATQBfAFMARQBUAFQASQBOAEcAQwBIAEEA 294 | TgBHAEUAIAA9ACAAMAB4ADEAYQA7AAoAIAAgACQAcgBlAHMAdQBsAHQAIAA9ACAA 295 | WwBVAEkAbgB0AFAAdAByAF0AOgA6AFoAZQByAG8ACgAKACAAIABbAHYAbwBpAGQA 296 | XQAgACgAWwBXAGkAbgAzADIALgBOAGEAdABpAHYAZQBtAGUAdABoAG8AZABzAF0A 297 | OgA6AFMAZQBuAGQATQBlAHMAcwBhAGcAZQBUAGkAbQBlAG8AdQB0ACgAJABIAFcA 298 | TgBEAF8AQgBSAE8AQQBEAEMAQQBTAFQALAAgACQAVwBNAF8AUwBFAFQAVABJAE4A 299 | RwBDAEgAQQBOAEcARQAsACAAWwBVAEkAbgB0AFAAdAByAF0AOgA6AFoAZQByAG8A 300 | LAAgACIARQBuAHYAaQByAG8AbgBtAGUAbgB0ACIALAAgADIALAAgADUAMAAwADAA 301 | LAAgAFsAcgBlAGYAXQAgACQAcgBlAHMAdQBsAHQAKQApAAoAfQAKAAoAUwBlAG4A 302 | ZAAtAFMAZQB0AHQAaQBuAGcAQwBoAGEAbgBnAGUAOwA= 303 | )" 304 | Run "powershell -NoProfile -EncodedCommand " _cmd,, "Hide" 305 | } -------------------------------------------------------------------------------- /map.ahk: -------------------------------------------------------------------------------- 1 | ; 这里主要复写ToString方法即可,其他的不做处理 2 | 3 | (Map.Prototype).DefineProp("ToString", { Call: __MapToString}) 4 | 5 | __MapToString(m){ 6 | return "Map(" ({}).ToString.Bind(m)() ")" 7 | } -------------------------------------------------------------------------------- /number.ahk: -------------------------------------------------------------------------------- 1 | ;@include en\number.d.ahk 2 | ;@include zh\number.d.ahk 3 | __DefProp := {}.DefineProp 4 | __DefProp(1.Base, 'ToChar', {Call: __NumberToChar}) ; 数字转字符 5 | __DefProp(1.Base, 'ToString', {Call: __NumberToString}) ; 数字转字符 6 | 7 | ; todo 还缺少进制转换相关函数 8 | 9 | __NumberToChar(num){ 10 | return Chr(num) 11 | } 12 | 13 | __NumberToString(num){ 14 | return String(num) 15 | } -------------------------------------------------------------------------------- /object.ahk: -------------------------------------------------------------------------------- 1 | 2 | ;@include en\object.d.ahk 3 | ;@include zh\object.d.ahk 4 | 5 | if !IsSet(UIA) { 6 | ({}.Base).DefineProp("__Enum", { Call: (obj, *) => obj.OwnProps()}) 7 | ({}.Base).DefineProp("__Item", { get: (obj, k) => obj.%k%, set: (obj, v, k) => obj.%k% := v}) 8 | } 9 | 10 | ({}.Base).DefineProp("Keys", { Call: __ObjectKeys }) 11 | ({}.Base).DefineProp("Values", { Call: __ObjectValues }) 12 | ({}.Base).DefineProp("Items", { Call: __ObjectItems }) 13 | ({}.Base).DefineProp("ToString", { Call: __ObjectToString }) 14 | ({}.Base).DefineProp("Length", { get: (obj, *) => obj.Keys().Length }) 15 | ({}.Base).DefineProp("Has", { Call: __ObjectHas }) 16 | ({}.Base).DefineProp("Contains", { Call: __ObjectContains }) 17 | ({}.Base).DefineProp("Merge", { Call: __ObjectMerge }) 18 | 19 | 20 | 21 | __ObjectMerge(obj, params*){ 22 | for oitem in params { 23 | for k, v in oitem { 24 | obj[k] := v 25 | } 26 | } 27 | return obj 28 | } 29 | 30 | __ObjectHas(obj, prop){ 31 | return obj.HasOwnProp(prop) 32 | } 33 | 34 | __ObjectContains(obj, prop, cases := true){ ; cases 表示是否大小写敏感 35 | if cases { 36 | return obj.HasOwnProp(prop) 37 | } 38 | for key, _ in obj { 39 | if prop = key { 40 | return true 41 | } 42 | } 43 | return false 44 | 45 | } 46 | 47 | __ObjectEnum(obj, paramNum){ 48 | EnumFn := obj.OwnProps() 49 | return innerEnum 50 | innerEnum(&arg1, &arg2?){ 51 | if paramNum == 1 { 52 | flag := EnumFn(&innerArg1) 53 | if !flag { 54 | return flag 55 | } 56 | arg1 := obj.%innerArg1% 57 | }else if paramNum == 2 { 58 | flag := EnumFn(&arg1, &arg2) 59 | if !flag { 60 | return flag 61 | } 62 | } 63 | } 64 | } 65 | 66 | 67 | __ObjectKeys(obj){ 68 | arr := [] 69 | for key in obj { 70 | arr.Push(key) 71 | } 72 | return arr 73 | } 74 | 75 | __ObjectValues(obj){ 76 | arr := [] 77 | for _, value in obj { 78 | arr.Push(value) 79 | } 80 | return arr 81 | } 82 | 83 | __ObjectItems(obj){ 84 | arr := [] 85 | for k, v in obj { 86 | arr.Push({key: k, value: v}) 87 | } 88 | return arr 89 | } 90 | 91 | __ObjectToString(obj){ 92 | o := "{ " 93 | for k, v in obj { 94 | o := o.Concat( 95 | k, 96 | ": ", 97 | type(v) == "String" ? v.wrap('"') : String(v), 98 | ", " 99 | ) 100 | } 101 | if o[-2, -1] == ", " { 102 | o := o[1, -3] 103 | } 104 | o := o " }" 105 | return o 106 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ahk-stdlib", 3 | "version": "0.0.6", 4 | "description": "autohotkey语言的标准库,目标是提供更好的数据结构操作体验.项目开源,欢迎参与.", 5 | "main": "stdlib.ahk", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": ["AutoHotkey", "AHK", "stdlib"], 10 | "author": "Autumn-one", 11 | "license": "ISC" 12 | } -------------------------------------------------------------------------------- /path.ahk: -------------------------------------------------------------------------------- 1 | #Include string.ahk 2 | class path{ 3 | /** 4 | * 连接路径,这个函数会处理一些一些麻烦情况,路径的最后一定不含\ 5 | * Join the path, this function will handle some troublesome cases, the path must not contain \ at the end 6 | * @param {Array} params* 7 | * 8 | * path.Concat("c:\cbs\", "\dds") // "c:\cbs\dds" 9 | * 10 | * path.Concat("c:\cbs\", "\dds\") // "c:\cbs\dds" 11 | * @returns {String} 12 | */ 13 | static Concat(params*){ 14 | output := "" 15 | prevEndBias := true ; 上一个是否以反斜杠结尾 16 | for item in params { 17 | ; 解决相对路径的拼接问题,例如 .\ 18 | if item.StartsWith(".\") { 19 | item := item[2, -1] 20 | } 21 | if prevEndBias { 22 | output := item.StartsWith("\") ? output.Concat(item[2, -1]) : output.Concat(item) 23 | }else{ 24 | output := item.StartsWith("\") ? output.Concat(item) : output.Concat("\", item) 25 | } 26 | if item.EndsWith("\") { 27 | prevEndBias := true 28 | }else{ 29 | prevEndBias := false 30 | } 31 | } 32 | if output.EndsWith("\"){ 33 | return output[1, -2] 34 | } 35 | return output 36 | } 37 | 38 | /** 39 | * 获取路径的文件夹路径 40 | * Obtain path Folder path 41 | * @param {String} pathStr 42 | * 43 | * path.DirName("c:\abc\ddd\efs.txt") // "c:\abc\ddd" 44 | * @returns {String} 45 | */ 46 | static DirName(pathStr){ 47 | arr := pathStr.RemoveRight("\").Split("\")[1, -2] 48 | if arr.Length == 0{ 49 | return "" 50 | } 51 | return arr.Join("\") 52 | } 53 | 54 | /** 55 | * 获取路径中文件的后缀名 56 | * Gets the file name extension in the path 57 | * @param {String} pathStr 58 | * 59 | * path.ExtName("c:\abc\ddd\efs.txt") // "txt" 60 | * @returns {String} 61 | */ 62 | static ExtName(pathStr, Dot := false){ 63 | temp := pathStr.RemoveRight("\").Split("\")[-1] 64 | arr := temp.Split(".") 65 | if arr.length <= 1 || arr.length == 2 && arr[1] == "" { 66 | return "" 67 | } 68 | return Dot ? "." arr[-1] : arr[-1] 69 | } 70 | 71 | /** 72 | * 获取路径中的文件或文件夹名称 73 | * Gets the name of the file or folder in the path 74 | * @param {String} PathStr 75 | * @param {String} HasSuffix 是否包含后缀 76 | * 77 | * path.BaseName("c:\abc\ddd\efs.txt") // "efs.txt" 78 | * 79 | * path.BaseName("c:\abc\ddd\efs.txt", false) // "efs" 80 | * @returns {String} 81 | */ 82 | static BaseName(pathStr, HasSuffix := true){ 83 | s := pathStr.RemoveRight("\").Split("\")[-1] 84 | return HasSuffix ? s : s.Split(".")[1] 85 | } 86 | } -------------------------------------------------------------------------------- /stdlib.ahk: -------------------------------------------------------------------------------- 1 | #Include string.ahk 2 | #Include utils.ahk 3 | #Include object.ahk 4 | #Include array.ahk 5 | #Include number.ahk 6 | #Include path.ahk 7 | #Include map.ahk 8 | #Include time.ahk -------------------------------------------------------------------------------- /string.ahk: -------------------------------------------------------------------------------- 1 | ; 让字符串具备基本的数组访问行为和可循环可切片的行为 2 | #Requires AutoHotkey v2.0 3 | #Include utils.ahk 4 | ;@include "en\string.d.ahk" 5 | ;@include "zh\string.d.ahk" 6 | #Include path.ahk 7 | __StrTemp(str, vars*) 8 | { 9 | for var in vars 10 | str := StrReplace(str, '{' NameOf(&%var%) '}', %var%) 11 | return str 12 | ; https://github.com/thqby/ahk2_lib/blob/master/nameof.ahk 13 | NameOf(&value) => StrGet(NumGet(ObjPtr(&value) + 8 + 6 * A_PtrSize, 'Ptr'), 'UTF-16') 14 | } 15 | 16 | __DefProp := {}.DefineProp 17 | __DefProp("".Base, '__Enum', {Call: __StrEnum}) 18 | __DefProp("".Base, '__Item', {get: __StrItemGet, set: __StrItemSet}) 19 | __DefProp("".Base, 'Split', {Call: __StrSplit}) 20 | __DefProp("".Base, 'SplitRight', {Call: __StrSplitRight}) 21 | __DefProp("".Base, 'Length', {get: __StrLength}) 22 | __DefProp("".Base, 'StartsWith', {Call: __StrStartsWith}) 23 | __DefProp("".Base, 'EndsWith', {Call: __StrEndsWith}) 24 | __DefProp("".Base, 'Includes', {Call: __StrIncludes}) 25 | __DefProp("".Base, 'IncludeSome', {Call: __StrIncludeSome}) 26 | __DefProp("".Base, 'IncludeEvery', {Call: __StrIncludeEvery}) 27 | __DefProp("".Base, 'IndexOf', {Call: __StrIndexOf}) 28 | __DefProp("".Base, 'IndexOfAll', {Call: __StrIndexOfAll}) 29 | __DefProp("".Base, 'LastIndexOf', {Call: __StrLastIndexOf}) 30 | __DefProp("".Base, 'Trim', {Call: __StrTrim}) 31 | __DefProp("".Base, 'TrimLeft', {Call: __StrTrimLeft}) 32 | __DefProp("".Base, 'TrimRight', {Call: __StrTrimRight}) 33 | __DefProp("".Base, 'CharCodeAt', {Call: __StrCharCodeAt}) 34 | __DefProp("".Base, 'CodeAt', {Call: __StrCharCodeAt}) 35 | __DefProp("".Base, 'Concat', {Call: __StrConcat}) 36 | __DefProp("".Base, 'Wrap', {Call: __StrWrap}) 37 | __DefProp("".Base, 'ToString', {Call: __StrToString}) 38 | __DefProp("".Base, 'Replace', {Call: __StrReplace}) 39 | __DefProp("".Base, 'Reverse', {Call: __StrReverse}) 40 | __DefProp("".Base, 'ToCode', {Call: __StrToCode}) 41 | __DefProp("".Base, 'ToCodes', {Call: __StrToCodes}) 42 | __DefProp("".Base, 'ToLower', {Call: (str) => StrLower(str)}) 43 | __DefProp("".Base, 'ToUpper', {Call: (str) => StrUpper(str)}) 44 | __DefProp("".Base, 'ToTitle', {Call: (str) => StrTitle(str)}) 45 | __DefProp("".Base, 'padStart', {Call: __StrPadStart}) 46 | __DefProp("".Base, 'padEnd', {Call: __StrPadEnd}) 47 | __DefProp("".Base, 'repeat', {Call: __StrRepeat}) 48 | __DefProp("".Base, 'Format', {Call: (str, params*) => Format(str, params*)}) 49 | __DefProp("".Base, 'Templ', {Call: __StrTemp}) 50 | __DefProp("".Base, 'Remove', {Call: (str, value) => value == "" ? str : StrReplace(str, value, unset, true)}) 51 | __DefProp("".Base, 'RemoveLeft', {Call: __StrRemoveLeft}) 52 | __DefProp("".Base, 'RemoveRight', {Call: __StrRemoveRight}) 53 | 54 | ; path相关的方法 55 | __DefProp("".Base, 'ConcatP', {Call: (str, params*) => path.Concat(str,params*)}) 56 | __DefProp("".Base, 'DirName', {Call: (str) => path.DirName(str)}) 57 | __DefProp("".Base, 'ExtName', {Call: (str, dot := false) => path.ExtName(str, dot)}) 58 | __DefProp("".Base, 'BaseName', {Call: (str, HasSuffix := true) => path.BaseName(str, HasSuffix)}) 59 | 60 | __StrRemoveLeft(str, value){ 61 | if value == "" { 62 | return str 63 | } 64 | if str.StartsWith(value){ 65 | return str[value.length + 1, -1] 66 | } 67 | return str 68 | } 69 | 70 | __StrRemoveRight(str, value){ 71 | if value == "" { 72 | return str 73 | } 74 | if str.EndsWith(value) { 75 | return str[1, str.length - value.length] 76 | } 77 | return str 78 | } 79 | 80 | __StrPadStart(str, num, fillStr := " ") { 81 | output := "" 82 | len := str.Length 83 | fillLen := fillStr.Length 84 | if len >= num { 85 | return str 86 | } 87 | if (mul := (num - len) // fillLen) >= 1{ 88 | output := fillStr.Repeat(mul) . str 89 | }else{ 90 | output := str 91 | } 92 | output := fillStr[1, num - output.length] . output 93 | return output 94 | } 95 | 96 | 97 | __StrPadEnd(str, num, fillStr := " ") { 98 | output := "" 99 | len := str.Length 100 | fillLen := fillStr.Length 101 | if len >= num { 102 | return str 103 | } 104 | if (mul := (num - len) // fillLen) >= 1{ 105 | output := str . fillStr.Repeat(mul) 106 | }else{ 107 | output := str 108 | } 109 | output := output . fillStr[1, num - output.length] 110 | return output 111 | } 112 | 113 | 114 | __StrRepeat(str, num){ 115 | output := "" 116 | loop num { 117 | output := output . str 118 | } 119 | 120 | return output 121 | } 122 | 123 | 124 | __StrEnum(str, paramNum) { 125 | index := 0, len := StrLen(str) 126 | return Enumerator 127 | 128 | Enumerator(&k, &v?) { 129 | char := SubStr(str, ++index, 1) 130 | if paramNum == 1 { 131 | k := char 132 | } else { 133 | k := index 134 | v := char 135 | } 136 | return index <= len 137 | } 138 | } 139 | 140 | __StrItemGet(str, params*) { 141 | len := StrLen(str) 142 | for index, item in params { 143 | if item < 0 { 144 | params[index] := len + item + 1 145 | } 146 | } 147 | if params.Length == 1 { 148 | return SubStr(str, params[1], 1) 149 | }else if params.Length == 2 { 150 | if params[1] > params[2] { 151 | start := params[2] 152 | end := params[1] 153 | } else { 154 | start := params[1] 155 | end := params[2] 156 | } 157 | return SubStr(str, start, end - start + 1) 158 | }else{ 159 | Throw IndexError("多余的索引") 160 | } 161 | } 162 | 163 | __StrItemSet(str, params*){ 164 | ; 对字符串设置不会产生任何的效果 165 | } 166 | 167 | __StrToCode(str){ 168 | output := "" 169 | for item in str { 170 | output := output.Concat(Ord(item)) 171 | } 172 | return output * 1 173 | } 174 | __StrToCodes(str){ 175 | newArr := [] 176 | for item in str { 177 | newArr.Push(Ord(item)) 178 | } 179 | return newArr 180 | } 181 | 182 | __StrSplit(str, separator, count := -1){ 183 | if count != -1{ 184 | count++ 185 | } 186 | return StrSplit(str, separator, unset, count) 187 | } 188 | 189 | __StrSplitRight(str, seqator, count := -1){ 190 | if count == 0 { 191 | return [str] 192 | } 193 | /**@type {Array} */ 194 | arr := str.Split(seqator) 195 | if count == -1 { 196 | return arr 197 | } 198 | newArr := [] 199 | loop arr.Length { 200 | if A_Index <= count { 201 | newArr.UnShift(arr.Pop()) 202 | } 203 | } 204 | (arr.length != 0) && newArr.UnShift(arr.Join(seqator)) 205 | return newArr 206 | } 207 | 208 | __StrLength(str){ 209 | return StrLen(str) 210 | } 211 | 212 | __StrStartsWith(str, startStr, caseSense := true){ 213 | return InStr(str, startStr, caseSense) == 1 214 | } 215 | 216 | __StrEndsWith(str, endStr, caseSense := true){ 217 | return InStr(str, endStr, caseSense, -1) == StrLen(str) - StrLen(endStr) + 1 218 | } 219 | 220 | __StrIncludes(str, v, caseSense:= true){ 221 | return InStr(str, v, caseSense) != 0 222 | } 223 | 224 | __StrIncludeSome(str, params*){ 225 | return params.Some(item => str.Includes(item), true) 226 | } 227 | 228 | __StrIncludeEvery(str, params*){ 229 | return params.Every(item => str.Includes(item), true) 230 | } 231 | 232 | __StrIndexOf(str, v, caseSense := true){ 233 | return InStr(str, v, caseSense) 234 | } 235 | 236 | __StrIndexOfAll(str, v, caseSense := true){ 237 | newArr := [] 238 | innerStr := str 239 | sublen := v.Length 240 | count := 0 241 | while i := innerStr.IndexOf(v) { 242 | if i != 0{ 243 | newArr.Push(i + count) 244 | count := count + i + sublen 245 | i := i + sublen + 1 246 | if i + sublen > innerStr.Length{ 247 | break 248 | } 249 | innerStr := innerStr[i, -1] 250 | }else{ 251 | break 252 | } 253 | } 254 | return newArr 255 | } 256 | 257 | __StrLastIndexOf(str, v, caseSense := true) { 258 | return InStr(str, v, caseSense, -1) 259 | } 260 | 261 | __StrTrim(str, omitChars?){ 262 | return Trim(str, IsSet(omitChars) ? omitChars : unset) 263 | } 264 | 265 | __StrTrimLeft(str, omitChars?){ 266 | return LTrim(str, IsSet(omitChars) ? omitChars : unset) 267 | } 268 | 269 | __StrTrimRight(str, omitChars?){ 270 | return RTrim(str, IsSet(omitChars) ? omitChars : unset) 271 | } 272 | 273 | __StrCharCodeAt(str, i){ 274 | return Ord(str[i]) 275 | } 276 | 277 | __StrConcat(str, params*){ 278 | o := str 279 | for item in params { 280 | o := o . item 281 | } 282 | return o 283 | } 284 | 285 | __StrWrap(str, ch){ 286 | return ch str ch 287 | } 288 | 289 | __StrToString(str){ 290 | return str.Wrap('"') 291 | } 292 | 293 | __StrReplace(str, params*){ 294 | return StrReplace(str, params*) 295 | } 296 | 297 | __StrReverse(str){ 298 | return str.Split().Reverse().Join("") 299 | } -------------------------------------------------------------------------------- /time.ahk: -------------------------------------------------------------------------------- 1 | ;@include en\time.d.ahk 2 | ;@include zh\time.d.ahk 3 | class time { 4 | static Now(){ 5 | return (A_Now A_MSec) * 1 6 | } 7 | } -------------------------------------------------------------------------------- /utils.ahk: -------------------------------------------------------------------------------- 1 | /** 2 | * 传入若干个参数,打印这些参数并换行,参数之间空格分隔 3 | * @param params* 4 | */ 5 | println(params*){ 6 | if !DllCall("GetStdHandle", "uint", -11, "ptr"){ 7 | ; OpenConsole() 8 | return 9 | } 10 | output := "" 11 | lastChar := params.Pop() 12 | for item in params { 13 | output := output.Concat( 14 | String(item), 15 | " " 16 | ) 17 | } 18 | output := output.Concat(String(lastChar), "`n") 19 | ; FileAppend output, "*" 20 | FileAppend output, "*", "utf-8" 21 | } 22 | 23 | /** 24 | * 传入若干个参数,打印这些参数, 参数之间空格分隔,这个函数不会换行 25 | * @param params 26 | */ 27 | print(params*){ 28 | if !DllCall("GetStdHandle", "uint", -11, "ptr"){ 29 | return 30 | } 31 | lastChar := params.Pop() 32 | for item in params { 33 | FileAppend String(item) " ", "*", "utf-8" 34 | } 35 | FileAppend String(lastChar), "*", "utf-8" 36 | } 37 | 38 | OpenConsole(){ 39 | if !DllCall("GetStdHandle", "uint", -11, "ptr") 40 | DllCall("AllocConsole") 41 | } 42 | 43 | HasConsole(){ 44 | return DllCall("GetStdHandle", "uint", -11, "ptr") 45 | } 46 | 47 | 48 | ; HashFile by Deo 49 | ; https://autohotkey.com/board/topic/66139-ahk-l-calculating-md5sha-checksum-from-file/ 50 | ; Modified for AutoHotkey v2 by lexikos. 51 | 52 | 53 | /* 54 | HASH types: 55 | 1 - MD2 56 | 2 - MD5 57 | 3 - SHA 58 | 4 - SHA256 59 | 5 - SHA384 60 | 6 - SHA512 61 | */ 62 | HashFile(filePath, hashType:=2) 63 | { 64 | static PROV_RSA_AES := 24 65 | static CRYPT_VERIFYCONTEXT := 0xF0000000 66 | static BUFF_SIZE := 1024 * 1024 ; 1 MB 67 | static HP_HASHVAL := 0x0002 68 | static HP_HASHSIZE := 0x0004 69 | 70 | switch hashType { 71 | case 1: hash_alg := (CALG_MD2 := 32769) 72 | case 2: hash_alg := (CALG_MD5 := 32771) 73 | case 3: hash_alg := (CALG_SHA := 32772) 74 | case 4: hash_alg := (CALG_SHA_256 := 32780) 75 | case 5: hash_alg := (CALG_SHA_384 := 32781) 76 | case 6: hash_alg := (CALG_SHA_512 := 32782) 77 | default: throw ValueError('Invalid hashType', -1, hashType) 78 | } 79 | 80 | f := FileOpen(filePath, "r") 81 | f.Pos := 0 ; Rewind in case of BOM. 82 | 83 | HCRYPTPROV() => { 84 | ptr: 0, 85 | __delete: this => this.ptr && DllCall("Advapi32\CryptReleaseContext", "Ptr", this, "UInt", 0) 86 | } 87 | 88 | if !DllCall("Advapi32\CryptAcquireContextW" 89 | , "Ptr*", hProv := HCRYPTPROV() 90 | , "Uint", 0 91 | , "Uint", 0 92 | , "Uint", PROV_RSA_AES 93 | , "UInt", CRYPT_VERIFYCONTEXT) 94 | throw OSError() 95 | 96 | HCRYPTHASH() => { 97 | ptr: 0, 98 | __delete: this => this.ptr && DllCall("Advapi32\CryptDestroyHash", "Ptr", this) 99 | } 100 | 101 | if !DllCall("Advapi32\CryptCreateHash" 102 | , "Ptr", hProv 103 | , "Uint", hash_alg 104 | , "Uint", 0 105 | , "Uint", 0 106 | , "Ptr*", hHash := HCRYPTHASH()) 107 | throw OSError() 108 | 109 | read_buf := Buffer(BUFF_SIZE, 0) 110 | 111 | While (cbCount := f.RawRead(read_buf, BUFF_SIZE)) 112 | { 113 | if !DllCall("Advapi32\CryptHashData" 114 | , "Ptr", hHash 115 | , "Ptr", read_buf 116 | , "Uint", cbCount 117 | , "Uint", 0) 118 | throw OSError() 119 | } 120 | 121 | if !DllCall("Advapi32\CryptGetHashParam" 122 | , "Ptr", hHash 123 | , "Uint", HP_HASHSIZE 124 | , "Uint*", &HashLen := 0 125 | , "Uint*", &HashLenSize := 4 126 | , "UInt", 0) 127 | throw OSError() 128 | 129 | bHash := Buffer(HashLen, 0) 130 | if !DllCall("Advapi32\CryptGetHashParam" 131 | , "Ptr", hHash 132 | , "Uint", HP_HASHVAL 133 | , "Ptr", bHash 134 | , "Uint*", &HashLen 135 | , "UInt", 0 ) 136 | throw OSError() 137 | 138 | loop HashLen 139 | HashVal .= Format('{:02x}', (NumGet(bHash, A_Index-1, "UChar")) & 0xff) 140 | 141 | return HashVal 142 | } 143 | 144 | 145 | /** 146 | * 获取本地操作系统的语言 中文是 zh-CN 147 | */ 148 | GetLocaleLanguage(){ 149 | LOCALE_NAME_MAX_LENGTH:=85 150 | lpLocaleName:=Buffer(bufferSize:=LOCALE_NAME_MAX_LENGTH*A_PtrSize, 0) 151 | length:=DllCall("Kernel32\GetUserDefaultLocaleName", "Ptr",lpLocaleName.Ptr, "Int",cchLocaleName:=LOCALE_NAME_MAX_LENGTH, "Int") 152 | return StrGet(lpLocaleName.Ptr, length, "UTF-16") 153 | } -------------------------------------------------------------------------------- /zh/array.d.ahk: -------------------------------------------------------------------------------- 1 | /** @extends {#Array} */ 2 | class Array { 3 | /** 4 | * 判断一个数组是否包含某个项目, 返回一个布尔值 0 或 1 5 | * 6 | * - arr := ["hello", "autumn", "one"] 7 | * 8 | * arr.Includes("hello") // 1 9 | * 10 | * arr.Includes("hello2") // 0 11 | */ 12 | Includes(item) => Integer 13 | /** 14 | * 将一个数组连接成字符串,默认以逗号连接 15 | * 16 | * arr := ["金", "木", "水", "火", "土"] 17 | * 18 | * arr.Join(",") // "金,木,水,火,土" 19 | */ 20 | Join(separator) => String 21 | /** 22 | * 将数组转换成字符串表示 23 | * 24 | * arr := [1,2,3] 25 | * 26 | * arr.ToString() // "123" 27 | * 28 | * String(arr) // "123" 29 | */ 30 | ToString() => String 31 | /** 32 | * 遍历数组并返回一个新数组,可用来修改数组的每一项 33 | * 34 | * arr := [1,2,3] 35 | * 36 | * arr.Map(i => i * 2) // [2, 4, 6] 37 | */ 38 | Map(MapFunc) => Array 39 | /** 40 | * 单纯遍历数组,返回数组自身 41 | * 42 | * arr := [1,2,3] 43 | * 44 | * arr.ForEach(i => msgbox(i)) // [1,2,3] 45 | */ 46 | /** 47 | * 过滤数组,返回一个过滤后的新数组 48 | * 49 | * arr := [1,2,3,4,5,6] 50 | * 51 | * arr.Filter(i => Mod(i, 2)) // [1,3,5] 52 | */ 53 | Filter(FilterFunc) => Array 54 | /** 55 | * 删除数组的第一个元素或从第一个开始的多个元素, 如果只删除一个元素则返回该元素, 删除多个则返回被删除元素组成的数组,该函数改变数组自身 56 | * 57 | * arr := [1,2,3] 58 | * 59 | * arr.Shift(arr) // 1 60 | * 61 | * arr // [2,3] 62 | */ 63 | Shift(count := 1) => T | Array 64 | /** 65 | * 向数组头部添加多个元素,并返回原数组,该方法改变自身 66 | * 67 | * arr := [1,2,3] 68 | * 69 | * arr.UnShift(6,7,8) // [6,7,8,1,2,3] 70 | */ 71 | UnShift(items*) => Array 72 | /** 73 | * 将多个数组连接成一个新数组并返回 74 | * 75 | * arr := [1,2,3] 76 | * 77 | * arr.Concat([4,5,6], [7,8,9]) // [1,2,3,4,5,6,7,8,9] 78 | */ 79 | Concat(arr*) => Array 80 | /** 81 | * 传入一个函数, 数组每一项带入执行, 返回值全部为真则返回真, 否则为假 82 | * @param short 是否短路, 默认为 false 不短路 83 | * 84 | * arr := [true, true] 85 | * 86 | * arr.Every(i => i) // 1 87 | */ 88 | Every(EveryFunc, short := false) => Integer 89 | /** 90 | * 传入一个函数, 数组的每一项带入执行, 有一个返回值为真则返回真, 否则为假 91 | * @param short 是否短路, 默认为 false 不短路 92 | * 93 | * arr := [true, false] 94 | * 95 | * arr.Some(i => i) // 1 96 | */ 97 | Some(SomeFunc, short := false) => Integer 98 | /** 99 | * 删除数组的某项一次或多次, 并返回原数组, 该函数改变自身 100 | * @param count 默认删除项目1次, 0 表示删除所有的相同项目 101 | * 102 | * arr := ["金", "木", "水", "火", "土", "土"] 103 | * 104 | * arr.Remove("土") // ["金", "木", "水", "火", "土"] 105 | * 106 | * arr.Remove("土", 2) // ["金", "木", "水", "火"] 107 | * 108 | * arr.Remove("土", 0) // ["金", "木", "水", "火"] 109 | */ 110 | Remove(item, count := 1) => Array 111 | /** 112 | * 传入一个待删除元素组成的数组, 从原数组中删除这些项, 返回原数组, 该函数改变数组自身 113 | * @param delArr 一个包含待删除元素的数组 114 | * @param count 每个要删除元素可以被删除的次数, 0 表示删除所有 115 | * 116 | * arr := ["金", "木", "水", "火", "土", "土"] 117 | * 118 | * arr.RemoveAll(["水", "土"]) // ["金", "木", "火", "土"] 119 | * 120 | * arr.RemoveAll(["水", "土"], 0) // ["金", "木", "火"] 121 | */ 122 | RemoveAll(delArr, count := 1) => Array 123 | 124 | /** 125 | * 传入一个函数, 找到结果为真的第一个数组项并返回 126 | * @param FindFunc 用来查找的函数 127 | * @param DefaultValue 没有找到的时候返回的值 128 | * 129 | * arr := ["木瓜", "西瓜", "土豆", "甜瓜"] 130 | * 131 | * arr.Find(i => i.Includes("甜")) // "甜瓜" 132 | * 133 | * arr.Find(i => i.Includes("黄瓜"), "Null") // "Null" 134 | */ 135 | Find(FindFunc, DefaultValue := "") => Any 136 | 137 | /** 138 | * 传入一个函数, 返回结果为真的所有项组成的新数组 139 | * 140 | * arr := ["木瓜", "西瓜", "土豆", "甜瓜"] 141 | * 142 | * arr.FindAll(i => i.Includes("瓜")) // ["木瓜", "西瓜", "甜瓜"] 143 | */ 144 | FindAll(FindFunc) => Array 145 | 146 | 147 | /** 148 | * 查看value是否在数组内部 149 | * @param value 一个数组项 150 | * 151 | * arr := ["哈哈", "嘿嘿"] 152 | * 153 | * arr.Includes("哈哈") // 1 154 | * @returns {Integer} 一个布尔值 155 | */ 156 | Includes(value) => Integer 157 | 158 | /** 159 | * 查看value在数组中的位置 160 | * @param value 查看value在数组中的索引位置 161 | * 162 | * arr := ["哈哈", "嘿嘿"] 163 | * 164 | * arr.IndexOf("嘿嘿") // 2 165 | * @returns {Integer} 如果在数组中返回索引, 0 表示不在 166 | */ 167 | IndexOf(value) => Integer 168 | 169 | /** 170 | * 传入一个值或函数返回匹配到的项对应索引组成的新数组 171 | * @param ValueOrFunc 一个要查找的值或者一个用于查找的函数,函数返回true表示匹配成功 172 | * 173 | * arr := ["木瓜", "西瓜", "土豆", "草莓", "葡萄", "甜瓜", "西瓜"] 174 | * 175 | * arr.IndexOfAll("西瓜") // [2, 7] 176 | * 177 | * arr.IndexOfAll(i => i.Includes("瓜")) // [1, 2, 6, 7] 178 | * @returns {Array} 返回包含所有找到索引的数组 179 | */ 180 | IndexOfAll(ValueOrFunc) => Array 181 | 182 | /** 183 | * 将数组扁平化 184 | * @param depth 要铺平数组的层数 0表示无限扁平化 185 | * 186 | * arr := [1, 2, [3, [4, 5]]] 187 | * 188 | * arr.Flat() // [1,2,3,4,5] 189 | * 190 | * arr.Flat(1) // [1,2,3,[4,5]] 191 | * @returns {Array} 192 | */ 193 | Flat(depth := 0) => Array 194 | 195 | /** 196 | * 数组去重 197 | * 198 | * arr := [1,1,1,2,2,2] 199 | * 200 | * arr.Unique() // [1,2] 201 | * @returns {Array} 202 | */ 203 | Unique() => Array 204 | 205 | /** 206 | * 数组排序,该方法不改变数组本身,返回新数组 207 | * @param SortFunc 一个用于排序的函数, 默认值 (a,b) => a - b 208 | * 209 | * arr := [8, 2, 1, 9] 210 | * 211 | * arr.Sort() // [1,2,8,9] 212 | * 213 | * arr.Sort((a,b) => b-a) // [9,8,2,1] 214 | * @returns {Array} 215 | */ 216 | Sort(SortFunc) => Array 217 | 218 | /** 219 | * 取所有数组交集, 返回一个新的数组 220 | * @param arr* 传入若干个数组 221 | * 222 | * arr := [1,2,3] 223 | * 224 | * arr.Intersect([2, 3]) // [2, 3] 225 | * @returns {Array} 226 | */ 227 | Intersect(arr*) => Array 228 | 229 | /** 230 | * 取数组并集, 返回新的数组 231 | * @param arr* 多个数组 232 | * 233 | * arr := [1,2,3] 234 | * 235 | * arr.Union([2,3,4,5]) // [1,2,3,4,5] 236 | * @returns {Array} 237 | */ 238 | Union(arr*) => Array 239 | 240 | /** 241 | * 排除所有数组共有元素, 剩余元素组成新的数组 242 | * @param arr* 若干的数组 243 | * 244 | * arr := [1, 2, 3] 245 | * 246 | * arr.Xor([2, 3, 6]) // [1, 6] 247 | * @returns {Array} 248 | */ 249 | Xor(arr*) => Array 250 | /** 251 | * 翻转数组, 返回一个新数组 252 | * @returns {Array} 253 | */ 254 | Reverse() => Array 255 | 256 | /** 257 | * 对一个只包含数字的数组求和 258 | * @returns {Integer} 259 | */ 260 | Sum() => Integer 261 | 262 | /** 263 | * javascript中Reduce方法的模仿 264 | * @param ReduceFunc 265 | * @param initial 266 | * 267 | * [1,2,3].Reduce((memo, item) => memo + item) // 1 + 2 + 3 = 6 268 | * 269 | * [1,2,3].Reduce((memo, item) => memo + item, 6) // 6 + 1 + 2 + 3 = 12 270 | * 271 | * @returns {Any} 272 | */ 273 | Reduce(ReduceFunc, initial?) => Any 274 | 275 | /** 276 | * javascript中ReduceRight方法的模仿 277 | * @param ReduceFunc 278 | * @param initial 279 | * 280 | * [1,2,3].ReduceRight((memo, item) => memo + item) // 3 + 2 + 1 = 6 281 | * 282 | * [1,2,3].ReduceRight((memo, item) => memo + item, 6) // 6 + 3 + 2 + 1 = 12 283 | * 284 | * @returns {Any} 285 | */ 286 | ReduceRight(ReduceFunc, initial?) => Any 287 | 288 | /** 289 | * 如果数组包含传入参数中的一个项那么返回 True, 否则返回 False 290 | * @param params* 291 | * 292 | * [1,2,3].IncludeSome(2, 6) // True 293 | * 294 | * [1,2,3].IncludeSome(8, 9) // False 295 | * 296 | * @returns {Integer} Boolean 297 | */ 298 | IncludeSome(params*) => Integer 299 | 300 | /** 301 | * 如果数组包含传入参数中的所有项那么返回True, 否则返回False 302 | * @param params* 303 | * 304 | * [1,2,3].IncludeEvery(1,2) // True 305 | * 306 | * [1,2,3].IncludeEvery(1,6) // False 307 | * 308 | * @returns {Integer} Boolean 309 | */ 310 | IncludeEvery(params*) => Integer 311 | } -------------------------------------------------------------------------------- /zh/number.d.ahk: -------------------------------------------------------------------------------- 1 | /** @extends {#Number} */ 2 | class Number { 3 | /** 4 | * 返回数字对应的字符 5 | * 6 | * 66.ToChar() // "B" 7 | * @returns {String} 8 | */ 9 | ToChar() => String 10 | } -------------------------------------------------------------------------------- /zh/object.d.ahk: -------------------------------------------------------------------------------- 1 | /** @extends {#Object} */ 2 | class Object{ 3 | /** 4 | * 获取对象的key组成的数组 5 | * 6 | * obj := {a: 1, b: 2} 7 | * 8 | * obj.Keys() // ["a", "b"] 9 | * @returns {Array} 10 | */ 11 | Keys() => Array 12 | 13 | /** 14 | * 获取对象的Value组成的数组 15 | * 16 | * obj := {a: 1, b: 2} 17 | * 18 | * obj.Values() // [1, 2] 19 | * @returns {Array} 20 | */ 21 | Values() => Array 22 | /** 23 | * 获取对象的key value对组成的数组 24 | * 25 | * obj := {a: 1, b: 2, c: 3} 26 | * 27 | * obj.Items() // [ { key: "a", value: 1 }, { key: "b", value: 2 }, { key: "c", value: 3 } ] 28 | * @returns {Array} 29 | */ 30 | Items() => Array 31 | /** 32 | * 返回一个对象的字符串表示 33 | * 34 | * obj := {a: 1, b: 2, c: 3} 35 | * 36 | * obj.ToString() // "{ a: 1, b: 2, c: 3 }" 37 | * @returns {String} 38 | */ 39 | ToString() => String 40 | /** 41 | * 一个属性,获取对象的长度 42 | * 43 | * obj := {a: 1, b: 2} 44 | * 45 | * obj.Length // 2 46 | */ 47 | Length { 48 | get => Integer 49 | } 50 | /** 51 | * 判断一个对象是否包含某个属性 52 | * 53 | * obj := {a: 1, b: 2, c: 3} 54 | * 55 | * obj.Has("d") // 0 56 | * 57 | * obj.Has("c") // 1 58 | * @returns {Integer} 59 | */ 60 | Has(prop) => Integer 61 | /** 62 | * 判断一个对象是否包含某个属性 63 | * 64 | * obj := {a: 1, b: 2, c: 3} 65 | * 66 | * obj.Contains("d") // 0 67 | * 68 | * obj.Contains("c") // 1 69 | * @returns {Integer} 70 | */ 71 | Contains() => Integer 72 | /** 73 | * 将多个对象进行合并 74 | * 75 | * obj := {a: 1, b: 2, c: 3} 76 | * 77 | * obj.Merge({c: 8, d: 9}) // { a: 1, b: 2, c: 8, d: 9 } 78 | * @returns {Object} 79 | */ 80 | Merge(objs*) => Object 81 | 82 | } -------------------------------------------------------------------------------- /zh/path.d.ahk: -------------------------------------------------------------------------------- 1 | class path{ 2 | /** 3 | * 连接路径,这个函数会处理一些一些麻烦情况,路径的最后一定不含\ 4 | * @param {Array} params* 5 | * 6 | * path.Concat("c:\cbs\", "\dds") // "c:\cbs\dds" 7 | * 8 | * path.Concat("c:\cbs\", "\dds\") // "c:\cbs\dds" 9 | * @returns {String} 10 | */ 11 | static Concat(params*: Array) => String 12 | 13 | /** 14 | * 获取路径的文件夹路径 15 | * @param {String} pathStr 16 | * 17 | * path.DirName("c:\abc\ddd\efs.txt") // "c:\abc\ddd" 18 | * @returns {String} 19 | */ 20 | static DirName(pathStr: String) => String 21 | 22 | /** 23 | * 获取路径中文件的后缀名 24 | * @param {String} pathStr 25 | * 26 | * path.ExtName("c:\abc\ddd\efs.txt") // "txt" 27 | * @returns {String} 28 | */ 29 | static ExtName(pathStr: String) => String 30 | 31 | /** 32 | * 获取路径中的文件或文件夹名称 33 | * @param {String} PathStr 34 | * @param {String} suffix 可选的要从结果后面去除的内容 35 | * 36 | * path.BaseName("c:\abc\ddd\efs.txt") // "efs.exe" 37 | * 38 | * path.BaseName("c:\abc\ddd\efs.txt", ".txt") // "efs" 39 | * @returns {String} 40 | */ 41 | static BaseName(PathStr: String, suffix?: String := "") => String 42 | } -------------------------------------------------------------------------------- /zh/string.d.ahk: -------------------------------------------------------------------------------- 1 | /** @extends {#string} */ 2 | class String extends Primitive{ 3 | /** 4 | * 将字符串切割成数组 5 | * @param {Array, String} Delimiters 一个分隔符或分隔符组成的数组, 不传就是切割成单个字符 6 | * @param SplitCount 切割次数 -1 表示无限次, 0 表示不切割 7 | * 8 | * 9 | * "木瓜".Split() // ["木", "瓜"] 10 | * 11 | * "金 木 水土 火".Split([A_Space, A_Tab]) // ["金", "木", "水土", "火"] 12 | * 13 | * "abc.bbc.ddd".Split(".", 1) // ["abc", "bbc.ddd"] 14 | * 15 | * "fff".Split() // ["fff"] 16 | * 17 | * "abc.".Split(".", 0) // ["abc."] 18 | * 19 | * "abc.".Split(".", 1) // ["abc", ""] 20 | * 21 | * ".abc".Split(".", 1) // ["", "abc"] 22 | * 23 | * @returns {Array} 24 | */ 25 | Split(Delimiters?: String, SplitCount?: -1) => Array 26 | /** 27 | * 从右边开始将字符串切割成数组 28 | * @param {Array, String} Delimiters 一个分隔符或分隔符组成的数组, 不传就是切割成单个字符 29 | * @param SplitCount 切割次数 -1 表示无限次, 0 表示不切割 30 | * 31 | * 32 | * "木瓜".SplitRight() // ["木", "瓜"] 33 | * 34 | * "金 木 水土 火".SplitRight([A_Space, A_Tab]) // ["金", "木", "水土", "火"] 35 | * 36 | * "abc.bbc.ddd".SplitRight(".", 1) // ["abc.bbc", "ddd"] 37 | * 38 | * @returns {Array} 39 | */ 40 | SplitRight(Delimiters?: String, SplitCount?: -1) => Array 41 | 42 | /** 43 | * 如果字符串包含传入参数中的一个项那么返回 True, 否则返回 False 44 | * @param params* 45 | * 46 | * "金木水火土".IncludeSome("金", "银") // True 47 | * 48 | * "木瓜".IncludeSome("大", "天", "子") // False 49 | * 50 | * @returns {Integer} Boolean 51 | */ 52 | IncludeSome(params*) => Integer 53 | 54 | /** 55 | * 如果字符串包含传入参数中的所有项那么返回True, 否则返回False 56 | * @param params* 57 | * 58 | * "金木水火土".IncludeEvery("金", "火") // True 59 | * 60 | * "西瓜".IncludeEvery("瓜", "白") // False 61 | * 62 | * @returns {Integer} Boolean 63 | */ 64 | IncludeEvery(params*) => Integer 65 | 66 | 67 | /** 68 | * 获取字符串的长度 69 | */ 70 | Length { 71 | get => Integer 72 | } 73 | /** 74 | * 判断字符串是否已某个子字符串开头 75 | * @param startStr 76 | * @param caseSense 是否区分大小写, 默认区分 77 | * 78 | * str := "木瓜" 79 | * 80 | * str.StartsWith("木") // 1 81 | * @returns {Integer} 布尔值0 或 1 82 | */ 83 | StartsWith(startStr, caseSense := true) => Integer 84 | /** 85 | * 判断字符串是否已某个子字符串结尾 86 | * @param endStr 87 | * @param caseSense 是否区分大小写, 默认区分 88 | * 89 | * str := "大西瓜" 90 | * 91 | * str.EndsWith("西瓜") // 1 92 | * @returns {Integer} 布尔值0 或 1 93 | */ 94 | EndsWith(endStr, caseSense := true) => Integer 95 | /** 96 | * 判断字符串是否包含子字符串 97 | * @param subStr 98 | * @param caseSense 是否区分大小写, 默认区分 99 | * 100 | * str := "金木水火土" 101 | * 102 | * str.Includes("火") // 1 103 | * @returns {Integer} 布尔值 104 | */ 105 | Includes(subStr, caseSense := true) => Integer 106 | /** 107 | * 获取子字符串在字符串中的位置 108 | * @param subStr 109 | * @param caseSense 是否区分大小写, 默认区分 110 | * 111 | * str := "木瓜西瓜" 112 | * 113 | * str.IndexOf("西") // 3 114 | * @returns {Integer} 115 | */ 116 | IndexOf(subStr, caseSense := true) => Integer 117 | /** 118 | * 获取子字符串在字符串中的位置, 从右向左搜索 119 | * @param subStr 120 | * @param caseSense 是否区分大小写, 默认区分 121 | * 122 | * str := "木瓜西瓜西" 123 | * 124 | * str.LastIndexOf("西") // 5 125 | * @returns {Integer} 126 | */ 127 | LastIndexOf(subStr, caseSense := true) => Integer 128 | /** 129 | * 获取子字符串在字符串中的所有位置, 返回包含所有位置的数组 130 | * @param subStr 131 | * @param caseSense 是否区分大小写, 默认区分 132 | * 133 | * str := "木瓜木有木哈哈木tutu" 134 | * 135 | * str.IndexOfAll("木") // [ 1, 3, 5, 8 ] 136 | * @returns {Array} 137 | */ 138 | IndexOfAll(subStr, caseSense := true) => Array 139 | /** 140 | * 删除字符串两边的指定字符, 默认删除空白 141 | * @param {String} omitChars 指定多个要删除的字符 142 | * @returns {String} 143 | */ 144 | Trim(omitChars?: String) => String 145 | /** 146 | * 删除字符串左边的指定字符, 默认删除空白 147 | * @param {String} omitChars 148 | * @returns {String} 149 | */ 150 | TrimLeft(omitChars?: String) => String 151 | /** 152 | * 删除字符串右边的指定字符, 默认删除空白 153 | * @param {String} omitChars 154 | * @returns {String} 155 | */ 156 | TrimRight(omitChars?: String) => String 157 | /** 158 | * 获取字符串指定索引位置的字符编码 159 | * @param {Integer} index 160 | * 161 | * str := "西瓜" 162 | * 163 | * str.CharCodeAt(2) // 29916 164 | * @returns {Integer} 165 | */ 166 | CharCodeAt(index: Integer) => Integer 167 | /** 168 | * 获取字符串指定索引位置的字符编码 169 | * @param {Integer} index 170 | * 171 | * str := "西瓜" 172 | * 173 | * str.CodeAt(2) // 29916 174 | * @returns {Integer} 175 | */ 176 | CodeAt(index: Integer) => Integer 177 | /** 178 | * 将多个字符串连接起来 179 | * @param params* 180 | * 181 | * str := "金" 182 | * 183 | * str.Concat("木", "水") // "金木水" 184 | * @returns {String} 185 | */ 186 | Concat(params*) => String 187 | /** 188 | * 使用字符串包裹另一个字符串 189 | * @param wrapStr 190 | * 191 | * str := "鸡蛋" 192 | * 193 | * str.Wrap("**") // "**鸡蛋**" 194 | * @returns {String} 195 | */ 196 | Wrap(wrapStr) => String 197 | /** 198 | * 字符串的字符串表示形式, 比普通的打印多一个双引号, 一般用于 String 方法的调用 199 | * 但是似乎String不会调用自定义的ToString,其他类型可以 200 | * @returns {String} 201 | */ 202 | ToString() => String 203 | /** 204 | * 将字符串的所有字符编码拼接起来,返回最终的数字,一般可以用来排序 205 | * @returns {Integer} 206 | */ 207 | ToCode() => Integer 208 | /** 209 | * 返回对应字符串的字符编码数组 210 | * @returns {Array} 211 | */ 212 | ToCodes() => Array 213 | /** 214 | * 返回字符串的小写形式 215 | * @returns {String} 216 | */ 217 | ToLower() => String 218 | /** 219 | * 返回字符串的大写形式 220 | * @returns {String} 221 | */ 222 | ToUpper() => String 223 | /** 224 | * 返回字符的标题形式 225 | * @returns {String} 226 | */ 227 | ToTitle() => String 228 | /** 229 | * 字符串模板, 是Format方法的别名 230 | * @param values 231 | * 232 | * "我的名字叫:{1}".Format("木瓜") // "我的名字叫:木瓜" 233 | * @returns {String} 234 | */ 235 | Format(values*) => String 236 | /** 237 | * 字符串模板 238 | * @param values 239 | * 240 | * name := "木瓜" 241 | * "我的名字叫:{name}".Format(&name) // "我的名字叫:木瓜" 242 | * @returns {String} 243 | */ 244 | Templ(&values*) => String 245 | /** 246 | * 替换字符串中的某些子字符串 247 | * @param {String} Needle 要搜索的子字符串 248 | * @param {String} ReplaceText 替换的字符, 不传就替换成空 249 | * @param {String | Integer} CaseSense 是否区分大小写, 默认区分 250 | * @param {VarRef} OutputVarCount 指针存储替换的次数 251 | * @param {Integer} Limit 默认 -1, 表示最大替换次数 252 | * 253 | * ret := "我是木瓜木木".Replace("木", "金", true, &cc, 2) 254 | * 255 | * println("ret:",ret) // ret: 我是金瓜金木 256 | * 257 | * println("cc:",cc) // cc: 2 258 | * @returns {String} 259 | */ 260 | Replace(Needle: String, ReplaceText?: String, CaseSense?: String | Integer := true, &OutputVarCount?: VarRef, Limit?: Integer) => String 261 | /** 262 | * 翻转字符串 263 | * @returns {String} 264 | */ 265 | Reverse() => String 266 | /** 267 | * 返回指定字符串的长度, 如果长度已够原样返回, 长度不够则从开始填充, 填充过程可能截断strFill 268 | * @param {Integer} num 指定要返回的字符串长度 269 | * @param {String} strFill 不够长度时用来填充的字符串 270 | * 271 | * 'x'.padStart(5, 'ab') // 'ababx' 272 | * 273 | * 'x'.padStart(4, 'ab') // 'abax' 274 | * 275 | * '12'.padStart(10, 'YYYY-MM-DD') // "YYYY-MM-12" 276 | * 277 | * '09-12'.padStart(10, 'YYYY-MM-DD') // "YYYY-09-12" 278 | * @returns {String} 279 | */ 280 | PadStart(num: Integer, strFill: String := " ") => String 281 | 282 | /** 283 | * 返回指定字符串的长度, 如果长度已够原样返回, 长度不够则从结尾填充, 填充过程可能截断strFill 284 | * @param {Integer} num 指定要返回的字符串长度 285 | * @param {String} strFill 不够长度时用来填充的字符串 286 | * 287 | * 'xxx'.padEnd(2, 'ab') // 'xxx' 288 | * 289 | * 'x'.padEnd(4) // 'x ' 290 | * @returns {String} 291 | */ 292 | PadEnd(num: Integer, strFill: String := " ") => String 293 | 294 | /** 295 | * 返回重复字符串 296 | * @param {Integer} num 重复次数 297 | * 298 | * 'x'.repeat(3) // "xxx" 299 | * 300 | * 'hello'.repeat(2) // "hellohello" 301 | * @returns {String} 302 | */ 303 | Repeat(num: Integer) => String 304 | 305 | /** 306 | * 移除字符串中的某个子字符串 307 | * @param {String} value 要移除的字符串 308 | * 309 | * "西瓜太大".Remove("西瓜") // "太大" 310 | * 311 | * @returns {String} 312 | */ 313 | Remove(value: String) => String 314 | 315 | /** 316 | * 移除字符串左边的子字符串,如果左边不匹配就不管 317 | * @param {String} value 要移除的左边的字符串 318 | * 319 | * "西瓜太大".RemoveLeft("西瓜") // "太大" 320 | * 321 | * "大西瓜太大".RemoveLeft("西瓜") // "大西瓜太大" 322 | * @returns {String} 323 | */ 324 | RemoveLeft(value: String) => String 325 | 326 | /** 327 | * 移除字符串右边的子字符串,如果右边不匹配就不管 328 | * @param {String} value 329 | * 330 | * "西瓜太甜".RemoveRight("太甜") // "西瓜" 331 | * @returns {String} 332 | */ 333 | RemoveRight(value: String) => String 334 | 335 | /** 336 | * path.Concat的别名,连接路径,这个函数会处理一些一些麻烦情况,路径的最后一定不含\ 337 | * @param params 338 | * 339 | * "c:\cbs\".ConcatP("\dds") // "c:\cbs\dds" 340 | * 341 | * "c:\cbs\".ConcatP("\dds\") // "c:\cbs\dds" 342 | * @returns {String} 343 | */ 344 | ConcatP(params*) => String 345 | 346 | /** 347 | * path.DirName的别名,获取路径的文件夹路径 348 | * 349 | * "c:\abc\ddd\efs.txt".DirName() // "c:\abc\ddd" 350 | * @returns {String} 351 | */ 352 | DirName() => String 353 | 354 | /** 355 | * path.ExtName的别名,获取路径中文件的后缀名 356 | * @param dot 357 | * 358 | * "c:\abc\ddd\efs.txt".ExtName() // "txt" 359 | * 360 | * "c:\abc\ddd\efs.txt".ExtName(true) // ".txt" 361 | * @returns {String} 362 | */ 363 | ExtName(dot := false) => String 364 | 365 | /** 366 | * path.BaseName的别名,获取路径中的文件或文件夹名称 367 | * @param HasSuffix 是否包含后缀名 368 | * 369 | * "c:\abc\ddd\efs.txt".BaseName() // "efs.txt" 370 | * 371 | * "c:\abc\ddd\efs.txt".BaseName(false) // "efs" 372 | * @returns {String} 373 | */ 374 | BaseName(HasSuffix := true) => String 375 | 376 | } -------------------------------------------------------------------------------- /zh/time.d.ahk: -------------------------------------------------------------------------------- 1 | class time { 2 | /** 3 | * 获取当前时间组成的数字,精确到毫秒 4 | * @returns {Integer} 5 | */ 6 | static time() => Integer 7 | } -------------------------------------------------------------------------------- /zh/utils.d.ahk: -------------------------------------------------------------------------------- 1 | /** 2 | * 传入若干个参数,打印这些参数并换行,参数之间空格分隔 3 | * @param params* 4 | */ 5 | println(params*) => void 6 | 7 | /** 8 | * 传入若干个参数,打印这些参数, 参数之间空格分隔,这个函数不会换行 9 | * @param params 10 | */ 11 | print(params*) => void --------------------------------------------------------------------------------