Advertisement
alexdubovyck

ferrib bot

Aug 7th, 2017
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 453.09 KB | None | 0 0
  1. #Region
  2. #AutoIt3Wrapper_Icon=..\..\..\pumpkin icons\Iconka-Wicked-Wall-Pumpkin-Potter.ico
  3. #EndRegion
  4. Global Const $gui_event_single = 0
  5. Global Const $gui_event_array = 1
  6. Global Const $gui_event_none = 0
  7. Global Const $gui_event_close = -3
  8. Global Const $gui_event_minimize = -4
  9. Global Const $gui_event_restore = -5
  10. Global Const $gui_event_maximize = -6
  11. Global Const $gui_event_primarydown = -7
  12. Global Const $gui_event_primaryup = -8
  13. Global Const $gui_event_secondarydown = -9
  14. Global Const $gui_event_secondaryup = -10
  15. Global Const $gui_event_mousemove = -11
  16. Global Const $gui_event_resized = -12
  17. Global Const $gui_event_dropped = -13
  18. Global Const $gui_rundefmsg = "GUI_RUNDEFMSG"
  19. Global Const $gui_avistop = 0
  20. Global Const $gui_avistart = 1
  21. Global Const $gui_aviclose = 2
  22. Global Const $gui_checked = 1
  23. Global Const $gui_indeterminate = 2
  24. Global Const $gui_unchecked = 4
  25. Global Const $gui_dropaccepted = 8
  26. Global Const $gui_nodropaccepted = 4096
  27. Global Const $gui_acceptfiles = $gui_dropaccepted
  28. Global Const $gui_show = 16
  29. Global Const $gui_hide = 32
  30. Global Const $gui_enable = 64
  31. Global Const $gui_disable = 128
  32. Global Const $gui_focus = 256
  33. Global Const $gui_nofocus = 8192
  34. Global Const $gui_defbutton = 512
  35. Global Const $gui_expand = 1024
  36. Global Const $gui_ontop = 2048
  37. Global Const $gui_fontnormal = 0
  38. Global Const $gui_fontitalic = 2
  39. Global Const $gui_fontunder = 4
  40. Global Const $gui_fontstrike = 8
  41. Global Const $gui_dockauto = 1
  42. Global Const $gui_dockleft = 2
  43. Global Const $gui_dockright = 4
  44. Global Const $gui_dockhcenter = 8
  45. Global Const $gui_docktop = 32
  46. Global Const $gui_dockbottom = 64
  47. Global Const $gui_dockvcenter = 128
  48. Global Const $gui_dockwidth = 256
  49. Global Const $gui_dockheight = 512
  50. Global Const $gui_docksize = 768
  51. Global Const $gui_dockmenubar = 544
  52. Global Const $gui_dockstatebar = 576
  53. Global Const $gui_dockall = 802
  54. Global Const $gui_dockborders = 102
  55. Global Const $gui_gr_close = 1
  56. Global Const $gui_gr_line = 2
  57. Global Const $gui_gr_bezier = 4
  58. Global Const $gui_gr_move = 6
  59. Global Const $gui_gr_color = 8
  60. Global Const $gui_gr_rect = 10
  61. Global Const $gui_gr_ellipse = 12
  62. Global Const $gui_gr_pie = 14
  63. Global Const $gui_gr_dot = 16
  64. Global Const $gui_gr_pixel = 18
  65. Global Const $gui_gr_hint = 20
  66. Global Const $gui_gr_refresh = 22
  67. Global Const $gui_gr_pensize = 24
  68. Global Const $gui_gr_nobkcolor = -2
  69. Global Const $gui_bkcolor_default = -1
  70. Global Const $gui_bkcolor_transparent = -2
  71. Global Const $gui_bkcolor_lv_alternate = -33554432
  72. Global Const $gui_read_default = 0
  73. Global Const $gui_read_extended = 1
  74. Global Const $gui_cursor_nooverride = 0
  75. Global Const $gui_cursor_override = 1
  76. Global Const $gui_ws_ex_parentdrag = 1048576
  77. Global Const $wc_animate = "SysAnimate32"
  78. Global Const $wc_button = "Button"
  79. Global Const $wc_combobox = "ComboBox"
  80. Global Const $wc_comboboxex = "ComboBoxEx32"
  81. Global Const $wc_datetimepick = "SysDateTimePick32"
  82. Global Const $wc_edit = "Edit"
  83. Global Const $wc_header = "SysHeader32"
  84. Global Const $wc_hotkey = "msctls_hotkey32"
  85. Global Const $wc_ipaddress = "SysIPAddress32"
  86. Global Const $wc_link = "SysLink"
  87. Global Const $wc_listbox = "ListBox"
  88. Global Const $wc_listview = "SysListView32"
  89. Global Const $wc_monthcal = "SysMonthCal32"
  90. Global Const $wc_nativefontctl = "NativeFontCtl"
  91. Global Const $wc_pagescroller = "SysPager"
  92. Global Const $wc_progress = "msctls_progress32"
  93. Global Const $wc_rebar = "ReBarWindow32"
  94. Global Const $wc_scrollbar = "ScrollBar"
  95. Global Const $wc_static = "Static"
  96. Global Const $wc_statusbar = "msctls_statusbar32"
  97. Global Const $wc_tabcontrol = "SysTabControl32"
  98. Global Const $wc_toolbar = "ToolbarWindow32"
  99. Global Const $wc_tooltips = "tooltips_class32"
  100. Global Const $wc_trackbar = "msctls_trackbar32"
  101. Global Const $wc_treeview = "SysTreeView32"
  102. Global Const $wc_updown = "msctls_updown32"
  103. Global Const $ws_overlapped = 0
  104. Global Const $ws_tiled = $ws_overlapped
  105. Global Const $ws_maximizebox = 65536
  106. Global Const $ws_minimizebox = 131072
  107. Global Const $ws_tabstop = 65536
  108. Global Const $ws_group = 131072
  109. Global Const $ws_sizebox = 262144
  110. Global Const $ws_thickframe = $ws_sizebox
  111. Global Const $ws_sysmenu = 524288
  112. Global Const $ws_hscroll = 1048576
  113. Global Const $ws_vscroll = 2097152
  114. Global Const $ws_dlgframe = 4194304
  115. Global Const $ws_border = 8388608
  116. Global Const $ws_caption = 12582912
  117. Global Const $ws_overlappedwindow = BitOR($ws_caption, $ws_maximizebox, $ws_minimizebox, $ws_overlapped, $ws_sysmenu, $ws_thickframe)
  118. Global Const $ws_tiledwindow = $ws_overlappedwindow
  119. Global Const $ws_maximize = 16777216
  120. Global Const $ws_clipchildren = 33554432
  121. Global Const $ws_clipsiblings = 67108864
  122. Global Const $ws_disabled = 134217728
  123. Global Const $ws_visible = 268435456
  124. Global Const $ws_minimize = 536870912
  125. Global Const $ws_iconic = $ws_minimize
  126. Global Const $ws_child = 1073741824
  127. Global Const $ws_childwindow = $ws_child
  128. Global Const $ws_popup = -2147483648
  129. Global Const $ws_popupwindow = -2138570752
  130. Global Const $ds_3dlook = 4
  131. Global Const $ds_absalign = 1
  132. Global Const $ds_center = 2048
  133. Global Const $ds_centermouse = 4096
  134. Global Const $ds_contexthelp = 8192
  135. Global Const $ds_control = 1024
  136. Global Const $ds_fixedsys = 8
  137. Global Const $ds_localedit = 32
  138. Global Const $ds_modalframe = 128
  139. Global Const $ds_nofailcreate = 16
  140. Global Const $ds_noidlemsg = 256
  141. Global Const $ds_setfont = 64
  142. Global Const $ds_setforeground = 512
  143. Global Const $ds_shellfont = BitOR($ds_fixedsys, $ds_setfont)
  144. Global Const $ds_sysmodal = 2
  145. Global Const $ws_ex_acceptfiles = 16
  146. Global Const $ws_ex_appwindow = 262144
  147. Global Const $ws_ex_composited = 33554432
  148. Global Const $ws_ex_controlparent = 65536
  149. Global Const $ws_ex_clientedge = 512
  150. Global Const $ws_ex_contexthelp = 1024
  151. Global Const $ws_ex_dlgmodalframe = 1
  152. Global Const $ws_ex_layered = 524288
  153. Global Const $ws_ex_layoutrtl = 4194304
  154. Global Const $ws_ex_left = 0
  155. Global Const $ws_ex_leftscrollbar = 16384
  156. Global Const $ws_ex_ltrreading = 0
  157. Global Const $ws_ex_mdichild = 64
  158. Global Const $ws_ex_noactivate = 134217728
  159. Global Const $ws_ex_noinheritlayout = 1048576
  160. Global Const $ws_ex_noparentnotify = 4
  161. Global Const $ws_ex_right = 4096
  162. Global Const $ws_ex_rightscrollbar = 0
  163. Global Const $ws_ex_rtlreading = 8192
  164. Global Const $ws_ex_staticedge = 131072
  165. Global Const $ws_ex_toolwindow = 128
  166. Global Const $ws_ex_topmost = 8
  167. Global Const $ws_ex_transparent = 32
  168. Global Const $ws_ex_windowedge = 256
  169. Global Const $ws_ex_overlappedwindow = BitOR($ws_ex_clientedge, $ws_ex_windowedge)
  170. Global Const $ws_ex_palettewindow = BitOR($ws_ex_toolwindow, $ws_ex_topmost, $ws_ex_windowedge)
  171. Global Const $wm_null = 0
  172. Global Const $wm_create = 1
  173. Global Const $wm_destroy = 2
  174. Global Const $wm_move = 3
  175. Global Const $wm_sizewait = 4
  176. Global Const $wm_size = 5
  177. Global Const $wm_activate = 6
  178. Global Const $wm_setfocus = 7
  179. Global Const $wm_killfocus = 8
  180. Global Const $wm_setvisible = 9
  181. Global Const $wm_enable = 10
  182. Global Const $wm_setredraw = 11
  183. Global Const $wm_settext = 12
  184. Global Const $wm_gettext = 13
  185. Global Const $wm_gettextlength = 14
  186. Global Const $wm_paint = 15
  187. Global Const $wm_close = 16
  188. Global Const $wm_queryendsession = 17
  189. Global Const $wm_quit = 18
  190. Global Const $wm_erasebkgnd = 20
  191. Global Const $wm_queryopen = 19
  192. Global Const $wm_syscolorchange = 21
  193. Global Const $wm_endsession = 22
  194. Global Const $wm_systemerror = 23
  195. Global Const $wm_showwindow = 24
  196. Global Const $wm_ctlcolor = 25
  197. Global Const $wm_settingchange = 26
  198. Global Const $wm_wininichange = 26
  199. Global Const $wm_devmodechange = 27
  200. Global Const $wm_activateapp = 28
  201. Global Const $wm_fontchange = 29
  202. Global Const $wm_timechange = 30
  203. Global Const $wm_cancelmode = 31
  204. Global Const $wm_setcursor = 32
  205. Global Const $wm_mouseactivate = 33
  206. Global Const $wm_childactivate = 34
  207. Global Const $wm_queuesync = 35
  208. Global Const $wm_getminmaxinfo = 36
  209. Global Const $wm_logoff = 37
  210. Global Const $wm_painticon = 38
  211. Global Const $wm_iconerasebkgnd = 39
  212. Global Const $wm_nextdlgctl = 40
  213. Global Const $wm_alttabactive = 41
  214. Global Const $wm_spoolerstatus = 42
  215. Global Const $wm_drawitem = 43
  216. Global Const $wm_measureitem = 44
  217. Global Const $wm_deleteitem = 45
  218. Global Const $wm_vkeytoitem = 46
  219. Global Const $wm_chartoitem = 47
  220. Global Const $wm_setfont = 48
  221. Global Const $wm_getfont = 49
  222. Global Const $wm_sethotkey = 50
  223. Global Const $wm_gethotkey = 51
  224. Global Const $wm_filesyschange = 52
  225. Global Const $wm_isactiveicon = 53
  226. Global Const $wm_queryparkicon = 54
  227. Global Const $wm_querydragicon = 55
  228. Global Const $wm_winhelp = 56
  229. Global Const $wm_compareitem = 57
  230. Global Const $wm_fullscreen = 58
  231. Global Const $wm_clientshutdown = 59
  232. Global Const $wm_ddemlevent = 60
  233. Global Const $wm_getobject = 61
  234. Global Const $wm_calcscroll = 63
  235. Global Const $wm_testing = 64
  236. Global Const $wm_compacting = 65
  237. Global Const $wm_otherwindowcreated = 66
  238. Global Const $wm_otherwindowdestroyed = 67
  239. Global Const $wm_commnotify = 68
  240. Global Const $wm_mediastatuschange = 69
  241. Global Const $wm_windowposchanging = 70
  242. Global Const $wm_windowposchanged = 71
  243. Global Const $wm_power = 72
  244. Global Const $wm_copyglobaldata = 73
  245. Global Const $wm_copydata = 74
  246. Global Const $wm_canceljournal = 75
  247. Global Const $wm_logonnotify = 76
  248. Global Const $wm_keyf1 = 77
  249. Global Const $wm_notify = 78
  250. Global Const $wm_access_window = 79
  251. Global Const $wm_inputlangchangerequest = 80
  252. Global Const $wm_inputlangchange = 81
  253. Global Const $wm_tcard = 82
  254. Global Const $wm_help = 83
  255. Global Const $wm_userchanged = 84
  256. Global Const $wm_notifyformat = 85
  257. Global Const $wm_qm_activate = 96
  258. Global Const $wm_hook_do_callback = 97
  259. Global Const $wm_syscopydata = 98
  260. Global Const $wm_finaldestroy = 112
  261. Global Const $wm_measureitem_clientdata = 113
  262. Global Const $wm_contextmenu = 123
  263. Global Const $wm_stylechanging = 124
  264. Global Const $wm_stylechanged = 125
  265. Global Const $wm_displaychange = 126
  266. Global Const $wm_geticon = 127
  267. Global Const $wm_seticon = 128
  268. Global Const $wm_nccreate = 129
  269. Global Const $wm_ncdestroy = 130
  270. Global Const $wm_nccalcsize = 131
  271. Global Const $wm_nchittest = 132
  272. Global Const $wm_ncpaint = 133
  273. Global Const $wm_ncactivate = 134
  274. Global Const $wm_getdlgcode = 135
  275. Global Const $wm_syncpaint = 136
  276. Global Const $wm_synctask = 137
  277. Global Const $wm_kludgeminrect = 139
  278. Global Const $wm_lpkdrawswitchwnd = 140
  279. Global Const $wm_uahdestroywindow = 144
  280. Global Const $wm_uahdrawmenu = 145
  281. Global Const $wm_uahdrawmenuitem = 146
  282. Global Const $wm_uahinitmenu = 147
  283. Global Const $wm_uahmeasuremenuitem = 148
  284. Global Const $wm_uahncpaintmenupopup = 149
  285. Global Const $wm_ncmousemove = 160
  286. Global Const $wm_nclbuttondown = 161
  287. Global Const $wm_nclbuttonup = 162
  288. Global Const $wm_nclbuttondblclk = 163
  289. Global Const $wm_ncrbuttondown = 164
  290. Global Const $wm_ncrbuttonup = 165
  291. Global Const $wm_ncrbuttondblclk = 166
  292. Global Const $wm_ncmbuttondown = 167
  293. Global Const $wm_ncmbuttonup = 168
  294. Global Const $wm_ncmbuttondblclk = 169
  295. Global Const $wm_ncxbuttondown = 171
  296. Global Const $wm_ncxbuttonup = 172
  297. Global Const $wm_ncxbuttondblclk = 173
  298. Global Const $wm_ncuahdrawcaption = 174
  299. Global Const $wm_ncuahdrawframe = 175
  300. Global Const $wm_input_device_change = 254
  301. Global Const $wm_input = 255
  302. Global Const $wm_keydown = 256
  303. Global Const $wm_keyfirst = 256
  304. Global Const $wm_keyup = 257
  305. Global Const $wm_char = 258
  306. Global Const $wm_deadchar = 259
  307. Global Const $wm_syskeydown = 260
  308. Global Const $wm_syskeyup = 261
  309. Global Const $wm_syschar = 262
  310. Global Const $wm_sysdeadchar = 263
  311. Global Const $wm_yomichar = 264
  312. Global Const $wm_keylast = 265
  313. Global Const $wm_unichar = 265
  314. Global Const $wm_convertrequest = 266
  315. Global Const $wm_convertresult = 267
  316. Global Const $wm_im_info = 268
  317. Global Const $wm_ime_startcomposition = 269
  318. Global Const $wm_ime_endcomposition = 270
  319. Global Const $wm_ime_composition = 271
  320. Global Const $wm_ime_keylast = 271
  321. Global Const $wm_initdialog = 272
  322. Global Const $wm_command = 273
  323. Global Const $wm_syscommand = 274
  324. Global Const $wm_timer = 275
  325. Global Const $wm_hscroll = 276
  326. Global Const $wm_vscroll = 277
  327. Global Const $wm_initmenu = 278
  328. Global Const $wm_initmenupopup = 279
  329. Global Const $wm_systimer = 280
  330. Global Const $wm_gesture = 281
  331. Global Const $wm_gesturenotify = 282
  332. Global Const $wm_gestureinput = 283
  333. Global Const $wm_gesturenotified = 284
  334. Global Const $wm_menuselect = 287
  335. Global Const $wm_menuchar = 288
  336. Global Const $wm_enteridle = 289
  337. Global Const $wm_menurbuttonup = 290
  338. Global Const $wm_menudrag = 291
  339. Global Const $wm_menugetobject = 292
  340. Global Const $wm_uninitmenupopup = 293
  341. Global Const $wm_menucommand = 294
  342. Global Const $wm_changeuistate = 295
  343. Global Const $wm_updateuistate = 296
  344. Global Const $wm_queryuistate = 297
  345. Global Const $wm_lbtrackpoint = 305
  346. Global Const $wm_ctlcolormsgbox = 306
  347. Global Const $wm_ctlcoloredit = 307
  348. Global Const $wm_ctlcolorlistbox = 308
  349. Global Const $wm_ctlcolorbtn = 309
  350. Global Const $wm_ctlcolordlg = 310
  351. Global Const $wm_ctlcolorscrollbar = 311
  352. Global Const $wm_ctlcolorstatic = 312
  353. Global Const $mn_gethmenu = 481
  354. Global Const $wm_parentnotify = 528
  355. Global Const $wm_entermenuloop = 529
  356. Global Const $wm_exitmenuloop = 530
  357. Global Const $wm_nextmenu = 531
  358. Global Const $wm_sizing = 532
  359. Global Const $wm_capturechanged = 533
  360. Global Const $wm_moving = 534
  361. Global Const $wm_powerbroadcast = 536
  362. Global Const $wm_devicechange = 537
  363. Global Const $wm_mdicreate = 544
  364. Global Const $wm_mdidestroy = 545
  365. Global Const $wm_mdiactivate = 546
  366. Global Const $wm_mdirestore = 547
  367. Global Const $wm_mdinext = 548
  368. Global Const $wm_mdimaximize = 549
  369. Global Const $wm_mditile = 550
  370. Global Const $wm_mdicascade = 551
  371. Global Const $wm_mdiiconarrange = 552
  372. Global Const $wm_mdigetactive = 553
  373. Global Const $wm_dropobject = 554
  374. Global Const $wm_querydropobject = 555
  375. Global Const $wm_begindrag = 556
  376. Global Const $wm_dragloop = 557
  377. Global Const $wm_dragselect = 558
  378. Global Const $wm_dragmove = 559
  379. Global Const $wm_mdisetmenu = 560
  380. Global Const $wm_entersizemove = 561
  381. Global Const $wm_exitsizemove = 562
  382. Global Const $wm_dropfiles = 563
  383. Global Const $wm_mdirefreshmenu = 564
  384. Global Const $wm_touch = 576
  385. Global Const $wm_ime_setcontext = 641
  386. Global Const $wm_ime_notify = 642
  387. Global Const $wm_ime_control = 643
  388. Global Const $wm_ime_compositionfull = 644
  389. Global Const $wm_ime_select = 645
  390. Global Const $wm_ime_char = 646
  391. Global Const $wm_ime_system = 647
  392. Global Const $wm_ime_request = 648
  393. Global Const $wm_ime_keydown = 656
  394. Global Const $wm_ime_keyup = 657
  395. Global Const $wm_ncmousehover = 672
  396. Global Const $wm_mousehover = 673
  397. Global Const $wm_ncmouseleave = 674
  398. Global Const $wm_mouseleave = 675
  399. Global Const $wm_wtssession_change = 689
  400. Global Const $wm_tablet_first = 704
  401. Global Const $wm_tablet_last = 735
  402. Global Const $wm_cut = 768
  403. Global Const $wm_copy = 769
  404. Global Const $wm_paste = 770
  405. Global Const $wm_clear = 771
  406. Global Const $wm_undo = 772
  407. Global Const $wm_paletteischanging = 784
  408. Global Const $wm_hotkey = 786
  409. Global Const $wm_palettechanged = 785
  410. Global Const $wm_sysmenu = 787
  411. Global Const $wm_hookmsg = 788
  412. Global Const $wm_exitprocess = 789
  413. Global Const $wm_wakethread = 790
  414. Global Const $wm_print = 791
  415. Global Const $wm_printclient = 792
  416. Global Const $wm_appcommand = 793
  417. Global Const $wm_querynewpalette = 783
  418. Global Const $wm_themechanged = 794
  419. Global Const $wm_uahinit = 795
  420. Global Const $wm_desktopnotify = 796
  421. Global Const $wm_clipboardupdate = 797
  422. Global Const $wm_dwmcompositionchanged = 798
  423. Global Const $wm_dwmncrenderingchanged = 799
  424. Global Const $wm_dwmcolorizationcolorchanged = 800
  425. Global Const $wm_dwmwindowmaximizedchange = 801
  426. Global Const $wm_dwmexileframe = 802
  427. Global Const $wm_dwmsendiconicthumbnail = 803
  428. Global Const $wm_magnification_started = 804
  429. Global Const $wm_magnification_ended = 805
  430. Global Const $wm_dwmsendiconiclivepreviewbitmap = 806
  431. Global Const $wm_dwmthumbnailsizechanged = 807
  432. Global Const $wm_magnification_output = 808
  433. Global Const $wm_measurecontrol = 816
  434. Global Const $wm_getactiontext = 817
  435. Global Const $wm_forwardkeydown = 819
  436. Global Const $wm_forwardkeyup = 820
  437. Global Const $wm_gettitlebarinfoex = 831
  438. Global Const $wm_notifywow = 832
  439. Global Const $wm_handheldfirst = 856
  440. Global Const $wm_handheldlast = 863
  441. Global Const $wm_afxfirst = 864
  442. Global Const $wm_afxlast = 895
  443. Global Const $wm_penwinfirst = 896
  444. Global Const $wm_penwinlast = 911
  445. Global Const $wm_dde_initiate = 992
  446. Global Const $wm_dde_terminate = 993
  447. Global Const $wm_dde_advise = 994
  448. Global Const $wm_dde_unadvise = 995
  449. Global Const $wm_dde_ack = 996
  450. Global Const $wm_dde_data = 997
  451. Global Const $wm_dde_request = 998
  452. Global Const $wm_dde_poke = 999
  453. Global Const $wm_dde_execute = 1000
  454. Global Const $wm_dbnotification = 1021
  455. Global Const $wm_netconnect = 1022
  456. Global Const $wm_hibernate = 1023
  457. Global Const $wm_user = 1024
  458. Global Const $wm_app = 32768
  459. Global Const $nm_first = 0
  460. Global Const $nm_outofmemory = $nm_first - 1
  461. Global Const $nm_click = $nm_first - 2
  462. Global Const $nm_dblclk = $nm_first - 3
  463. Global Const $nm_return = $nm_first - 4
  464. Global Const $nm_rclick = $nm_first - 5
  465. Global Const $nm_rdblclk = $nm_first - 6
  466. Global Const $nm_setfocus = $nm_first - 7
  467. Global Const $nm_killfocus = $nm_first - 8
  468. Global Const $nm_customdraw = $nm_first - 12
  469. Global Const $nm_hover = $nm_first - 13
  470. Global Const $nm_nchittest = $nm_first - 14
  471. Global Const $nm_keydown = $nm_first - 15
  472. Global Const $nm_releasedcapture = $nm_first - 16
  473. Global Const $nm_setcursor = $nm_first - 17
  474. Global Const $nm_char = $nm_first - 18
  475. Global Const $nm_tooltipscreated = $nm_first - 19
  476. Global Const $nm_ldown = $nm_first - 20
  477. Global Const $nm_rdown = $nm_first - 21
  478. Global Const $nm_themechanged = $nm_first - 22
  479. Global Const $wm_mousefirst = 512
  480. Global Const $wm_mousemove = 512
  481. Global Const $wm_lbuttondown = 513
  482. Global Const $wm_lbuttonup = 514
  483. Global Const $wm_lbuttondblclk = 515
  484. Global Const $wm_rbuttondown = 516
  485. Global Const $wm_rbuttonup = 517
  486. Global Const $wm_rbuttondblclk = 518
  487. Global Const $wm_mbuttondown = 519
  488. Global Const $wm_mbuttonup = 520
  489. Global Const $wm_mbuttondblclk = 521
  490. Global Const $wm_mousewheel = 522
  491. Global Const $wm_xbuttondown = 523
  492. Global Const $wm_xbuttonup = 524
  493. Global Const $wm_xbuttondblclk = 525
  494. Global Const $wm_mousehwheel = 526
  495. Global Const $ps_solid = 0
  496. Global Const $ps_dash = 1
  497. Global Const $ps_dot = 2
  498. Global Const $ps_dashdot = 3
  499. Global Const $ps_dashdotdot = 4
  500. Global Const $ps_null = 5
  501. Global Const $ps_insideframe = 6
  502. Global Const $ps_userstyle = 7
  503. Global Const $ps_alternate = 8
  504. Global Const $ps_endcap_round = 0
  505. Global Const $ps_endcap_square = 256
  506. Global Const $ps_endcap_flat = 512
  507. Global Const $ps_join_bevel = 4096
  508. Global Const $ps_join_miter = 8192
  509. Global Const $ps_join_round = 0
  510. Global Const $ps_geometric = 65536
  511. Global Const $ps_cosmetic = 0
  512. Global Const $lwa_alpha = 2
  513. Global Const $lwa_colorkey = 1
  514. Global Const $rgn_and = 1
  515. Global Const $rgn_or = 2
  516. Global Const $rgn_xor = 3
  517. Global Const $rgn_diff = 4
  518. Global Const $rgn_copy = 5
  519. Global Const $errorregion = 0
  520. Global Const $nullregion = 1
  521. Global Const $simpleregion = 2
  522. Global Const $complexregion = 3
  523. Global Const $transparent = 1
  524. Global Const $opaque = 2
  525. Global Const $ccm_first = 8192
  526. Global Const $ccm_getunicodeformat = ($ccm_first + 6)
  527. Global Const $ccm_setunicodeformat = ($ccm_first + 5)
  528. Global Const $ccm_setbkcolor = $ccm_first + 1
  529. Global Const $ccm_setcolorscheme = $ccm_first + 2
  530. Global Const $ccm_getcolorscheme = $ccm_first + 3
  531. Global Const $ccm_getdroptarget = $ccm_first + 4
  532. Global Const $ccm_setwindowtheme = $ccm_first + 11
  533. Global Const $ga_parent = 1
  534. Global Const $ga_root = 2
  535. Global Const $ga_rootowner = 3
  536. Global Const $sm_cxscreen = 0
  537. Global Const $sm_cyscreen = 1
  538. Global Const $sm_cxvscroll = 2
  539. Global Const $sm_cyhscroll = 3
  540. Global Const $sm_cycaption = 4
  541. Global Const $sm_cxborder = 5
  542. Global Const $sm_cyborder = 6
  543. Global Const $sm_cxdlgframe = 7
  544. Global Const $sm_cydlgframe = 8
  545. Global Const $sm_cyvthumb = 9
  546. Global Const $sm_cxhthumb = 10
  547. Global Const $sm_cxicon = 11
  548. Global Const $sm_cyicon = 12
  549. Global Const $sm_cxcursor = 13
  550. Global Const $sm_cycursor = 14
  551. Global Const $sm_cymenu = 15
  552. Global Const $sm_cxfullscreen = 16
  553. Global Const $sm_cyfullscreen = 17
  554. Global Const $sm_cykanjiwindow = 18
  555. Global Const $sm_mousepresent = 19
  556. Global Const $sm_cyvscroll = 20
  557. Global Const $sm_cxhscroll = 21
  558. Global Const $sm_debug = 22
  559. Global Const $sm_swapbutton = 23
  560. Global Const $sm_reserved1 = 24
  561. Global Const $sm_reserved2 = 25
  562. Global Const $sm_reserved3 = 26
  563. Global Const $sm_reserved4 = 27
  564. Global Const $sm_cxmin = 28
  565. Global Const $sm_cymin = 29
  566. Global Const $sm_cxsize = 30
  567. Global Const $sm_cysize = 31
  568. Global Const $sm_cxframe = 32
  569. Global Const $sm_cyframe = 33
  570. Global Const $sm_cxmintrack = 34
  571. Global Const $sm_cymintrack = 35
  572. Global Const $sm_cxdoubleclk = 36
  573. Global Const $sm_cydoubleclk = 37
  574. Global Const $sm_cxiconspacing = 38
  575. Global Const $sm_cyiconspacing = 39
  576. Global Const $sm_menudropalignment = 40
  577. Global Const $sm_penwindows = 41
  578. Global Const $sm_dbcsenabled = 42
  579. Global Const $sm_cmousebuttons = 43
  580. Global Const $sm_secure = 44
  581. Global Const $sm_cxedge = 45
  582. Global Const $sm_cyedge = 46
  583. Global Const $sm_cxminspacing = 47
  584. Global Const $sm_cyminspacing = 48
  585. Global Const $sm_cxsmicon = 49
  586. Global Const $sm_cysmicon = 50
  587. Global Const $sm_cysmcaption = 51
  588. Global Const $sm_cxsmsize = 52
  589. Global Const $sm_cysmsize = 53
  590. Global Const $sm_cxmenusize = 54
  591. Global Const $sm_cymenusize = 55
  592. Global Const $sm_arrange = 56
  593. Global Const $sm_cxminimized = 57
  594. Global Const $sm_cyminimized = 58
  595. Global Const $sm_cxmaxtrack = 59
  596. Global Const $sm_cymaxtrack = 60
  597. Global Const $sm_cxmaximized = 61
  598. Global Const $sm_cymaximized = 62
  599. Global Const $sm_network = 63
  600. Global Const $sm_cleanboot = 67
  601. Global Const $sm_cxdrag = 68
  602. Global Const $sm_cydrag = 69
  603. Global Const $sm_showsounds = 70
  604. Global Const $sm_cxmenucheck = 71
  605. Global Const $sm_cymenucheck = 72
  606. Global Const $sm_slowmachine = 73
  607. Global Const $sm_mideastenabled = 74
  608. Global Const $sm_mousewheelpresent = 75
  609. Global Const $sm_xvirtualscreen = 76
  610. Global Const $sm_yvirtualscreen = 77
  611. Global Const $sm_cxvirtualscreen = 78
  612. Global Const $sm_cyvirtualscreen = 79
  613. Global Const $sm_cmonitors = 80
  614. Global Const $sm_samedisplayformat = 81
  615. Global Const $sm_immenabled = 82
  616. Global Const $sm_cxfocusborder = 83
  617. Global Const $sm_cyfocusborder = 84
  618. Global Const $sm_tabletpc = 86
  619. Global Const $sm_mediacenter = 87
  620. Global Const $sm_starter = 88
  621. Global Const $sm_serverr2 = 89
  622. Global Const $sm_cmetrics = 90
  623. Global Const $sm_remotesession = 4096
  624. Global Const $sm_shuttingdown = 8192
  625. Global Const $sm_remotecontrol = 8193
  626. Global Const $sm_caretblinkingenabled = 8194
  627. Global Const $blackness = 66
  628. Global Const $captureblt = 1073741824
  629. Global Const $dstinvert = 5570569
  630. Global Const $mergecopy = 12583114
  631. Global Const $mergepaint = 12255782
  632. Global Const $nomirrorbitmap = -2147483648
  633. Global Const $notsrccopy = 3342344
  634. Global Const $notsrcerase = 1114278
  635. Global Const $patcopy = 15728673
  636. Global Const $patinvert = 5898313
  637. Global Const $patpaint = 16452105
  638. Global Const $srcand = 8913094
  639. Global Const $srccopy = 13369376
  640. Global Const $srcerase = 4457256
  641. Global Const $srcinvert = 6684742
  642. Global Const $srcpaint = 15597702
  643. Global Const $whiteness = 16711778
  644. Global Const $dt_bottom = 8
  645. Global Const $dt_calcrect = 1024
  646. Global Const $dt_center = 1
  647. Global Const $dt_editcontrol = 8192
  648. Global Const $dt_end_ellipsis = 32768
  649. Global Const $dt_expandtabs = 64
  650. Global Const $dt_externalleading = 512
  651. Global Const $dt_hideprefix = 1048576
  652. Global Const $dt_internal = 4096
  653. Global Const $dt_left = 0
  654. Global Const $dt_modifystring = 65536
  655. Global Const $dt_noclip = 256
  656. Global Const $dt_nofullwidthcharbreak = 524288
  657. Global Const $dt_noprefix = 2048
  658. Global Const $dt_path_ellipsis = 16384
  659. Global Const $dt_prefixonly = 2097152
  660. Global Const $dt_right = 2
  661. Global Const $dt_rtlreading = 131072
  662. Global Const $dt_singleline = 32
  663. Global Const $dt_tabstop = 128
  664. Global Const $dt_top = 0
  665. Global Const $dt_vcenter = 4
  666. Global Const $dt_wordbreak = 16
  667. Global Const $dt_word_ellipsis = 262144
  668. Global Const $rdw_erase = 4
  669. Global Const $rdw_frame = 1024
  670. Global Const $rdw_internalpaint = 2
  671. Global Const $rdw_invalidate = 1
  672. Global Const $rdw_noerase = 32
  673. Global Const $rdw_noframe = 2048
  674. Global Const $rdw_nointernalpaint = 16
  675. Global Const $rdw_validate = 8
  676. Global Const $rdw_erasenow = 512
  677. Global Const $rdw_updatenow = 256
  678. Global Const $rdw_allchildren = 128
  679. Global Const $rdw_nochildren = 64
  680. Global Const $wm_renderformat = 773
  681. Global Const $wm_renderallformats = 774
  682. Global Const $wm_destroyclipboard = 775
  683. Global Const $wm_drawclipboard = 776
  684. Global Const $wm_paintclipboard = 777
  685. Global Const $wm_vscrollclipboard = 778
  686. Global Const $wm_sizeclipboard = 779
  687. Global Const $wm_askcbformatname = 780
  688. Global Const $wm_changecbchain = 781
  689. Global Const $wm_hscrollclipboard = 782
  690. Global Const $hterror = -2
  691. Global Const $httransparent = -1
  692. Global Const $htnowhere = 0
  693. Global Const $htclient = 1
  694. Global Const $htcaption = 2
  695. Global Const $htsysmenu = 3
  696. Global Const $htgrowbox = 4
  697. Global Const $htsize = $htgrowbox
  698. Global Const $htmenu = 5
  699. Global Const $hthscroll = 6
  700. Global Const $htvscroll = 7
  701. Global Const $htminbutton = 8
  702. Global Const $htmaxbutton = 9
  703. Global Const $htleft = 10
  704. Global Const $htright = 11
  705. Global Const $httop = 12
  706. Global Const $httopleft = 13
  707. Global Const $httopright = 14
  708. Global Const $htbottom = 15
  709. Global Const $htbottomleft = 16
  710. Global Const $htbottomright = 17
  711. Global Const $htborder = 18
  712. Global Const $htreduce = $htminbutton
  713. Global Const $htzoom = $htmaxbutton
  714. Global Const $htsizefirst = $htleft
  715. Global Const $htsizelast = $htbottomright
  716. Global Const $htobject = 19
  717. Global Const $htclose = 20
  718. Global Const $hthelp = 21
  719. Global Const $color_scrollbar = 0
  720. Global Const $color_background = 1
  721. Global Const $color_activecaption = 2
  722. Global Const $color_inactivecaption = 3
  723. Global Const $color_menu = 4
  724. Global Const $color_window = 5
  725. Global Const $color_windowframe = 6
  726. Global Const $color_menutext = 7
  727. Global Const $color_windowtext = 8
  728. Global Const $color_captiontext = 9
  729. Global Const $color_activeborder = 10
  730. Global Const $color_inactiveborder = 11
  731. Global Const $color_appworkspace = 12
  732. Global Const $color_highlight = 13
  733. Global Const $color_highlighttext = 14
  734. Global Const $color_btnface = 15
  735. Global Const $color_btnshadow = 16
  736. Global Const $color_graytext = 17
  737. Global Const $color_btntext = 18
  738. Global Const $color_inactivecaptiontext = 19
  739. Global Const $color_btnhighlight = 20
  740. Global Const $color_3ddkshadow = 21
  741. Global Const $color_3dlight = 22
  742. Global Const $color_infotext = 23
  743. Global Const $color_infobk = 24
  744. Global Const $color_hotlight = 26
  745. Global Const $color_gradientactivecaption = 27
  746. Global Const $color_gradientinactivecaption = 28
  747. Global Const $color_menuhilight = 29
  748. Global Const $color_menubar = 30
  749. Global Const $color_desktop = 1
  750. Global Const $color_3dface = 15
  751. Global Const $color_3dshadow = 16
  752. Global Const $color_3dhighlight = 20
  753. Global Const $color_3dhilight = 20
  754. Global Const $color_btnhilight = 20
  755. Global Const $hinst_commctrl = -1
  756. Global Const $idb_std_small_color = 0
  757. Global Const $idb_std_large_color = 1
  758. Global Const $idb_view_small_color = 4
  759. Global Const $idb_view_large_color = 5
  760. Global Const $idb_hist_small_color = 8
  761. Global Const $idb_hist_large_color = 9
  762. Global Const $startf_forceofffeedback = 128
  763. Global Const $startf_forceonfeedback = 64
  764. Global Const $startf_preventpinning = 8192
  765. Global Const $startf_runfullscreen = 32
  766. Global Const $startf_titleisappid = 4096
  767. Global Const $startf_titleislinkname = 2048
  768. Global Const $startf_usecountchars = 8
  769. Global Const $startf_usefillattribute = 16
  770. Global Const $startf_usehotkey = 512
  771. Global Const $startf_useposition = 4
  772. Global Const $startf_useshowwindow = 1
  773. Global Const $startf_usesize = 2
  774. Global Const $startf_usestdhandles = 256
  775. Global Const $cdds_prepaint = 1
  776. Global Const $cdds_postpaint = 2
  777. Global Const $cdds_preerase = 3
  778. Global Const $cdds_posterase = 4
  779. Global Const $cdds_item = 65536
  780. Global Const $cdds_itemprepaint = 65537
  781. Global Const $cdds_itempostpaint = 65538
  782. Global Const $cdds_itempreerase = 65539
  783. Global Const $cdds_itemposterase = 65540
  784. Global Const $cdds_subitem = 131072
  785. Global Const $cdis_selected = 1
  786. Global Const $cdis_grayed = 2
  787. Global Const $cdis_disabled = 4
  788. Global Const $cdis_checked = 8
  789. Global Const $cdis_focus = 16
  790. Global Const $cdis_default = 32
  791. Global Const $cdis_hot = 64
  792. Global Const $cdis_marked = 128
  793. Global Const $cdis_indeterminate = 256
  794. Global Const $cdis_showkeyboardcues = 512
  795. Global Const $cdis_nearhot = 1024
  796. Global Const $cdis_othersidehot = 2048
  797. Global Const $cdis_drophilited = 4096
  798. Global Const $cdrf_dodefault = 0
  799. Global Const $cdrf_newfont = 2
  800. Global Const $cdrf_skipdefault = 4
  801. Global Const $cdrf_notifypostpaint = 16
  802. Global Const $cdrf_notifyitemdraw = 32
  803. Global Const $cdrf_notifysubitemdraw = 32
  804. Global Const $cdrf_notifyposterase = 64
  805. Global Const $cdrf_doerase = 8
  806. Global Const $cdrf_skippostpaint = 256
  807. Global Const $gui_ss_default_gui = BitOR($ws_minimizebox, $ws_caption, $ws_popup, $ws_sysmenu)
  808. Global Const $es_left = 0
  809. Global Const $es_center = 1
  810. Global Const $es_right = 2
  811. Global Const $es_multiline = 4
  812. Global Const $es_uppercase = 8
  813. Global Const $es_lowercase = 16
  814. Global Const $es_password = 32
  815. Global Const $es_autovscroll = 64
  816. Global Const $es_autohscroll = 128
  817. Global Const $es_nohidesel = 256
  818. Global Const $es_oemconvert = 1024
  819. Global Const $es_readonly = 2048
  820. Global Const $es_wantreturn = 4096
  821. Global Const $es_number = 8192
  822. Global Const $ec_err = -1
  823. Global Const $ecm_first = 5376
  824. Global Const $em_canundo = 198
  825. Global Const $em_charfrompos = 215
  826. Global Const $em_emptyundobuffer = 205
  827. Global Const $em_fmtlines = 200
  828. Global Const $em_getcuebanner = ($ecm_first + 2)
  829. Global Const $em_getfirstvisibleline = 206
  830. Global Const $em_gethandle = 189
  831. Global Const $em_getimestatus = 217
  832. Global Const $em_getlimittext = 213
  833. Global Const $em_getline = 196
  834. Global Const $em_getlinecount = 186
  835. Global Const $em_getmargins = 212
  836. Global Const $em_getmodify = 184
  837. Global Const $em_getpasswordchar = 210
  838. Global Const $em_getrect = 178
  839. Global Const $em_getsel = 176
  840. Global Const $em_getthumb = 190
  841. Global Const $em_getwordbreakproc = 209
  842. Global Const $em_hideballoontip = ($ecm_first + 4)
  843. Global Const $em_limittext = 197
  844. Global Const $em_linefromchar = 201
  845. Global Const $em_lineindex = 187
  846. Global Const $em_linelength = 193
  847. Global Const $em_linescroll = 182
  848. Global Const $em_posfromchar = 214
  849. Global Const $em_replacesel = 194
  850. Global Const $em_scroll = 181
  851. Global Const $em_scrollcaret = 183
  852. Global Const $em_setcuebanner = ($ecm_first + 1)
  853. Global Const $em_sethandle = 188
  854. Global Const $em_setimestatus = 216
  855. Global Const $em_setlimittext = $em_limittext
  856. Global Const $em_setmargins = 211
  857. Global Const $em_setmodify = 185
  858. Global Const $em_setpasswordchar = 204
  859. Global Const $em_setreadonly = 207
  860. Global Const $em_setrect = 179
  861. Global Const $em_setrectnp = 180
  862. Global Const $em_setsel = 177
  863. Global Const $em_settabstops = 203
  864. Global Const $em_setwordbreakproc = 208
  865. Global Const $em_showballoontip = ($ecm_first + 3)
  866. Global Const $em_undo = 199
  867. Global Const $ec_leftmargin = 1
  868. Global Const $ec_rightmargin = 2
  869. Global Const $ec_usefontinfo = 65535
  870. Global Const $emsis_compositionstring = 1
  871. Global Const $eimes_getcompstratonce = 1
  872. Global Const $eimes_cancelcompstrinfocus = 2
  873. Global Const $eimes_completecompstrkillfocus = 4
  874. Global Const $en_align_ltr_ec = 1792
  875. Global Const $en_align_rtl_ec = 1793
  876. Global Const $en_change = 768
  877. Global Const $en_errspace = 1280
  878. Global Const $en_hscroll = 1537
  879. Global Const $en_killfocus = 512
  880. Global Const $en_maxtext = 1281
  881. Global Const $en_setfocus = 256
  882. Global Const $en_update = 1024
  883. Global Const $en_vscroll = 1538
  884. Global Const $gui_ss_default_edit = 3150016
  885. Global Const $gui_ss_default_input = 128
  886. #Region _Memory
  887.  
  888. Func _memoryopen($iv_pid, $iv_desiredaccess = 2035711, $if_inherithandle = 1)
  889. If NOT ProcessExists($iv_pid) Then
  890. SetError(1)
  891. Return 0
  892. EndIf
  893. Local $ah_handle[2] = [DllOpen("kernel32.dll")]
  894. If @error Then
  895. SetError(2)
  896. Return 0
  897. EndIf
  898. Local $av_openprocess = DllCall($ah_handle[0], "int", "OpenProcess", "int", $iv_desiredaccess, "int", $if_inherithandle, "int", $iv_pid)
  899. If @error Then
  900. DllClose($ah_handle[0])
  901. SetError(3)
  902. Return 0
  903. EndIf
  904. $ah_handle[1] = $av_openprocess[0]
  905. Return $ah_handle
  906. EndFunc
  907.  
  908. Func _memoryread($iv_address, $ah_handle, $sv_type = "dword")
  909. If NOT IsArray($ah_handle) Then
  910. SetError(1)
  911. Return 0
  912. EndIf
  913. Local $v_buffer = DllStructCreate($sv_type)
  914. If @error Then
  915. SetError(@error + 1)
  916. Return 0
  917. EndIf
  918. DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
  919. If NOT @error Then
  920. Local $v_value = DllStructGetData($v_buffer, 1)
  921. Return $v_value
  922. Else
  923. SetError(6)
  924. Return 0
  925. EndIf
  926. EndFunc
  927.  
  928. Func _memorywrite($iv_address, $ah_handle, $v_data, $sv_type = "dword")
  929. If NOT IsArray($ah_handle) Then
  930. SetError(1)
  931. Return 0
  932. EndIf
  933. Local $v_buffer = DllStructCreate($sv_type)
  934. If @error Then
  935. SetError(@error + 1)
  936. Return 0
  937. Else
  938. DllStructSetData($v_buffer, 1, $v_data)
  939. If @error Then
  940. SetError(6)
  941. Return 0
  942. EndIf
  943. EndIf
  944. DllCall($ah_handle[0], "int", "WriteProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
  945. If NOT @error Then
  946. Return 1
  947. Else
  948. SetError(7)
  949. Return 0
  950. EndIf
  951. EndFunc
  952.  
  953. Func _memoryclose($ah_handle)
  954. If NOT IsArray($ah_handle) Then
  955. SetError(1)
  956. Return 0
  957. EndIf
  958. DllCall($ah_handle[0], "int", "CloseHandle", "int", $ah_handle[1])
  959. If NOT @error Then
  960. DllClose($ah_handle[0])
  961. Return 1
  962. Else
  963. DllClose($ah_handle[0])
  964. SetError(2)
  965. Return 0
  966. EndIf
  967. EndFunc
  968.  
  969. Func _memorypointerread($iv_address, $ah_handle, $av_offset, $sv_type = "dword")
  970. If IsArray($av_offset) Then
  971. If IsArray($ah_handle) Then
  972. Local $iv_pointercount = UBound($av_offset) - 1
  973. Else
  974. SetError(2)
  975. Return 0
  976. EndIf
  977. Else
  978. SetError(1)
  979. Return 0
  980. EndIf
  981. Local $iv_data[2], $i
  982. Local $v_buffer = DllStructCreate("dword")
  983. For $i = 0 To $iv_pointercount
  984. If $i = $iv_pointercount Then
  985. $v_buffer = DllStructCreate($sv_type)
  986. If @error Then
  987. SetError(@error + 2)
  988. Return 0
  989. EndIf
  990. $iv_address = "0x" & Hex($iv_data[1] + $av_offset[$i])
  991. DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
  992. If @error Then
  993. SetError(7)
  994. Return 0
  995. EndIf
  996. $iv_data[1] = DllStructGetData($v_buffer, 1)
  997. ElseIf $i = 0 Then
  998. DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
  999. If @error Then
  1000. SetError(7)
  1001. Return 0
  1002. EndIf
  1003. $iv_data[1] = DllStructGetData($v_buffer, 1)
  1004. Else
  1005. $iv_address = "0x" & Hex($iv_data[1] + $av_offset[$i])
  1006. DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
  1007. If @error Then
  1008. SetError(7)
  1009. Return 0
  1010. EndIf
  1011. $iv_data[1] = DllStructGetData($v_buffer, 1)
  1012. EndIf
  1013. Next
  1014. $iv_data[0] = $iv_address
  1015. Return $iv_data
  1016. EndFunc
  1017.  
  1018. Func _memorypointerwrite($iv_address, $ah_handle, $av_offset, $v_data, $sv_type = "dword")
  1019. If IsArray($av_offset) Then
  1020. If IsArray($ah_handle) Then
  1021. Local $iv_pointercount = UBound($av_offset) - 1
  1022. Else
  1023. SetError(2)
  1024. Return 0
  1025. EndIf
  1026. Else
  1027. SetError(1)
  1028. Return 0
  1029. EndIf
  1030. Local $iv_structdata, $i
  1031. Local $v_buffer = DllStructCreate("dword")
  1032. For $i = 0 To $iv_pointercount
  1033. If $i = $iv_pointercount Then
  1034. $v_buffer = DllStructCreate($sv_type)
  1035. If @error Then
  1036. SetError(@error + 3)
  1037. Return 0
  1038. EndIf
  1039. DllStructSetData($v_buffer, 1, $v_data)
  1040. If @error Then
  1041. SetError(8)
  1042. Return 0
  1043. EndIf
  1044. $iv_address = "0x" & Hex($iv_structdata + $av_offset[$i])
  1045. DllCall($ah_handle[0], "int", "WriteProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
  1046. If @error Then
  1047. SetError(9)
  1048. Return 0
  1049. Else
  1050. Return $iv_address
  1051. EndIf
  1052. ElseIf $i = 0 Then
  1053. DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
  1054. If @error Then
  1055. SetError(3)
  1056. Return 0
  1057. EndIf
  1058. $iv_structdata = DllStructGetData($v_buffer, 1)
  1059. Else
  1060. $iv_address = "0x" & Hex($iv_structdata + $av_offset[$i])
  1061. DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
  1062. If @error Then
  1063. SetError(3)
  1064. Return 0
  1065. EndIf
  1066. $iv_structdata = DllStructGetData($v_buffer, 1)
  1067. EndIf
  1068. Next
  1069. EndFunc
  1070.  
  1071. Func setprivilege($privilege, $benable)
  1072. Const $token_adjust_privileges = 32
  1073. Const $token_query = 8
  1074. Const $se_privilege_enabled = 2
  1075. Local $htoken, $sp_auxret, $sp_ret, $hcurrprocess, $ntokens, $ntokenindex, $priv
  1076. $ntokens = 1
  1077. $luid = DllStructCreate("dword;int")
  1078. If IsArray($privilege) Then $ntokens = UBound($privilege)
  1079. $token_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
  1080. $newtoken_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
  1081. $hcurrprocess = DllCall("kernel32.dll", "hwnd", "GetCurrentProcess")
  1082. $sp_auxret = DllCall("advapi32.dll", "int", "OpenProcessToken", "hwnd", $hcurrprocess[0], "int", BitOR($token_adjust_privileges, $token_query), "int*", 0)
  1083. If $sp_auxret[0] Then
  1084. $htoken = $sp_auxret[3]
  1085. DllStructSetData($token_privileges, 1, 1)
  1086. $ntokenindex = 1
  1087. While $ntokenindex <= $ntokens
  1088. If IsArray($privilege) Then
  1089. $priv = $privilege[$ntokenindex - 1]
  1090. Else
  1091. $priv = $privilege
  1092. EndIf
  1093. $ret = DllCall("advapi32.dll", "int", "LookupPrivilegeValue", "str", "", "str", $priv, "ptr", DllStructGetPtr($luid))
  1094. If $ret[0] Then
  1095. If $benable Then
  1096. DllStructSetData($token_privileges, 2, $se_privilege_enabled, (3 * $ntokenindex))
  1097. Else
  1098. DllStructSetData($token_privileges, 2, 0, (3 * $ntokenindex))
  1099. EndIf
  1100. DllStructSetData($token_privileges, 2, DllStructGetData($luid, 1), (3 * ($ntokenindex - 1)) + 1)
  1101. DllStructSetData($token_privileges, 2, DllStructGetData($luid, 2), (3 * ($ntokenindex - 1)) + 2)
  1102. DllStructSetData($luid, 1, 0)
  1103. DllStructSetData($luid, 2, 0)
  1104. EndIf
  1105. $ntokenindex += 1
  1106. WEnd
  1107. $ret = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "hwnd", $htoken, "int", 0, "ptr", DllStructGetPtr($token_privileges), "int", DllStructGetSize($newtoken_privileges), "ptr", DllStructGetPtr($newtoken_privileges), "int*", 0)
  1108. $f = DllCall("kernel32.dll", "int", "GetLastError")
  1109. EndIf
  1110. $newtoken_privileges = 0
  1111. $token_privileges = 0
  1112. $luid = 0
  1113. If $sp_auxret[0] = 0 Then Return 0
  1114. $sp_auxret = DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $htoken)
  1115. If NOT $ret[0] AND NOT $sp_auxret[0] Then Return 0
  1116. Return $ret[0]
  1117. EndFunc
  1118.  
  1119. Func _memorygetbaseaddress($ah_handle, $ihexdec = 0)
  1120. Local $iv_address = 1048576
  1121. Local $v_buffer = DllStructCreate("dword;dword;dword;dword;dword;dword;dword")
  1122. Local $vdata
  1123. Local $vtype
  1124. If NOT IsArray($ah_handle) Then
  1125. SetError(1)
  1126. Return 0
  1127. EndIf
  1128. DllCall($ah_handle[0], "int", "VirtualQueryEx", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer))
  1129. If NOT @error Then
  1130. $vdata = Hex(DllStructGetData($v_buffer, 2))
  1131. $vtype = Hex(DllStructGetData($v_buffer, 3))
  1132. While $vtype <> "00000080"
  1133. DllCall($ah_handle[0], "int", "VirtualQueryEx", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer))
  1134. $vdata = Hex(DllStructGetData($v_buffer, 2))
  1135. $vtype = Hex(DllStructGetData($v_buffer, 3))
  1136. If Hex($iv_address) = "01000000" Then ExitLoop
  1137. $iv_address += 65536
  1138. WEnd
  1139. If $vtype = "00000080" Then
  1140. SetError(0)
  1141. If $ihexdec = 1 Then
  1142. Return Dec($vdata)
  1143. Else
  1144. Return $vdata
  1145. EndIf
  1146. Else
  1147. SetError(2)
  1148. Return 0
  1149. EndIf
  1150. Else
  1151. SetError(3)
  1152. Return 0
  1153. EndIf
  1154. EndFunc
  1155.  
  1156. Func _memorymodulegetbaseaddress($ipid, $smodule)
  1157. If NOT ProcessExists($ipid) Then Return SetError(1, 0, 0)
  1158. If NOT IsString($smodule) Then Return SetError(2, 0, 0)
  1159. Local $psapi = DllOpen("psapi.dll")
  1160. Local $hprocess
  1161. Local $permission = BitOR(2, 1024, 8, 16, 32)
  1162. If $ipid > 0 Then
  1163. Local $hprocess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $permission, "int", 0, "dword", $ipid)
  1164. If $hprocess[0] Then
  1165. $hprocess = $hprocess[0]
  1166. EndIf
  1167. EndIf
  1168. Local $modules = DllStructCreate("ptr[1024]")
  1169. Local $acall = DllCall($psapi, "int", "EnumProcessModules", "ptr", $hprocess, "ptr", DllStructGetPtr($modules), "dword", DllStructGetSize($modules), "dword*", 0)
  1170. If $acall[4] > 0 Then
  1171. Local $imodnum = $acall[4] / 4
  1172. Local $atemp
  1173. For $i = 1 To $imodnum
  1174. $atemp = DllCall($psapi, "dword", "GetModuleBaseNameW", "ptr", $hprocess, "ptr", Ptr(DllStructGetData($modules, 1, $i)), "wstr", "", "dword", 260)
  1175. If $atemp[3] = $smodule Then
  1176. DllClose($psapi)
  1177. Return Ptr(DllStructGetData($modules, 1, $i))
  1178. EndIf
  1179. Next
  1180. EndIf
  1181. DllClose($psapi)
  1182. Return SetError(-1, 0, 0)
  1183. EndFunc
  1184.  
  1185. #EndRegion
  1186. Global Const $math_isnotdivisible = 1
  1187. Global Const $math_isdivisible = 2
  1188. Global Const $math_degrees = 57.2957795130823
  1189.  
  1190. Func _degree($iradians)
  1191. Return IsNumber($iradians) ? $iradians * $math_degrees : SetError(1, 0, "")
  1192. EndFunc
  1193.  
  1194. Func _mathcheckdiv($inum1, $inum2 = 2)
  1195. If NOT (IsInt($inum1) AND IsInt($inum2)) Then
  1196. Return SetError(1, 0, -1)
  1197. EndIf
  1198. Return (Mod($inum1, $inum2) = 0) ? $math_isdivisible : $math_isnotdivisible
  1199. EndFunc
  1200.  
  1201. Func _max($inum1, $inum2)
  1202. If NOT IsNumber($inum1) Then Return SetError(1, 0, 0)
  1203. If NOT IsNumber($inum2) Then Return SetError(2, 0, 0)
  1204. Return ($inum1 > $inum2) ? $inum1 : $inum2
  1205. EndFunc
  1206.  
  1207. Func _min($inum1, $inum2)
  1208. If NOT IsNumber($inum1) Then Return SetError(1, 0, 0)
  1209. If NOT IsNumber($inum2) Then Return SetError(2, 0, 0)
  1210. Return ($inum1 > $inum2) ? $inum2 : $inum1
  1211. EndFunc
  1212.  
  1213. Func _radian($idegrees)
  1214. Return Number($idegrees) ? $idegrees / $math_degrees : SetError(1, 0, "")
  1215. EndFunc
  1216.  
  1217. Global Const $str_nocasesense = 0
  1218. Global Const $str_casesense = 1
  1219. Global Const $str_nocasesensebasic = 2
  1220. Global Const $str_stripleading = 1
  1221. Global Const $str_striptrailing = 2
  1222. Global Const $str_stripspaces = 4
  1223. Global Const $str_stripall = 8
  1224. Global Const $str_chrsplit = 0
  1225. Global Const $str_entiresplit = 1
  1226. Global Const $str_nocount = 2
  1227. Global Const $str_regexpmatch = 0
  1228. Global Const $str_regexparraymatch = 1
  1229. Global Const $str_regexparrayfullmatch = 2
  1230. Global Const $str_regexparrayglobalmatch = 3
  1231. Global Const $str_regexparrayglobalfullmatch = 4
  1232. Global Const $str_endisstart = 0
  1233. Global Const $str_endnotstart = 1
  1234. Global Const $sb_ansi = 1
  1235. Global Const $sb_utf16le = 2
  1236. Global Const $sb_utf16be = 3
  1237. Global Const $sb_utf8 = 4
  1238. Global Const $se_utf16 = 0
  1239. Global Const $se_ansi = 1
  1240. Global Const $se_utf8 = 2
  1241. Global Const $str_utf16 = 0
  1242. Global Const $str_ucs2 = 1
  1243.  
  1244. Func _hextostring($shex)
  1245. If NOT (StringLeft($shex, 2) == "0x") Then $shex = "0x" & $shex
  1246. Return BinaryToString($shex, $sb_utf8)
  1247. EndFunc
  1248.  
  1249. Func _stringbetween($sstring, $sstart, $send, $imode = $str_endisstart, $bcase = False)
  1250. $sstart = $sstart ? "\Q" & $sstart & "\E" : "\A"
  1251. If $imode <> $str_endnotstart Then $imode = $str_endisstart
  1252. If $imode = $str_endisstart Then
  1253. $send = $send ? "(?=\Q" & $send & "\E)" : "\z"
  1254. Else
  1255. $send = $send ? "\Q" & $send & "\E" : "\z"
  1256. EndIf
  1257. If $bcase = Default Then
  1258. $bcase = False
  1259. EndIf
  1260. Local $areturn = StringRegExp($sstring, "(?s" & (NOT $bcase ? "i" : "") & ")" & $sstart & "(.*?)" & $send, $str_regexparrayglobalmatch)
  1261. If @error Then Return SetError(1, 0, 0)
  1262. Return $areturn
  1263. EndFunc
  1264.  
  1265. Func _stringexplode($sstring, $sdelimiter, $ilimit = 0)
  1266. If $ilimit = Default Then $ilimit = 0
  1267. If $ilimit > 0 Then
  1268. Local Const $null = Chr(0)
  1269. $sstring = StringReplace($sstring, $sdelimiter, $null, $ilimit)
  1270. $sdelimiter = $null
  1271. ElseIf $ilimit < 0 Then
  1272. Local $iindex = StringInStr($sstring, $sdelimiter, 0, $ilimit)
  1273. If $iindex Then
  1274. $sstring = StringLeft($sstring, $iindex - 1)
  1275. EndIf
  1276. EndIf
  1277. Return StringSplit($sstring, $sdelimiter, $str_entiresplit + $str_nocount)
  1278. EndFunc
  1279.  
  1280. Func _stringinsert($sstring, $sinsertstring, $iposition)
  1281. Local $ilength = StringLen($sstring)
  1282. $iposition = Int($iposition)
  1283. If $iposition < 0 Then $iposition = $ilength + $iposition
  1284. If $ilength < $iposition OR $iposition < 0 Then Return SetError(1, 0, $sstring)
  1285. Return StringLeft($sstring, $iposition) & $sinsertstring & StringRight($sstring, $ilength - $iposition)
  1286. EndFunc
  1287.  
  1288. Func _stringproper($sstring)
  1289. Local $bcapnext = True, $schr = "", $sreturn = ""
  1290. For $i = 1 To StringLen($sstring)
  1291. $schr = StringMid($sstring, $i, 1)
  1292. Select
  1293. Case $bcapnext = True
  1294. If StringRegExp($schr, "[a-zA-ZГЂ-ГїЕЎЕ“ЕѕЕё]") Then
  1295. $schr = StringUpper($schr)
  1296. $bcapnext = False
  1297. EndIf
  1298. Case NOT StringRegExp($schr, "[a-zA-ZГЂ-ГїЕЎЕ“ЕѕЕё]")
  1299. $bcapnext = True
  1300. Case Else
  1301. $schr = StringLower($schr)
  1302. EndSelect
  1303. $sreturn &= $schr
  1304. Next
  1305. Return $sreturn
  1306. EndFunc
  1307.  
  1308. Func _stringrepeat($sstring, $irepeatcount)
  1309. $irepeatcount = Int($irepeatcount)
  1310. If $irepeatcount = 0 Then Return ""
  1311. If StringLen($sstring) < 1 OR $irepeatcount < 0 Then Return SetError(1, 0, "")
  1312. Local $sresult = ""
  1313. While $irepeatcount > 1
  1314. If BitAND($irepeatcount, 1) Then $sresult &= $sstring
  1315. $sstring &= $sstring
  1316. $irepeatcount = BitShift($irepeatcount, 1)
  1317. WEnd
  1318. Return $sstring & $sresult
  1319. EndFunc
  1320.  
  1321. Func _stringtitlecase($sstring)
  1322. Local $bcapnext = True, $schr = "", $sreturn = ""
  1323. For $i = 1 To StringLen($sstring)
  1324. $schr = StringMid($sstring, $i, 1)
  1325. Select
  1326. Case $bcapnext = True
  1327. If StringRegExp($schr, "[a-zA-Z\xC0-\xFF0-9]") Then
  1328. $schr = StringUpper($schr)
  1329. $bcapnext = False
  1330. EndIf
  1331. Case NOT StringRegExp($schr, "[a-zA-Z\xC0-\xFF'0-9]")
  1332. $bcapnext = True
  1333. Case Else
  1334. $schr = StringLower($schr)
  1335. EndSelect
  1336. $sreturn &= $schr
  1337. Next
  1338. Return $sreturn
  1339. EndFunc
  1340.  
  1341. Func _stringtohex($sstring)
  1342. Return Hex(StringToBinary($sstring, $sb_utf8))
  1343. EndFunc
  1344.  
  1345. Global Const $opt_coordsrelative = 0
  1346. Global Const $opt_coordsabsolute = 1
  1347. Global Const $opt_coordsclient = 2
  1348. Global Const $opt_errorsilent = 0
  1349. Global Const $opt_errorfatal = 1
  1350. Global Const $opt_capsnostore = 0
  1351. Global Const $opt_capsstore = 1
  1352. Global Const $opt_matchstart = 1
  1353. Global Const $opt_matchany = 2
  1354. Global Const $opt_matchexact = 3
  1355. Global Const $opt_matchadvanced = 4
  1356. Global Const $ccs_top = 1
  1357. Global Const $ccs_nomovey = 2
  1358. Global Const $ccs_bottom = 3
  1359. Global Const $ccs_noresize = 4
  1360. Global Const $ccs_noparentalign = 8
  1361. Global Const $ccs_nohilite = 16
  1362. Global Const $ccs_adjustable = 32
  1363. Global Const $ccs_nodivider = 64
  1364. Global Const $ccs_vert = 128
  1365. Global Const $ccs_left = 129
  1366. Global Const $ccs_nomovex = 130
  1367. Global Const $ccs_right = 131
  1368. Global Const $dt_drivetype = 1
  1369. Global Const $dt_ssdstatus = 2
  1370. Global Const $dt_bustype = 3
  1371. Global Const $proxy_ie = 0
  1372. Global Const $proxy_none = 1
  1373. Global Const $proxy_specified = 2
  1374. Global Const $objid_window = 0
  1375. Global Const $objid_titlebar = -2
  1376. Global Const $objid_sizegrip = -7
  1377. Global Const $objid_caret = -8
  1378. Global Const $objid_cursor = -9
  1379. Global Const $objid_alert = -10
  1380. Global Const $objid_sound = -11
  1381. Global Const $dlg_centerontop = 0
  1382. Global Const $dlg_notitle = 1
  1383. Global Const $dlg_notontop = 2
  1384. Global Const $dlg_textleft = 4
  1385. Global Const $dlg_textright = 8
  1386. Global Const $dlg_moveable = 16
  1387. Global Const $dlg_textvcenter = 32
  1388. Global Const $idc_unknown = 0
  1389. Global Const $idc_appstarting = 1
  1390. Global Const $idc_arrow = 2
  1391. Global Const $idc_cross = 3
  1392. Global Const $idc_hand = 32649
  1393. Global Const $idc_help = 4
  1394. Global Const $idc_ibeam = 5
  1395. Global Const $idc_icon = 6
  1396. Global Const $idc_no = 7
  1397. Global Const $idc_size = 8
  1398. Global Const $idc_sizeall = 9
  1399. Global Const $idc_sizenesw = 10
  1400. Global Const $idc_sizens = 11
  1401. Global Const $idc_sizenwse = 12
  1402. Global Const $idc_sizewe = 13
  1403. Global Const $idc_uparrow = 14
  1404. Global Const $idc_wait = 15
  1405. Global Const $idi_application = 32512
  1406. Global Const $idi_asterisk = 32516
  1407. Global Const $idi_exclamation = 32515
  1408. Global Const $idi_hand = 32513
  1409. Global Const $idi_question = 32514
  1410. Global Const $idi_winlogo = 32517
  1411. Global Const $idi_shield = 32518
  1412. Global Const $idi_error = $idi_hand
  1413. Global Const $idi_information = $idi_asterisk
  1414. Global Const $idi_warning = $idi_exclamation
  1415. Global Const $sd_logoff = 0
  1416. Global Const $sd_shutdown = 1
  1417. Global Const $sd_reboot = 2
  1418. Global Const $sd_force = 4
  1419. Global Const $sd_powerdown = 8
  1420. Global Const $sd_forcehung = 16
  1421. Global Const $sd_standby = 32
  1422. Global Const $sd_hibernate = 64
  1423. Global Const $stdin_child = 1
  1424. Global Const $stdout_child = 2
  1425. Global Const $stderr_child = 4
  1426. Global Const $stderr_merged = 8
  1427. Global Const $stdio_inherit_parent = 16
  1428. Global Const $run_create_new_console = 65536
  1429. Global Const $ubound_dimensions = 0
  1430. Global Const $ubound_rows = 1
  1431. Global Const $ubound_columns = 2
  1432. Global Const $mouseeventf_absolute = 32768
  1433. Global Const $mouseeventf_move = 1
  1434. Global Const $mouseeventf_leftdown = 2
  1435. Global Const $mouseeventf_leftup = 4
  1436. Global Const $mouseeventf_rightdown = 8
  1437. Global Const $mouseeventf_rightup = 16
  1438. Global Const $mouseeventf_middledown = 32
  1439. Global Const $mouseeventf_middleup = 64
  1440. Global Const $mouseeventf_wheel = 2048
  1441. Global Const $mouseeventf_xdown = 128
  1442. Global Const $mouseeventf_xup = 256
  1443. Global Const $reg_none = 0
  1444. Global Const $reg_sz = 1
  1445. Global Const $reg_expand_sz = 2
  1446. Global Const $reg_binary = 3
  1447. Global Const $reg_dword = 4
  1448. Global Const $reg_dword_little_endian = 4
  1449. Global Const $reg_dword_big_endian = 5
  1450. Global Const $reg_link = 6
  1451. Global Const $reg_multi_sz = 7
  1452. Global Const $reg_resource_list = 8
  1453. Global Const $reg_full_resource_descriptor = 9
  1454. Global Const $reg_resource_requirements_list = 10
  1455. Global Const $reg_qword = 11
  1456. Global Const $reg_qword_little_endian = 11
  1457. Global Const $hwnd_bottom = 1
  1458. Global Const $hwnd_notopmost = -2
  1459. Global Const $hwnd_top = 0
  1460. Global Const $hwnd_topmost = -1
  1461. Global Const $swp_nosize = 1
  1462. Global Const $swp_nomove = 2
  1463. Global Const $swp_nozorder = 4
  1464. Global Const $swp_noredraw = 8
  1465. Global Const $swp_noactivate = 16
  1466. Global Const $swp_framechanged = 32
  1467. Global Const $swp_drawframe = 32
  1468. Global Const $swp_showwindow = 64
  1469. Global Const $swp_hidewindow = 128
  1470. Global Const $swp_nocopybits = 256
  1471. Global Const $swp_noownerzorder = 512
  1472. Global Const $swp_noreposition = 512
  1473. Global Const $swp_nosendchanging = 1024
  1474. Global Const $swp_defererase = 8192
  1475. Global Const $swp_asyncwindowpos = 16384
  1476. Global Const $keyword_default = 1
  1477. Global Const $keyword_null = 2
  1478. Global Const $declared_local = -1
  1479. Global Const $declared_unknown = 0
  1480. Global Const $declared_global = 1
  1481. Global Const $assign_create = 0
  1482. Global Const $assign_forcelocal = 1
  1483. Global Const $assign_forceglobal = 2
  1484. Global Const $assign_existfail = 4
  1485. Global Const $bi_enable = 0
  1486. Global Const $bi_disable = 1
  1487. Global Const $break_enable = 1
  1488. Global Const $break_disable = 0
  1489. Global Const $cdtray_open = "open"
  1490. Global Const $cdtray_closed = "closed"
  1491. Global Const $send_default = 0
  1492. Global Const $send_raw = 1
  1493. Global Const $dir_default = 0
  1494. Global Const $dir_extended = 1
  1495. Global Const $dir_norecurse = 2
  1496. Global Const $dir_remove = 1
  1497. Global Const $dt_all = "ALL"
  1498. Global Const $dt_cdrom = "CDROM"
  1499. Global Const $dt_removable = "REMOVABLE"
  1500. Global Const $dt_fixed = "FIXED"
  1501. Global Const $dt_network = "NETWORK"
  1502. Global Const $dt_ramdisk = "RAMDISK"
  1503. Global Const $dt_unknown = "UNKNOWN"
  1504. Global Const $dt_undefined = 1
  1505. Global Const $dt_fat = "FAT"
  1506. Global Const $dt_fat32 = "FAT32"
  1507. Global Const $dt_exfat = "exFAT"
  1508. Global Const $dt_ntfs = "NTFS"
  1509. Global Const $dt_nwfs = "NWFS"
  1510. Global Const $dt_cdfs = "CDFS"
  1511. Global Const $dt_udf = "UDF"
  1512. Global Const $dma_default = 0
  1513. Global Const $dma_persistent = 1
  1514. Global Const $dma_authentication = 8
  1515. Global Const $ds_unknown = "UNKNOWN"
  1516. Global Const $ds_ready = "READY"
  1517. Global Const $ds_notready = "NOTREADY"
  1518. Global Const $ds_invalid = "INVALID"
  1519. Global Const $mouse_click_left = "left"
  1520. Global Const $mouse_click_right = "right"
  1521. Global Const $mouse_click_middle = "middle"
  1522. Global Const $mouse_click_main = "main"
  1523. Global Const $mouse_click_menu = "menu"
  1524. Global Const $mouse_click_primary = "primary"
  1525. Global Const $mouse_click_secondary = "secondary"
  1526. Global Const $mouse_wheel_up = "up"
  1527. Global Const $mouse_wheel_down = "down"
  1528. Global Const $number_auto = 0
  1529. Global Const $number_32bit = 1
  1530. Global Const $number_64bit = 2
  1531. Global Const $number_double = 3
  1532. Global Const $obj_name = 1
  1533. Global Const $obj_string = 2
  1534. Global Const $obj_progid = 3
  1535. Global Const $obj_file = 4
  1536. Global Const $obj_module = 5
  1537. Global Const $obj_clsid = 6
  1538. Global Const $obj_iid = 7
  1539. Global Const $exitclose_normal = 0
  1540. Global Const $exitclose_byexit = 1
  1541. Global Const $exitclose_byclick = 2
  1542. Global Const $exitclose_bylogoff = 3
  1543. Global Const $exitclose_bysutdown = 4
  1544. Global Const $process_stats_memory = 0
  1545. Global Const $process_stats_io = 1
  1546. Global Const $process_low = 0
  1547. Global Const $process_belownormal = 1
  1548. Global Const $process_normal = 2
  1549. Global Const $process_abovenormal = 3
  1550. Global Const $process_high = 4
  1551. Global Const $process_realtime = 5
  1552. Global Const $run_logon_noprofile = 0
  1553. Global Const $run_logon_profile = 1
  1554. Global Const $run_logon_network = 2
  1555. Global Const $run_logon_inherit = 4
  1556. Global Const $sound_nowait = 0
  1557. Global Const $sound_wait = 1
  1558. Global Const $shex_open = "open"
  1559. Global Const $shex_edit = "edit"
  1560. Global Const $shex_print = "print"
  1561. Global Const $shex_properties = "properties"
  1562. Global Const $tcp_data_default = 0
  1563. Global Const $tcp_data_binary = 1
  1564. Global Const $udp_open_default = 0
  1565. Global Const $udp_open_broadcast = 1
  1566. Global Const $udp_data_default = 0
  1567. Global Const $udp_data_binary = 1
  1568. Global Const $udp_data_array = 2
  1569. Global Const $tip_noicon = 0
  1570. Global Const $tip_infoicon = 1
  1571. Global Const $tip_warningicon = 2
  1572. Global Const $tip_erroricon = 3
  1573. Global Const $tip_balloon = 1
  1574. Global Const $tip_center = 2
  1575. Global Const $tip_forcevisible = 4
  1576. Global Const $windows_noontop = 0
  1577. Global Const $windows_ontop = 1
  1578. Global Const $mb_ok = 0
  1579. Global Const $mb_okcancel = 1
  1580. Global Const $mb_abortretryignore = 2
  1581. Global Const $mb_yesnocancel = 3
  1582. Global Const $mb_yesno = 4
  1583. Global Const $mb_retrycancel = 5
  1584. Global Const $mb_canceltrycontinue = 6
  1585. Global Const $mb_help = 16384
  1586. Global Const $mb_iconstop = 16
  1587. Global Const $mb_iconerror = 16
  1588. Global Const $mb_iconhand = 16
  1589. Global Const $mb_iconquestion = 32
  1590. Global Const $mb_iconexclamation = 48
  1591. Global Const $mb_iconwarning = 48
  1592. Global Const $mb_iconinformation = 64
  1593. Global Const $mb_iconasterisk = 64
  1594. Global Const $mb_usericon = 128
  1595. Global Const $mb_defbutton1 = 0
  1596. Global Const $mb_defbutton2 = 256
  1597. Global Const $mb_defbutton3 = 512
  1598. Global Const $mb_defbutton4 = 768
  1599. Global Const $mb_applmodal = 0
  1600. Global Const $mb_systemmodal = 4096
  1601. Global Const $mb_taskmodal = 8192
  1602. Global Const $mb_default_desktop_only = 131072
  1603. Global Const $mb_right = 524288
  1604. Global Const $mb_rtlreading = 1048576
  1605. Global Const $mb_setforeground = 65536
  1606. Global Const $mb_topmost = 262144
  1607. Global Const $mb_service_notification = 2097152
  1608. Global Const $mb_rightjustified = $mb_right
  1609. Global Const $idtimeout = -1
  1610. Global Const $idok = 1
  1611. Global Const $idcancel = 2
  1612. Global Const $idabort = 3
  1613. Global Const $idretry = 4
  1614. Global Const $idignore = 5
  1615. Global Const $idyes = 6
  1616. Global Const $idno = 7
  1617. Global Const $idclose = 8
  1618. Global Const $idhelp = 9
  1619. Global Const $idtryagain = 10
  1620. Global Const $idcontinue = 11
  1621. Global Enum $arrayfill_force_default, $arrayfill_force_singleitem, $arrayfill_force_int, $arrayfill_force_number, $arrayfill_force_ptr, $arrayfill_force_hwnd, $arrayfill_force_string
  1622. Global Enum $arrayunique_nocount, $arrayunique_count
  1623. Global Enum $arrayunique_auto, $arrayunique_force32, $arrayunique_force64, $arrayunique_match, $arrayunique_distinct
  1624.  
  1625. Func _arrayadd(ByRef $aarray, $vvalue, $istart = 0, $sdelim_item = "|", $sdelim_row = @CRLF, $iforce = $arrayfill_force_default)
  1626. If $istart = Default Then $istart = 0
  1627. If $sdelim_item = Default Then $sdelim_item = "|"
  1628. If $sdelim_row = Default Then $sdelim_row = @CRLF
  1629. If $iforce = Default Then $iforce = $arrayfill_force_default
  1630. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  1631. Local $idim_1 = UBound($aarray, $ubound_rows)
  1632. Local $hdatatype = 0
  1633. Switch $iforce
  1634. Case $arrayfill_force_int
  1635. $hdatatype = Int
  1636. Case $arrayfill_force_number
  1637. $hdatatype = Number
  1638. Case $arrayfill_force_ptr
  1639. $hdatatype = Ptr
  1640. Case $arrayfill_force_hwnd
  1641. $hdatatype = HWnd
  1642. Case $arrayfill_force_string
  1643. $hdatatype = String
  1644. EndSwitch
  1645. Switch UBound($aarray, $ubound_dimensions)
  1646. Case 1
  1647. If $iforce = $arrayfill_force_singleitem Then
  1648. ReDim $aarray[$idim_1 + 1]
  1649. $aarray[$idim_1] = $vvalue
  1650. Return $idim_1
  1651. EndIf
  1652. If IsArray($vvalue) Then
  1653. If UBound($vvalue, $ubound_dimensions) <> 1 Then Return SetError(5, 0, -1)
  1654. $hdatatype = 0
  1655. Else
  1656. Local $atmp = StringSplit($vvalue, $sdelim_item, $str_nocount + $str_entiresplit)
  1657. If UBound($atmp, $ubound_rows) = 1 Then
  1658. $atmp[0] = $vvalue
  1659. EndIf
  1660. $vvalue = $atmp
  1661. EndIf
  1662. Local $iadd = UBound($vvalue, $ubound_rows)
  1663. ReDim $aarray[$idim_1 + $iadd]
  1664. For $i = 0 To $iadd - 1
  1665. If IsFunc($hdatatype) Then
  1666. $aarray[$idim_1 + $i] = $hdatatype($vvalue[$i])
  1667. Else
  1668. $aarray[$idim_1 + $i] = $vvalue[$i]
  1669. EndIf
  1670. Next
  1671. Return $idim_1 + $iadd - 1
  1672. Case 2
  1673. Local $idim_2 = UBound($aarray, $ubound_columns)
  1674. If $istart < 0 OR $istart > $idim_2 - 1 Then Return SetError(4, 0, -1)
  1675. Local $ivaldim_1, $ivaldim_2 = 0, $icolcount
  1676. If IsArray($vvalue) Then
  1677. If UBound($vvalue, $ubound_dimensions) <> 2 Then Return SetError(5, 0, -1)
  1678. $ivaldim_1 = UBound($vvalue, $ubound_rows)
  1679. $ivaldim_2 = UBound($vvalue, $ubound_columns)
  1680. $hdatatype = 0
  1681. Else
  1682. Local $asplit_1 = StringSplit($vvalue, $sdelim_row, $str_nocount + $str_entiresplit)
  1683. $ivaldim_1 = UBound($asplit_1, $ubound_rows)
  1684. Local $atmp[$ivaldim_1][0], $asplit_2
  1685. For $i = 0 To $ivaldim_1 - 1
  1686. $asplit_2 = StringSplit($asplit_1[$i], $sdelim_item, $str_nocount + $str_entiresplit)
  1687. $icolcount = UBound($asplit_2)
  1688. If $icolcount > $ivaldim_2 Then
  1689. $ivaldim_2 = $icolcount
  1690. ReDim $atmp[$ivaldim_1][$ivaldim_2]
  1691. EndIf
  1692. For $j = 0 To $icolcount - 1
  1693. $atmp[$i][$j] = $asplit_2[$j]
  1694. Next
  1695. Next
  1696. $vvalue = $atmp
  1697. EndIf
  1698. If UBound($vvalue, $ubound_columns) + $istart > UBound($aarray, $ubound_columns) Then Return SetError(3, 0, -1)
  1699. ReDim $aarray[$idim_1 + $ivaldim_1][$idim_2]
  1700. For $iwriteto_index = 0 To $ivaldim_1 - 1
  1701. For $j = 0 To $idim_2 - 1
  1702. If $j < $istart Then
  1703. $aarray[$iwriteto_index + $idim_1][$j] = ""
  1704. ElseIf $j - $istart > $ivaldim_2 - 1 Then
  1705. $aarray[$iwriteto_index + $idim_1][$j] = ""
  1706. Else
  1707. If IsFunc($hdatatype) Then
  1708. $aarray[$iwriteto_index + $idim_1][$j] = $hdatatype($vvalue[$iwriteto_index][$j - $istart])
  1709. Else
  1710. $aarray[$iwriteto_index + $idim_1][$j] = $vvalue[$iwriteto_index][$j - $istart]
  1711. EndIf
  1712. EndIf
  1713. Next
  1714. Next
  1715. Case Else
  1716. Return SetError(2, 0, -1)
  1717. EndSwitch
  1718. Return UBound($aarray, $ubound_rows) - 1
  1719. EndFunc
  1720.  
  1721. Func _arraybinarysearch(Const ByRef $aarray, $vvalue, $istart = 0, $iend = 0, $icolumn = 0)
  1722. If $istart = Default Then $istart = 0
  1723. If $iend = Default Then $iend = 0
  1724. If $icolumn = Default Then $icolumn = 0
  1725. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  1726. Local $idim_1 = UBound($aarray, $ubound_rows)
  1727. If $idim_1 = 0 Then Return SetError(6, 0, -1)
  1728. If $iend < 1 OR $iend > $idim_1 - 1 Then $iend = $idim_1 - 1
  1729. If $istart < 0 Then $istart = 0
  1730. If $istart > $iend Then Return SetError(4, 0, -1)
  1731. Local $imid = Int(($iend + $istart) / 2)
  1732. Switch UBound($aarray, $ubound_dimensions)
  1733. Case 1
  1734. If $aarray[$istart] > $vvalue OR $aarray[$iend] < $vvalue Then Return SetError(2, 0, -1)
  1735. While $istart <= $imid AND $vvalue <> $aarray[$imid]
  1736. If $vvalue < $aarray[$imid] Then
  1737. $iend = $imid - 1
  1738. Else
  1739. $istart = $imid + 1
  1740. EndIf
  1741. $imid = Int(($iend + $istart) / 2)
  1742. WEnd
  1743. If $istart > $iend Then Return SetError(3, 0, -1)
  1744. Case 2
  1745. Local $idim_2 = UBound($aarray, $ubound_columns) - 1
  1746. If $icolumn < 0 OR $icolumn > $idim_2 Then Return SetError(7, 0, -1)
  1747. If $aarray[$istart][$icolumn] > $vvalue OR $aarray[$iend][$icolumn] < $vvalue Then Return SetError(2, 0, -1)
  1748. While $istart <= $imid AND $vvalue <> $aarray[$imid][$icolumn]
  1749. If $vvalue < $aarray[$imid][$icolumn] Then
  1750. $iend = $imid - 1
  1751. Else
  1752. $istart = $imid + 1
  1753. EndIf
  1754. $imid = Int(($iend + $istart) / 2)
  1755. WEnd
  1756. If $istart > $iend Then Return SetError(3, 0, -1)
  1757. Case Else
  1758. Return SetError(5, 0, -1)
  1759. EndSwitch
  1760. Return $imid
  1761. EndFunc
  1762.  
  1763. Func _arraycoldelete(ByRef $aarray, $icolumn, $bconvert = False)
  1764. If $bconvert = Default Then $bconvert = False
  1765. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  1766. Local $idim_1 = UBound($aarray, $ubound_rows)
  1767. If UBound($aarray, $ubound_dimensions) <> 2 Then Return SetError(2, 0, -1)
  1768. Local $idim_2 = UBound($aarray, $ubound_columns)
  1769. Switch $idim_2
  1770. Case 2
  1771. If $icolumn < 0 OR $icolumn > 1 Then Return SetError(3, 0, -1)
  1772. If $bconvert Then
  1773. Local $atemparray[$idim_1]
  1774. For $i = 0 To $idim_1 - 1
  1775. $atemparray[$i] = $aarray[$i][(NOT $icolumn)]
  1776. Next
  1777. $aarray = $atemparray
  1778. Else
  1779. ContinueCase
  1780. EndIf
  1781. Case Else
  1782. If $icolumn < 0 OR $icolumn > $idim_2 - 1 Then Return SetError(3, 0, -1)
  1783. For $i = 0 To $idim_1 - 1
  1784. For $j = $icolumn To $idim_2 - 2
  1785. $aarray[$i][$j] = $aarray[$i][$j + 1]
  1786. Next
  1787. Next
  1788. ReDim $aarray[$idim_1][$idim_2 - 1]
  1789. EndSwitch
  1790. Return UBound($aarray, $ubound_columns)
  1791. EndFunc
  1792.  
  1793. Func _arraycolinsert(ByRef $aarray, $icolumn)
  1794. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  1795. Local $idim_1 = UBound($aarray, $ubound_rows)
  1796. Switch UBound($aarray, $ubound_dimensions)
  1797. Case 1
  1798. Local $atemparray[$idim_1][2]
  1799. Switch $icolumn
  1800. Case 0, 1
  1801. For $i = 0 To $idim_1 - 1
  1802. $atemparray[$i][(NOT $icolumn)] = $aarray[$i]
  1803. Next
  1804. Case Else
  1805. Return SetError(3, 0, -1)
  1806. EndSwitch
  1807. $aarray = $atemparray
  1808. Case 2
  1809. Local $idim_2 = UBound($aarray, $ubound_columns)
  1810. If $icolumn < 0 OR $icolumn > $idim_2 Then Return SetError(3, 0, -1)
  1811. ReDim $aarray[$idim_1][$idim_2 + 1]
  1812. For $i = 0 To $idim_1 - 1
  1813. For $j = $idim_2 To $icolumn + 1 Step -1
  1814. $aarray[$i][$j] = $aarray[$i][$j - 1]
  1815. Next
  1816. $aarray[$i][$icolumn] = ""
  1817. Next
  1818. Case Else
  1819. Return SetError(2, 0, -1)
  1820. EndSwitch
  1821. Return UBound($aarray, $ubound_columns)
  1822. EndFunc
  1823.  
  1824. Func _arraycombinations(Const ByRef $aarray, $iset, $sdelimiter = "")
  1825. If $sdelimiter = Default Then $sdelimiter = ""
  1826. If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
  1827. If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError(2, 0, 0)
  1828. Local $in = UBound($aarray)
  1829. Local $ir = $iset
  1830. Local $aidx[$ir]
  1831. For $i = 0 To $ir - 1
  1832. $aidx[$i] = $i
  1833. Next
  1834. Local $itotal = __array_combinations($in, $ir)
  1835. Local $ileft = $itotal
  1836. Local $aresult[$itotal + 1]
  1837. $aresult[0] = $itotal
  1838. Local $icount = 1
  1839. While $ileft > 0
  1840. __array_getnext($in, $ir, $ileft, $itotal, $aidx)
  1841. For $i = 0 To $iset - 1
  1842. $aresult[$icount] &= $aarray[$aidx[$i]] & $sdelimiter
  1843. Next
  1844. If $sdelimiter <> "" Then $aresult[$icount] = StringTrimRight($aresult[$icount], 1)
  1845. $icount += 1
  1846. WEnd
  1847. Return $aresult
  1848. EndFunc
  1849.  
  1850. Func _arrayconcatenate(ByRef $aarraytarget, Const ByRef $aarraysource, $istart = 0)
  1851. If $istart = Default Then $istart = 0
  1852. If NOT IsArray($aarraytarget) Then Return SetError(1, 0, -1)
  1853. If NOT IsArray($aarraysource) Then Return SetError(2, 0, -1)
  1854. Local $idim_total_tgt = UBound($aarraytarget, $ubound_dimensions)
  1855. Local $idim_total_src = UBound($aarraysource, $ubound_dimensions)
  1856. Local $idim_1_tgt = UBound($aarraytarget, $ubound_rows)
  1857. Local $idim_1_src = UBound($aarraysource, $ubound_rows)
  1858. If $istart < 0 OR $istart > $idim_1_src - 1 Then Return SetError(6, 0, -1)
  1859. Switch $idim_total_tgt
  1860. Case 1
  1861. If $idim_total_src <> 1 Then Return SetError(4, 0, -1)
  1862. ReDim $aarraytarget[$idim_1_tgt + $idim_1_src - $istart]
  1863. For $i = $istart To $idim_1_src - 1
  1864. $aarraytarget[$idim_1_tgt + $i - $istart] = $aarraysource[$i]
  1865. Next
  1866. Case 2
  1867. If $idim_total_src <> 2 Then Return SetError(4, 0, -1)
  1868. Local $idim_2_tgt = UBound($aarraytarget, $ubound_columns)
  1869. If UBound($aarraysource, $ubound_columns) <> $idim_2_tgt Then Return SetError(5, 0, -1)
  1870. ReDim $aarraytarget[$idim_1_tgt + $idim_1_src - $istart][$idim_2_tgt]
  1871. For $i = $istart To $idim_1_src - 1
  1872. For $j = 0 To $idim_2_tgt - 1
  1873. $aarraytarget[$idim_1_tgt + $i - $istart][$j] = $aarraysource[$i][$j]
  1874. Next
  1875. Next
  1876. Case Else
  1877. Return SetError(3, 0, -1)
  1878. EndSwitch
  1879. Return UBound($aarraytarget, $ubound_rows)
  1880. EndFunc
  1881.  
  1882. Func _arraydelete(ByRef $aarray, $vrange)
  1883. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  1884. Local $idim_1 = UBound($aarray, $ubound_rows) - 1
  1885. If IsArray($vrange) Then
  1886. If UBound($vrange, $ubound_dimensions) <> 1 OR UBound($vrange, $ubound_rows) < 2 Then Return SetError(4, 0, -1)
  1887. Else
  1888. Local $inumber, $asplit_1, $asplit_2
  1889. $vrange = StringStripWS($vrange, 8)
  1890. $asplit_1 = StringSplit($vrange, ";")
  1891. $vrange = ""
  1892. For $i = 1 To $asplit_1[0]
  1893. If NOT StringRegExp($asplit_1[$i], "^\d+(-\d+)?$") Then Return SetError(3, 0, -1)
  1894. $asplit_2 = StringSplit($asplit_1[$i], "-")
  1895. Switch $asplit_2[0]
  1896. Case 1
  1897. $vrange &= $asplit_2[1] & ";"
  1898. Case 2
  1899. If Number($asplit_2[2]) >= Number($asplit_2[1]) Then
  1900. $inumber = $asplit_2[1] - 1
  1901. Do
  1902. $inumber += 1
  1903. $vrange &= $inumber & ";"
  1904. Until $inumber = $asplit_2[2]
  1905. EndIf
  1906. EndSwitch
  1907. Next
  1908. $vrange = StringSplit(StringTrimRight($vrange, 1), ";")
  1909. EndIf
  1910. If $vrange[1] < 0 OR $vrange[$vrange[0]] > $idim_1 Then Return SetError(5, 0, -1)
  1911. Local $icopyto_index = 0
  1912. Switch UBound($aarray, $ubound_dimensions)
  1913. Case 1
  1914. For $i = 1 To $vrange[0]
  1915. $aarray[$vrange[$i]] = ChrW(64177)
  1916. Next
  1917. For $ireadfrom_index = 0 To $idim_1
  1918. If $aarray[$ireadfrom_index] == ChrW(64177) Then
  1919. ContinueLoop
  1920. Else
  1921. If $ireadfrom_index <> $icopyto_index Then
  1922. $aarray[$icopyto_index] = $aarray[$ireadfrom_index]
  1923. EndIf
  1924. $icopyto_index += 1
  1925. EndIf
  1926. Next
  1927. ReDim $aarray[$idim_1 - $vrange[0] + 1]
  1928. Case 2
  1929. Local $idim_2 = UBound($aarray, $ubound_columns) - 1
  1930. For $i = 1 To $vrange[0]
  1931. $aarray[$vrange[$i]][0] = ChrW(64177)
  1932. Next
  1933. For $ireadfrom_index = 0 To $idim_1
  1934. If $aarray[$ireadfrom_index][0] == ChrW(64177) Then
  1935. ContinueLoop
  1936. Else
  1937. If $ireadfrom_index <> $icopyto_index Then
  1938. For $j = 0 To $idim_2
  1939. $aarray[$icopyto_index][$j] = $aarray[$ireadfrom_index][$j]
  1940. Next
  1941. EndIf
  1942. $icopyto_index += 1
  1943. EndIf
  1944. Next
  1945. ReDim $aarray[$idim_1 - $vrange[0] + 1][$idim_2 + 1]
  1946. Case Else
  1947. Return SetError(2, 0, False)
  1948. EndSwitch
  1949. Return UBound($aarray, $ubound_rows)
  1950. EndFunc
  1951.  
  1952. Func _arraydisplay(Const ByRef $aarray, $stitle = Default, $sarrayrange = Default, $iflags = Default, $vuser_separator = Default, $sheader = Default, $imax_colwidth = Default, $ialt_color = Default, $huser_function = Default)
  1953. If $stitle = Default Then $stitle = "ArrayDisplay"
  1954. If $sarrayrange = Default Then $sarrayrange = ""
  1955. If $iflags = Default Then $iflags = 0
  1956. If $vuser_separator = Default Then $vuser_separator = ""
  1957. If $sheader = Default Then $sheader = ""
  1958. If $imax_colwidth = Default Then $imax_colwidth = 350
  1959. If $ialt_color = Default Then $ialt_color = 0
  1960. If $huser_function = Default Then $huser_function = 0
  1961. Local $itranspose = BitAND($iflags, 1)
  1962. Local $icolalign = BitAND($iflags, 6)
  1963. Local $iverbose = BitAND($iflags, 8)
  1964. Local $ibuttonmargin = ((BitAND($iflags, 32)) ? (0) : ((BitAND($iflags, 16)) ? (20) : (40)))
  1965. Local $inorow = BitAND($iflags, 64)
  1966. Local $smsg = "", $iret = 1
  1967. If IsArray($aarray) Then
  1968. Local $idimension = UBound($aarray, $ubound_dimensions), $irowcount = UBound($aarray, $ubound_rows), $icolcount = UBound($aarray, $ubound_columns)
  1969. If $idimension > 2 Then
  1970. $smsg = "Larger than 2D array passed to function"
  1971. $iret = 2
  1972. EndIf
  1973. Else
  1974. $smsg = "No array variable passed to function"
  1975. EndIf
  1976. If $smsg Then
  1977. If $iverbose AND MsgBox($mb_systemmodal + $mb_iconerror + $mb_yesno, "ArrayDisplay Error: " & $stitle, $smsg & @CRLF & @CRLF & "Exit the script?") = $idyes Then
  1978. Exit
  1979. Else
  1980. Return SetError($iret, 0, "")
  1981. EndIf
  1982. EndIf
  1983. Local $icw_colwidth = Number($vuser_separator)
  1984. Local $sad_separator = ChrW(64177)
  1985. Local $scurr_separator = Opt("GUIDataSeparatorChar", $sad_separator)
  1986. If $vuser_separator = "" Then $vuser_separator = $scurr_separator
  1987. Local $vtmp, $irowlimit = 65525, $icollimit = 250
  1988. Local $idatarow = $irowcount
  1989. Local $idatacol = $icolcount
  1990. Local $iitem_start = 0, $iitem_end = $irowcount - 1, $isubitem_start = 0, $isubitem_end = (($idimension = 2) ? ($icolcount - 1) : (0))
  1991. Local $brange_flag = False, $avrangesplit
  1992. If $sarrayrange Then
  1993. Local $aarray_range = StringRegExp($sarrayrange & "||", "(?U)(.*)\|", 3)
  1994. If $aarray_range[0] Then
  1995. $avrangesplit = StringSplit($aarray_range[0], ":")
  1996. If @error Then
  1997. $iitem_end = Number($avrangesplit[1])
  1998. Else
  1999. $iitem_start = Number($avrangesplit[1])
  2000. $iitem_end = Number($avrangesplit[2])
  2001. EndIf
  2002. EndIf
  2003. If $iitem_start > $iitem_end Then
  2004. $vtmp = $iitem_start
  2005. $iitem_start = $iitem_end
  2006. $iitem_end = $vtmp
  2007. EndIf
  2008. If $iitem_start < 0 Then $iitem_start = 0
  2009. If $iitem_end > $irowcount - 1 Then $iitem_end = $irowcount - 1
  2010. If $iitem_start <> 0 OR $iitem_end <> $irowcount - 1 Then $brange_flag = True
  2011. If $idimension = 2 AND $aarray_range[1] Then
  2012. $avrangesplit = StringSplit($aarray_range[1], ":")
  2013. If @error Then
  2014. $isubitem_end = Number($avrangesplit[1])
  2015. Else
  2016. $isubitem_start = Number($avrangesplit[1])
  2017. $isubitem_end = Number($avrangesplit[2])
  2018. EndIf
  2019. If $isubitem_start > $isubitem_end Then
  2020. $vtmp = $isubitem_start
  2021. $isubitem_start = $isubitem_end
  2022. $isubitem_end = $vtmp
  2023. EndIf
  2024. If $isubitem_start < 0 Then $isubitem_start = 0
  2025. If $isubitem_end > $icolcount - 1 Then $isubitem_end = $icolcount - 1
  2026. If $isubitem_start <> 0 OR $isubitem_end <> $icolcount - 1 Then $brange_flag = True
  2027. EndIf
  2028. EndIf
  2029. Local $sdisplaydata = "[" & $idatarow
  2030. Local $btruncated = False
  2031. If $itranspose Then
  2032. If $iitem_end - $iitem_start > $icollimit Then
  2033. $btruncated = True
  2034. $iitem_end = $iitem_start + $icollimit - 1
  2035. EndIf
  2036. Else
  2037. If $iitem_end - $iitem_start > $irowlimit Then
  2038. $btruncated = True
  2039. $iitem_end = $iitem_start + $irowlimit - 1
  2040. EndIf
  2041. EndIf
  2042. If $btruncated Then
  2043. $sdisplaydata &= "*]"
  2044. Else
  2045. $sdisplaydata &= "]"
  2046. EndIf
  2047. If $idimension = 2 Then
  2048. $sdisplaydata &= " [" & $idatacol
  2049. If $itranspose Then
  2050. If $isubitem_end - $isubitem_start > $irowlimit Then
  2051. $btruncated = True
  2052. $isubitem_end = $isubitem_start + $irowlimit - 1
  2053. EndIf
  2054. Else
  2055. If $isubitem_end - $isubitem_start > $icollimit Then
  2056. $btruncated = True
  2057. $isubitem_end = $isubitem_start + $icollimit - 1
  2058. EndIf
  2059. EndIf
  2060. If $btruncated Then
  2061. $sdisplaydata &= "*]"
  2062. Else
  2063. $sdisplaydata &= "]"
  2064. EndIf
  2065. EndIf
  2066. Local $stipdata = ""
  2067. If $btruncated Then $stipdata &= "Truncated"
  2068. If $brange_flag Then
  2069. If $stipdata Then $stipdata &= " - "
  2070. $stipdata &= "Range set"
  2071. EndIf
  2072. If $itranspose Then
  2073. If $stipdata Then $stipdata &= " - "
  2074. $stipdata &= "Transposed"
  2075. EndIf
  2076. Local $asheader = StringSplit($sheader, $scurr_separator, $str_nocount)
  2077. If UBound($asheader) = 0 Then Local $asheader[1] = [""]
  2078. $sheader = "Row"
  2079. Local $iindex = $isubitem_start
  2080. If $itranspose Then
  2081. For $j = $iitem_start To $iitem_end
  2082. $sheader &= $sad_separator & "Col " & $j
  2083. Next
  2084. Else
  2085. If $asheader[0] Then
  2086. For $iindex = $isubitem_start To $isubitem_end
  2087. If $iindex >= UBound($asheader) Then ExitLoop
  2088. $sheader &= $sad_separator & $asheader[$iindex]
  2089. Next
  2090. EndIf
  2091. For $j = $iindex To $isubitem_end
  2092. $sheader &= $sad_separator & "Col " & $j
  2093. Next
  2094. EndIf
  2095. If $inorow Then $sheader = StringTrimLeft($sheader, 4)
  2096. If $iverbose AND ($iitem_end - $iitem_start + 1) * ($isubitem_end - $isubitem_start + 1) > 10000 Then
  2097. SplashTextOn("ArrayDisplay", "Preparing display" & @CRLF & @CRLF & "Please be patient", 300, 100)
  2098. EndIf
  2099. Local $ibuffer = 4094
  2100. If $itranspose Then
  2101. $vtmp = $iitem_start
  2102. $iitem_start = $isubitem_start
  2103. $isubitem_start = $vtmp
  2104. $vtmp = $iitem_end
  2105. $iitem_end = $isubitem_end
  2106. $isubitem_end = $vtmp
  2107. EndIf
  2108. Local $avarraytext[$iitem_end - $iitem_start + 1]
  2109. For $i = $iitem_start To $iitem_end
  2110. If NOT $inorow Then $avarraytext[$i - $iitem_start] = "[" & $i & "]"
  2111. For $j = $isubitem_start To $isubitem_end
  2112. If $idimension = 1 Then
  2113. If $itranspose Then
  2114. Switch VarGetType($aarray[$j])
  2115. Case "Array"
  2116. $vtmp = "{Array}"
  2117. Case Else
  2118. $vtmp = $aarray[$j]
  2119. EndSwitch
  2120. Else
  2121. Switch VarGetType($aarray[$i])
  2122. Case "Array"
  2123. $vtmp = "{Array}"
  2124. Case Else
  2125. $vtmp = $aarray[$i]
  2126. EndSwitch
  2127. EndIf
  2128. Else
  2129. If $itranspose Then
  2130. Switch VarGetType($aarray[$j][$i])
  2131. Case "Array"
  2132. $vtmp = "{Array}"
  2133. Case Else
  2134. $vtmp = $aarray[$j][$i]
  2135. EndSwitch
  2136. Else
  2137. Switch VarGetType($aarray[$i][$j])
  2138. Case "Array"
  2139. $vtmp = "{Array}"
  2140. Case Else
  2141. $vtmp = $aarray[$i][$j]
  2142. EndSwitch
  2143. EndIf
  2144. EndIf
  2145. If StringLen($vtmp) > $ibuffer Then $vtmp = StringLeft($vtmp, $ibuffer)
  2146. $avarraytext[$i - $iitem_start] &= $sad_separator & $vtmp
  2147. Next
  2148. If $inorow Then $avarraytext[$i - $iitem_start] = StringTrimLeft($avarraytext[$i - $iitem_start], 1)
  2149. Next
  2150. Local Const $_arrayconstant_gui_dockbottom = 64
  2151. Local Const $_arrayconstant_gui_dockborders = 102
  2152. Local Const $_arrayconstant_gui_dockheight = 512
  2153. Local Const $_arrayconstant_gui_dockleft = 2
  2154. Local Const $_arrayconstant_gui_dockright = 4
  2155. Local Const $_arrayconstant_gui_dockhcenter = 8
  2156. Local Const $_arrayconstant_gui_event_close = -3
  2157. Local Const $_arrayconstant_gui_focus = 256
  2158. Local Const $_arrayconstant_gui_bkcolor_lv_alternate = -33554432
  2159. Local Const $_arrayconstant_ss_center = 1
  2160. Local Const $_arrayconstant_ss_centerimage = 512
  2161. Local Const $_arrayconstant_lvm_getitemcount = (4096 + 4)
  2162. Local Const $_arrayconstant_lvm_getitemrect = (4096 + 14)
  2163. Local Const $_arrayconstant_lvm_getcolumnwidth = (4096 + 29)
  2164. Local Const $_arrayconstant_lvm_setcolumnwidth = (4096 + 30)
  2165. Local Const $_arrayconstant_lvm_getitemstate = (4096 + 44)
  2166. Local Const $_arrayconstant_lvm_getselectedcount = (4096 + 50)
  2167. Local Const $_arrayconstant_lvm_setextendedlistviewstyle = (4096 + 54)
  2168. Local Const $_arrayconstant_lvs_ex_gridlines = 1
  2169. Local Const $_arrayconstant_lvis_selected = 2
  2170. Local Const $_arrayconstant_lvs_showselalways = 8
  2171. Local Const $_arrayconstant_lvs_ex_fullrowselect = 32
  2172. Local Const $_arrayconstant_ws_ex_clientedge = 512
  2173. Local Const $_arrayconstant_ws_maximizebox = 65536
  2174. Local Const $_arrayconstant_ws_minimizebox = 131072
  2175. Local Const $_arrayconstant_ws_sizebox = 262144
  2176. Local Const $_arrayconstant_wm_setredraw = 11
  2177. Local Const $_arrayconstant_lvscw_autosize = -1
  2178. Local $icoordmode = Opt("GUICoordMode", 1)
  2179. Local $iorgwidth = 210, $iheight = 200, $iminsize = 250
  2180. Local $hgui = GUICreate($stitle, $iorgwidth, $iheight, Default, Default, BitOR($_arrayconstant_ws_sizebox, $_arrayconstant_ws_minimizebox, $_arrayconstant_ws_maximizebox))
  2181. Local $aiguisize = WinGetClientSize($hgui)
  2182. Local $ibuttonwidth_2 = $aiguisize[0] / 2
  2183. Local $ibuttonwidth_3 = $aiguisize[0] / 3
  2184. Local $idlistview = GUICtrlCreateListView($sheader, 0, 0, $aiguisize[0], $aiguisize[1] - $ibuttonmargin, $_arrayconstant_lvs_showselalways)
  2185. GUICtrlSetBkColor($idlistview, $_arrayconstant_gui_bkcolor_lv_alternate)
  2186. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_lvs_ex_gridlines, $_arrayconstant_lvs_ex_gridlines)
  2187. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_lvs_ex_fullrowselect, $_arrayconstant_lvs_ex_fullrowselect)
  2188. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_ws_ex_clientedge, $_arrayconstant_ws_ex_clientedge)
  2189. Local $idcopy_id = 9999, $idcopy_data = 99999, $iddata_label = 99999, $iduser_func = 99999, $idexit_script = 99999
  2190. If $ibuttonmargin Then
  2191. $idcopy_id = GUICtrlCreateButton("Copy Data && Hdr/Row", 0, $aiguisize[1] - $ibuttonmargin, $ibuttonwidth_2, 20)
  2192. $idcopy_data = GUICtrlCreateButton("Copy Data Only", $ibuttonwidth_2, $aiguisize[1] - $ibuttonmargin, $ibuttonwidth_2, 20)
  2193. If $ibuttonmargin = 40 Then
  2194. Local $ibuttonwidth_var = $ibuttonwidth_2
  2195. Local $ioffset = $ibuttonwidth_2
  2196. If IsFunc($huser_function) Then
  2197. $iduser_func = GUICtrlCreateButton("Run User Func", $ibuttonwidth_3, $aiguisize[1] - 20, $ibuttonwidth_3, 20)
  2198. $ibuttonwidth_var = $ibuttonwidth_3
  2199. $ioffset = $ibuttonwidth_3 * 2
  2200. EndIf
  2201. $idexit_script = GUICtrlCreateButton("Exit Script", $ioffset, $aiguisize[1] - 20, $ibuttonwidth_var, 20)
  2202. $iddata_label = GUICtrlCreateLabel($sdisplaydata, 0, $aiguisize[1] - 20, $ibuttonwidth_var, 18, BitOR($_arrayconstant_ss_center, $_arrayconstant_ss_centerimage))
  2203. Select
  2204. Case $btruncated OR $itranspose OR $brange_flag
  2205. GUICtrlSetColor($iddata_label, 16711680)
  2206. GUICtrlSetTip($iddata_label, $stipdata)
  2207. EndSelect
  2208. EndIf
  2209. EndIf
  2210. GUICtrlSetResizing($idlistview, $_arrayconstant_gui_dockborders)
  2211. GUICtrlSetResizing($idcopy_id, $_arrayconstant_gui_dockleft + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
  2212. GUICtrlSetResizing($idcopy_data, $_arrayconstant_gui_dockright + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
  2213. GUICtrlSetResizing($iddata_label, $_arrayconstant_gui_dockleft + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
  2214. GUICtrlSetResizing($iduser_func, $_arrayconstant_gui_dockhcenter + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
  2215. GUICtrlSetResizing($idexit_script, $_arrayconstant_gui_dockright + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
  2216. GUICtrlSendMsg($idlistview, $_arrayconstant_wm_setredraw, 0, 0)
  2217. Local $iditem
  2218. For $i = 0 To UBound($avarraytext) - 1
  2219. $iditem = GUICtrlCreateListViewItem($avarraytext[$i], $idlistview)
  2220. If $ialt_color Then
  2221. GUICtrlSetBkColor($iditem, $ialt_color)
  2222. EndIf
  2223. Next
  2224. If $icolalign Then
  2225. Local Const $_arrayconstant_lvcf_fmt = 1
  2226. Local Const $_arrayconstant_lvm_setcolumnw = (4096 + 96)
  2227. Local $tcolumn = DllStructCreate("uint Mask;int Fmt;int CX;ptr Text;int TextMax;int SubItem;int Image;int Order;int cxMin;int cxDefault;int cxIdeal")
  2228. DllStructSetData($tcolumn, "Mask", $_arrayconstant_lvcf_fmt)
  2229. DllStructSetData($tcolumn, "Fmt", $icolalign / 2)
  2230. Local $pcolumn = DllStructGetPtr($tcolumn)
  2231. For $i = 1 To $isubitem_end - $isubitem_start + 1
  2232. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnw, $i, $pcolumn)
  2233. Next
  2234. EndIf
  2235. GUICtrlSendMsg($idlistview, $_arrayconstant_wm_setredraw, 1, 0)
  2236. Local $iborder = 45
  2237. If UBound($avarraytext) > 20 Then
  2238. $iborder += 20
  2239. EndIf
  2240. Local $iwidth = $iborder, $icolwidth = 0, $aicolwidth[$isubitem_end - $isubitem_start + 2], $imin_colwidth = 55
  2241. For $i = 0 To $isubitem_end - $isubitem_start + 1
  2242. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnwidth, $i, $_arrayconstant_lvscw_autosize)
  2243. $icolwidth = GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getcolumnwidth, $i, 0)
  2244. If $icolwidth < $imin_colwidth Then
  2245. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnwidth, $i, $imin_colwidth)
  2246. $icolwidth = $imin_colwidth
  2247. EndIf
  2248. $iwidth += $icolwidth
  2249. $aicolwidth[$i] = $icolwidth
  2250. Next
  2251. If $inorow Then $iwidth -= 55
  2252. If $iwidth > @DesktopWidth - 100 Then
  2253. $iwidth = $iborder
  2254. For $i = 0 To $isubitem_end - $isubitem_start + 1
  2255. If $aicolwidth[$i] > $imax_colwidth Then
  2256. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnwidth, $i, $imax_colwidth)
  2257. $iwidth += $imax_colwidth
  2258. Else
  2259. $iwidth += $aicolwidth[$i]
  2260. EndIf
  2261. Next
  2262. EndIf
  2263. If $iwidth > @DesktopWidth - 100 Then
  2264. $iwidth = @DesktopWidth - 100
  2265. ElseIf $iwidth < $iminsize Then
  2266. $iwidth = $iminsize
  2267. EndIf
  2268. Local $trect = DllStructCreate("struct; long Left;long Top;long Right;long Bottom; endstruct")
  2269. DllCall("user32.dll", "struct*", "SendMessageW", "hwnd", GUICtrlGetHandle($idlistview), "uint", $_arrayconstant_lvm_getitemrect, "wparam", 0, "struct*", $trect)
  2270. Local $aiwin_pos = WinGetPos($hgui)
  2271. Local $ailv_pos = ControlGetPos($hgui, "", $idlistview)
  2272. $iheight = ((UBound($avarraytext) + 2) * (DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top"))) + $aiwin_pos[3] - $ailv_pos[3]
  2273. If $iheight > @DesktopHeight - 100 Then
  2274. $iheight = @DesktopHeight - 100
  2275. ElseIf $iheight < $iminsize Then
  2276. $iheight = $iminsize
  2277. EndIf
  2278. If $iverbose Then SplashOff()
  2279. GUISetState(@SW_HIDE, $hgui)
  2280. WinMove($hgui, "", (@DesktopWidth - $iwidth) / 2, (@DesktopHeight - $iheight) / 2, $iwidth, $iheight)
  2281. GUISetState(@SW_SHOW, $hgui)
  2282. Local $ioneventmode = Opt("GUIOnEventMode", 0), $imsg
  2283. While 1
  2284. $imsg = GUIGetMsg()
  2285. Switch $imsg
  2286. Case $_arrayconstant_gui_event_close
  2287. ExitLoop
  2288. Case $idcopy_id, $idcopy_data
  2289. Local $isel_count = GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getselectedcount, 0, 0)
  2290. If $iverbose AND (NOT $isel_count) AND ($iitem_end - $iitem_start) * ($isubitem_end - $isubitem_start) > 10000 Then
  2291. SplashTextOn("ArrayDisplay", "Copying data" & @CRLF & @CRLF & "Please be patient", 300, 100)
  2292. EndIf
  2293. Local $sclip = "", $sitem, $asplit
  2294. For $i = 0 To $iitem_end - $iitem_start
  2295. If $isel_count AND NOT (GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getitemstate, $i, $_arrayconstant_lvis_selected)) Then
  2296. ContinueLoop
  2297. EndIf
  2298. $sitem = $avarraytext[$i]
  2299. If $imsg = $idcopy_data Then
  2300. $sitem = StringRegExpReplace($sitem, "^\[\d+\].(.*)$", "$1")
  2301. EndIf
  2302. If $icw_colwidth Then
  2303. $asplit = StringSplit($sitem, $sad_separator)
  2304. $sitem = ""
  2305. For $j = 1 To $asplit[0]
  2306. $sitem &= StringFormat("%-" & $icw_colwidth + 1 & "s", StringLeft($asplit[$j], $icw_colwidth))
  2307. Next
  2308. Else
  2309. $sitem = StringReplace($sitem, $sad_separator, $vuser_separator)
  2310. EndIf
  2311. $sclip &= $sitem & @CRLF
  2312. Next
  2313. If $imsg = $idcopy_id Then
  2314. If $icw_colwidth Then
  2315. $asplit = StringSplit($sheader, $sad_separator)
  2316. $sitem = ""
  2317. For $j = 1 To $asplit[0]
  2318. $sitem &= StringFormat("%-" & $icw_colwidth + 1 & "s", StringLeft($asplit[$j], $icw_colwidth))
  2319. Next
  2320. Else
  2321. $sitem = StringReplace($sheader, $sad_separator, $vuser_separator)
  2322. EndIf
  2323. $sclip = $sitem & @CRLF & $sclip
  2324. EndIf
  2325. ClipPut($sclip)
  2326. SplashOff()
  2327. GUICtrlSetState($idlistview, $_arrayconstant_gui_focus)
  2328. Case $iduser_func
  2329. Local $aiselitems[$irowlimit] = [0]
  2330. For $i = 0 To GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getitemcount, 0, 0)
  2331. If GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getitemstate, $i, $_arrayconstant_lvis_selected) Then
  2332. $aiselitems[0] += 1
  2333. $aiselitems[$aiselitems[0]] = $i + $iitem_start
  2334. EndIf
  2335. Next
  2336. ReDim $aiselitems[$aiselitems[0] + 1]
  2337. $huser_function($aarray, $aiselitems)
  2338. GUICtrlSetState($idlistview, $_arrayconstant_gui_focus)
  2339. Case $idexit_script
  2340. GUIDelete($hgui)
  2341. Exit
  2342. EndSwitch
  2343. WEnd
  2344. GUIDelete($hgui)
  2345. Opt("GUICoordMode", $icoordmode)
  2346. Opt("GUIOnEventMode", $ioneventmode)
  2347. Opt("GUIDataSeparatorChar", $scurr_separator)
  2348. Return 1
  2349. EndFunc
  2350.  
  2351. Func _arrayextract(Const ByRef $aarray, $istart_row = -1, $iend_row = -1, $istart_col = -1, $iend_col = -1)
  2352. If $istart_row = Default Then $istart_row = -1
  2353. If $iend_row = Default Then $iend_row = -1
  2354. If $istart_col = Default Then $istart_col = -1
  2355. If $iend_col = Default Then $iend_col = -1
  2356. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  2357. Local $idim_1 = UBound($aarray, $ubound_rows) - 1
  2358. If $iend_row = -1 Then $iend_row = $idim_1
  2359. If $istart_row = -1 Then $istart_row = 0
  2360. If $istart_row < -1 OR $iend_row < -1 Then Return SetError(3, 0, -1)
  2361. If $istart_row > $idim_1 OR $iend_row > $idim_1 Then Return SetError(3, 0, -1)
  2362. If $istart_row > $iend_row Then Return SetError(4, 0, -1)
  2363. Switch UBound($aarray, $ubound_dimensions)
  2364. Case 1
  2365. Local $aretarray[$iend_row - $istart_row + 1]
  2366. For $i = 0 To $iend_row - $istart_row
  2367. $aretarray[$i] = $aarray[$i + $istart_row]
  2368. Next
  2369. Return $aretarray
  2370. Case 2
  2371. Local $idim_2 = UBound($aarray, $ubound_columns) - 1
  2372. If $iend_col = -1 Then $iend_col = $idim_2
  2373. If $istart_col = -1 Then $istart_col = 0
  2374. If $istart_col < -1 OR $iend_col < -1 Then Return SetError(5, 0, -1)
  2375. If $istart_col > $idim_2 OR $iend_col > $idim_2 Then Return SetError(5, 0, -1)
  2376. If $istart_col > $iend_col Then Return SetError(6, 0, -1)
  2377. If $istart_col = $iend_col Then
  2378. Local $aretarray[$iend_row - $istart_row + 1]
  2379. Else
  2380. Local $aretarray[$iend_row - $istart_row + 1][$iend_col - $istart_col + 1]
  2381. EndIf
  2382. For $i = 0 To $iend_row - $istart_row
  2383. For $j = 0 To $iend_col - $istart_col
  2384. If $istart_col = $iend_col Then
  2385. $aretarray[$i] = $aarray[$i + $istart_row][$j + $istart_col]
  2386. Else
  2387. $aretarray[$i][$j] = $aarray[$i + $istart_row][$j + $istart_col]
  2388. EndIf
  2389. Next
  2390. Next
  2391. Return $aretarray
  2392. Case Else
  2393. Return SetError(2, 0, -1)
  2394. EndSwitch
  2395. Return 1
  2396. EndFunc
  2397.  
  2398. Func _arrayfindall(Const ByRef $aarray, $vvalue, $istart = 0, $iend = 0, $icase = 0, $icompare = 0, $isubitem = 0, $brow = False)
  2399. If $istart = Default Then $istart = 0
  2400. If $iend = Default Then $iend = 0
  2401. If $icase = Default Then $icase = 0
  2402. If $icompare = Default Then $icompare = 0
  2403. If $isubitem = Default Then $isubitem = 0
  2404. If $brow = Default Then $brow = False
  2405. $istart = _arraysearch($aarray, $vvalue, $istart, $iend, $icase, $icompare, 1, $isubitem, $brow)
  2406. If @error Then Return SetError(@error, 0, -1)
  2407. Local $iindex = 0, $avresult[UBound($aarray, ($brow ? $ubound_columns : $ubound_rows))]
  2408. Do
  2409. $avresult[$iindex] = $istart
  2410. $iindex += 1
  2411. $istart = _arraysearch($aarray, $vvalue, $istart + 1, $iend, $icase, $icompare, 1, $isubitem, $brow)
  2412. Until @error
  2413. ReDim $avresult[$iindex]
  2414. Return $avresult
  2415. EndFunc
  2416.  
  2417. Func _arrayinsert(ByRef $aarray, $vrange, $vvalue = "", $istart = 0, $sdelim_item = "|", $sdelim_row = @CRLF, $iforce = $arrayfill_force_default)
  2418. If $vvalue = Default Then $vvalue = ""
  2419. If $istart = Default Then $istart = 0
  2420. If $sdelim_item = Default Then $sdelim_item = "|"
  2421. If $sdelim_row = Default Then $sdelim_row = @CRLF
  2422. If $iforce = Default Then $iforce = $arrayfill_force_default
  2423. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  2424. Local $idim_1 = UBound($aarray, $ubound_rows) - 1
  2425. Local $hdatatype = 0
  2426. Switch $iforce
  2427. Case $arrayfill_force_int
  2428. $hdatatype = Int
  2429. Case $arrayfill_force_number
  2430. $hdatatype = Number
  2431. Case $arrayfill_force_ptr
  2432. $hdatatype = Ptr
  2433. Case $arrayfill_force_hwnd
  2434. $hdatatype = HWnd
  2435. Case $arrayfill_force_string
  2436. $hdatatype = String
  2437. EndSwitch
  2438. Local $asplit_1, $asplit_2
  2439. If IsArray($vrange) Then
  2440. If UBound($vrange, $ubound_dimensions) <> 1 OR UBound($vrange, $ubound_rows) < 2 Then Return SetError(4, 0, -1)
  2441. Else
  2442. Local $inumber
  2443. $vrange = StringStripWS($vrange, 8)
  2444. $asplit_1 = StringSplit($vrange, ";")
  2445. $vrange = ""
  2446. For $i = 1 To $asplit_1[0]
  2447. If NOT StringRegExp($asplit_1[$i], "^\d+(-\d+)?$") Then Return SetError(3, 0, -1)
  2448. $asplit_2 = StringSplit($asplit_1[$i], "-")
  2449. Switch $asplit_2[0]
  2450. Case 1
  2451. $vrange &= $asplit_2[1] & ";"
  2452. Case 2
  2453. If Number($asplit_2[2]) >= Number($asplit_2[1]) Then
  2454. $inumber = $asplit_2[1] - 1
  2455. Do
  2456. $inumber += 1
  2457. $vrange &= $inumber & ";"
  2458. Until $inumber = $asplit_2[2]
  2459. EndIf
  2460. EndSwitch
  2461. Next
  2462. $vrange = StringSplit(StringTrimRight($vrange, 1), ";")
  2463. EndIf
  2464. If $vrange[1] < 0 OR $vrange[$vrange[0]] > $idim_1 Then Return SetError(5, 0, -1)
  2465. For $i = 2 To $vrange[0]
  2466. If $vrange[$i] < $vrange[$i - 1] Then Return SetError(3, 0, -1)
  2467. Next
  2468. Local $icopyto_index = $idim_1 + $vrange[0]
  2469. Local $iinsertpoint_index = $vrange[0]
  2470. Local $iinsert_index = $vrange[$iinsertpoint_index]
  2471. Switch UBound($aarray, $ubound_dimensions)
  2472. Case 1
  2473. If $iforce = $arrayfill_force_singleitem Then
  2474. ReDim $aarray[$idim_1 + $vrange[0] + 1]
  2475. For $ireadfromindex = $idim_1 To 0 Step -1
  2476. $aarray[$icopyto_index] = $aarray[$ireadfromindex]
  2477. $icopyto_index -= 1
  2478. $iinsert_index = $vrange[$iinsertpoint_index]
  2479. While $ireadfromindex = $iinsert_index
  2480. $aarray[$icopyto_index] = $vvalue
  2481. $icopyto_index -= 1
  2482. $iinsertpoint_index -= 1
  2483. If $iinsertpoint_index < 1 Then ExitLoop 2
  2484. $iinsert_index = $vrange[$iinsertpoint_index]
  2485. WEnd
  2486. Next
  2487. Return $idim_1 + $vrange[0] + 1
  2488. EndIf
  2489. ReDim $aarray[$idim_1 + $vrange[0] + 1]
  2490. If IsArray($vvalue) Then
  2491. If UBound($vvalue, $ubound_dimensions) <> 1 Then Return SetError(5, 0, -1)
  2492. $hdatatype = 0
  2493. Else
  2494. Local $atmp = StringSplit($vvalue, $sdelim_item, $str_nocount + $str_entiresplit)
  2495. If UBound($atmp, $ubound_rows) = 1 Then
  2496. $atmp[0] = $vvalue
  2497. $hdatatype = 0
  2498. EndIf
  2499. $vvalue = $atmp
  2500. EndIf
  2501. For $ireadfromindex = $idim_1 To 0 Step -1
  2502. $aarray[$icopyto_index] = $aarray[$ireadfromindex]
  2503. $icopyto_index -= 1
  2504. $iinsert_index = $vrange[$iinsertpoint_index]
  2505. While $ireadfromindex = $iinsert_index
  2506. If $iinsertpoint_index <= UBound($vvalue, $ubound_rows) Then
  2507. If IsFunc($hdatatype) Then
  2508. $aarray[$icopyto_index] = $hdatatype($vvalue[$iinsertpoint_index - 1])
  2509. Else
  2510. $aarray[$icopyto_index] = $vvalue[$iinsertpoint_index - 1]
  2511. EndIf
  2512. Else
  2513. $aarray[$icopyto_index] = ""
  2514. EndIf
  2515. $icopyto_index -= 1
  2516. $iinsertpoint_index -= 1
  2517. If $iinsertpoint_index = 0 Then ExitLoop 2
  2518. $iinsert_index = $vrange[$iinsertpoint_index]
  2519. WEnd
  2520. Next
  2521. Case 2
  2522. Local $idim_2 = UBound($aarray, $ubound_columns)
  2523. If $istart < 0 OR $istart > $idim_2 - 1 Then Return SetError(6, 0, -1)
  2524. Local $ivaldim_1, $ivaldim_2
  2525. If IsArray($vvalue) Then
  2526. If UBound($vvalue, $ubound_dimensions) <> 2 Then Return SetError(7, 0, -1)
  2527. $ivaldim_1 = UBound($vvalue, $ubound_rows)
  2528. $ivaldim_2 = UBound($vvalue, $ubound_columns)
  2529. $hdatatype = 0
  2530. Else
  2531. $asplit_1 = StringSplit($vvalue, $sdelim_row, $str_nocount + $str_entiresplit)
  2532. $ivaldim_1 = UBound($asplit_1, $ubound_rows)
  2533. StringReplace($asplit_1[0], $sdelim_item, "")
  2534. $ivaldim_2 = @extended + 1
  2535. Local $atmp[$ivaldim_1][$ivaldim_2]
  2536. For $i = 0 To $ivaldim_1 - 1
  2537. $asplit_2 = StringSplit($asplit_1[$i], $sdelim_item, $str_nocount + $str_entiresplit)
  2538. For $j = 0 To $ivaldim_2 - 1
  2539. $atmp[$i][$j] = $asplit_2[$j]
  2540. Next
  2541. Next
  2542. $vvalue = $atmp
  2543. EndIf
  2544. If UBound($vvalue, $ubound_columns) + $istart > UBound($aarray, $ubound_columns) Then Return SetError(8, 0, -1)
  2545. ReDim $aarray[$idim_1 + $vrange[0] + 1][$idim_2]
  2546. For $ireadfromindex = $idim_1 To 0 Step -1
  2547. For $j = 0 To $idim_2 - 1
  2548. $aarray[$icopyto_index][$j] = $aarray[$ireadfromindex][$j]
  2549. Next
  2550. $icopyto_index -= 1
  2551. $iinsert_index = $vrange[$iinsertpoint_index]
  2552. While $ireadfromindex = $iinsert_index
  2553. For $j = 0 To $idim_2 - 1
  2554. If $j < $istart Then
  2555. $aarray[$icopyto_index][$j] = ""
  2556. ElseIf $j - $istart > $ivaldim_2 - 1 Then
  2557. $aarray[$icopyto_index][$j] = ""
  2558. Else
  2559. If $iinsertpoint_index - 1 < $ivaldim_1 Then
  2560. If IsFunc($hdatatype) Then
  2561. $aarray[$icopyto_index][$j] = $hdatatype($vvalue[$iinsertpoint_index - 1][$j - $istart])
  2562. Else
  2563. $aarray[$icopyto_index][$j] = $vvalue[$iinsertpoint_index - 1][$j - $istart]
  2564. EndIf
  2565. Else
  2566. $aarray[$icopyto_index][$j] = ""
  2567. EndIf
  2568. EndIf
  2569. Next
  2570. $icopyto_index -= 1
  2571. $iinsertpoint_index -= 1
  2572. If $iinsertpoint_index = 0 Then ExitLoop 2
  2573. $iinsert_index = $vrange[$iinsertpoint_index]
  2574. WEnd
  2575. Next
  2576. Case Else
  2577. Return SetError(2, 0, -1)
  2578. EndSwitch
  2579. Return UBound($aarray, $ubound_rows)
  2580. EndFunc
  2581.  
  2582. Func _arraymax(Const ByRef $aarray, $icompnumeric = 0, $istart = -1, $iend = -1, $isubitem = 0)
  2583. Local $iresult = _arraymaxindex($aarray, $icompnumeric, $istart, $iend, $isubitem)
  2584. If @error Then Return SetError(@error, 0, "")
  2585. If UBound($aarray, $ubound_dimensions) = 1 Then
  2586. Return $aarray[$iresult]
  2587. Else
  2588. Return $aarray[$iresult][$isubitem]
  2589. EndIf
  2590. EndFunc
  2591.  
  2592. Func _arraymaxindex(Const ByRef $aarray, $icompnumeric = 0, $istart = -1, $iend = -1, $isubitem = 0)
  2593. If $icompnumeric = Default Then $icompnumeric = 0
  2594. If $istart = Default Then $istart = -1
  2595. If $iend = Default Then $iend = -1
  2596. If $isubitem = Default Then $isubitem = 0
  2597. Local $iret = __array_minmaxindex($aarray, $icompnumeric, $istart, $iend, $isubitem, __array_greaterthan)
  2598. Return SetError(@error, 0, $iret)
  2599. EndFunc
  2600.  
  2601. Func _arraymin(Const ByRef $aarray, $icompnumeric = 0, $istart = -1, $iend = -1, $isubitem = 0)
  2602. Local $iresult = _arrayminindex($aarray, $icompnumeric, $istart, $iend, $isubitem)
  2603. If @error Then Return SetError(@error, 0, "")
  2604. If UBound($aarray, $ubound_dimensions) = 1 Then
  2605. Return $aarray[$iresult]
  2606. Else
  2607. Return $aarray[$iresult][$isubitem]
  2608. EndIf
  2609. EndFunc
  2610.  
  2611. Func _arrayminindex(Const ByRef $aarray, $icompnumeric = 0, $istart = -1, $iend = -1, $isubitem = 0)
  2612. If $icompnumeric = Default Then $icompnumeric = 0
  2613. If $istart = Default Then $istart = -1
  2614. If $iend = Default Then $iend = -1
  2615. If $isubitem = Default Then $isubitem = 0
  2616. Local $iret = __array_minmaxindex($aarray, $icompnumeric, $istart, $iend, $isubitem, __array_lessthan)
  2617. Return SetError(@error, 0, $iret)
  2618. EndFunc
  2619.  
  2620. Func _arraypermute(ByRef $aarray, $sdelimiter = "")
  2621. If $sdelimiter = Default Then $sdelimiter = ""
  2622. If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
  2623. If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError(2, 0, 0)
  2624. Local $isize = UBound($aarray), $ifactorial = 1, $aidx[$isize], $aresult[1], $icount = 1
  2625. If UBound($aarray) Then
  2626. For $i = 0 To $isize - 1
  2627. $aidx[$i] = $i
  2628. Next
  2629. For $i = $isize To 1 Step -1
  2630. $ifactorial *= $i
  2631. Next
  2632. ReDim $aresult[$ifactorial + 1]
  2633. $aresult[0] = $ifactorial
  2634. __array_exeterinternal($aarray, 0, $isize, $sdelimiter, $aidx, $aresult, $icount)
  2635. Else
  2636. $aresult[0] = 0
  2637. EndIf
  2638. Return $aresult
  2639. EndFunc
  2640.  
  2641. Func _arraypop(ByRef $aarray)
  2642. If (NOT IsArray($aarray)) Then Return SetError(1, 0, "")
  2643. If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError(2, 0, "")
  2644. Local $iubound = UBound($aarray) - 1
  2645. If $iubound = -1 Then Return SetError(3, 0, "")
  2646. Local $slastval = $aarray[$iubound]
  2647. If $iubound > -1 Then
  2648. ReDim $aarray[$iubound]
  2649. EndIf
  2650. Return $slastval
  2651. EndFunc
  2652.  
  2653. Func _arraypush(ByRef $aarray, $vvalue, $idirection = 0)
  2654. If $idirection = Default Then $idirection = 0
  2655. If (NOT IsArray($aarray)) Then Return SetError(1, 0, 0)
  2656. If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError(3, 0, 0)
  2657. Local $iubound = UBound($aarray) - 1
  2658. If IsArray($vvalue) Then
  2659. Local $iubounds = UBound($vvalue)
  2660. If ($iubounds - 1) > $iubound Then Return SetError(2, 0, 0)
  2661. If $idirection Then
  2662. For $i = $iubound To $iubounds Step -1
  2663. $aarray[$i] = $aarray[$i - $iubounds]
  2664. Next
  2665. For $i = 0 To $iubounds - 1
  2666. $aarray[$i] = $vvalue[$i]
  2667. Next
  2668. Else
  2669. For $i = 0 To $iubound - $iubounds
  2670. $aarray[$i] = $aarray[$i + $iubounds]
  2671. Next
  2672. For $i = 0 To $iubounds - 1
  2673. $aarray[$i + $iubound - $iubounds + 1] = $vvalue[$i]
  2674. Next
  2675. EndIf
  2676. Else
  2677. If $iubound > -1 Then
  2678. If $idirection Then
  2679. For $i = $iubound To 1 Step -1
  2680. $aarray[$i] = $aarray[$i - 1]
  2681. Next
  2682. $aarray[0] = $vvalue
  2683. Else
  2684. For $i = 0 To $iubound - 1
  2685. $aarray[$i] = $aarray[$i + 1]
  2686. Next
  2687. $aarray[$iubound] = $vvalue
  2688. EndIf
  2689. EndIf
  2690. EndIf
  2691. Return 1
  2692. EndFunc
  2693.  
  2694. Func _arrayreverse(ByRef $aarray, $istart = 0, $iend = 0)
  2695. If $istart = Default Then $istart = 0
  2696. If $iend = Default Then $iend = 0
  2697. If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
  2698. If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError(3, 0, 0)
  2699. If NOT UBound($aarray) Then Return SetError(4, 0, 0)
  2700. Local $vtmp, $iubound = UBound($aarray) - 1
  2701. If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  2702. If $istart < 0 Then $istart = 0
  2703. If $istart > $iend Then Return SetError(2, 0, 0)
  2704. For $i = $istart To Int(($istart + $iend - 1) / 2)
  2705. $vtmp = $aarray[$i]
  2706. $aarray[$i] = $aarray[$iend]
  2707. $aarray[$iend] = $vtmp
  2708. $iend -= 1
  2709. Next
  2710. Return 1
  2711. EndFunc
  2712.  
  2713. Func _arraysearch(Const ByRef $aarray, $vvalue, $istart = 0, $iend = 0, $icase = 0, $icompare = 0, $iforward = 1, $isubitem = -1, $brow = False)
  2714. If $istart = Default Then $istart = 0
  2715. If $iend = Default Then $iend = 0
  2716. If $icase = Default Then $icase = 0
  2717. If $icompare = Default Then $icompare = 0
  2718. If $iforward = Default Then $iforward = 1
  2719. If $isubitem = Default Then $isubitem = -1
  2720. If $brow = Default Then $brow = False
  2721. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  2722. Local $idim_1 = UBound($aarray) - 1
  2723. If $idim_1 = -1 Then Return SetError(3, 0, -1)
  2724. Local $idim_2 = UBound($aarray, $ubound_columns) - 1
  2725. Local $bcomptype = False
  2726. If $icompare = 2 Then
  2727. $icompare = 0
  2728. $bcomptype = True
  2729. EndIf
  2730. If $brow Then
  2731. If UBound($aarray, $ubound_dimensions) = 1 Then Return SetError(5, 0, -1)
  2732. If $iend < 1 OR $iend > $idim_2 Then $iend = $idim_2
  2733. If $istart < 0 Then $istart = 0
  2734. If $istart > $iend Then Return SetError(4, 0, -1)
  2735. Else
  2736. If $iend < 1 OR $iend > $idim_1 Then $iend = $idim_1
  2737. If $istart < 0 Then $istart = 0
  2738. If $istart > $iend Then Return SetError(4, 0, -1)
  2739. EndIf
  2740. Local $istep = 1
  2741. If NOT $iforward Then
  2742. Local $itmp = $istart
  2743. $istart = $iend
  2744. $iend = $itmp
  2745. $istep = -1
  2746. EndIf
  2747. Switch UBound($aarray, $ubound_dimensions)
  2748. Case 1
  2749. If NOT $icompare Then
  2750. If NOT $icase Then
  2751. For $i = $istart To $iend Step $istep
  2752. If $bcomptype AND VarGetType($aarray[$i]) <> VarGetType($vvalue) Then ContinueLoop
  2753. If $aarray[$i] = $vvalue Then Return $i
  2754. Next
  2755. Else
  2756. For $i = $istart To $iend Step $istep
  2757. If $bcomptype AND VarGetType($aarray[$i]) <> VarGetType($vvalue) Then ContinueLoop
  2758. If $aarray[$i] == $vvalue Then Return $i
  2759. Next
  2760. EndIf
  2761. Else
  2762. For $i = $istart To $iend Step $istep
  2763. If $icompare = 3 Then
  2764. If StringRegExp($aarray[$i], $vvalue) Then Return $i
  2765. Else
  2766. If StringInStr($aarray[$i], $vvalue, $icase) > 0 Then Return $i
  2767. EndIf
  2768. Next
  2769. EndIf
  2770. Case 2
  2771. Local $idim_sub
  2772. If $brow Then
  2773. $idim_sub = $idim_1
  2774. If $isubitem > $idim_sub Then $isubitem = $idim_sub
  2775. If $isubitem < 0 Then
  2776. $isubitem = 0
  2777. Else
  2778. $idim_sub = $isubitem
  2779. EndIf
  2780. Else
  2781. $idim_sub = $idim_2
  2782. If $isubitem > $idim_sub Then $isubitem = $idim_sub
  2783. If $isubitem < 0 Then
  2784. $isubitem = 0
  2785. Else
  2786. $idim_sub = $isubitem
  2787. EndIf
  2788. EndIf
  2789. For $j = $isubitem To $idim_sub
  2790. If NOT $icompare Then
  2791. If NOT $icase Then
  2792. For $i = $istart To $iend Step $istep
  2793. If $brow Then
  2794. If $bcomptype AND VarGetType($aarray[$j][$j]) <> VarGetType($vvalue) Then ContinueLoop
  2795. If $aarray[$j][$i] = $vvalue Then Return $i
  2796. Else
  2797. If $bcomptype AND VarGetType($aarray[$i][$j]) <> VarGetType($vvalue) Then ContinueLoop
  2798. If $aarray[$i][$j] = $vvalue Then Return $i
  2799. EndIf
  2800. Next
  2801. Else
  2802. For $i = $istart To $iend Step $istep
  2803. If $brow Then
  2804. If $bcomptype AND VarGetType($aarray[$j][$i]) <> VarGetType($vvalue) Then ContinueLoop
  2805. If $aarray[$j][$i] == $vvalue Then Return $i
  2806. Else
  2807. If $bcomptype AND VarGetType($aarray[$i][$j]) <> VarGetType($vvalue) Then ContinueLoop
  2808. If $aarray[$i][$j] == $vvalue Then Return $i
  2809. EndIf
  2810. Next
  2811. EndIf
  2812. Else
  2813. For $i = $istart To $iend Step $istep
  2814. If $icompare = 3 Then
  2815. If $brow Then
  2816. If StringRegExp($aarray[$j][$i], $vvalue) Then Return $i
  2817. Else
  2818. If StringRegExp($aarray[$i][$j], $vvalue) Then Return $i
  2819. EndIf
  2820. Else
  2821. If $brow Then
  2822. If StringInStr($aarray[$j][$i], $vvalue, $icase) > 0 Then Return $i
  2823. Else
  2824. If StringInStr($aarray[$i][$j], $vvalue, $icase) > 0 Then Return $i
  2825. EndIf
  2826. EndIf
  2827. Next
  2828. EndIf
  2829. Next
  2830. Case Else
  2831. Return SetError(2, 0, -1)
  2832. EndSwitch
  2833. Return SetError(6, 0, -1)
  2834. EndFunc
  2835.  
  2836. Func _arrayshuffle(ByRef $aarray, $istart_row = 0, $iend_row = 0, $icol = -1)
  2837. If $istart_row = Default Then $istart_row = 0
  2838. If $iend_row = Default Then $iend_row = 0
  2839. If $icol = Default Then $icol = -1
  2840. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  2841. Local $idim_1 = UBound($aarray, $ubound_rows)
  2842. If $iend_row = 0 Then $iend_row = $idim_1 - 1
  2843. If $istart_row < 0 OR $istart_row > $idim_1 - 1 Then Return SetError(3, 0, -1)
  2844. If $iend_row < 1 OR $iend_row > $idim_1 - 1 Then Return SetError(3, 0, -1)
  2845. If $istart_row > $iend_row Then Return SetError(4, 0, -1)
  2846. Local $vtmp, $irand
  2847. Switch UBound($aarray, $ubound_dimensions)
  2848. Case 1
  2849. For $i = $iend_row To $istart_row + 1 Step -1
  2850. $irand = Random($istart_row, $i, 1)
  2851. $vtmp = $aarray[$i]
  2852. $aarray[$i] = $aarray[$irand]
  2853. $aarray[$irand] = $vtmp
  2854. Next
  2855. Return 1
  2856. Case 2
  2857. Local $idim_2 = UBound($aarray, $ubound_columns)
  2858. If $icol < -1 OR $icol > $idim_2 - 1 Then Return SetError(5, 0, -1)
  2859. Local $icol_start, $icol_end
  2860. If $icol = -1 Then
  2861. $icol_start = 0
  2862. $icol_end = $idim_2 - 1
  2863. Else
  2864. $icol_start = $icol
  2865. $icol_end = $icol
  2866. EndIf
  2867. For $i = $iend_row To $istart_row + 1 Step -1
  2868. $irand = Random($istart_row, $i, 1)
  2869. For $j = $icol_start To $icol_end
  2870. $vtmp = $aarray[$i][$j]
  2871. $aarray[$i][$j] = $aarray[$irand][$j]
  2872. $aarray[$irand][$j] = $vtmp
  2873. Next
  2874. Next
  2875. Return 1
  2876. Case Else
  2877. Return SetError(2, 0, -1)
  2878. EndSwitch
  2879. EndFunc
  2880.  
  2881. Func _arraysort(ByRef $aarray, $idescending = 0, $istart = 0, $iend = 0, $isubitem = 0, $ipivot = 0)
  2882. If $idescending = Default Then $idescending = 0
  2883. If $istart = Default Then $istart = 0
  2884. If $iend = Default Then $iend = 0
  2885. If $isubitem = Default Then $isubitem = 0
  2886. If $ipivot = Default Then $ipivot = 0
  2887. If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
  2888. Local $iubound = UBound($aarray) - 1
  2889. If $iubound = -1 Then Return SetError(5, 0, 0)
  2890. If $iend = Default Then $iend = 0
  2891. If $iend < 1 OR $iend > $iubound OR $iend = Default Then $iend = $iubound
  2892. If $istart < 0 OR $istart = Default Then $istart = 0
  2893. If $istart > $iend Then Return SetError(2, 0, 0)
  2894. If $idescending = Default Then $idescending = 0
  2895. If $ipivot = Default Then $ipivot = 0
  2896. If $isubitem = Default Then $isubitem = 0
  2897. Switch UBound($aarray, $ubound_dimensions)
  2898. Case 1
  2899. If $ipivot Then
  2900. __arraydualpivotsort($aarray, $istart, $iend)
  2901. Else
  2902. __arrayquicksort1d($aarray, $istart, $iend)
  2903. EndIf
  2904. If $idescending Then _arrayreverse($aarray, $istart, $iend)
  2905. Case 2
  2906. If $ipivot Then Return SetError(6, 0, 0)
  2907. Local $isubmax = UBound($aarray, $ubound_columns) - 1
  2908. If $isubitem > $isubmax Then Return SetError(3, 0, 0)
  2909. If $idescending Then
  2910. $idescending = -1
  2911. Else
  2912. $idescending = 1
  2913. EndIf
  2914. __arrayquicksort2d($aarray, $idescending, $istart, $iend, $isubitem, $isubmax)
  2915. Case Else
  2916. Return SetError(4, 0, 0)
  2917. EndSwitch
  2918. Return 1
  2919. EndFunc
  2920.  
  2921. Func __arrayquicksort1d(ByRef $aarray, Const ByRef $istart, Const ByRef $iend)
  2922. If $iend <= $istart Then Return
  2923. Local $vtmp
  2924. If ($iend - $istart) < 15 Then
  2925. Local $vcur
  2926. For $i = $istart + 1 To $iend
  2927. $vtmp = $aarray[$i]
  2928. If IsNumber($vtmp) Then
  2929. For $j = $i - 1 To $istart Step -1
  2930. $vcur = $aarray[$j]
  2931. If ($vtmp >= $vcur AND IsNumber($vcur)) OR (NOT IsNumber($vcur) AND StringCompare($vtmp, $vcur) >= 0) Then ExitLoop
  2932. $aarray[$j + 1] = $vcur
  2933. Next
  2934. Else
  2935. For $j = $i - 1 To $istart Step -1
  2936. If (StringCompare($vtmp, $aarray[$j]) >= 0) Then ExitLoop
  2937. $aarray[$j + 1] = $aarray[$j]
  2938. Next
  2939. EndIf
  2940. $aarray[$j + 1] = $vtmp
  2941. Next
  2942. Return
  2943. EndIf
  2944. Local $l = $istart, $r = $iend, $vpivot = $aarray[Int(($istart + $iend) / 2)], $bnum = IsNumber($vpivot)
  2945. Do
  2946. If $bnum Then
  2947. While ($aarray[$l] < $vpivot AND IsNumber($aarray[$l])) OR (NOT IsNumber($aarray[$l]) AND StringCompare($aarray[$l], $vpivot) < 0)
  2948. $l += 1
  2949. WEnd
  2950. While ($aarray[$r] > $vpivot AND IsNumber($aarray[$r])) OR (NOT IsNumber($aarray[$r]) AND StringCompare($aarray[$r], $vpivot) > 0)
  2951. $r -= 1
  2952. WEnd
  2953. Else
  2954. While (StringCompare($aarray[$l], $vpivot) < 0)
  2955. $l += 1
  2956. WEnd
  2957. While (StringCompare($aarray[$r], $vpivot) > 0)
  2958. $r -= 1
  2959. WEnd
  2960. EndIf
  2961. If $l <= $r Then
  2962. $vtmp = $aarray[$l]
  2963. $aarray[$l] = $aarray[$r]
  2964. $aarray[$r] = $vtmp
  2965. $l += 1
  2966. $r -= 1
  2967. EndIf
  2968. Until $l > $r
  2969. __arrayquicksort1d($aarray, $istart, $r)
  2970. __arrayquicksort1d($aarray, $l, $iend)
  2971. EndFunc
  2972.  
  2973. Func __arrayquicksort2d(ByRef $aarray, Const ByRef $istep, Const ByRef $istart, Const ByRef $iend, Const ByRef $isubitem, Const ByRef $isubmax)
  2974. If $iend <= $istart Then Return
  2975. Local $vtmp, $l = $istart, $r = $iend, $vpivot = $aarray[Int(($istart + $iend) / 2)][$isubitem], $bnum = IsNumber($vpivot)
  2976. Do
  2977. If $bnum Then
  2978. While ($istep * ($aarray[$l][$isubitem] - $vpivot) < 0 AND IsNumber($aarray[$l][$isubitem])) OR (NOT IsNumber($aarray[$l][$isubitem]) AND $istep * StringCompare($aarray[$l][$isubitem], $vpivot) < 0)
  2979. $l += 1
  2980. WEnd
  2981. While ($istep * ($aarray[$r][$isubitem] - $vpivot) > 0 AND IsNumber($aarray[$r][$isubitem])) OR (NOT IsNumber($aarray[$r][$isubitem]) AND $istep * StringCompare($aarray[$r][$isubitem], $vpivot) > 0)
  2982. $r -= 1
  2983. WEnd
  2984. Else
  2985. While ($istep * StringCompare($aarray[$l][$isubitem], $vpivot) < 0)
  2986. $l += 1
  2987. WEnd
  2988. While ($istep * StringCompare($aarray[$r][$isubitem], $vpivot) > 0)
  2989. $r -= 1
  2990. WEnd
  2991. EndIf
  2992. If $l <= $r Then
  2993. For $i = 0 To $isubmax
  2994. $vtmp = $aarray[$l][$i]
  2995. $aarray[$l][$i] = $aarray[$r][$i]
  2996. $aarray[$r][$i] = $vtmp
  2997. Next
  2998. $l += 1
  2999. $r -= 1
  3000. EndIf
  3001. Until $l > $r
  3002. __arrayquicksort2d($aarray, $istep, $istart, $r, $isubitem, $isubmax)
  3003. __arrayquicksort2d($aarray, $istep, $l, $iend, $isubitem, $isubmax)
  3004. EndFunc
  3005.  
  3006. Func __arraydualpivotsort(ByRef $aarray, $ipivot_left, $ipivot_right, $bleftmost = True)
  3007. If $ipivot_left > $ipivot_right Then Return
  3008. Local $ilength = $ipivot_right - $ipivot_left + 1
  3009. Local $i, $j, $k, $iai, $iak, $ia1, $ia2, $ilast
  3010. If $ilength < 45 Then
  3011. If $bleftmost Then
  3012. $i = $ipivot_left
  3013. While $i < $ipivot_right
  3014. $j = $i
  3015. $iai = $aarray[$i + 1]
  3016. While $iai < $aarray[$j]
  3017. $aarray[$j + 1] = $aarray[$j]
  3018. $j -= 1
  3019. If $j + 1 = $ipivot_left Then ExitLoop
  3020. WEnd
  3021. $aarray[$j + 1] = $iai
  3022. $i += 1
  3023. WEnd
  3024. Else
  3025. While 1
  3026. If $ipivot_left >= $ipivot_right Then Return 1
  3027. $ipivot_left += 1
  3028. If $aarray[$ipivot_left] < $aarray[$ipivot_left - 1] Then ExitLoop
  3029. WEnd
  3030. While 1
  3031. $k = $ipivot_left
  3032. $ipivot_left += 1
  3033. If $ipivot_left > $ipivot_right Then ExitLoop
  3034. $ia1 = $aarray[$k]
  3035. $ia2 = $aarray[$ipivot_left]
  3036. If $ia1 < $ia2 Then
  3037. $ia2 = $ia1
  3038. $ia1 = $aarray[$ipivot_left]
  3039. EndIf
  3040. $k -= 1
  3041. While $ia1 < $aarray[$k]
  3042. $aarray[$k + 2] = $aarray[$k]
  3043. $k -= 1
  3044. WEnd
  3045. $aarray[$k + 2] = $ia1
  3046. While $ia2 < $aarray[$k]
  3047. $aarray[$k + 1] = $aarray[$k]
  3048. $k -= 1
  3049. WEnd
  3050. $aarray[$k + 1] = $ia2
  3051. $ipivot_left += 1
  3052. WEnd
  3053. $ilast = $aarray[$ipivot_right]
  3054. $ipivot_right -= 1
  3055. While $ilast < $aarray[$ipivot_right]
  3056. $aarray[$ipivot_right + 1] = $aarray[$ipivot_right]
  3057. $ipivot_right -= 1
  3058. WEnd
  3059. $aarray[$ipivot_right + 1] = $ilast
  3060. EndIf
  3061. Return 1
  3062. EndIf
  3063. Local $iseventh = BitShift($ilength, 3) + BitShift($ilength, 6) + 1
  3064. Local $ie1, $ie2, $ie3, $ie4, $ie5, $t
  3065. $ie3 = Ceiling(($ipivot_left + $ipivot_right) / 2)
  3066. $ie2 = $ie3 - $iseventh
  3067. $ie1 = $ie2 - $iseventh
  3068. $ie4 = $ie3 + $iseventh
  3069. $ie5 = $ie4 + $iseventh
  3070. If $aarray[$ie2] < $aarray[$ie1] Then
  3071. $t = $aarray[$ie2]
  3072. $aarray[$ie2] = $aarray[$ie1]
  3073. $aarray[$ie1] = $t
  3074. EndIf
  3075. If $aarray[$ie3] < $aarray[$ie2] Then
  3076. $t = $aarray[$ie3]
  3077. $aarray[$ie3] = $aarray[$ie2]
  3078. $aarray[$ie2] = $t
  3079. If $t < $aarray[$ie1] Then
  3080. $aarray[$ie2] = $aarray[$ie1]
  3081. $aarray[$ie1] = $t
  3082. EndIf
  3083. EndIf
  3084. If $aarray[$ie4] < $aarray[$ie3] Then
  3085. $t = $aarray[$ie4]
  3086. $aarray[$ie4] = $aarray[$ie3]
  3087. $aarray[$ie3] = $t
  3088. If $t < $aarray[$ie2] Then
  3089. $aarray[$ie3] = $aarray[$ie2]
  3090. $aarray[$ie2] = $t
  3091. If $t < $aarray[$ie1] Then
  3092. $aarray[$ie2] = $aarray[$ie1]
  3093. $aarray[$ie1] = $t
  3094. EndIf
  3095. EndIf
  3096. EndIf
  3097. If $aarray[$ie5] < $aarray[$ie4] Then
  3098. $t = $aarray[$ie5]
  3099. $aarray[$ie5] = $aarray[$ie4]
  3100. $aarray[$ie4] = $t
  3101. If $t < $aarray[$ie3] Then
  3102. $aarray[$ie4] = $aarray[$ie3]
  3103. $aarray[$ie3] = $t
  3104. If $t < $aarray[$ie2] Then
  3105. $aarray[$ie3] = $aarray[$ie2]
  3106. $aarray[$ie2] = $t
  3107. If $t < $aarray[$ie1] Then
  3108. $aarray[$ie2] = $aarray[$ie1]
  3109. $aarray[$ie1] = $t
  3110. EndIf
  3111. EndIf
  3112. EndIf
  3113. EndIf
  3114. Local $iless = $ipivot_left
  3115. Local $igreater = $ipivot_right
  3116. If (($aarray[$ie1] <> $aarray[$ie2]) AND ($aarray[$ie2] <> $aarray[$ie3]) AND ($aarray[$ie3] <> $aarray[$ie4]) AND ($aarray[$ie4] <> $aarray[$ie5])) Then
  3117. Local $ipivot_1 = $aarray[$ie2]
  3118. Local $ipivot_2 = $aarray[$ie4]
  3119. $aarray[$ie2] = $aarray[$ipivot_left]
  3120. $aarray[$ie4] = $aarray[$ipivot_right]
  3121. Do
  3122. $iless += 1
  3123. Until $aarray[$iless] >= $ipivot_1
  3124. Do
  3125. $igreater -= 1
  3126. Until $aarray[$igreater] <= $ipivot_2
  3127. $k = $iless
  3128. While $k <= $igreater
  3129. $iak = $aarray[$k]
  3130. If $iak < $ipivot_1 Then
  3131. $aarray[$k] = $aarray[$iless]
  3132. $aarray[$iless] = $iak
  3133. $iless += 1
  3134. ElseIf $iak > $ipivot_2 Then
  3135. While $aarray[$igreater] > $ipivot_2
  3136. $igreater -= 1
  3137. If $igreater + 1 = $k Then ExitLoop 2
  3138. WEnd
  3139. If $aarray[$igreater] < $ipivot_1 Then
  3140. $aarray[$k] = $aarray[$iless]
  3141. $aarray[$iless] = $aarray[$igreater]
  3142. $iless += 1
  3143. Else
  3144. $aarray[$k] = $aarray[$igreater]
  3145. EndIf
  3146. $aarray[$igreater] = $iak
  3147. $igreater -= 1
  3148. EndIf
  3149. $k += 1
  3150. WEnd
  3151. $aarray[$ipivot_left] = $aarray[$iless - 1]
  3152. $aarray[$iless - 1] = $ipivot_1
  3153. $aarray[$ipivot_right] = $aarray[$igreater + 1]
  3154. $aarray[$igreater + 1] = $ipivot_2
  3155. __arraydualpivotsort($aarray, $ipivot_left, $iless - 2, True)
  3156. __arraydualpivotsort($aarray, $igreater + 2, $ipivot_right, False)
  3157. If ($iless < $ie1) AND ($ie5 < $igreater) Then
  3158. While $aarray[$iless] = $ipivot_1
  3159. $iless += 1
  3160. WEnd
  3161. While $aarray[$igreater] = $ipivot_2
  3162. $igreater -= 1
  3163. WEnd
  3164. $k = $iless
  3165. While $k <= $igreater
  3166. $iak = $aarray[$k]
  3167. If $iak = $ipivot_1 Then
  3168. $aarray[$k] = $aarray[$iless]
  3169. $aarray[$iless] = $iak
  3170. $iless += 1
  3171. ElseIf $iak = $ipivot_2 Then
  3172. While $aarray[$igreater] = $ipivot_2
  3173. $igreater -= 1
  3174. If $igreater + 1 = $k Then ExitLoop 2
  3175. WEnd
  3176. If $aarray[$igreater] = $ipivot_1 Then
  3177. $aarray[$k] = $aarray[$iless]
  3178. $aarray[$iless] = $ipivot_1
  3179. $iless += 1
  3180. Else
  3181. $aarray[$k] = $aarray[$igreater]
  3182. EndIf
  3183. $aarray[$igreater] = $iak
  3184. $igreater -= 1
  3185. EndIf
  3186. $k += 1
  3187. WEnd
  3188. EndIf
  3189. __arraydualpivotsort($aarray, $iless, $igreater, False)
  3190. Else
  3191. Local $ipivot = $aarray[$ie3]
  3192. $k = $iless
  3193. While $k <= $igreater
  3194. If $aarray[$k] = $ipivot Then
  3195. $k += 1
  3196. ContinueLoop
  3197. EndIf
  3198. $iak = $aarray[$k]
  3199. If $iak < $ipivot Then
  3200. $aarray[$k] = $aarray[$iless]
  3201. $aarray[$iless] = $iak
  3202. $iless += 1
  3203. Else
  3204. While $aarray[$igreater] > $ipivot
  3205. $igreater -= 1
  3206. WEnd
  3207. If $aarray[$igreater] < $ipivot Then
  3208. $aarray[$k] = $aarray[$iless]
  3209. $aarray[$iless] = $aarray[$igreater]
  3210. $iless += 1
  3211. Else
  3212. $aarray[$k] = $ipivot
  3213. EndIf
  3214. $aarray[$igreater] = $iak
  3215. $igreater -= 1
  3216. EndIf
  3217. $k += 1
  3218. WEnd
  3219. __arraydualpivotsort($aarray, $ipivot_left, $iless - 1, True)
  3220. __arraydualpivotsort($aarray, $igreater + 1, $ipivot_right, False)
  3221. EndIf
  3222. EndFunc
  3223.  
  3224. Func _arrayswap(ByRef $aarray, $iindex_1, $iindex_2, $bcol = False, $istart = -1, $iend = -1)
  3225. If $bcol = Default Then $bcol = False
  3226. If $istart = Default Then $istart = -1
  3227. If $iend = Default Then $iend = -1
  3228. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  3229. Local $idim_1 = UBound($aarray, $ubound_rows) - 1
  3230. Local $idim_2 = UBound($aarray, $ubound_columns) - 1
  3231. If $idim_2 = -1 Then
  3232. $bcol = False
  3233. $istart = -1
  3234. $iend = -1
  3235. EndIf
  3236. If $istart > $iend Then Return SetError(5, 0, -1)
  3237. If $bcol Then
  3238. If $iindex_1 < 0 OR $iindex_2 > $idim_2 Then Return SetError(3, 0, -1)
  3239. If $istart = -1 Then $istart = 0
  3240. If $iend = -1 Then $iend = $idim_1
  3241. Else
  3242. If $iindex_1 < 0 OR $iindex_2 > $idim_1 Then Return SetError(3, 0, -1)
  3243. If $istart = -1 Then $istart = 0
  3244. If $iend = -1 Then $iend = $idim_2
  3245. EndIf
  3246. Local $vtmp
  3247. Switch UBound($aarray, $ubound_dimensions)
  3248. Case 1
  3249. $vtmp = $aarray[$iindex_1]
  3250. $aarray[$iindex_1] = $aarray[$iindex_2]
  3251. $aarray[$iindex_2] = $vtmp
  3252. Case 2
  3253. If $istart < -1 OR $iend < -1 Then Return SetError(4, 0, -1)
  3254. If $bcol Then
  3255. If $istart > $idim_1 OR $iend > $idim_1 Then Return SetError(4, 0, -1)
  3256. For $j = $istart To $iend
  3257. $vtmp = $aarray[$j][$iindex_1]
  3258. $aarray[$j][$iindex_1] = $aarray[$j][$iindex_2]
  3259. $aarray[$j][$iindex_2] = $vtmp
  3260. Next
  3261. Else
  3262. If $istart > $idim_2 OR $iend > $idim_2 Then Return SetError(4, 0, -1)
  3263. For $j = $istart To $iend
  3264. $vtmp = $aarray[$iindex_1][$j]
  3265. $aarray[$iindex_1][$j] = $aarray[$iindex_2][$j]
  3266. $aarray[$iindex_2][$j] = $vtmp
  3267. Next
  3268. EndIf
  3269. Case Else
  3270. Return SetError(2, 0, -1)
  3271. EndSwitch
  3272. Return 1
  3273. EndFunc
  3274.  
  3275. Func _arraytoclip(Const ByRef $aarray, $sdelim_col = "|", $istart_row = -1, $iend_row = -1, $sdelim_row = @CRLF, $istart_col = -1, $iend_col = -1)
  3276. Local $sresult = _arraytostring($aarray, $sdelim_col, $istart_row, $iend_row, $sdelim_row, $istart_col, $iend_col)
  3277. If @error Then Return SetError(@error, 0, 0)
  3278. If ClipPut($sresult) Then Return 1
  3279. Return SetError(-1, 0, 0)
  3280. EndFunc
  3281.  
  3282. Func _arraytostring(Const ByRef $aarray, $sdelim_col = "|", $istart_row = -1, $iend_row = -1, $sdelim_row = @CRLF, $istart_col = -1, $iend_col = -1)
  3283. If $sdelim_col = Default Then $sdelim_col = "|"
  3284. If $sdelim_row = Default Then $sdelim_row = @CRLF
  3285. If $istart_row = Default Then $istart_row = -1
  3286. If $iend_row = Default Then $iend_row = -1
  3287. If $istart_col = Default Then $istart_col = -1
  3288. If $iend_col = Default Then $iend_col = -1
  3289. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  3290. Local $idim_1 = UBound($aarray, $ubound_rows) - 1
  3291. If $istart_row = -1 Then $istart_row = 0
  3292. If $iend_row = -1 Then $iend_row = $idim_1
  3293. If $istart_row < -1 OR $iend_row < -1 Then Return SetError(3, 0, -1)
  3294. If $istart_row > $idim_1 OR $iend_row > $idim_1 Then Return SetError(3, 0, "")
  3295. If $istart_row > $iend_row Then Return SetError(4, 0, -1)
  3296. Local $sret = ""
  3297. Switch UBound($aarray, $ubound_dimensions)
  3298. Case 1
  3299. For $i = $istart_row To $iend_row
  3300. $sret &= $aarray[$i] & $sdelim_col
  3301. Next
  3302. Return StringTrimRight($sret, StringLen($sdelim_col))
  3303. Case 2
  3304. Local $idim_2 = UBound($aarray, $ubound_columns) - 1
  3305. If $istart_col = -1 Then $istart_col = 0
  3306. If $iend_col = -1 Then $iend_col = $idim_2
  3307. If $istart_col < -1 OR $iend_col < -1 Then Return SetError(5, 0, -1)
  3308. If $istart_col > $idim_2 OR $iend_col > $idim_2 Then Return SetError(5, 0, -1)
  3309. If $istart_col > $iend_col Then Return SetError(6, 0, -1)
  3310. For $i = $istart_row To $iend_row
  3311. For $j = $istart_col To $iend_col
  3312. $sret &= $aarray[$i][$j] & $sdelim_col
  3313. Next
  3314. $sret = StringTrimRight($sret, StringLen($sdelim_col)) & $sdelim_row
  3315. Next
  3316. Return StringTrimRight($sret, StringLen($sdelim_row))
  3317. Case Else
  3318. Return SetError(2, 0, -1)
  3319. EndSwitch
  3320. Return 1
  3321. EndFunc
  3322.  
  3323. Func _arraytranspose(ByRef $aarray)
  3324. Switch UBound($aarray, 0)
  3325. Case 0
  3326. Return SetError(2, 0, 0)
  3327. Case 1
  3328. Local $atemp[1][UBound($aarray)]
  3329. For $i = 0 To UBound($aarray) - 1
  3330. $atemp[0][$i] = $aarray[$i]
  3331. Next
  3332. $aarray = $atemp
  3333. Case 2
  3334. Local $idim_1 = UBound($aarray, 1), $idim_2 = UBound($aarray, 2)
  3335. If $idim_1 <> $idim_2 Then
  3336. Local $atemp[$idim_2][$idim_1]
  3337. For $i = 0 To $idim_1 - 1
  3338. For $j = 0 To $idim_2 - 1
  3339. $atemp[$j][$i] = $aarray[$i][$j]
  3340. Next
  3341. Next
  3342. $aarray = $atemp
  3343. Else
  3344. Local $velement
  3345. For $i = 0 To $idim_1 - 1
  3346. For $j = $i + 1 To $idim_2 - 1
  3347. $velement = $aarray[$i][$j]
  3348. $aarray[$i][$j] = $aarray[$j][$i]
  3349. $aarray[$j][$i] = $velement
  3350. Next
  3351. Next
  3352. EndIf
  3353. Case Else
  3354. Return SetError(1, 0, 0)
  3355. EndSwitch
  3356. Return 1
  3357. EndFunc
  3358.  
  3359. Func _arraytrim(ByRef $aarray, $itrimnum, $idirection = 0, $istart = 0, $iend = 0, $isubitem = 0)
  3360. If $idirection = Default Then $idirection = 0
  3361. If $istart = Default Then $istart = 0
  3362. If $iend = Default Then $iend = 0
  3363. If $isubitem = Default Then $isubitem = 0
  3364. If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
  3365. Local $idim_1 = UBound($aarray, $ubound_rows) - 1
  3366. If $iend = 0 Then $iend = $idim_1
  3367. If $istart > $iend Then Return SetError(3, 0, -1)
  3368. If $istart < 0 OR $iend < 0 Then Return SetError(3, 0, -1)
  3369. If $istart > $idim_1 OR $iend > $idim_1 Then Return SetError(3, 0, -1)
  3370. If $istart > $iend Then Return SetError(4, 0, -1)
  3371. Switch UBound($aarray, $ubound_dimensions)
  3372. Case 1
  3373. If $idirection Then
  3374. For $i = $istart To $iend
  3375. $aarray[$i] = StringTrimRight($aarray[$i], $itrimnum)
  3376. Next
  3377. Else
  3378. For $i = $istart To $iend
  3379. $aarray[$i] = StringTrimLeft($aarray[$i], $itrimnum)
  3380. Next
  3381. EndIf
  3382. Case 2
  3383. Local $idim_2 = UBound($aarray, $ubound_columns) - 1
  3384. If $isubitem < 0 OR $isubitem > $idim_2 Then Return SetError(5, 0, -1)
  3385. If $idirection Then
  3386. For $i = $istart To $iend
  3387. $aarray[$i][$isubitem] = StringTrimRight($aarray[$i][$isubitem], $itrimnum)
  3388. Next
  3389. Else
  3390. For $i = $istart To $iend
  3391. $aarray[$i][$isubitem] = StringTrimLeft($aarray[$i][$isubitem], $itrimnum)
  3392. Next
  3393. EndIf
  3394. Case Else
  3395. Return SetError(2, 0, 0)
  3396. EndSwitch
  3397. Return 1
  3398. EndFunc
  3399.  
  3400. Func _arrayunique(Const ByRef $aarray, $icolumn = 0, $ibase = 0, $icase = 0, $icount = $arrayunique_count, $iinttype = $arrayunique_auto)
  3401. If $icolumn = Default Then $icolumn = 0
  3402. If $ibase = Default Then $ibase = 0
  3403. If $icase = Default Then $icase = 0
  3404. If $icount = Default Then $icount = $arrayunique_count
  3405. If UBound($aarray, $ubound_rows) = 0 Then Return SetError(1, 0, 0)
  3406. Local $idims = UBound($aarray, $ubound_dimensions), $inumcolumns = UBound($aarray, $ubound_columns)
  3407. If $idims > 2 Then Return SetError(2, 0, 0)
  3408. If $ibase < 0 OR $ibase > 1 OR (NOT IsInt($ibase)) Then Return SetError(3, 0, 0)
  3409. If $icase < 0 OR $icase > 1 OR (NOT IsInt($icase)) Then Return SetError(3, 0, 0)
  3410. If $icount < 0 OR $icount > 1 OR (NOT IsInt($icount)) Then Return SetError(4, 0, 0)
  3411. If $iinttype < 0 OR $iinttype > 4 OR (NOT IsInt($iinttype)) Then Return SetError(5, 0, 0)
  3412. If $icolumn < 0 OR ($inumcolumns = 0 AND $icolumn > 0) OR ($inumcolumns > 0 AND $icolumn >= $inumcolumns) Then Return SetError(6, 0, 0)
  3413. If $iinttype = $arrayunique_auto Then
  3414. Local $vfirstelem = (($idims = 1) ? ($aarray[$ibase]) : ($aarray[$icolumn][$ibase]))
  3415. If IsInt($vfirstelem) Then
  3416. Switch VarGetType($vfirstelem)
  3417. Case "Int32"
  3418. $iinttype = $arrayunique_force32
  3419. Case "Int64"
  3420. $iinttype = $arrayunique_force64
  3421. EndSwitch
  3422. Else
  3423. $iinttype = $arrayunique_force32
  3424. EndIf
  3425. EndIf
  3426. ObjEvent("AutoIt.Error", "__ArrayUnique_AutoErrFunc")
  3427. Local $odictionary = ObjCreate("Scripting.Dictionary")
  3428. $odictionary.comparemode = Number(NOT $icase)
  3429. Local $velem, $stype, $vkey, $bcomerror = False
  3430. For $i = $ibase To UBound($aarray) - 1
  3431. If $idims = 1 Then
  3432. $velem = $aarray[$i]
  3433. Else
  3434. $velem = $aarray[$i][$icolumn]
  3435. EndIf
  3436. Switch $iinttype
  3437. Case $arrayunique_force32
  3438. $odictionary.item($velem)
  3439. If @error Then
  3440. $bcomerror = True
  3441. ExitLoop
  3442. EndIf
  3443. Case $arrayunique_force64
  3444. $stype = VarGetType($velem)
  3445. If $stype = "Int32" Then
  3446. $bcomerror = True
  3447. ExitLoop
  3448. EndIf
  3449. $vkey = "#" & $stype & "#" & String($velem)
  3450. If NOT $odictionary.item($vkey) Then
  3451. $odictionary($vkey) = $velem
  3452. EndIf
  3453. Case $arrayunique_match
  3454. $stype = VarGetType($velem)
  3455. If StringLeft($stype, 3) = "Int" Then
  3456. $vkey = "#Int#" & String($velem)
  3457. Else
  3458. $vkey = "#" & $stype & "#" & String($velem)
  3459. EndIf
  3460. If NOT $odictionary.item($vkey) Then
  3461. $odictionary($vkey) = $velem
  3462. EndIf
  3463. Case $arrayunique_distinct
  3464. $vkey = "#" & VarGetType($velem) & "#" & String($velem)
  3465. If NOT $odictionary.item($vkey) Then
  3466. $odictionary($vkey) = $velem
  3467. EndIf
  3468. EndSwitch
  3469. Next
  3470. Local $avalues, $j = 0
  3471. If $bcomerror Then
  3472. Return SetError(7, 0, 0)
  3473. ElseIf $iinttype <> $arrayunique_force32 Then
  3474. Local $avalues[$odictionary.count]
  3475. For $vkey In $odictionary.keys()
  3476. $avalues[$j] = $odictionary($vkey)
  3477. If StringLeft($vkey, 5) = "#Ptr#" Then
  3478. $avalues[$j] = Ptr($avalues[$j])
  3479. EndIf
  3480. $j += 1
  3481. Next
  3482. Else
  3483. $avalues = $odictionary.keys()
  3484. EndIf
  3485. If $icount Then
  3486. _arrayinsert($avalues, 0, $odictionary.count)
  3487. EndIf
  3488. Return $avalues
  3489. EndFunc
  3490.  
  3491. Func _array1dtohistogram($aarray, $isizing = 100)
  3492. If UBound($aarray, 0) > 1 Then Return SetError(1, 0, "")
  3493. $isizing = $isizing * 8
  3494. Local $t, $n, $imin = 0, $imax = 0, $ioffset = 0
  3495. For $i = 0 To UBound($aarray) - 1
  3496. $t = $aarray[$i]
  3497. $t = IsNumber($t) ? Round($t) : 0
  3498. If $t < $imin Then $imin = $t
  3499. If $t > $imax Then $imax = $t
  3500. Next
  3501. Local $irange = Int(Round(($imax - $imin) / 8)) * 8
  3502. Local $ispaceratio = 4
  3503. For $i = 0 To UBound($aarray) - 1
  3504. $t = $aarray[$i]
  3505. If $t Then
  3506. $n = Abs(Round(($isizing * $t) / $irange) / 8)
  3507. $aarray[$i] = ""
  3508. If $t > 0 Then
  3509. If $imin Then
  3510. $ioffset = Int(Abs(Round(($isizing * $imin) / $irange) / 8) / 8 * $ispaceratio)
  3511. $aarray[$i] = __array_stringrepeat(ChrW(32), $ioffset)
  3512. EndIf
  3513. Else
  3514. If $imin <> $t Then
  3515. $ioffset = Int(Abs(Round(($isizing * ($t - $imin)) / $irange) / 8) / 8 * $ispaceratio)
  3516. $aarray[$i] = __array_stringrepeat(ChrW(32), $ioffset)
  3517. EndIf
  3518. EndIf
  3519. $aarray[$i] &= __array_stringrepeat(ChrW(9608), Int($n / 8))
  3520. $n = Mod($n, 8)
  3521. If $n > 0 Then $aarray[$i] &= ChrW(9608 + 8 - $n)
  3522. $aarray[$i] &= " " & $t
  3523. Else
  3524. $aarray[$i] = ""
  3525. EndIf
  3526. Next
  3527. Return $aarray
  3528. EndFunc
  3529.  
  3530. Func __array_stringrepeat($sstring, $irepeatcount)
  3531. $irepeatcount = Int($irepeatcount)
  3532. If StringLen($sstring) < 1 OR $irepeatcount <= 0 Then Return SetError(1, 0, "")
  3533. Local $sresult = ""
  3534. While $irepeatcount > 1
  3535. If BitAND($irepeatcount, 1) Then $sresult &= $sstring
  3536. $sstring &= $sstring
  3537. $irepeatcount = BitShift($irepeatcount, 1)
  3538. WEnd
  3539. Return $sstring & $sresult
  3540. EndFunc
  3541.  
  3542. Func __array_exeterinternal(ByRef $aarray, $istart, $isize, $sdelimiter, ByRef $aidx, ByRef $aresult, ByRef $icount)
  3543. If $istart == $isize - 1 Then
  3544. For $i = 0 To $isize - 1
  3545. $aresult[$icount] &= $aarray[$aidx[$i]] & $sdelimiter
  3546. Next
  3547. If $sdelimiter <> "" Then $aresult[$icount] = StringTrimRight($aresult[$icount], StringLen($sdelimiter))
  3548. $icount += 1
  3549. Else
  3550. Local $itemp
  3551. For $i = $istart To $isize - 1
  3552. $itemp = $aidx[$i]
  3553. $aidx[$i] = $aidx[$istart]
  3554. $aidx[$istart] = $itemp
  3555. __array_exeterinternal($aarray, $istart + 1, $isize, $sdelimiter, $aidx, $aresult, $icount)
  3556. $aidx[$istart] = $aidx[$i]
  3557. $aidx[$i] = $itemp
  3558. Next
  3559. EndIf
  3560. EndFunc
  3561.  
  3562. Func __array_combinations($in, $ir)
  3563. Local $i_total = 1
  3564. For $i = $ir To 1 Step -1
  3565. $i_total *= ($in / $i)
  3566. $in -= 1
  3567. Next
  3568. Return Round($i_total)
  3569. EndFunc
  3570.  
  3571. Func __array_getnext($in, $ir, ByRef $ileft, $itotal, ByRef $aidx)
  3572. If $ileft == $itotal Then
  3573. $ileft -= 1
  3574. Return
  3575. EndIf
  3576. Local $i = $ir - 1
  3577. While $aidx[$i] == $in - $ir + $i
  3578. $i -= 1
  3579. WEnd
  3580. $aidx[$i] += 1
  3581. For $j = $i + 1 To $ir - 1
  3582. $aidx[$j] = $aidx[$i] + $j - $i
  3583. Next
  3584. $ileft -= 1
  3585. EndFunc
  3586.  
  3587. Func __array_minmaxindex(Const ByRef $aarray, $icompnumeric, $istart, $iend, $isubitem, $fucomparison)
  3588. If $icompnumeric = Default Then $icompnumeric = 0
  3589. If $icompnumeric <> 1 Then $icompnumeric = 0
  3590. If $istart = Default Then $istart = 0
  3591. If $iend = Default Then $iend = 0
  3592. If $isubitem = Default Then $isubitem = 0
  3593. If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
  3594. Local $idim_1 = UBound($aarray, $ubound_rows) - 1
  3595. If $idim_1 < 0 Then Return SetError(1, 0, -1)
  3596. If $iend = -1 Then $iend = $idim_1
  3597. If $istart = -1 Then $istart = 0
  3598. If $istart < -1 OR $iend < -1 Then Return SetError(3, 0, -1)
  3599. If $istart > $idim_1 OR $iend > $idim_1 Then Return SetError(3, 0, -1)
  3600. If $istart > $iend Then Return SetError(4, 0, -1)
  3601. If $idim_1 < 0 Then Return SetError(5, 0, -1)
  3602. Local $imaxminindex = $istart
  3603. Switch UBound($aarray, $ubound_dimensions)
  3604. Case 1
  3605. If $icompnumeric Then
  3606. For $i = $istart To $iend
  3607. If $fucomparison(Number($aarray[$i]), Number($aarray[$imaxminindex])) Then $imaxminindex = $i
  3608. Next
  3609. Else
  3610. For $i = $istart To $iend
  3611. If $fucomparison($aarray[$i], $aarray[$imaxminindex]) Then $imaxminindex = $i
  3612. Next
  3613. EndIf
  3614. Case 2
  3615. If $isubitem < 0 OR $isubitem > UBound($aarray, $ubound_columns) - 1 Then Return SetError(6, 0, -1)
  3616. If $icompnumeric Then
  3617. For $i = $istart To $iend
  3618. If $fucomparison(Number($aarray[$i][$isubitem]), Number($aarray[$imaxminindex][$isubitem])) Then $imaxminindex = $i
  3619. Next
  3620. Else
  3621. For $i = $istart To $iend
  3622. If $fucomparison($aarray[$i][$isubitem], $aarray[$imaxminindex][$isubitem]) Then $imaxminindex = $i
  3623. Next
  3624. EndIf
  3625. Case Else
  3626. Return SetError(2, 0, -1)
  3627. EndSwitch
  3628. Return $imaxminindex
  3629. EndFunc
  3630.  
  3631. Func __array_greaterthan($vvalue1, $vvalue2)
  3632. Return $vvalue1 > $vvalue2
  3633. EndFunc
  3634.  
  3635. Func __array_lessthan($vvalue1, $vvalue2)
  3636. Return $vvalue1 < $vvalue2
  3637. EndFunc
  3638.  
  3639. Func __arrayunique_autoerrfunc()
  3640. EndFunc
  3641.  
  3642. Global Const $gmem_fixed = 0
  3643. Global Const $gmem_moveable = 2
  3644. Global Const $gmem_nocompact = 16
  3645. Global Const $gmem_nodiscard = 32
  3646. Global Const $gmem_zeroinit = 64
  3647. Global Const $gmem_modify = 128
  3648. Global Const $gmem_discardable = 256
  3649. Global Const $gmem_not_banked = 4096
  3650. Global Const $gmem_share = 8192
  3651. Global Const $gmem_ddeshare = 8192
  3652. Global Const $gmem_notify = 16384
  3653. Global Const $gmem_lower = 4096
  3654. Global Const $gmem_valid_flags = 32626
  3655. Global Const $gmem_invalid_handle = 32768
  3656. Global Const $gptr = BitOR($gmem_fixed, $gmem_zeroinit)
  3657. Global Const $ghnd = BitOR($gmem_moveable, $gmem_zeroinit)
  3658. Global Const $mem_commit = 4096
  3659. Global Const $mem_reserve = 8192
  3660. Global Const $mem_top_down = 1048576
  3661. Global Const $mem_shared = 134217728
  3662. Global Const $page_noaccess = 1
  3663. Global Const $page_readonly = 2
  3664. Global Const $page_readwrite = 4
  3665. Global Const $page_execute = 16
  3666. Global Const $page_execute_read = 32
  3667. Global Const $page_execute_readwrite = 64
  3668. Global Const $page_execute_writecopy = 128
  3669. Global Const $page_guard = 256
  3670. Global Const $page_nocache = 512
  3671. Global Const $page_writecombine = 1024
  3672. Global Const $page_writecopy = 8
  3673. Global Const $mem_decommit = 16384
  3674. Global Const $mem_release = 32768
  3675. Global Const $tagpoint = "struct;long X;long Y;endstruct"
  3676. Global Const $tagrect = "struct;long Left;long Top;long Right;long Bottom;endstruct"
  3677. Global Const $tagsize = "struct;long X;long Y;endstruct"
  3678. Global Const $tagmargins = "int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight"
  3679. Global Const $tagfiletime = "struct;dword Lo;dword Hi;endstruct"
  3680. Global Const $tagsystemtime = "struct;word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds;endstruct"
  3681. Global Const $tagtime_zone_information = "struct;long Bias;wchar StdName[32];word StdDate[8];long StdBias;wchar DayName[32];word DayDate[8];long DayBias;endstruct"
  3682. Global Const $tagnmhdr = "struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct"
  3683. Global Const $tagcomboboxexitem = "uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;int SelectedImage;int OverlayImage;" & "int Indent;lparam Param"
  3684. Global Const $tagnmcbedragbegin = $tagnmhdr & ";int ItemID;wchar szText[260]"
  3685. Global Const $tagnmcbeendedit = $tagnmhdr & ";bool fChanged;int NewSelection;wchar szText[260];int Why"
  3686. Global Const $tagnmcomboboxex = $tagnmhdr & ";uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;" & "int SelectedImage;int OverlayImage;int Indent;lparam Param"
  3687. Global Const $tagdtprange = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;" & "word MinSecond;word MinMSecond;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;" & "word MaxMinute;word MaxSecond;word MaxMSecond;bool MinValid;bool MaxValid"
  3688. Global Const $tagnmdatetimechange = $tagnmhdr & ";dword Flag;" & $tagsystemtime
  3689. Global Const $tagnmdatetimeformat = $tagnmhdr & ";ptr Format;" & $tagsystemtime & ";ptr pDisplay;wchar Display[64]"
  3690. Global Const $tagnmdatetimeformatquery = $tagnmhdr & ";ptr Format;struct;long SizeX;long SizeY;endstruct"
  3691. Global Const $tagnmdatetimekeydown = $tagnmhdr & ";int VirtKey;ptr Format;" & $tagsystemtime
  3692. Global Const $tagnmdatetimestring = $tagnmhdr & ";ptr UserString;" & $tagsystemtime & ";dword Flags"
  3693. Global Const $tageventlogrecord = "dword Length;dword Reserved;dword RecordNumber;dword TimeGenerated;dword TimeWritten;dword EventID;" & "word EventType;word NumStrings;word EventCategory;word ReservedFlags;dword ClosingRecordNumber;dword StringOffset;" & "dword UserSidLength;dword UserSidOffset;dword DataLength;dword DataOffset"
  3694. Global Const $taggdip_effectparams_blur = "float Radius; bool ExpandEdge"
  3695. Global Const $taggdip_effectparams_brightnesscontrast = "int BrightnessLevel; int ContrastLevel"
  3696. Global Const $taggdip_effectparams_colorbalance = "int CyanRed; int MagentaGreen; int YellowBlue"
  3697. Global Const $taggdip_effectparams_colorcurve = "int Adjustment; int Channel; int AdjustValue"
  3698. Global Const $taggdip_effectparams_colorlut = "byte LutB[256]; byte LutG[256]; byte LutR[256]; byte LutA[256]"
  3699. Global Const $taggdip_effectparams_huesaturationlightness = "int HueLevel; int SaturationLevel; int LightnessLevel"
  3700. Global Const $taggdip_effectparams_levels = "int Highlight; int Midtone; int Shadow"
  3701. Global Const $taggdip_effectparams_redeyecorrection = "uint NumberOfAreas; ptr Areas"
  3702. Global Const $taggdip_effectparams_sharpen = "float Radius; float Amount"
  3703. Global Const $taggdip_effectparams_tint = "int Hue; int Amount"
  3704. Global Const $taggdipbitmapdata = "uint Width;uint Height;int Stride;int Format;ptr Scan0;uint_ptr Reserved"
  3705. Global Const $taggdipcolormatrix = "float m[25]"
  3706. Global Const $taggdipencoderparam = "struct;byte GUID[16];ulong NumberOfValues;ulong Type;ptr Values;endstruct"
  3707. Global Const $taggdipencoderparams = "uint Count;" & $taggdipencoderparam
  3708. Global Const $taggdiprectf = "struct;float X;float Y;float Width;float Height;endstruct"
  3709. Global Const $taggdipstartupinput = "uint Version;ptr Callback;bool NoThread;bool NoCodecs"
  3710. Global Const $taggdipstartupoutput = "ptr HookProc;ptr UnhookProc"
  3711. Global Const $taggdipimagecodecinfo = "byte CLSID[16];byte FormatID[16];ptr CodecName;ptr DllName;ptr FormatDesc;ptr FileExt;" & "ptr MimeType;dword Flags;dword Version;dword SigCount;dword SigSize;ptr SigPattern;ptr SigMask"
  3712. Global Const $taggdippencoderparams = "uint Count;byte Params[1]"
  3713. Global Const $taghditem = "uint Mask;int XY;ptr Text;handle hBMP;int TextMax;int Fmt;lparam Param;int Image;int Order;uint Type;ptr pFilter;uint State"
  3714. Global Const $tagnmhddispinfo = $tagnmhdr & ";int Item;uint Mask;ptr Text;int TextMax;int Image;lparam lParam"
  3715. Global Const $tagnmhdfilterbtnclick = $tagnmhdr & ";int Item;" & $tagrect
  3716. Global Const $tagnmheader = $tagnmhdr & ";int Item;int Button;ptr pItem"
  3717. Global Const $taggetipaddress = "byte Field4;byte Field3;byte Field2;byte Field1"
  3718. Global Const $tagnmipaddress = $tagnmhdr & ";int Field;int Value"
  3719. Global Const $taglvfindinfo = "struct;uint Flags;ptr Text;lparam Param;" & $tagpoint & ";uint Direction;endstruct"
  3720. Global Const $taglvhittestinfo = $tagpoint & ";uint Flags;int Item;int SubItem;int iGroup"
  3721. Global Const $taglvitem = "struct;uint Mask;int Item;int SubItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;lparam Param;" & "int Indent;int GroupID;uint Columns;ptr pColumns;ptr piColFmt;int iGroup;endstruct"
  3722. Global Const $tagnmlistview = $tagnmhdr & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;" & "struct;long ActionX;long ActionY;endstruct;lparam Param"
  3723. Global Const $tagnmlvcustomdraw = "struct;" & $tagnmhdr & ";dword dwDrawStage;handle hdc;" & $tagrect & ";dword_ptr dwItemSpec;uint uItemState;lparam lItemlParam;endstruct" & ";dword clrText;dword clrTextBk;int iSubItem;dword dwItemType;dword clrFace;int iIconEffect;" & "int iIconPhase;int iPartID;int iStateID;struct;long TextLeft;long TextTop;long TextRight;long TextBottom;endstruct;uint uAlign"
  3724. Global Const $tagnmlvdispinfo = $tagnmhdr & ";" & $taglvitem
  3725. Global Const $tagnmlvfinditem = $tagnmhdr & ";int Start;" & $taglvfindinfo
  3726. Global Const $tagnmlvgetinfotip = $tagnmhdr & ";dword Flags;ptr Text;int TextMax;int Item;int SubItem;lparam lParam"
  3727. Global Const $tagnmitemactivate = $tagnmhdr & ";int Index;int SubItem;uint NewState;uint OldState;uint Changed;" & $tagpoint & ";lparam lParam;uint KeyFlags"
  3728. Global Const $tagnmlvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  3729. Global Const $tagnmlvscroll = $tagnmhdr & ";int DX;int DY"
  3730. Global Const $tagmchittestinfo = "uint Size;" & $tagpoint & ";uint Hit;" & $tagsystemtime & ";" & $tagrect & ";int iOffset;int iRow;int iCol"
  3731. Global Const $tagmcmonthrange = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxSecond;" & "word MaxMSeconds;short Span"
  3732. Global Const $tagmcrange = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxSecond;" & "word MaxMSeconds;short MinSet;short MaxSet"
  3733. Global Const $tagmcselrange = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxSecond;" & "word MaxMSeconds"
  3734. Global Const $tagnmdaystate = $tagnmhdr & ";" & $tagsystemtime & ";int DayState;ptr pDayState"
  3735. Global Const $tagnmselchange = $tagnmhdr & ";struct;word BegYear;word BegMonth;word BegDOW;word BegDay;word BegHour;word BegMinute;word BegSecond;word BegMSeconds;endstruct;" & "struct;word EndYear;word EndMonth;word EndDOW;word EndDay;word EndHour;word EndMinute;word EndSecond;word EndMSeconds;endstruct"
  3736. Global Const $tagnmobjectnotify = $tagnmhdr & ";int Item;ptr piid;ptr pObject;long Result;dword dwFlags"
  3737. Global Const $tagnmtckeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  3738. Global Const $tagtvitem = "struct;uint Mask;handle hItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;int SelectedImage;" & "int Children;lparam Param;endstruct"
  3739. Global Const $tagtvitemex = "struct;" & $tagtvitem & ";int Integral;uint uStateEx;hwnd hwnd;int iExpandedImage;int iReserved;endstruct"
  3740. Global Const $tagnmtreeview = $tagnmhdr & ";uint Action;" & "struct;uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & "ptr OldText;int OldTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam;endstruct;" & "struct;uint NewMask;handle NewhItem;uint NewState;uint NewStateMask;" & "ptr NewText;int NewTextMax;int NewImage;int NewSelectedImage;int NewChildren;lparam NewParam;endstruct;" & "struct;long PointX;long PointY;endstruct"
  3741. Global Const $tagnmtvcustomdraw = "struct;" & $tagnmhdr & ";dword DrawStage;handle HDC;" & $tagrect & ";dword_ptr ItemSpec;uint ItemState;lparam ItemParam;endstruct" & ";dword ClrText;dword ClrTextBk;int Level"
  3742. Global Const $tagnmtvdispinfo = $tagnmhdr & ";" & $tagtvitem
  3743. Global Const $tagnmtvgetinfotip = $tagnmhdr & ";ptr Text;int TextMax;handle hItem;lparam lParam"
  3744. Global Const $tagnmtvitemchange = $tagnmhdr & ";uint Changed;handle hItem;uint StateNew;uint StateOld;lparam lParam;"
  3745. Global Const $tagtvhittestinfo = $tagpoint & ";uint Flags;handle Item"
  3746. Global Const $tagnmtvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  3747. Global Const $tagnmmouse = $tagnmhdr & ";dword_ptr ItemSpec;dword_ptr ItemData;" & $tagpoint & ";lparam HitInfo"
  3748. Global Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
  3749. Global Const $tagimageinfo = "handle hBitmap;handle hMask;int Unused1;int Unused2;" & $tagrect
  3750. Global Const $tagmenuinfo = "dword Size;INT Mask;dword Style;uint YMax;handle hBack;dword ContextHelpID;ulong_ptr MenuData"
  3751. Global Const $tagmenuiteminfo = "uint Size;uint Mask;uint Type;uint State;uint ID;handle SubMenu;handle BmpChecked;handle BmpUnchecked;" & "ulong_ptr ItemData;ptr TypeData;uint CCH;handle BmpItem"
  3752. Global Const $tagrebarbandinfo = "uint cbSize;uint fMask;uint fStyle;dword clrFore;dword clrBack;ptr lpText;uint cch;" & "int iImage;hwnd hwndChild;uint cxMinChild;uint cyMinChild;uint cx;handle hbmBack;uint wID;uint cyChild;uint cyMaxChild;" & "uint cyIntegral;uint cxIdeal;lparam lParam;uint cxHeader" & ((@OSVersion = "WIN_XP") ? "" : ";" & $tagrect & ";uint uChevronState")
  3753. Global Const $tagnmrebarautobreak = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;uint uMsg;uint fStyleCurrent;bool fAutoBreak"
  3754. Global Const $tagnmrbautosize = $tagnmhdr & ";bool fChanged;" & "struct;long TargetLeft;long TargetTop;long TargetRight;long TargetBottom;endstruct;" & "struct;long ActualLeft;long ActualTop;long ActualRight;long ActualBottom;endstruct"
  3755. Global Const $tagnmrebar = $tagnmhdr & ";dword dwMask;uint uBand;uint fStyle;uint wID;lparam lParam"
  3756. Global Const $tagnmrebarchevron = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;" & $tagrect & ";lparam lParamNM"
  3757. Global Const $tagnmrebarchildsize = $tagnmhdr & ";uint uBand;uint wID;" & "struct;long CLeft;long CTop;long CRight;long CBottom;endstruct;" & "struct;long BLeft;long BTop;long BRight;long BBottom;endstruct"
  3758. Global Const $tagcolorscheme = "dword Size;dword BtnHighlight;dword BtnShadow"
  3759. Global Const $tagnmtoolbar = $tagnmhdr & ";int iItem;" & "struct;int iBitmap;int idCommand;byte fsState;byte fsStyle;dword_ptr dwData;int_ptr iString;endstruct" & ";int cchText;ptr pszText;" & $tagrect
  3760. Global Const $tagnmtbhotitem = $tagnmhdr & ";int idOld;int idNew;dword dwFlags"
  3761. Global Const $tagtbbutton = "int Bitmap;int Command;byte State;byte Style;dword_ptr Param;int_ptr String"
  3762. Global Const $tagtbbuttoninfo = "uint Size;dword Mask;int Command;int Image;byte State;byte Style;word CX;dword_ptr Param;ptr Text;int TextMax"
  3763. Global Const $tagnetresource = "dword Scope;dword Type;dword DisplayType;dword Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider"
  3764. Global Const $tagoverlapped = "ulong_ptr Internal;ulong_ptr InternalHigh;struct;dword Offset;dword OffsetHigh;endstruct;handle hEvent"
  3765. Global Const $tagopenfilename = "dword StructSize;hwnd hwndOwner;handle hInstance;ptr lpstrFilter;ptr lpstrCustomFilter;" & "dword nMaxCustFilter;dword nFilterIndex;ptr lpstrFile;dword nMaxFile;ptr lpstrFileTitle;dword nMaxFileTitle;" & "ptr lpstrInitialDir;ptr lpstrTitle;dword Flags;word nFileOffset;word nFileExtension;ptr lpstrDefExt;lparam lCustData;" & "ptr lpfnHook;ptr lpTemplateName;ptr pvReserved;dword dwReserved;dword FlagsEx"
  3766. Global Const $tagbitmapinfoheader = "struct;dword biSize;long biWidth;long biHeight;word biPlanes;word biBitCount;" & "dword biCompression;dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImportant;endstruct"
  3767. Global Const $tagbitmapinfo = $tagbitmapinfoheader & ";dword biRGBQuad[1]"
  3768. Global Const $tagblendfunction = "byte Op;byte Flags;byte Alpha;byte Format"
  3769. Global Const $tagguid = "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct"
  3770. Global Const $tagwindowplacement = "uint length;uint flags;uint showCmd;long ptMinPosition[2];long ptMaxPosition[2];long rcNormalPosition[4]"
  3771. Global Const $tagwindowpos = "hwnd hWnd;hwnd InsertAfter;int X;int Y;int CX;int CY;uint Flags"
  3772. Global Const $tagscrollinfo = "uint cbSize;uint fMask;int nMin;int nMax;uint nPage;int nPos;int nTrackPos"
  3773. Global Const $tagscrollbarinfo = "dword cbSize;" & $tagrect & ";int dxyLineButton;int xyThumbTop;" & "int xyThumbBottom;int reserved;dword rgstate[6]"
  3774. Global Const $taglogfont = "struct;long Height;long Width;long Escapement;long Orientation;long Weight;byte Italic;byte Underline;" & "byte Strikeout;byte CharSet;byte OutPrecision;byte ClipPrecision;byte Quality;byte PitchAndFamily;wchar FaceName[32];endstruct"
  3775. Global Const $tagkbdllhookstruct = "dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo"
  3776. Global Const $tagprocess_information = "handle hProcess;handle hThread;dword ProcessID;dword ThreadID"
  3777. Global Const $tagstartupinfo = "dword Size;ptr Reserved1;ptr Desktop;ptr Title;dword X;dword Y;dword XSize;dword YSize;dword XCountChars;" & "dword YCountChars;dword FillAttribute;dword Flags;word ShowWindow;word Reserved2;ptr Reserved3;handle StdInput;" & "handle StdOutput;handle StdError"
  3778. Global Const $tagsecurity_attributes = "dword Length;ptr Descriptor;bool InheritHandle"
  3779. Global Const $tagwin32_find_data = "dword dwFileAttributes;dword ftCreationTime[2];dword ftLastAccessTime[2];dword ftLastWriteTime[2];dword nFileSizeHigh;dword nFileSizeLow;dword dwReserved0;dword dwReserved1;wchar cFileName[260];wchar cAlternateFileName[14]"
  3780. Global Const $tagtextmetric = "long tmHeight;long tmAscent;long tmDescent;long tmInternalLeading;long tmExternalLeading;" & "long tmAveCharWidth;long tmMaxCharWidth;long tmWeight;long tmOverhang;long tmDigitizedAspectX;long tmDigitizedAspectY;" & "wchar tmFirstChar;wchar tmLastChar;wchar tmDefaultChar;wchar tmBreakChar;byte tmItalic;byte tmUnderlined;byte tmStruckOut;" & "byte tmPitchAndFamily;byte tmCharSet"
  3781. Global Const $process_terminate = 1
  3782. Global Const $process_create_thread = 2
  3783. Global Const $process_set_sessionid = 4
  3784. Global Const $process_vm_operation = 8
  3785. Global Const $process_vm_read = 16
  3786. Global Const $process_vm_write = 32
  3787. Global Const $process_dup_handle = 64
  3788. Global Const $process_create_process = 128
  3789. Global Const $process_set_quota = 256
  3790. Global Const $process_set_information = 512
  3791. Global Const $process_query_information = 1024
  3792. Global Const $process_query_limited_information = 4096
  3793. Global Const $process_suspend_resume = 2048
  3794. Global Const $process_all_access = 2035711
  3795. Global Const $se_assignprimarytoken_name = "SeAssignPrimaryTokenPrivilege"
  3796. Global Const $se_audit_name = "SeAuditPrivilege"
  3797. Global Const $se_backup_name = "SeBackupPrivilege"
  3798. Global Const $se_change_notify_name = "SeChangeNotifyPrivilege"
  3799. Global Const $se_create_global_name = "SeCreateGlobalPrivilege"
  3800. Global Const $se_create_pagefile_name = "SeCreatePagefilePrivilege"
  3801. Global Const $se_create_permanent_name = "SeCreatePermanentPrivilege"
  3802. Global Const $se_create_symbolic_link_name = "SeCreateSymbolicLinkPrivilege"
  3803. Global Const $se_create_token_name = "SeCreateTokenPrivilege"
  3804. Global Const $se_debug_name = "SeDebugPrivilege"
  3805. Global Const $se_enable_delegation_name = "SeEnableDelegationPrivilege"
  3806. Global Const $se_impersonate_name = "SeImpersonatePrivilege"
  3807. Global Const $se_inc_base_priority_name = "SeIncreaseBasePriorityPrivilege"
  3808. Global Const $se_inc_working_set_name = "SeIncreaseWorkingSetPrivilege"
  3809. Global Const $se_increase_quota_name = "SeIncreaseQuotaPrivilege"
  3810. Global Const $se_load_driver_name = "SeLoadDriverPrivilege"
  3811. Global Const $se_lock_memory_name = "SeLockMemoryPrivilege"
  3812. Global Const $se_machine_account_name = "SeMachineAccountPrivilege"
  3813. Global Const $se_manage_volume_name = "SeManageVolumePrivilege"
  3814. Global Const $se_prof_single_process_name = "SeProfileSingleProcessPrivilege"
  3815. Global Const $se_relabel_name = "SeRelabelPrivilege"
  3816. Global Const $se_remote_shutdown_name = "SeRemoteShutdownPrivilege"
  3817. Global Const $se_restore_name = "SeRestorePrivilege"
  3818. Global Const $se_security_name = "SeSecurityPrivilege"
  3819. Global Const $se_shutdown_name = "SeShutdownPrivilege"
  3820. Global Const $se_sync_agent_name = "SeSyncAgentPrivilege"
  3821. Global Const $se_system_environment_name = "SeSystemEnvironmentPrivilege"
  3822. Global Const $se_system_profile_name = "SeSystemProfilePrivilege"
  3823. Global Const $se_systemtime_name = "SeSystemtimePrivilege"
  3824. Global Const $se_take_ownership_name = "SeTakeOwnershipPrivilege"
  3825. Global Const $se_tcb_name = "SeTcbPrivilege"
  3826. Global Const $se_time_zone_name = "SeTimeZonePrivilege"
  3827. Global Const $se_trusted_credman_access_name = "SeTrustedCredManAccessPrivilege"
  3828. Global Const $se_unsolicited_input_name = "SeUnsolicitedInputPrivilege"
  3829. Global Const $se_undock_name = "SeUndockPrivilege"
  3830. Global Const $se_privilege_enabled_by_default = 1
  3831. Global Const $se_privilege_enabled = 2
  3832. Global Const $se_privilege_removed = 4
  3833. Global Const $se_privilege_used_for_access = -2147483648
  3834. Global Const $se_group_mandatory = 1
  3835. Global Const $se_group_enabled_by_default = 2
  3836. Global Const $se_group_enabled = 4
  3837. Global Const $se_group_owner = 8
  3838. Global Const $se_group_use_for_deny_only = 16
  3839. Global Const $se_group_integrity = 32
  3840. Global Const $se_group_integrity_enabled = 64
  3841. Global Const $se_group_resource = 536870912
  3842. Global Const $se_group_logon_id = -1073741824
  3843. Global Enum $tokenprimary = 1, $tokenimpersonation
  3844. Global Enum $securityanonymous = 0, $securityidentification, $securityimpersonation, $securitydelegation
  3845. Global Enum $tokenuser = 1, $tokengroups, $tokenprivileges, $tokenowner, $tokenprimarygroup, $tokendefaultdacl, $tokensource, $tokentype, $tokenimpersonationlevel, $tokenstatistics, $tokenrestrictedsids, $tokensessionid, $tokengroupsandprivileges, $tokensessionreference, $tokensandboxinert, $tokenauditpolicy, $tokenorigin, $tokenelevationtype, $tokenlinkedtoken, $tokenelevation, $tokenhasrestrictions, $tokenaccessinformation, $tokenvirtualizationallowed, $tokenvirtualizationenabled, $tokenintegritylevel, $tokenuiaccess, $tokenmandatorypolicy, $tokenlogonsid
  3846. Global Const $token_assign_primary = 1
  3847. Global Const $token_duplicate = 2
  3848. Global Const $token_impersonate = 4
  3849. Global Const $token_query = 8
  3850. Global Const $token_query_source = 16
  3851. Global Const $token_adjust_privileges = 32
  3852. Global Const $token_adjust_groups = 64
  3853. Global Const $token_adjust_default = 128
  3854. Global Const $token_adjust_sessionid = 256
  3855. Global Const $token_all_access = 983551
  3856. Global Const $token_read = 131080
  3857. Global Const $token_write = 131296
  3858. Global Const $token_execute = 131072
  3859. Global Const $token_has_traverse_privilege = 1
  3860. Global Const $token_has_backup_privilege = 2
  3861. Global Const $token_has_restore_privilege = 4
  3862. Global Const $token_has_admin_group = 8
  3863. Global Const $token_is_restricted = 16
  3864. Global Const $token_session_not_referenced = 32
  3865. Global Const $token_sandbox_inert = 64
  3866. Global Const $token_has_impersonate_privilege = 128
  3867. Global Const $rights_delete = 65536
  3868. Global Const $read_control = 131072
  3869. Global Const $write_dac = 262144
  3870. Global Const $write_owner = 524288
  3871. Global Const $synchronize = 1048576
  3872. Global Const $access_system_security = 16777216
  3873. Global Const $standard_rights_required = 983040
  3874. Global Const $standard_rights_read = $read_control
  3875. Global Const $standard_rights_write = $read_control
  3876. Global Const $standard_rights_execute = $read_control
  3877. Global Const $standard_rights_all = 2031616
  3878. Global Const $specific_rights_all = 65535
  3879. Global Enum $not_used_access = 0, $grant_access, $set_access, $deny_access, $revoke_access, $set_audit_success, $set_audit_failure
  3880. Global Enum $trustee_is_unknown = 0, $trustee_is_user, $trustee_is_group, $trustee_is_domain, $trustee_is_alias, $trustee_is_well_known_group, $trustee_is_deleted, $trustee_is_invalid, $trustee_is_computer
  3881. Global Const $logon_with_profile = 1
  3882. Global Const $logon_netcredentials_only = 2
  3883. Global Enum $sidtypeuser = 1, $sidtypegroup, $sidtypedomain, $sidtypealias, $sidtypewellknowngroup, $sidtypedeletedaccount, $sidtypeinvalid, $sidtypeunknown, $sidtypecomputer, $sidtypelabel
  3884. Global Const $sid_administrators = "S-1-5-32-544"
  3885. Global Const $sid_users = "S-1-5-32-545"
  3886. Global Const $sid_guests = "S-1-5-32-546"
  3887. Global Const $sid_account_operators = "S-1-5-32-548"
  3888. Global Const $sid_server_operators = "S-1-5-32-549"
  3889. Global Const $sid_print_operators = "S-1-5-32-550"
  3890. Global Const $sid_backup_operators = "S-1-5-32-551"
  3891. Global Const $sid_replicator = "S-1-5-32-552"
  3892. Global Const $sid_owner = "S-1-3-0"
  3893. Global Const $sid_everyone = "S-1-1-0"
  3894. Global Const $sid_network = "S-1-5-2"
  3895. Global Const $sid_interactive = "S-1-5-4"
  3896. Global Const $sid_system = "S-1-5-18"
  3897. Global Const $sid_authenticated_users = "S-1-5-11"
  3898. Global Const $sid_schannel_authentication = "S-1-5-64-14"
  3899. Global Const $sid_digest_authentication = "S-1-5-64-21"
  3900. Global Const $sid_nt_service = "S-1-5-80"
  3901. Global Const $sid_untrusted_mandatory_level = "S-1-16-0"
  3902. Global Const $sid_low_mandatory_level = "S-1-16-4096"
  3903. Global Const $sid_medium_mandatory_level = "S-1-16-8192"
  3904. Global Const $sid_medium_plus_mandatory_level = "S-1-16-8448"
  3905. Global Const $sid_high_mandatory_level = "S-1-16-12288"
  3906. Global Const $sid_system_mandatory_level = "S-1-16-16384"
  3907. Global Const $sid_protected_process_mandatory_level = "S-1-16-20480"
  3908. Global Const $sid_secure_process_mandatory_level = "S-1-16-28672"
  3909. Global Const $sid_all_services = "S-1-5-80-0"
  3910.  
  3911. Func _winapi_getlasterror(Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
  3912. Local $aresult = DllCall("kernel32.dll", "dword", "GetLastError")
  3913. Return SetError($_icurrenterror, $_icurrentextended, $aresult[0])
  3914. EndFunc
  3915.  
  3916. Func _winapi_setlasterror($ierrorcode, Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
  3917. DllCall("kernel32.dll", "none", "SetLastError", "dword", $ierrorcode)
  3918. Return SetError($_icurrenterror, $_icurrentextended, NULL )
  3919. EndFunc
  3920.  
  3921. Func __comerrorformating($ocomerror, $sprefix = @TAB)
  3922. Local Const $str_striptrailing = 2
  3923. Local $serror = "COM Error encountered in " & @ScriptName & " (" & $ocomerror.scriptline & ") :" & @CRLF & $sprefix & "Number " & @TAB & "= 0x" & Hex($ocomerror.number, 8) & " (" & $ocomerror.number & ")" & @CRLF & $sprefix & "WinDescription" & @TAB & "= " & StringStripWS($ocomerror.windescription, $str_striptrailing) & @CRLF & $sprefix & "Description " & @TAB & "= " & StringStripWS($ocomerror.description, $str_striptrailing) & @CRLF & $sprefix & "Source " & @TAB & "= " & $ocomerror.source & @CRLF & $sprefix & "HelpFile " & @TAB & "= " & $ocomerror.helpfile & @CRLF & $sprefix & "HelpContext " & @TAB & "= " & $ocomerror.helpcontext & @CRLF & $sprefix & "LastDllError " & @TAB & "= " & $ocomerror.lastdllerror & @CRLF & $sprefix & "Retcode " & @TAB & "= 0x" & Hex($ocomerror.retcode)
  3924. Return $serror
  3925. EndFunc
  3926.  
  3927. Func _security__adjusttokenprivileges($htoken, $bdisableall, $tnewstate, $ibufferlen, $tprevstate = 0, $prequired = 0)
  3928. Local $acall = DllCall("advapi32.dll", "bool", "AdjustTokenPrivileges", "handle", $htoken, "bool", $bdisableall, "struct*", $tnewstate, "dword", $ibufferlen, "struct*", $tprevstate, "struct*", $prequired)
  3929. If @error Then Return SetError(@error, @extended, False)
  3930. Return NOT ($acall[0] = 0)
  3931. EndFunc
  3932.  
  3933. Func _security__createprocesswithtoken($htoken, $ilogonflags, $scommandline, $icreationflags, $scurdir, $tstartupinfo, $tprocess_information)
  3934. Local $acall = DllCall("advapi32.dll", "bool", "CreateProcessWithTokenW", "handle", $htoken, "dword", $ilogonflags, "ptr", 0, "wstr", $scommandline, "dword", $icreationflags, "struct*", 0, "wstr", $scurdir, "struct*", $tstartupinfo, "struct*", $tprocess_information)
  3935. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
  3936. Return True
  3937. EndFunc
  3938.  
  3939. Func _security__duplicatetokenex($hexistingtoken, $idesiredaccess, $iimpersonationlevel, $itokentype)
  3940. Local $acall = DllCall("advapi32.dll", "bool", "DuplicateTokenEx", "handle", $hexistingtoken, "dword", $idesiredaccess, "struct*", 0, "int", $iimpersonationlevel, "int", $itokentype, "handle*", 0)
  3941. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  3942. Return $acall[6]
  3943. EndFunc
  3944.  
  3945. Func _security__getaccountsid($saccount, $ssystem = "")
  3946. Local $aacct = _security__lookupaccountname($saccount, $ssystem)
  3947. If @error Then Return SetError(@error, @extended, 0)
  3948. If IsArray($aacct) Then Return _security__stringsidtosid($aacct[0])
  3949. Return ""
  3950. EndFunc
  3951.  
  3952. Func _security__getlengthsid($psid)
  3953. If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
  3954. Local $acall = DllCall("advapi32.dll", "dword", "GetLengthSid", "struct*", $psid)
  3955. If @error Then Return SetError(@error, @extended, 0)
  3956. Return $acall[0]
  3957. EndFunc
  3958.  
  3959. Func _security__gettokeninformation($htoken, $iclass)
  3960. Local $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", 0, "dword", 0, "dword*", 0)
  3961. If @error OR NOT $acall[5] Then Return SetError(@error + 10, @extended, 0)
  3962. Local $ilen = $acall[5]
  3963. Local $tbuffer = DllStructCreate("byte[" & $ilen & "]")
  3964. $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", $tbuffer, "dword", DllStructGetSize($tbuffer), "dword*", 0)
  3965. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  3966. Return $tbuffer
  3967. EndFunc
  3968.  
  3969. Func _security__impersonateself($ilevel = $securityimpersonation)
  3970. Local $acall = DllCall("advapi32.dll", "bool", "ImpersonateSelf", "int", $ilevel)
  3971. If @error Then Return SetError(@error, @extended, False)
  3972. Return NOT ($acall[0] = 0)
  3973. EndFunc
  3974.  
  3975. Func _security__isvalidsid($psid)
  3976. Local $acall = DllCall("advapi32.dll", "bool", "IsValidSid", "struct*", $psid)
  3977. If @error Then Return SetError(@error, @extended, False)
  3978. Return NOT ($acall[0] = 0)
  3979. EndFunc
  3980.  
  3981. Func _security__lookupaccountname($saccount, $ssystem = "")
  3982. Local $tdata = DllStructCreate("byte SID[256]")
  3983. Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountNameW", "wstr", $ssystem, "wstr", $saccount, "struct*", $tdata, "dword*", DllStructGetSize($tdata), "wstr", "", "dword*", DllStructGetSize($tdata), "int*", 0)
  3984. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  3985. Local $aacct[3]
  3986. $aacct[0] = _security__sidtostringsid(DllStructGetPtr($tdata, "SID"))
  3987. $aacct[1] = $acall[5]
  3988. $aacct[2] = $acall[7]
  3989. Return $aacct
  3990. EndFunc
  3991.  
  3992. Func _security__lookupaccountsid($vsid, $ssystem = "")
  3993. Local $psid, $aacct[3]
  3994. If IsString($vsid) Then
  3995. $psid = _security__stringsidtosid($vsid)
  3996. Else
  3997. $psid = $vsid
  3998. EndIf
  3999. If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
  4000. Local $stypesystem = "ptr"
  4001. If $ssystem Then $stypesystem = "wstr"
  4002. Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountSidW", $stypesystem, $ssystem, "struct*", $psid, "wstr", "", "dword*", 65536, "wstr", "", "dword*", 65536, "int*", 0)
  4003. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  4004. Local $aacct[3]
  4005. $aacct[0] = $acall[3]
  4006. $aacct[1] = $acall[5]
  4007. $aacct[2] = $acall[7]
  4008. Return $aacct
  4009. EndFunc
  4010.  
  4011. Func _security__lookupprivilegevalue($ssystem, $sname)
  4012. Local $acall = DllCall("advapi32.dll", "bool", "LookupPrivilegeValueW", "wstr", $ssystem, "wstr", $sname, "int64*", 0)
  4013. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  4014. Return $acall[3]
  4015. EndFunc
  4016.  
  4017. Func _security__openprocesstoken($hprocess, $iaccess)
  4018. Local $acall = DllCall("advapi32.dll", "bool", "OpenProcessToken", "handle", $hprocess, "dword", $iaccess, "handle*", 0)
  4019. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  4020. Return $acall[3]
  4021. EndFunc
  4022.  
  4023. Func _security__openthreadtoken($iaccess, $hthread = 0, $bopenasself = False)
  4024. If $hthread = 0 Then
  4025. Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  4026. If @error Then Return SetError(@error + 10, @extended, 0)
  4027. $hthread = $aresult[0]
  4028. EndIf
  4029. Local $acall = DllCall("advapi32.dll", "bool", "OpenThreadToken", "handle", $hthread, "dword", $iaccess, "bool", $bopenasself, "handle*", 0)
  4030. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  4031. Return $acall[4]
  4032. EndFunc
  4033.  
  4034. Func _security__openthreadtokenex($iaccess, $hthread = 0, $bopenasself = False)
  4035. Local $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
  4036. If $htoken = 0 Then
  4037. Local Const $error_no_token = 1008
  4038. If _winapi_getlasterror() <> $error_no_token Then Return SetError(20, _winapi_getlasterror(), 0)
  4039. If NOT _security__impersonateself() Then Return SetError(@error + 10, _winapi_getlasterror(), 0)
  4040. $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
  4041. If $htoken = 0 Then Return SetError(@error, _winapi_getlasterror(), 0)
  4042. EndIf
  4043. Return $htoken
  4044. EndFunc
  4045.  
  4046. Func _security__setprivilege($htoken, $sprivilege, $benable)
  4047. Local $iluid = _security__lookupprivilegevalue("", $sprivilege)
  4048. If $iluid = 0 Then Return SetError(@error + 10, @extended, False)
  4049. Local Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
  4050. Local $tcurrstate = DllStructCreate($tagtoken_privileges)
  4051. Local $icurrstate = DllStructGetSize($tcurrstate)
  4052. Local $tprevstate = DllStructCreate($tagtoken_privileges)
  4053. Local $iprevstate = DllStructGetSize($tprevstate)
  4054. Local $trequired = DllStructCreate("int Data")
  4055. DllStructSetData($tcurrstate, "Count", 1)
  4056. DllStructSetData($tcurrstate, "LUID", $iluid)
  4057. If NOT _security__adjusttokenprivileges($htoken, False, $tcurrstate, $icurrstate, $tprevstate, $trequired) Then Return SetError(2, @error, False)
  4058. DllStructSetData($tprevstate, "Count", 1)
  4059. DllStructSetData($tprevstate, "LUID", $iluid)
  4060. Local $iattributes = DllStructGetData($tprevstate, "Attributes")
  4061. If $benable Then
  4062. $iattributes = BitOR($iattributes, $se_privilege_enabled)
  4063. Else
  4064. $iattributes = BitAND($iattributes, BitNOT($se_privilege_enabled))
  4065. EndIf
  4066. DllStructSetData($tprevstate, "Attributes", $iattributes)
  4067. If NOT _security__adjusttokenprivileges($htoken, False, $tprevstate, $iprevstate, $tcurrstate, $trequired) Then Return SetError(3, @error, False)
  4068. Return True
  4069. EndFunc
  4070.  
  4071. Func _security__settokeninformation($htoken, $itokeninformation, $vtokeninformation, $itokeninformationlength)
  4072. Local $acall = DllCall("advapi32.dll", "bool", "SetTokenInformation", "handle", $htoken, "int", $itokeninformation, "struct*", $vtokeninformation, "dword", $itokeninformationlength)
  4073. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
  4074. Return True
  4075. EndFunc
  4076.  
  4077. Func _security__sidtostringsid($psid)
  4078. If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, 0, "")
  4079. Local $acall = DllCall("advapi32.dll", "bool", "ConvertSidToStringSidW", "struct*", $psid, "ptr*", 0)
  4080. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, "")
  4081. Local $pstringsid = $acall[2]
  4082. Local $alen = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $pstringsid)
  4083. Local $ssid = DllStructGetData(DllStructCreate("wchar Text[" & $alen[0] + 1 & "]", $pstringsid), "Text")
  4084. DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pstringsid)
  4085. Return $ssid
  4086. EndFunc
  4087.  
  4088. Func _security__sidtypestr($itype)
  4089. Switch $itype
  4090. Case $sidtypeuser
  4091. Return "User"
  4092. Case $sidtypegroup
  4093. Return "Group"
  4094. Case $sidtypedomain
  4095. Return "Domain"
  4096. Case $sidtypealias
  4097. Return "Alias"
  4098. Case $sidtypewellknowngroup
  4099. Return "Well Known Group"
  4100. Case $sidtypedeletedaccount
  4101. Return "Deleted Account"
  4102. Case $sidtypeinvalid
  4103. Return "Invalid"
  4104. Case $sidtypeunknown
  4105. Return "Unknown Type"
  4106. Case $sidtypecomputer
  4107. Return "Computer"
  4108. Case $sidtypelabel
  4109. Return "A mandatory integrity label SID"
  4110. Case Else
  4111. Return "Unknown SID Type"
  4112. EndSwitch
  4113. EndFunc
  4114.  
  4115. Func _security__stringsidtosid($ssid)
  4116. Local $acall = DllCall("advapi32.dll", "bool", "ConvertStringSidToSidW", "wstr", $ssid, "ptr*", 0)
  4117. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  4118. Local $psid = $acall[2]
  4119. Local $tbuffer = DllStructCreate("byte Data[" & _security__getlengthsid($psid) & "]", $psid)
  4120. Local $tsid = DllStructCreate("byte Data[" & DllStructGetSize($tbuffer) & "]")
  4121. DllStructSetData($tsid, "Data", DllStructGetData($tbuffer, "Data"))
  4122. DllCall("kernel32.dll", "handle", "LocalFree", "handle", $psid)
  4123. Return $tsid
  4124. EndFunc
  4125.  
  4126. Global Const $tagmemmap = "handle hProc;ulong_ptr Size;ptr Mem"
  4127.  
  4128. Func _memfree(ByRef $tmemmap)
  4129. Local $pmemory = DllStructGetData($tmemmap, "Mem")
  4130. Local $hprocess = DllStructGetData($tmemmap, "hProc")
  4131. Local $bresult = _memvirtualfreeex($hprocess, $pmemory, 0, $mem_release)
  4132. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hprocess)
  4133. If @error Then Return SetError(@error, @extended, False)
  4134. Return $bresult
  4135. EndFunc
  4136.  
  4137. Func _memglobalalloc($ibytes, $iflags = 0)
  4138. Local $aresult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $iflags, "ulong_ptr", $ibytes)
  4139. If @error Then Return SetError(@error, @extended, 0)
  4140. Return $aresult[0]
  4141. EndFunc
  4142.  
  4143. Func _memglobalfree($hmem)
  4144. Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hmem)
  4145. If @error Then Return SetError(@error, @extended, False)
  4146. Return $aresult[0]
  4147. EndFunc
  4148.  
  4149. Func _memgloballock($hmem)
  4150. Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hmem)
  4151. If @error Then Return SetError(@error, @extended, 0)
  4152. Return $aresult[0]
  4153. EndFunc
  4154.  
  4155. Func _memglobalsize($hmem)
  4156. Local $aresult = DllCall("kernel32.dll", "ulong_ptr", "GlobalSize", "handle", $hmem)
  4157. If @error Then Return SetError(@error, @extended, 0)
  4158. Return $aresult[0]
  4159. EndFunc
  4160.  
  4161. Func _memglobalunlock($hmem)
  4162. Local $aresult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hmem)
  4163. If @error Then Return SetError(@error, @extended, 0)
  4164. Return $aresult[0]
  4165. EndFunc
  4166.  
  4167. Func _meminit($hwnd, $isize, ByRef $tmemmap)
  4168. Local $aresult = DllCall("User32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
  4169. If @error Then Return SetError(@error, @extended, 0)
  4170. Local $iprocessid = $aresult[2]
  4171. If $iprocessid = 0 Then Return SetError(1, 0, 0)
  4172. Local $iaccess = BitOR($process_vm_operation, $process_vm_read, $process_vm_write)
  4173. Local $hprocess = __mem_openprocess($iaccess, False, $iprocessid, True)
  4174. Local $ialloc = BitOR($mem_reserve, $mem_commit)
  4175. Local $pmemory = _memvirtualallocex($hprocess, 0, $isize, $ialloc, $page_readwrite)
  4176. If $pmemory = 0 Then Return SetError(2, 0, 0)
  4177. $tmemmap = DllStructCreate($tagmemmap)
  4178. DllStructSetData($tmemmap, "hProc", $hprocess)
  4179. DllStructSetData($tmemmap, "Size", $isize)
  4180. DllStructSetData($tmemmap, "Mem", $pmemory)
  4181. Return $pmemory
  4182. EndFunc
  4183.  
  4184. Func _memmovememory($psource, $pdest, $ilength)
  4185. DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pdest, "struct*", $psource, "ulong_ptr", $ilength)
  4186. If @error Then Return SetError(@error, @extended)
  4187. EndFunc
  4188.  
  4189. Func _memread(ByRef $tmemmap, $psrce, $pdest, $isize)
  4190. Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $psrce, "struct*", $pdest, "ulong_ptr", $isize, "ulong_ptr*", 0)
  4191. If @error Then Return SetError(@error, @extended, False)
  4192. Return $aresult[0]
  4193. EndFunc
  4194.  
  4195. Func _memwrite(ByRef $tmemmap, $psrce, $pdest = 0, $isize = 0, $ssrce = "struct*")
  4196. If $pdest = 0 Then $pdest = DllStructGetData($tmemmap, "Mem")
  4197. If $isize = 0 Then $isize = DllStructGetData($tmemmap, "Size")
  4198. Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $pdest, $ssrce, $psrce, "ulong_ptr", $isize, "ulong_ptr*", 0)
  4199. If @error Then Return SetError(@error, @extended, False)
  4200. Return $aresult[0]
  4201. EndFunc
  4202.  
  4203. Func _memvirtualalloc($paddress, $isize, $iallocation, $iprotect)
  4204. Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
  4205. If @error Then Return SetError(@error, @extended, 0)
  4206. Return $aresult[0]
  4207. EndFunc
  4208.  
  4209. Func _memvirtualallocex($hprocess, $paddress, $isize, $iallocation, $iprotect)
  4210. Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
  4211. If @error Then Return SetError(@error, @extended, 0)
  4212. Return $aresult[0]
  4213. EndFunc
  4214.  
  4215. Func _memvirtualfree($paddress, $isize, $ifreetype)
  4216. Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFree", "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
  4217. If @error Then Return SetError(@error, @extended, False)
  4218. Return $aresult[0]
  4219. EndFunc
  4220.  
  4221. Func _memvirtualfreeex($hprocess, $paddress, $isize, $ifreetype)
  4222. Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
  4223. If @error Then Return SetError(@error, @extended, False)
  4224. Return $aresult[0]
  4225. EndFunc
  4226.  
  4227. Func __mem_openprocess($iaccess, $finherit, $iprocessid, $fdebugpriv = False)
  4228. Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
  4229. If @error Then Return SetError(@error, @extended, 0)
  4230. If $aresult[0] Then Return $aresult[0]
  4231. If NOT $fdebugpriv Then Return 0
  4232. Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  4233. If @error Then Return SetError(@error, @extended, 0)
  4234. _security__setprivilege($htoken, "SeDebugPrivilege", True)
  4235. Local $ierror = @error
  4236. Local $ilasterror = @extended
  4237. Local $iret = 0
  4238. If NOT @error Then
  4239. $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
  4240. $ierror = @error
  4241. $ilasterror = @extended
  4242. If $aresult[0] Then $iret = $aresult[0]
  4243. _security__setprivilege($htoken, "SeDebugPrivilege", False)
  4244. If @error Then
  4245. $ierror = @error
  4246. $ilasterror = @extended
  4247. EndIf
  4248. EndIf
  4249. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $htoken)
  4250. Return SetError($ierror, $ilasterror, $iret)
  4251. EndFunc
  4252.  
  4253. Func _sendmessage($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  4254. Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageW", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  4255. If @error Then Return SetError(@error, @extended, "")
  4256. If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  4257. Return $aresult
  4258. EndFunc
  4259.  
  4260. Func _sendmessagea($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  4261. Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageA", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  4262. If @error Then Return SetError(@error, @extended, "")
  4263. If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  4264. Return $aresult
  4265. EndFunc
  4266.  
  4267. Global Const $sbars_sizegrip = 256
  4268. Global Const $sbt_tooltips = 2048
  4269. Global Const $sbars_tooltips = 2048
  4270. Global Const $sbt_sunken = 0
  4271. Global Const $sbt_noborders = 256
  4272. Global Const $sbt_popout = 512
  4273. Global Const $sbt_rtlreading = 1024
  4274. Global Const $sbt_notabparsing = 2048
  4275. Global Const $sbt_ownerdraw = 4096
  4276. Global Const $__statusbarconstant_wm_user = 1024
  4277. Global Const $sb_getborders = ($__statusbarconstant_wm_user + 7)
  4278. Global Const $sb_geticon = ($__statusbarconstant_wm_user + 20)
  4279. Global Const $sb_getparts = ($__statusbarconstant_wm_user + 6)
  4280. Global Const $sb_getrect = ($__statusbarconstant_wm_user + 10)
  4281. Global Const $sb_gettexta = ($__statusbarconstant_wm_user + 2)
  4282. Global Const $sb_gettextw = ($__statusbarconstant_wm_user + 13)
  4283. Global Const $sb_gettext = $sb_gettexta
  4284. Global Const $sb_gettextlengtha = ($__statusbarconstant_wm_user + 3)
  4285. Global Const $sb_gettextlengthw = ($__statusbarconstant_wm_user + 12)
  4286. Global Const $sb_gettextlength = $sb_gettextlengtha
  4287. Global Const $sb_gettiptexta = ($__statusbarconstant_wm_user + 18)
  4288. Global Const $sb_gettiptextw = ($__statusbarconstant_wm_user + 19)
  4289. Global Const $sb_getunicodeformat = 8192 + 6
  4290. Global Const $sb_issimple = ($__statusbarconstant_wm_user + 14)
  4291. Global Const $sb_setbkcolor = 8192 + 1
  4292. Global Const $sb_seticon = ($__statusbarconstant_wm_user + 15)
  4293. Global Const $sb_setminheight = ($__statusbarconstant_wm_user + 8)
  4294. Global Const $sb_setparts = ($__statusbarconstant_wm_user + 4)
  4295. Global Const $sb_settexta = ($__statusbarconstant_wm_user + 1)
  4296. Global Const $sb_settextw = ($__statusbarconstant_wm_user + 11)
  4297. Global Const $sb_settext = $sb_settexta
  4298. Global Const $sb_settiptexta = ($__statusbarconstant_wm_user + 16)
  4299. Global Const $sb_settiptextw = ($__statusbarconstant_wm_user + 17)
  4300. Global Const $sb_setunicodeformat = 8192 + 5
  4301. Global Const $sb_simple = ($__statusbarconstant_wm_user + 9)
  4302. Global Const $sb_simpleid = 255
  4303. Global Const $sbn_first = -880
  4304. Global Const $sbn_simplemodechange = $sbn_first + 0
  4305. Global Const $fc_nooverwrite = 0
  4306. Global Const $fc_overwrite = 1
  4307. Global Const $fc_createpath = 8
  4308. Global Const $ft_modified = 0
  4309. Global Const $ft_created = 1
  4310. Global Const $ft_accessed = 2
  4311. Global Const $ft_array = 0
  4312. Global Const $ft_string = 1
  4313. Global Const $fsf_createbutton = 1
  4314. Global Const $fsf_newdialog = 2
  4315. Global Const $fsf_editcontrol = 4
  4316. Global Const $ft_nonrecursive = 0
  4317. Global Const $ft_recursive = 1
  4318. Global Const $fo_read = 0
  4319. Global Const $fo_append = 1
  4320. Global Const $fo_overwrite = 2
  4321. Global Const $fo_createpath = 8
  4322. Global Const $fo_binary = 16
  4323. Global Const $fo_unicode = 32
  4324. Global Const $fo_utf16_le = 32
  4325. Global Const $fo_utf16_be = 64
  4326. Global Const $fo_utf8 = 128
  4327. Global Const $fo_utf8_nobom = 256
  4328. Global Const $fo_ansi = 512
  4329. Global Const $fo_utf16_le_nobom = 1024
  4330. Global Const $fo_utf16_be_nobom = 2048
  4331. Global Const $fo_utf8_full = 16384
  4332. Global Const $fo_fullfile_detect = 16384
  4333. Global Const $eof = -1
  4334. Global Const $fd_filemustexist = 1
  4335. Global Const $fd_pathmustexist = 2
  4336. Global Const $fd_multiselect = 4
  4337. Global Const $fd_promptcreatenew = 8
  4338. Global Const $fd_promptoverwrite = 16
  4339. Global Const $create_new = 1
  4340. Global Const $create_always = 2
  4341. Global Const $open_existing = 3
  4342. Global Const $open_always = 4
  4343. Global Const $truncate_existing = 5
  4344. Global Const $invalid_set_file_pointer = -1
  4345. Global Const $file_begin = 0
  4346. Global Const $file_current = 1
  4347. Global Const $file_end = 2
  4348. Global Const $file_attribute_readonly = 1
  4349. Global Const $file_attribute_hidden = 2
  4350. Global Const $file_attribute_system = 4
  4351. Global Const $file_attribute_directory = 16
  4352. Global Const $file_attribute_archive = 32
  4353. Global Const $file_attribute_device = 64
  4354. Global Const $file_attribute_normal = 128
  4355. Global Const $file_attribute_temporary = 256
  4356. Global Const $file_attribute_sparse_file = 512
  4357. Global Const $file_attribute_reparse_point = 1024
  4358. Global Const $file_attribute_compressed = 2048
  4359. Global Const $file_attribute_offline = 4096
  4360. Global Const $file_attribute_not_content_indexed = 8192
  4361. Global Const $file_attribute_encrypted = 16384
  4362. Global Const $file_share_read = 1
  4363. Global Const $file_share_write = 2
  4364. Global Const $file_share_delete = 4
  4365. Global Const $file_share_readwrite = BitOR($file_share_read, $file_share_write)
  4366. Global Const $file_share_any = BitOR($file_share_read, $file_share_write, $file_share_delete)
  4367. Global Const $generic_all = 268435456
  4368. Global Const $generic_execute = 536870912
  4369. Global Const $generic_write = 1073741824
  4370. Global Const $generic_read = -2147483648
  4371. Global Const $generic_readwrite = BitOR($generic_read, $generic_write)
  4372. Global Const $file_encoding_utf16le = 32
  4373. Global Const $fe_entire_utf8 = 1
  4374. Global Const $fe_partialfirst_utf8 = 2
  4375. Global Const $fn_fullpath = 0
  4376. Global Const $fn_relativepath = 1
  4377. Global Const $fv_comments = "Comments"
  4378. Global Const $fv_companyname = "CompanyName"
  4379. Global Const $fv_filedescription = "FileDescription"
  4380. Global Const $fv_fileversion = "FileVersion"
  4381. Global Const $fv_internalname = "InternalName"
  4382. Global Const $fv_legalcopyright = "LegalCopyright"
  4383. Global Const $fv_legaltrademarks = "LegalTrademarks"
  4384. Global Const $fv_originalfilename = "OriginalFilename"
  4385. Global Const $fv_productname = "ProductName"
  4386. Global Const $fv_productversion = "ProductVersion"
  4387. Global Const $fv_privatebuild = "PrivateBuild"
  4388. Global Const $fv_specialbuild = "SpecialBuild"
  4389. Global Const $frta_nocount = 0
  4390. Global Const $frta_count = 1
  4391. Global Const $frta_intarrays = 2
  4392. Global Const $frta_entiresplit = 4
  4393. Global Const $flta_filesfolders = 0
  4394. Global Const $flta_files = 1
  4395. Global Const $flta_folders = 2
  4396. Global Const $fltar_filesfolders = 0
  4397. Global Const $fltar_files = 1
  4398. Global Const $fltar_folders = 2
  4399. Global Const $fltar_nohidden = 4
  4400. Global Const $fltar_nosystem = 8
  4401. Global Const $fltar_nolink = 16
  4402. Global Const $fltar_norecur = 0
  4403. Global Const $fltar_recur = 1
  4404. Global Const $fltar_nosort = 0
  4405. Global Const $fltar_sort = 1
  4406. Global Const $fltar_fastsort = 2
  4407. Global Const $fltar_nopath = 0
  4408. Global Const $fltar_relpath = 1
  4409. Global Const $fltar_fullpath = 2
  4410. Global Const $hgdi_error = Ptr(-1)
  4411. Global Const $invalid_handle_value = Ptr(-1)
  4412. Global Const $clr_invalid = -1
  4413. Global Const $null_brush = 5
  4414. Global Const $null_pen = 8
  4415. Global Const $black_brush = 4
  4416. Global Const $dkgray_brush = 3
  4417. Global Const $dc_brush = 18
  4418. Global Const $gray_brush = 2
  4419. Global Const $hollow_brush = $null_brush
  4420. Global Const $ltgray_brush = 1
  4421. Global Const $white_brush = 0
  4422. Global Const $black_pen = 7
  4423. Global Const $dc_pen = 19
  4424. Global Const $white_pen = 6
  4425. Global Const $ansi_fixed_font = 11
  4426. Global Const $ansi_var_font = 12
  4427. Global Const $device_default_font = 14
  4428. Global Const $default_gui_font = 17
  4429. Global Const $oem_fixed_font = 10
  4430. Global Const $system_font = 13
  4431. Global Const $system_fixed_font = 16
  4432. Global Const $default_palette = 15
  4433. Global Const $mb_precomposed = 1
  4434. Global Const $mb_composite = 2
  4435. Global Const $mb_useglyphchars = 4
  4436. Global Const $ulw_alpha = 2
  4437. Global Const $ulw_colorkey = 1
  4438. Global Const $ulw_opaque = 4
  4439. Global Const $ulw_ex_noresize = 8
  4440. Global Const $wh_callwndproc = 4
  4441. Global Const $wh_callwndprocret = 12
  4442. Global Const $wh_cbt = 5
  4443. Global Const $wh_debug = 9
  4444. Global Const $wh_foregroundidle = 11
  4445. Global Const $wh_getmessage = 3
  4446. Global Const $wh_journalplayback = 1
  4447. Global Const $wh_journalrecord = 0
  4448. Global Const $wh_keyboard = 2
  4449. Global Const $wh_keyboard_ll = 13
  4450. Global Const $wh_mouse = 7
  4451. Global Const $wh_mouse_ll = 14
  4452. Global Const $wh_msgfilter = -1
  4453. Global Const $wh_shell = 10
  4454. Global Const $wh_sysmsgfilter = 6
  4455. Global Const $wpf_asyncwindowplacement = 4
  4456. Global Const $wpf_restoretomaximized = 2
  4457. Global Const $wpf_setminposition = 1
  4458. Global Const $kf_extended = 256
  4459. Global Const $kf_altdown = 8192
  4460. Global Const $kf_up = 32768
  4461. Global Const $llkhf_extended = BitShift($kf_extended, 8)
  4462. Global Const $llkhf_injected = 16
  4463. Global Const $llkhf_altdown = BitShift($kf_altdown, 8)
  4464. Global Const $llkhf_up = BitShift($kf_up, 8)
  4465. Global Const $ofn_allowmultiselect = 512
  4466. Global Const $ofn_createprompt = 8192
  4467. Global Const $ofn_dontaddtorecent = 33554432
  4468. Global Const $ofn_enablehook = 32
  4469. Global Const $ofn_enableincludenotify = 4194304
  4470. Global Const $ofn_enablesizing = 8388608
  4471. Global Const $ofn_enabletemplate = 64
  4472. Global Const $ofn_enabletemplatehandle = 128
  4473. Global Const $ofn_explorer = 524288
  4474. Global Const $ofn_extensiondifferent = 1024
  4475. Global Const $ofn_filemustexist = 4096
  4476. Global Const $ofn_forceshowhidden = 268435456
  4477. Global Const $ofn_hidereadonly = 4
  4478. Global Const $ofn_longnames = 2097152
  4479. Global Const $ofn_nochangedir = 8
  4480. Global Const $ofn_nodereferencelinks = 1048576
  4481. Global Const $ofn_nolongnames = 262144
  4482. Global Const $ofn_nonetworkbutton = 131072
  4483. Global Const $ofn_noreadonlyreturn = 32768
  4484. Global Const $ofn_notestfilecreate = 65536
  4485. Global Const $ofn_novalidate = 256
  4486. Global Const $ofn_overwriteprompt = 2
  4487. Global Const $ofn_pathmustexist = 2048
  4488. Global Const $ofn_readonly = 1
  4489. Global Const $ofn_shareaware = 16384
  4490. Global Const $ofn_showhelp = 16
  4491. Global Const $ofn_ex_noplacesbar = 1
  4492. Global Const $tmpf_fixed_pitch = 1
  4493. Global Const $tmpf_vector = 2
  4494. Global Const $tmpf_truetype = 4
  4495. Global Const $tmpf_device = 8
  4496. Global Const $duplicate_close_source = 1
  4497. Global Const $duplicate_same_access = 2
  4498. Global Const $di_mask = 1
  4499. Global Const $di_image = 2
  4500. Global Const $di_normal = 3
  4501. Global Const $di_compat = 4
  4502. Global Const $di_defaultsize = 8
  4503. Global Const $di_nomirror = 16
  4504. Global Const $display_device_attached_to_desktop = 1
  4505. Global Const $display_device_multi_driver = 2
  4506. Global Const $display_device_primary_device = 4
  4507. Global Const $display_device_mirroring_driver = 8
  4508. Global Const $display_device_vga_compatible = 16
  4509. Global Const $display_device_removable = 32
  4510. Global Const $display_device_disconnect = 33554432
  4511. Global Const $display_device_remote = 67108864
  4512. Global Const $display_device_modespruned = 134217728
  4513. Global Const $flashw_caption = 1
  4514. Global Const $flashw_tray = 2
  4515. Global Const $flashw_timer = 4
  4516. Global Const $flashw_timernofg = 12
  4517. Global Const $format_message_allocate_buffer = 256
  4518. Global Const $format_message_ignore_inserts = 512
  4519. Global Const $format_message_from_string = 1024
  4520. Global Const $format_message_from_hmodule = 2048
  4521. Global Const $format_message_from_system = 4096
  4522. Global Const $format_message_argument_array = 8192
  4523. Global Const $gw_hwndfirst = 0
  4524. Global Const $gw_hwndlast = 1
  4525. Global Const $gw_hwndnext = 2
  4526. Global Const $gw_hwndprev = 3
  4527. Global Const $gw_owner = 4
  4528. Global Const $gw_child = 5
  4529. Global Const $gw_enabledpopup = 6
  4530. Global Const $gwl_wndproc = -4
  4531. Global Const $gwl_hinstance = -6
  4532. Global Const $gwl_hwndparent = -8
  4533. Global Const $gwl_id = -12
  4534. Global Const $gwl_style = -16
  4535. Global Const $gwl_exstyle = -20
  4536. Global Const $gwl_userdata = -21
  4537. Global Const $std_cut = 0
  4538. Global Const $std_copy = 1
  4539. Global Const $std_paste = 2
  4540. Global Const $std_undo = 3
  4541. Global Const $std_redow = 4
  4542. Global Const $std_delete = 5
  4543. Global Const $std_filenew = 6
  4544. Global Const $std_fileopen = 7
  4545. Global Const $std_filesave = 8
  4546. Global Const $std_printpre = 9
  4547. Global Const $std_properties = 10
  4548. Global Const $std_help = 11
  4549. Global Const $std_find = 12
  4550. Global Const $std_replace = 13
  4551. Global Const $std_print = 14
  4552. Global Const $image_bitmap = 0
  4553. Global Const $image_icon = 1
  4554. Global Const $image_cursor = 2
  4555. Global Const $image_enhmetafile = 3
  4556. Global Const $kb_sendspecial = 0
  4557. Global Const $kb_sendraw = 1
  4558. Global Const $kb_capsoff = 0
  4559. Global Const $kb_capson = 1
  4560. Global Const $dont_resolve_dll_references = 1
  4561. Global Const $load_library_as_datafile = 2
  4562. Global Const $load_with_altered_search_path = 8
  4563. Global Const $load_ignore_code_authz_level = 16
  4564. Global Const $load_library_as_datafile_exclusive = 64
  4565. Global Const $load_library_as_image_resource = 32
  4566. Global Const $load_library_search_application_dir = 512
  4567. Global Const $load_library_search_default_dirs = 4096
  4568. Global Const $load_library_search_dll_load_dir = 256
  4569. Global Const $load_library_search_system32 = 2048
  4570. Global Const $load_library_search_user_dirs = 1024
  4571. Global Const $s_ok = 0
  4572. Global Const $e_abort = -2147467260
  4573. Global Const $e_accessdenied = -2147024891
  4574. Global Const $e_fail = -2147467259
  4575. Global Const $e_handle = -2147024890
  4576. Global Const $e_invalidarg = -2147024809
  4577. Global Const $e_nointerface = -2147467262
  4578. Global Const $e_notimpl = -2147467263
  4579. Global Const $e_outofmemory = -2147024882
  4580. Global Const $e_pointer = -2147467261
  4581. Global Const $e_unexpected = -2147418113
  4582. Global Const $lr_defaultcolor = 0
  4583. Global Const $lr_monochrome = 1
  4584. Global Const $lr_color = 2
  4585. Global Const $lr_copyreturnorg = 4
  4586. Global Const $lr_copydeleteorg = 8
  4587. Global Const $lr_loadfromfile = 16
  4588. Global Const $lr_loadtransparent = 32
  4589. Global Const $lr_defaultsize = 64
  4590. Global Const $lr_vgacolor = 128
  4591. Global Const $lr_loadmap3dcolors = 4096
  4592. Global Const $lr_createdibsection = 8192
  4593. Global Const $lr_copyfromresource = 16384
  4594. Global Const $lr_shared = 32768
  4595. Global Const $obm_trtype = 32732
  4596. Global Const $obm_lfarrowi = 32734
  4597. Global Const $obm_rgarrowi = 32735
  4598. Global Const $obm_dnarrowi = 32736
  4599. Global Const $obm_uparrowi = 32737
  4600. Global Const $obm_combo = 32738
  4601. Global Const $obm_mnarrow = 32739
  4602. Global Const $obm_lfarrowd = 32740
  4603. Global Const $obm_rgarrowd = 32741
  4604. Global Const $obm_dnarrowd = 32742
  4605. Global Const $obm_uparrowd = 32743
  4606. Global Const $obm_restored = 32744
  4607. Global Const $obm_zoomd = 32745
  4608. Global Const $obm_reduced = 32746
  4609. Global Const $obm_restore = 32747
  4610. Global Const $obm_zoom = 32748
  4611. Global Const $obm_reduce = 32749
  4612. Global Const $obm_lfarrow = 32750
  4613. Global Const $obm_rgarrow = 32751
  4614. Global Const $obm_dnarrow = 32752
  4615. Global Const $obm_uparrow = 32753
  4616. Global Const $obm_close = 32754
  4617. Global Const $obm_old_restore = 32755
  4618. Global Const $obm_old_zoom = 32756
  4619. Global Const $obm_old_reduce = 32757
  4620. Global Const $obm_btncorners = 32758
  4621. Global Const $obm_checkboxes = 32759
  4622. Global Const $obm_check = 32760
  4623. Global Const $obm_btsize = 32761
  4624. Global Const $obm_old_lfarrow = 32762
  4625. Global Const $obm_old_rgarrow = 32763
  4626. Global Const $obm_old_dnarrow = 32764
  4627. Global Const $obm_old_uparrow = 32765
  4628. Global Const $obm_size = 32766
  4629. Global Const $obm_old_close = 32767
  4630. Global Const $oic_sample = 32512
  4631. Global Const $oic_hand = 32513
  4632. Global Const $oic_ques = 32514
  4633. Global Const $oic_bang = 32515
  4634. Global Const $oic_note = 32516
  4635. Global Const $oic_winlogo = 32517
  4636. Global Const $oic_warning = $oic_bang
  4637. Global Const $oic_error = $oic_hand
  4638. Global Const $oic_information = $oic_note
  4639. Global $__g_ainprocess_winapi[64][2] = [[0, 0]]
  4640. Global $__g_awinlist_winapi[64][2] = [[0, 0]]
  4641. Global Const $__winapiconstant_wm_setfont = 48
  4642. Global Const $__winapiconstant_fw_normal = 400
  4643. Global Const $__winapiconstant_default_charset = 1
  4644. Global Const $__winapiconstant_out_default_precis = 0
  4645. Global Const $__winapiconstant_clip_default_precis = 0
  4646. Global Const $__winapiconstant_default_quality = 0
  4647. Global Const $__winapiconstant_logpixelsx = 88
  4648. Global Const $__winapiconstant_logpixelsy = 90
  4649. Global Const $tagcursorinfo = "dword Size;dword Flags;handle hCursor;" & $tagpoint
  4650. Global Const $tagdisplay_device = "dword Size;wchar Name[32];wchar String[128];dword Flags;wchar ID[128];wchar Key[128]"
  4651. Global Const $tagflashwinfo = "uint Size;hwnd hWnd;dword Flags;uint Count;dword TimeOut"
  4652. Global Const $tagiconinfo = "bool Icon;dword XHotSpot;dword YHotSpot;handle hMask;handle hColor"
  4653. Global Const $tagmemorystatusex = "dword Length;dword MemoryLoad;" & "uint64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & "uint64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual"
  4654.  
  4655. Func _winapi_attachconsole($ipid = -1)
  4656. Local $aresult = DllCall("kernel32.dll", "bool", "AttachConsole", "dword", $ipid)
  4657. If @error Then Return SetError(@error, @extended, False)
  4658. Return $aresult[0]
  4659. EndFunc
  4660.  
  4661. Func _winapi_attachthreadinput($iattach, $iattachto, $battach)
  4662. Local $aresult = DllCall("user32.dll", "bool", "AttachThreadInput", "dword", $iattach, "dword", $iattachto, "bool", $battach)
  4663. If @error Then Return SetError(@error, @extended, False)
  4664. Return $aresult[0]
  4665. EndFunc
  4666.  
  4667. Func _winapi_beep($ifreq = 500, $iduration = 1000)
  4668. Local $aresult = DllCall("kernel32.dll", "bool", "Beep", "dword", $ifreq, "dword", $iduration)
  4669. If @error Then Return SetError(@error, @extended, False)
  4670. Return $aresult[0]
  4671. EndFunc
  4672.  
  4673. Func _winapi_bitblt($hdestdc, $ixdest, $iydest, $iwidth, $iheight, $hsrcdc, $ixsrc, $iysrc, $irop)
  4674. Local $aresult = DllCall("gdi32.dll", "bool", "BitBlt", "handle", $hdestdc, "int", $ixdest, "int", $iydest, "int", $iwidth, "int", $iheight, "handle", $hsrcdc, "int", $ixsrc, "int", $iysrc, "dword", $irop)
  4675. If @error Then Return SetError(@error, @extended, False)
  4676. Return $aresult[0]
  4677. EndFunc
  4678.  
  4679. Func _winapi_callnexthookex($hhook, $icode, $wparam, $lparam)
  4680. Local $aresult = DllCall("user32.dll", "lresult", "CallNextHookEx", "handle", $hhook, "int", $icode, "wparam", $wparam, "lparam", $lparam)
  4681. If @error Then Return SetError(@error, @extended, -1)
  4682. Return $aresult[0]
  4683. EndFunc
  4684.  
  4685. Func _winapi_callwindowproc($pprevwndfunc, $hwnd, $imsg, $wparam, $lparam)
  4686. Local $aresult = DllCall("user32.dll", "lresult", "CallWindowProc", "ptr", $pprevwndfunc, "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
  4687. If @error Then Return SetError(@error, @extended, -1)
  4688. Return $aresult[0]
  4689. EndFunc
  4690.  
  4691. Func _winapi_clienttoscreen($hwnd, ByRef $tpoint)
  4692. Local $aret = DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hwnd, "struct*", $tpoint)
  4693. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  4694. Return $tpoint
  4695. EndFunc
  4696.  
  4697. Func _winapi_closehandle($hobject)
  4698. Local $aresult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hobject)
  4699. If @error Then Return SetError(@error, @extended, False)
  4700. Return $aresult[0]
  4701. EndFunc
  4702.  
  4703. Func _winapi_combinergn($hrgndest, $hrgnsrc1, $hrgnsrc2, $icombinemode)
  4704. Local $aresult = DllCall("gdi32.dll", "int", "CombineRgn", "handle", $hrgndest, "handle", $hrgnsrc1, "handle", $hrgnsrc2, "int", $icombinemode)
  4705. If @error Then Return SetError(@error, @extended, 0)
  4706. Return $aresult[0]
  4707. EndFunc
  4708.  
  4709. Func _winapi_commdlgextendederror()
  4710. Local Const $cderr_dialogfailure = 65535
  4711. Local Const $cderr_findresfailure = 6
  4712. Local Const $cderr_initialization = 2
  4713. Local Const $cderr_loadresfailure = 7
  4714. Local Const $cderr_loadstrfailure = 5
  4715. Local Const $cderr_lockresfailure = 8
  4716. Local Const $cderr_memallocfailure = 9
  4717. Local Const $cderr_memlockfailure = 10
  4718. Local Const $cderr_nohinstance = 4
  4719. Local Const $cderr_nohook = 11
  4720. Local Const $cderr_notemplate = 3
  4721. Local Const $cderr_registermsgfail = 12
  4722. Local Const $cderr_structsize = 1
  4723. Local Const $fnerr_buffertoosmall = 12291
  4724. Local Const $fnerr_invalidfilename = 12290
  4725. Local Const $fnerr_subclassfailure = 12289
  4726. Local $aresult = DllCall("comdlg32.dll", "dword", "CommDlgExtendedError")
  4727. If NOT @error Then
  4728. Switch $aresult[0]
  4729. Case $cderr_dialogfailure
  4730. Return SetError($aresult[0], 0, "The dialog box could not be created." & @LF & "The common dialog box function's call to the DialogBox function failed." & @LF & "For example, this error occurs if the common dialog box call specifies an invalid window handle.")
  4731. Case $cderr_findresfailure
  4732. Return SetError($aresult[0], 0, "The common dialog box function failed to find a specified resource.")
  4733. Case $cderr_initialization
  4734. Return SetError($aresult[0], 0, "The common dialog box function failed during initialization." & @LF & "This error often occurs when sufficient memory is not available.")
  4735. Case $cderr_loadresfailure
  4736. Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified resource.")
  4737. Case $cderr_loadstrfailure
  4738. Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified string.")
  4739. Case $cderr_lockresfailure
  4740. Return SetError($aresult[0], 0, "The common dialog box function failed to lock a specified resource.")
  4741. Case $cderr_memallocfailure
  4742. Return SetError($aresult[0], 0, "The common dialog box function was unable to allocate memory for internal structures.")
  4743. Case $cderr_memlockfailure
  4744. Return SetError($aresult[0], 0, "The common dialog box function was unable to lock the memory associated with a handle.")
  4745. Case $cderr_nohinstance
  4746. Return SetError($aresult[0], 0, "The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box," & @LF & "but you failed to provide a corresponding instance handle.")
  4747. Case $cderr_nohook
  4748. Return SetError($aresult[0], 0, "The ENABLEHOOK flag was set in the Flags member of the initialization structure for the corresponding common dialog box," & @LF & "but you failed to provide a pointer to a corresponding hook procedure.")
  4749. Case $cderr_notemplate
  4750. Return SetError($aresult[0], 0, "The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box," & @LF & "but you failed to provide a corresponding template.")
  4751. Case $cderr_registermsgfail
  4752. Return SetError($aresult[0], 0, "The RegisterWindowMessage function returned an error code when it was called by the common dialog box function.")
  4753. Case $cderr_structsize
  4754. Return SetError($aresult[0], 0, "The lStructSize member of the initialization structure for the corresponding common dialog box is invalid")
  4755. Case $fnerr_buffertoosmall
  4756. Return SetError($aresult[0], 0, "The buffer pointed to by the lpstrFile member of the OPENFILENAME structure is too small for the file name specified by the user." & @LF & "The first two bytes of the lpstrFile buffer contain an integer value specifying the size, in TCHARs, required to receive the full name.")
  4757. Case $fnerr_invalidfilename
  4758. Return SetError($aresult[0], 0, "A file name is invalid.")
  4759. Case $fnerr_subclassfailure
  4760. Return SetError($aresult[0], 0, "An attempt to subclass a list box failed because sufficient memory was not available.")
  4761. EndSwitch
  4762. EndIf
  4763. Return SetError(@error, @extended, "0x" & Hex($aresult[0]))
  4764. EndFunc
  4765.  
  4766. Func _winapi_copyicon($hicon)
  4767. Local $aresult = DllCall("user32.dll", "handle", "CopyIcon", "handle", $hicon)
  4768. If @error Then Return SetError(@error, @extended, 0)
  4769. Return $aresult[0]
  4770. EndFunc
  4771.  
  4772. Func _winapi_createbitmap($iwidth, $iheight, $iplanes = 1, $ibitsperpel = 1, $pbits = 0)
  4773. Local $aresult = DllCall("gdi32.dll", "handle", "CreateBitmap", "int", $iwidth, "int", $iheight, "uint", $iplanes, "uint", $ibitsperpel, "struct*", $pbits)
  4774. If @error Then Return SetError(@error, @extended, 0)
  4775. Return $aresult[0]
  4776. EndFunc
  4777.  
  4778. Func _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  4779. Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleBitmap", "handle", $hdc, "int", $iwidth, "int", $iheight)
  4780. If @error Then Return SetError(@error, @extended, 0)
  4781. Return $aresult[0]
  4782. EndFunc
  4783.  
  4784. Func _winapi_createcompatibledc($hdc)
  4785. Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleDC", "handle", $hdc)
  4786. If @error Then Return SetError(@error, @extended, 0)
  4787. Return $aresult[0]
  4788. EndFunc
  4789.  
  4790. Func _winapi_createevent($tattributes = 0, $bmanualreset = True, $binitialstate = True, $sname = "")
  4791. Local $snametype = "wstr"
  4792. If $sname = "" Then
  4793. $sname = 0
  4794. $snametype = "ptr"
  4795. EndIf
  4796. Local $aresult = DllCall("kernel32.dll", "handle", "CreateEventW", "struct*", $tattributes, "bool", $bmanualreset, "bool", $binitialstate, $snametype, $sname)
  4797. If @error Then Return SetError(@error, @extended, 0)
  4798. Return $aresult[0]
  4799. EndFunc
  4800.  
  4801. Func _winapi_createfile($sfilename, $icreation, $iaccess = 4, $ishare = 0, $iattributes = 0, $tsecurity = 0)
  4802. Local $ida = 0, $ism = 0, $icd = 0, $ifa = 0
  4803. If BitAND($iaccess, 1) <> 0 Then $ida = BitOR($ida, $generic_execute)
  4804. If BitAND($iaccess, 2) <> 0 Then $ida = BitOR($ida, $generic_read)
  4805. If BitAND($iaccess, 4) <> 0 Then $ida = BitOR($ida, $generic_write)
  4806. If BitAND($ishare, 1) <> 0 Then $ism = BitOR($ism, $file_share_delete)
  4807. If BitAND($ishare, 2) <> 0 Then $ism = BitOR($ism, $file_share_read)
  4808. If BitAND($ishare, 4) <> 0 Then $ism = BitOR($ism, $file_share_write)
  4809. Switch $icreation
  4810. Case 0
  4811. $icd = $create_new
  4812. Case 1
  4813. $icd = $create_always
  4814. Case 2
  4815. $icd = $open_existing
  4816. Case 3
  4817. $icd = $open_always
  4818. Case 4
  4819. $icd = $truncate_existing
  4820. EndSwitch
  4821. If BitAND($iattributes, 1) <> 0 Then $ifa = BitOR($ifa, $file_attribute_archive)
  4822. If BitAND($iattributes, 2) <> 0 Then $ifa = BitOR($ifa, $file_attribute_hidden)
  4823. If BitAND($iattributes, 4) <> 0 Then $ifa = BitOR($ifa, $file_attribute_readonly)
  4824. If BitAND($iattributes, 8) <> 0 Then $ifa = BitOR($ifa, $file_attribute_system)
  4825. Local $aresult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sfilename, "dword", $ida, "dword", $ism, "struct*", $tsecurity, "dword", $icd, "dword", $ifa, "ptr", 0)
  4826. If @error OR ($aresult[0] = $invalid_handle_value) Then Return SetError(@error, @extended, 0)
  4827. Return $aresult[0]
  4828. EndFunc
  4829.  
  4830. Func _winapi_createfont($iheight, $iwidth, $iescape = 0, $iorientn = 0, $iweight = $__winapiconstant_fw_normal, $bitalic = False, $bunderline = False, $bstrikeout = False, $icharset = $__winapiconstant_default_charset, $ioutputprec = $__winapiconstant_out_default_precis, $iclipprec = $__winapiconstant_clip_default_precis, $iquality = $__winapiconstant_default_quality, $ipitch = 0, $sface = "Arial")
  4831. Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontW", "int", $iheight, "int", $iwidth, "int", $iescape, "int", $iorientn, "int", $iweight, "dword", $bitalic, "dword", $bunderline, "dword", $bstrikeout, "dword", $icharset, "dword", $ioutputprec, "dword", $iclipprec, "dword", $iquality, "dword", $ipitch, "wstr", $sface)
  4832. If @error Then Return SetError(@error, @extended, 0)
  4833. Return $aresult[0]
  4834. EndFunc
  4835.  
  4836. Func _winapi_createfontindirect($tlogfont)
  4837. Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontIndirectW", "struct*", $tlogfont)
  4838. If @error Then Return SetError(@error, @extended, 0)
  4839. Return $aresult[0]
  4840. EndFunc
  4841.  
  4842. Func _winapi_createpen($ipenstyle, $iwidth, $icolor)
  4843. Local $aresult = DllCall("gdi32.dll", "handle", "CreatePen", "int", $ipenstyle, "int", $iwidth, "INT", $icolor)
  4844. If @error Then Return SetError(@error, @extended, 0)
  4845. Return $aresult[0]
  4846. EndFunc
  4847.  
  4848. Func _winapi_createprocess($sappname, $scommand, $tsecurity, $tthread, $binherit, $iflags, $penviron, $sdir, $tstartupinfo, $tprocess)
  4849. Local $tcommand = 0
  4850. Local $sappnametype = "wstr", $sdirtype = "wstr"
  4851. If $sappname = "" Then
  4852. $sappnametype = "ptr"
  4853. $sappname = 0
  4854. EndIf
  4855. If $scommand <> "" Then
  4856. $tcommand = DllStructCreate("wchar Text[" & 260 + 1 & "]")
  4857. DllStructSetData($tcommand, "Text", $scommand)
  4858. EndIf
  4859. If $sdir = "" Then
  4860. $sdirtype = "ptr"
  4861. $sdir = 0
  4862. EndIf
  4863. Local $aresult = DllCall("kernel32.dll", "bool", "CreateProcessW", $sappnametype, $sappname, "struct*", $tcommand, "struct*", $tsecurity, "struct*", $tthread, "bool", $binherit, "dword", $iflags, "struct*", $penviron, $sdirtype, $sdir, "struct*", $tstartupinfo, "struct*", $tprocess)
  4864. If @error Then Return SetError(@error, @extended, False)
  4865. Return $aresult[0]
  4866. EndFunc
  4867.  
  4868. Func _winapi_createrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect)
  4869. Local $aresult = DllCall("gdi32.dll", "handle", "CreateRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect)
  4870. If @error Then Return SetError(@error, @extended, 0)
  4871. Return $aresult[0]
  4872. EndFunc
  4873.  
  4874. Func _winapi_createroundrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect, $iwidthellipse, $iheightellipse)
  4875. Local $aresult = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect, "int", $iwidthellipse, "int", $iheightellipse)
  4876. If @error Then Return SetError(@error, @extended, 0)
  4877. Return $aresult[0]
  4878. EndFunc
  4879.  
  4880. Func _winapi_createsolidbitmap($hwnd, $icolor, $iwidth, $iheight, $brgb = 1)
  4881. Local $hdc = _winapi_getdc($hwnd)
  4882. Local $hdestdc = _winapi_createcompatibledc($hdc)
  4883. Local $hbitmap = _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  4884. Local $hold = _winapi_selectobject($hdestdc, $hbitmap)
  4885. Local $trect = DllStructCreate($tagrect)
  4886. DllStructSetData($trect, 1, 0)
  4887. DllStructSetData($trect, 2, 0)
  4888. DllStructSetData($trect, 3, $iwidth)
  4889. DllStructSetData($trect, 4, $iheight)
  4890. If $brgb Then
  4891. $icolor = BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
  4892. EndIf
  4893. Local $hbrush = _winapi_createsolidbrush($icolor)
  4894. If NOT _winapi_fillrect($hdestdc, $trect, $hbrush) Then
  4895. _winapi_deleteobject($hbitmap)
  4896. $hbitmap = 0
  4897. EndIf
  4898. _winapi_deleteobject($hbrush)
  4899. _winapi_releasedc($hwnd, $hdc)
  4900. _winapi_selectobject($hdestdc, $hold)
  4901. _winapi_deletedc($hdestdc)
  4902. If NOT $hbitmap Then Return SetError(1, 0, 0)
  4903. Return $hbitmap
  4904. EndFunc
  4905.  
  4906. Func _winapi_createsolidbrush($icolor)
  4907. Local $aresult = DllCall("gdi32.dll", "handle", "CreateSolidBrush", "INT", $icolor)
  4908. If @error Then Return SetError(@error, @extended, 0)
  4909. Return $aresult[0]
  4910. EndFunc
  4911.  
  4912. Func _winapi_createwindowex($iexstyle, $sclass, $sname, $istyle, $ix, $iy, $iwidth, $iheight, $hparent, $hmenu = 0, $hinstance = 0, $pparam = 0)
  4913. If $hinstance = 0 Then $hinstance = _winapi_getmodulehandle("")
  4914. Local $aresult = DllCall("user32.dll", "hwnd", "CreateWindowExW", "dword", $iexstyle, "wstr", $sclass, "wstr", $sname, "dword", $istyle, "int", $ix, "int", $iy, "int", $iwidth, "int", $iheight, "hwnd", $hparent, "handle", $hmenu, "handle", $hinstance, "struct*", $pparam)
  4915. If @error Then Return SetError(@error, @extended, 0)
  4916. Return $aresult[0]
  4917. EndFunc
  4918.  
  4919. Func _winapi_defwindowproc($hwnd, $imsg, $wparam, $lparam)
  4920. Local $aresult = DllCall("user32.dll", "lresult", "DefWindowProc", "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
  4921. If @error Then Return SetError(@error, @extended, 0)
  4922. Return $aresult[0]
  4923. EndFunc
  4924.  
  4925. Func _winapi_deletedc($hdc)
  4926. Local $aresult = DllCall("gdi32.dll", "bool", "DeleteDC", "handle", $hdc)
  4927. If @error Then Return SetError(@error, @extended, False)
  4928. Return $aresult[0]
  4929. EndFunc
  4930.  
  4931. Func _winapi_deleteobject($hobject)
  4932. Local $aresult = DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hobject)
  4933. If @error Then Return SetError(@error, @extended, False)
  4934. Return $aresult[0]
  4935. EndFunc
  4936.  
  4937. Func _winapi_destroyicon($hicon)
  4938. Local $aresult = DllCall("user32.dll", "bool", "DestroyIcon", "handle", $hicon)
  4939. If @error Then Return SetError(@error, @extended, False)
  4940. Return $aresult[0]
  4941. EndFunc
  4942.  
  4943. Func _winapi_destroywindow($hwnd)
  4944. Local $aresult = DllCall("user32.dll", "bool", "DestroyWindow", "hwnd", $hwnd)
  4945. If @error Then Return SetError(@error, @extended, False)
  4946. Return $aresult[0]
  4947. EndFunc
  4948.  
  4949. Func _winapi_drawedge($hdc, $trect, $iedgetype, $iflags)
  4950. Local $aresult = DllCall("user32.dll", "bool", "DrawEdge", "handle", $hdc, "struct*", $trect, "uint", $iedgetype, "uint", $iflags)
  4951. If @error Then Return SetError(@error, @extended, False)
  4952. Return $aresult[0]
  4953. EndFunc
  4954.  
  4955. Func _winapi_drawframecontrol($hdc, $trect, $itype, $istate)
  4956. Local $aresult = DllCall("user32.dll", "bool", "DrawFrameControl", "handle", $hdc, "struct*", $trect, "uint", $itype, "uint", $istate)
  4957. If @error Then Return SetError(@error, @extended, False)
  4958. Return $aresult[0]
  4959. EndFunc
  4960.  
  4961. Func _winapi_drawicon($hdc, $ix, $iy, $hicon)
  4962. Local $aresult = DllCall("user32.dll", "bool", "DrawIcon", "handle", $hdc, "int", $ix, "int", $iy, "handle", $hicon)
  4963. If @error Then Return SetError(@error, @extended, False)
  4964. Return $aresult[0]
  4965. EndFunc
  4966.  
  4967. Func _winapi_drawiconex($hdc, $ix, $iy, $hicon, $iwidth = 0, $iheight = 0, $istep = 0, $hbrush = 0, $iflags = 3)
  4968. Local $ioptions
  4969. Switch $iflags
  4970. Case 1
  4971. $ioptions = $di_mask
  4972. Case 2
  4973. $ioptions = $di_image
  4974. Case 3
  4975. $ioptions = $di_normal
  4976. Case 4
  4977. $ioptions = $di_compat
  4978. Case 5
  4979. $ioptions = $di_defaultsize
  4980. Case Else
  4981. $ioptions = $di_nomirror
  4982. EndSwitch
  4983. Local $aresult = DllCall("user32.dll", "bool", "DrawIconEx", "handle", $hdc, "int", $ix, "int", $iy, "handle", $hicon, "int", $iwidth, "int", $iheight, "uint", $istep, "handle", $hbrush, "uint", $ioptions)
  4984. If @error Then Return SetError(@error, @extended, False)
  4985. Return $aresult[0]
  4986. EndFunc
  4987.  
  4988. Func _winapi_drawline($hdc, $ix1, $iy1, $ix2, $iy2)
  4989. _winapi_moveto($hdc, $ix1, $iy1)
  4990. If @error Then Return SetError(@error, @extended, False)
  4991. _winapi_lineto($hdc, $ix2, $iy2)
  4992. If @error Then Return SetError(@error + 10, @extended, False)
  4993. Return True
  4994. EndFunc
  4995.  
  4996. Func _winapi_drawtext($hdc, $stext, ByRef $trect, $iflags)
  4997. Local $aresult = DllCall("user32.dll", "int", "DrawTextW", "handle", $hdc, "wstr", $stext, "int", -1, "struct*", $trect, "uint", $iflags)
  4998. If @error Then Return SetError(@error, @extended, 0)
  4999. Return $aresult[0]
  5000. EndFunc
  5001.  
  5002. Func _winapi_duplicatehandle($hsourceprocesshandle, $hsourcehandle, $htargetprocesshandle, $idesiredaccess, $iinherithandle, $ioptions)
  5003. Local $aresult = DllCall("kernel32.dll", "bool", "DuplicateHandle", "handle", $hsourceprocesshandle, "handle", $hsourcehandle, "handle", $htargetprocesshandle, "handle*", 0, "dword", $idesiredaccess, "bool", $iinherithandle, "dword", $ioptions)
  5004. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  5005. Return $aresult[4]
  5006. EndFunc
  5007.  
  5008. Func _winapi_enablewindow($hwnd, $benable = True)
  5009. Local $aresult = DllCall("user32.dll", "bool", "EnableWindow", "hwnd", $hwnd, "bool", $benable)
  5010. If @error Then Return SetError(@error, @extended, False)
  5011. Return $aresult[0]
  5012. EndFunc
  5013.  
  5014. Func _winapi_enumdisplaydevices($sdevice, $idevnum)
  5015. Local $tname = 0, $iflags = 0, $adevice[5]
  5016. If $sdevice <> "" Then
  5017. $tname = DllStructCreate("wchar Text[" & StringLen($sdevice) + 1 & "]")
  5018. DllStructSetData($tname, "Text", $sdevice)
  5019. EndIf
  5020. Local $tdevice = DllStructCreate($tagdisplay_device)
  5021. Local $idevice = DllStructGetSize($tdevice)
  5022. DllStructSetData($tdevice, "Size", $idevice)
  5023. Local $aret = DllCall("user32.dll", "bool", "EnumDisplayDevicesW", "struct*", $tname, "dword", $idevnum, "struct*", $tdevice, "dword", 1)
  5024. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5025. Local $in = DllStructGetData($tdevice, "Flags")
  5026. If BitAND($in, $display_device_attached_to_desktop) <> 0 Then $iflags = BitOR($iflags, 1)
  5027. If BitAND($in, $display_device_primary_device) <> 0 Then $iflags = BitOR($iflags, 2)
  5028. If BitAND($in, $display_device_mirroring_driver) <> 0 Then $iflags = BitOR($iflags, 4)
  5029. If BitAND($in, $display_device_vga_compatible) <> 0 Then $iflags = BitOR($iflags, 8)
  5030. If BitAND($in, $display_device_removable) <> 0 Then $iflags = BitOR($iflags, 16)
  5031. If BitAND($in, $display_device_modespruned) <> 0 Then $iflags = BitOR($iflags, 32)
  5032. $adevice[0] = True
  5033. $adevice[1] = DllStructGetData($tdevice, "Name")
  5034. $adevice[2] = DllStructGetData($tdevice, "String")
  5035. $adevice[3] = $iflags
  5036. $adevice[4] = DllStructGetData($tdevice, "ID")
  5037. Return $adevice
  5038. EndFunc
  5039.  
  5040. Func _winapi_enumwindows($bvisible = True, $hwnd = Default)
  5041. __winapi_enumwindowsinit()
  5042. If $hwnd = Default Then $hwnd = _winapi_getdesktopwindow()
  5043. __winapi_enumwindowschild($hwnd, $bvisible)
  5044. Return $__g_awinlist_winapi
  5045. EndFunc
  5046.  
  5047. Func __winapi_enumwindowsadd($hwnd, $sclass = "")
  5048. If $sclass = "" Then $sclass = _winapi_getclassname($hwnd)
  5049. $__g_awinlist_winapi[0][0] += 1
  5050. Local $icount = $__g_awinlist_winapi[0][0]
  5051. If $icount >= $__g_awinlist_winapi[0][1] Then
  5052. ReDim $__g_awinlist_winapi[$icount + 64][2]
  5053. $__g_awinlist_winapi[0][1] += 64
  5054. EndIf
  5055. $__g_awinlist_winapi[$icount][0] = $hwnd
  5056. $__g_awinlist_winapi[$icount][1] = $sclass
  5057. EndFunc
  5058.  
  5059. Func __winapi_enumwindowschild($hwnd, $bvisible = True)
  5060. $hwnd = _winapi_getwindow($hwnd, $gw_child)
  5061. While $hwnd <> 0
  5062. If (NOT $bvisible) OR _winapi_iswindowvisible($hwnd) Then
  5063. __winapi_enumwindowsadd($hwnd)
  5064. __winapi_enumwindowschild($hwnd, $bvisible)
  5065. EndIf
  5066. $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  5067. WEnd
  5068. EndFunc
  5069.  
  5070. Func __winapi_enumwindowsinit()
  5071. ReDim $__g_awinlist_winapi[64][2]
  5072. $__g_awinlist_winapi[0][0] = 0
  5073. $__g_awinlist_winapi[0][1] = 64
  5074. EndFunc
  5075.  
  5076. Func _winapi_enumwindowspopup()
  5077. __winapi_enumwindowsinit()
  5078. Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_child)
  5079. Local $sclass
  5080. While $hwnd <> 0
  5081. If _winapi_iswindowvisible($hwnd) Then
  5082. $sclass = _winapi_getclassname($hwnd)
  5083. If $sclass = "#32768" Then
  5084. __winapi_enumwindowsadd($hwnd)
  5085. ElseIf $sclass = "ToolbarWindow32" Then
  5086. __winapi_enumwindowsadd($hwnd)
  5087. ElseIf $sclass = "ToolTips_Class32" Then
  5088. __winapi_enumwindowsadd($hwnd)
  5089. ElseIf $sclass = "BaseBar" Then
  5090. __winapi_enumwindowschild($hwnd)
  5091. EndIf
  5092. EndIf
  5093. $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  5094. WEnd
  5095. Return $__g_awinlist_winapi
  5096. EndFunc
  5097.  
  5098. Func _winapi_enumwindowstop()
  5099. __winapi_enumwindowsinit()
  5100. Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_child)
  5101. While $hwnd <> 0
  5102. If _winapi_iswindowvisible($hwnd) Then __winapi_enumwindowsadd($hwnd)
  5103. $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  5104. WEnd
  5105. Return $__g_awinlist_winapi
  5106. EndFunc
  5107.  
  5108. Func _winapi_expandenvironmentstrings($sstring)
  5109. Local $aresult = DllCall("kernel32.dll", "dword", "ExpandEnvironmentStringsW", "wstr", $sstring, "wstr", "", "dword", 4096)
  5110. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  5111. Return $aresult[2]
  5112. EndFunc
  5113.  
  5114. Func _winapi_extracticonex($sfilepath, $iindex, $palarge, $pasmall, $iicons)
  5115. Local $aresult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sfilepath, "int", $iindex, "struct*", $palarge, "struct*", $pasmall, "uint", $iicons)
  5116. If @error Then Return SetError(@error, @extended, 0)
  5117. Return $aresult[0]
  5118. EndFunc
  5119.  
  5120. Func _winapi_fatalappexit($smessage)
  5121. DllCall("kernel32.dll", "none", "FatalAppExitW", "uint", 0, "wstr", $smessage)
  5122. If @error Then Return SetError(@error, @extended)
  5123. EndFunc
  5124.  
  5125. Func _winapi_fillrect($hdc, $trect, $hbrush)
  5126. Local $aresult
  5127. If IsPtr($hbrush) Then
  5128. $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "struct*", $trect, "handle", $hbrush)
  5129. Else
  5130. $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "struct*", $trect, "dword_ptr", $hbrush)
  5131. EndIf
  5132. If @error Then Return SetError(@error, @extended, False)
  5133. Return $aresult[0]
  5134. EndFunc
  5135.  
  5136. Func _winapi_findexecutable($sfilename, $sdirectory = "")
  5137. Local $aresult = DllCall("shell32.dll", "INT", "FindExecutableW", "wstr", $sfilename, "wstr", $sdirectory, "wstr", "")
  5138. If @error Then Return SetError(@error, @extended, "")
  5139. If $aresult[0] <= 32 Then Return SetError(10, $aresult[0], "")
  5140. Return SetExtended($aresult[0], $aresult[3])
  5141. EndFunc
  5142.  
  5143. Func _winapi_findwindow($sclassname, $swindowname)
  5144. Local $aresult = DllCall("user32.dll", "hwnd", "FindWindowW", "wstr", $sclassname, "wstr", $swindowname)
  5145. If @error Then Return SetError(@error, @extended, 0)
  5146. Return $aresult[0]
  5147. EndFunc
  5148.  
  5149. Func _winapi_flashwindow($hwnd, $binvert = True)
  5150. Local $aresult = DllCall("user32.dll", "bool", "FlashWindow", "hwnd", $hwnd, "bool", $binvert)
  5151. If @error Then Return SetError(@error, @extended, False)
  5152. Return $aresult[0]
  5153. EndFunc
  5154.  
  5155. Func _winapi_flashwindowex($hwnd, $iflags = 3, $icount = 3, $itimeout = 0)
  5156. Local $tflash = DllStructCreate($tagflashwinfo)
  5157. Local $iflash = DllStructGetSize($tflash)
  5158. Local $imode = 0
  5159. If BitAND($iflags, 1) <> 0 Then $imode = BitOR($imode, $flashw_caption)
  5160. If BitAND($iflags, 2) <> 0 Then $imode = BitOR($imode, $flashw_tray)
  5161. If BitAND($iflags, 4) <> 0 Then $imode = BitOR($imode, $flashw_timer)
  5162. If BitAND($iflags, 8) <> 0 Then $imode = BitOR($imode, $flashw_timernofg)
  5163. DllStructSetData($tflash, "Size", $iflash)
  5164. DllStructSetData($tflash, "hWnd", $hwnd)
  5165. DllStructSetData($tflash, "Flags", $imode)
  5166. DllStructSetData($tflash, "Count", $icount)
  5167. DllStructSetData($tflash, "Timeout", $itimeout)
  5168. Local $aresult = DllCall("user32.dll", "bool", "FlashWindowEx", "struct*", $tflash)
  5169. If @error Then Return SetError(@error, @extended, False)
  5170. Return $aresult[0]
  5171. EndFunc
  5172.  
  5173. Func _winapi_floattoint($nfloat)
  5174. Local $tfloat = DllStructCreate("float")
  5175. Local $tint = DllStructCreate("int", DllStructGetPtr($tfloat))
  5176. DllStructSetData($tfloat, 1, $nfloat)
  5177. Return DllStructGetData($tint, 1)
  5178. EndFunc
  5179.  
  5180. Func _winapi_flushfilebuffers($hfile)
  5181. Local $aresult = DllCall("kernel32.dll", "bool", "FlushFileBuffers", "handle", $hfile)
  5182. If @error Then Return SetError(@error, @extended, False)
  5183. Return $aresult[0]
  5184. EndFunc
  5185.  
  5186. Func _winapi_formatmessage($iflags, $psource, $imessageid, $ilanguageid, ByRef $pbuffer, $isize, $varguments)
  5187. Local $sbuffertype = "struct*"
  5188. If IsString($pbuffer) Then $sbuffertype = "wstr"
  5189. Local $aresult = DllCall("kernel32.dll", "dword", "FormatMessageW", "dword", $iflags, "struct*", $psource, "dword", $imessageid, "dword", $ilanguageid, $sbuffertype, $pbuffer, "dword", $isize, "ptr", $varguments)
  5190. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  5191. If $sbuffertype = "wstr" Then $pbuffer = $aresult[5]
  5192. Return $aresult[0]
  5193. EndFunc
  5194.  
  5195. Func _winapi_framerect($hdc, $trect, $hbrush)
  5196. Local $aresult = DllCall("user32.dll", "int", "FrameRect", "handle", $hdc, "struct*", $trect, "handle", $hbrush)
  5197. If @error Then Return SetError(@error, @extended, False)
  5198. Return $aresult[0]
  5199. EndFunc
  5200.  
  5201. Func _winapi_freelibrary($hmodule)
  5202. Local $aresult = DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hmodule)
  5203. If @error Then Return SetError(@error, @extended, False)
  5204. Return $aresult[0]
  5205. EndFunc
  5206.  
  5207. Func _winapi_getancestor($hwnd, $iflags = 1)
  5208. Local $aresult = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hwnd, "uint", $iflags)
  5209. If @error Then Return SetError(@error, @extended, 0)
  5210. Return $aresult[0]
  5211. EndFunc
  5212.  
  5213. Func _winapi_getasynckeystate($ikey)
  5214. Local $aresult = DllCall("user32.dll", "short", "GetAsyncKeyState", "int", $ikey)
  5215. If @error Then Return SetError(@error, @extended, 0)
  5216. Return $aresult[0]
  5217. EndFunc
  5218.  
  5219. Func _winapi_getbkmode($hdc)
  5220. Local $aresult = DllCall("gdi32.dll", "int", "GetBkMode", "handle", $hdc)
  5221. If @error Then Return SetError(@error, @extended, 0)
  5222. Return $aresult[0]
  5223. EndFunc
  5224.  
  5225. Func _winapi_getclassname($hwnd)
  5226. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  5227. Local $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  5228. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
  5229. Return SetExtended($aresult[0], $aresult[2])
  5230. EndFunc
  5231.  
  5232. Func _winapi_getclientheight($hwnd)
  5233. Local $trect = _winapi_getclientrect($hwnd)
  5234. If @error Then Return SetError(@error, @extended, 0)
  5235. Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
  5236. EndFunc
  5237.  
  5238. Func _winapi_getclientwidth($hwnd)
  5239. Local $trect = _winapi_getclientrect($hwnd)
  5240. If @error Then Return SetError(@error, @extended, 0)
  5241. Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  5242. EndFunc
  5243.  
  5244. Func _winapi_getclientrect($hwnd)
  5245. Local $trect = DllStructCreate($tagrect)
  5246. Local $aret = DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "struct*", $trect)
  5247. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5248. Return $trect
  5249. EndFunc
  5250.  
  5251. Func _winapi_getcurrentprocess()
  5252. Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentProcess")
  5253. If @error Then Return SetError(@error, @extended, 0)
  5254. Return $aresult[0]
  5255. EndFunc
  5256.  
  5257. Func _winapi_getcurrentprocessid()
  5258. Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentProcessId")
  5259. If @error Then Return SetError(@error, @extended, 0)
  5260. Return $aresult[0]
  5261. EndFunc
  5262.  
  5263. Func _winapi_getcurrentthread()
  5264. Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  5265. If @error Then Return SetError(@error, @extended, 0)
  5266. Return $aresult[0]
  5267. EndFunc
  5268.  
  5269. Func _winapi_getcurrentthreadid()
  5270. Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
  5271. If @error Then Return SetError(@error, @extended, 0)
  5272. Return $aresult[0]
  5273. EndFunc
  5274.  
  5275. Func _winapi_getcursorinfo()
  5276. Local $tcursor = DllStructCreate($tagcursorinfo)
  5277. Local $icursor = DllStructGetSize($tcursor)
  5278. DllStructSetData($tcursor, "Size", $icursor)
  5279. Local $aret = DllCall("user32.dll", "bool", "GetCursorInfo", "struct*", $tcursor)
  5280. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5281. Local $acursor[5]
  5282. $acursor[0] = True
  5283. $acursor[1] = DllStructGetData($tcursor, "Flags") <> 0
  5284. $acursor[2] = DllStructGetData($tcursor, "hCursor")
  5285. $acursor[3] = DllStructGetData($tcursor, "X")
  5286. $acursor[4] = DllStructGetData($tcursor, "Y")
  5287. Return $acursor
  5288. EndFunc
  5289.  
  5290. Func _winapi_getdc($hwnd)
  5291. Local $aresult = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
  5292. If @error Then Return SetError(@error, @extended, 0)
  5293. Return $aresult[0]
  5294. EndFunc
  5295.  
  5296. Func _winapi_getdesktopwindow()
  5297. Local $aresult = DllCall("user32.dll", "hwnd", "GetDesktopWindow")
  5298. If @error Then Return SetError(@error, @extended, 0)
  5299. Return $aresult[0]
  5300. EndFunc
  5301.  
  5302. Func _winapi_getdevicecaps($hdc, $iindex)
  5303. Local $aresult = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hdc, "int", $iindex)
  5304. If @error Then Return SetError(@error, @extended, 0)
  5305. Return $aresult[0]
  5306. EndFunc
  5307.  
  5308. Func _winapi_getdibits($hdc, $hbitmap, $istartscan, $iscanlines, $pbits, $tbi, $iusage)
  5309. Local $aresult = DllCall("gdi32.dll", "int", "GetDIBits", "handle", $hdc, "handle", $hbitmap, "uint", $istartscan, "uint", $iscanlines, "struct*", $pbits, "struct*", $tbi, "uint", $iusage)
  5310. If @error Then Return SetError(@error, @extended, False)
  5311. Return $aresult[0]
  5312. EndFunc
  5313.  
  5314. Func _winapi_getdlgctrlid($hwnd)
  5315. Local $aresult = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
  5316. If @error Then Return SetError(@error, @extended, 0)
  5317. Return $aresult[0]
  5318. EndFunc
  5319.  
  5320. Func _winapi_getdlgitem($hwnd, $iitemid)
  5321. Local $aresult = DllCall("user32.dll", "hwnd", "GetDlgItem", "hwnd", $hwnd, "int", $iitemid)
  5322. If @error Then Return SetError(@error, @extended, 0)
  5323. Return $aresult[0]
  5324. EndFunc
  5325.  
  5326. Func _winapi_getfilesizeex($hfile)
  5327. Local $aresult = DllCall("kernel32.dll", "bool", "GetFileSizeEx", "handle", $hfile, "int64*", 0)
  5328. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, -1)
  5329. Return $aresult[2]
  5330. EndFunc
  5331.  
  5332. Func _winapi_getfocus()
  5333. Local $aresult = DllCall("user32.dll", "hwnd", "GetFocus")
  5334. If @error Then Return SetError(@error, @extended, 0)
  5335. Return $aresult[0]
  5336. EndFunc
  5337.  
  5338. Func _winapi_getforegroundwindow()
  5339. Local $aresult = DllCall("user32.dll", "hwnd", "GetForegroundWindow")
  5340. If @error Then Return SetError(@error, @extended, 0)
  5341. Return $aresult[0]
  5342. EndFunc
  5343.  
  5344. Func _winapi_getguiresources($iflag = 0, $hprocess = -1)
  5345. If $hprocess = -1 Then $hprocess = _winapi_getcurrentprocess()
  5346. Local $aresult = DllCall("user32.dll", "dword", "GetGuiResources", "handle", $hprocess, "dword", $iflag)
  5347. If @error Then Return SetError(@error, @extended, 0)
  5348. Return $aresult[0]
  5349. EndFunc
  5350.  
  5351. Func _winapi_geticoninfo($hicon)
  5352. Local $tinfo = DllStructCreate($tagiconinfo)
  5353. Local $aret = DllCall("user32.dll", "bool", "GetIconInfo", "handle", $hicon, "struct*", $tinfo)
  5354. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5355. Local $aicon[6]
  5356. $aicon[0] = True
  5357. $aicon[1] = DllStructGetData($tinfo, "Icon") <> 0
  5358. $aicon[2] = DllStructGetData($tinfo, "XHotSpot")
  5359. $aicon[3] = DllStructGetData($tinfo, "YHotSpot")
  5360. $aicon[4] = DllStructGetData($tinfo, "hMask")
  5361. $aicon[5] = DllStructGetData($tinfo, "hColor")
  5362. Return $aicon
  5363. EndFunc
  5364.  
  5365. Func _winapi_getlasterrormessage()
  5366. Local $ilasterror = _winapi_getlasterror()
  5367. Local $tbufferptr = DllStructCreate("ptr")
  5368. Local $ncount = _winapi_formatmessage(BitOR($format_message_allocate_buffer, $format_message_from_system), 0, $ilasterror, 0, $tbufferptr, 0, 0)
  5369. If @error Then Return SetError(@error, 0, "")
  5370. Local $stext = ""
  5371. Local $pbuffer = DllStructGetData($tbufferptr, 1)
  5372. If $pbuffer Then
  5373. If $ncount > 0 Then
  5374. Local $tbuffer = DllStructCreate("wchar[" & ($ncount + 1) & "]", $pbuffer)
  5375. $stext = DllStructGetData($tbuffer, 1)
  5376. If StringRight($stext, 2) = @CRLF Then $stext = StringTrimRight($stext, 2)
  5377. EndIf
  5378. _winapi_localfree($pbuffer)
  5379. EndIf
  5380. Return $stext
  5381. EndFunc
  5382.  
  5383. Func _winapi_getlayeredwindowattributes($hwnd, ByRef $itranscolor, ByRef $itransgui, $bcolorref = False)
  5384. $itranscolor = -1
  5385. $itransgui = -1
  5386. Local $aresult = DllCall("user32.dll", "bool", "GetLayeredWindowAttributes", "hwnd", $hwnd, "INT*", $itranscolor, "byte*", $itransgui, "dword*", 0)
  5387. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  5388. If NOT $bcolorref Then
  5389. $aresult[2] = Int(BinaryMid($aresult[2], 3, 1) & BinaryMid($aresult[2], 2, 1) & BinaryMid($aresult[2], 1, 1))
  5390. EndIf
  5391. $itranscolor = $aresult[2]
  5392. $itransgui = $aresult[3]
  5393. Return $aresult[4]
  5394. EndFunc
  5395.  
  5396. Func _winapi_getmodulehandle($smodulename)
  5397. Local $smodulenametype = "wstr"
  5398. If $smodulename = "" Then
  5399. $smodulename = 0
  5400. $smodulenametype = "ptr"
  5401. EndIf
  5402. Local $aresult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $smodulenametype, $smodulename)
  5403. If @error Then Return SetError(@error, @extended, 0)
  5404. Return $aresult[0]
  5405. EndFunc
  5406.  
  5407. Func _winapi_getmousepos($btoclient = False, $hwnd = 0)
  5408. Local $imode = Opt("MouseCoordMode", 1)
  5409. Local $apos = MouseGetPos()
  5410. Opt("MouseCoordMode", $imode)
  5411. Local $tpoint = DllStructCreate($tagpoint)
  5412. DllStructSetData($tpoint, "X", $apos[0])
  5413. DllStructSetData($tpoint, "Y", $apos[1])
  5414. If $btoclient AND NOT _winapi_screentoclient($hwnd, $tpoint) Then Return SetError(@error + 20, @extended, 0)
  5415. Return $tpoint
  5416. EndFunc
  5417.  
  5418. Func _winapi_getmouseposx($btoclient = False, $hwnd = 0)
  5419. Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
  5420. If @error Then Return SetError(@error, @extended, 0)
  5421. Return DllStructGetData($tpoint, "X")
  5422. EndFunc
  5423.  
  5424. Func _winapi_getmouseposy($btoclient = False, $hwnd = 0)
  5425. Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
  5426. If @error Then Return SetError(@error, @extended, 0)
  5427. Return DllStructGetData($tpoint, "Y")
  5428. EndFunc
  5429.  
  5430. Func _winapi_getobject($hobject, $isize, $pobject)
  5431. Local $aresult = DllCall("gdi32.dll", "int", "GetObjectW", "handle", $hobject, "int", $isize, "struct*", $pobject)
  5432. If @error Then Return SetError(@error, @extended, 0)
  5433. Return $aresult[0]
  5434. EndFunc
  5435.  
  5436. Func _winapi_getopenfilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
  5437. Local $ipathlen = 4096
  5438. Local $inulls = 0
  5439. Local $tofn = DllStructCreate($tagopenfilename)
  5440. Local $afiles[1] = [0]
  5441. Local $iflag = $iflags
  5442. Local $asflines = StringSplit($sfilter, "|")
  5443. Local $asfilter[$asflines[0] * 2 + 1]
  5444. Local $istart, $ifinal, $tagfilter
  5445. $asfilter[0] = $asflines[0] * 2
  5446. For $i = 1 To $asflines[0]
  5447. $istart = StringInStr($asflines[$i], "(", 0, 1)
  5448. $ifinal = StringInStr($asflines[$i], ")", 0, -1)
  5449. $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), $str_stripleading + $str_striptrailing)
  5450. $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), $str_stripleading + $str_striptrailing)
  5451. $tagfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
  5452. Next
  5453. Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
  5454. Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
  5455. Local $tfilter = DllStructCreate($tagfilter & "wchar")
  5456. Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
  5457. Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
  5458. For $i = 1 To $asfilter[0]
  5459. DllStructSetData($tfilter, $i, $asfilter[$i])
  5460. Next
  5461. DllStructSetData($ttitle, "Title", $stitle)
  5462. DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
  5463. DllStructSetData($tpath, "Path", $sdefaultfile)
  5464. DllStructSetData($textn, "Extension", $sdefaultext)
  5465. DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
  5466. DllStructSetData($tofn, "hwndOwner", $hwndowner)
  5467. DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
  5468. DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
  5469. DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
  5470. DllStructSetData($tofn, "nMaxFile", $ipathlen)
  5471. DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
  5472. DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
  5473. DllStructSetData($tofn, "Flags", $iflag)
  5474. DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
  5475. DllStructSetData($tofn, "FlagsEx", $iflagsex)
  5476. Local $ares = DllCall("comdlg32.dll", "bool", "GetOpenFileNameW", "struct*", $tofn)
  5477. If @error OR NOT $ares[0] Then Return SetError(@error + 10, @extended, $afiles)
  5478. If BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect AND BitAND($iflags, $ofn_explorer) = $ofn_explorer Then
  5479. For $x = 1 To $ipathlen
  5480. If DllStructGetData($tpath, "Path", $x) = Chr(0) Then
  5481. DllStructSetData($tpath, "Path", "|", $x)
  5482. $inulls += 1
  5483. Else
  5484. $inulls = 0
  5485. EndIf
  5486. If $inulls = 2 Then ExitLoop
  5487. Next
  5488. DllStructSetData($tpath, "Path", Chr(0), $x - 1)
  5489. $afiles = StringSplit(DllStructGetData($tpath, "Path"), "|")
  5490. If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  5491. Return StringSplit(DllStructGetData($tpath, "Path"), "|")
  5492. ElseIf BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect Then
  5493. $afiles = StringSplit(DllStructGetData($tpath, "Path"), " ")
  5494. If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  5495. Return StringSplit(StringReplace(DllStructGetData($tpath, "Path"), " ", "|"), "|")
  5496. Else
  5497. Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  5498. EndIf
  5499. EndFunc
  5500.  
  5501. Func _winapi_getoverlappedresult($hfile, $toverlapped, ByRef $ibytes, $bwait = False)
  5502. Local $aresult = DllCall("kernel32.dll", "bool", "GetOverlappedResult", "handle", $hfile, "struct*", $toverlapped, "dword*", 0, "bool", $bwait)
  5503. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, False)
  5504. $ibytes = $aresult[3]
  5505. Return $aresult[0]
  5506. EndFunc
  5507.  
  5508. Func _winapi_getparent($hwnd)
  5509. Local $aresult = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hwnd)
  5510. If @error Then Return SetError(@error, @extended, 0)
  5511. Return $aresult[0]
  5512. EndFunc
  5513.  
  5514. Func _winapi_getprocaddress($hmodule, $vname)
  5515. Local $stype = "str"
  5516. If IsNumber($vname) Then $stype = "word"
  5517. Local $aresult = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", $hmodule, $stype, $vname)
  5518. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  5519. Return $aresult[0]
  5520. EndFunc
  5521.  
  5522. Func _winapi_getprocessaffinitymask($hprocess)
  5523. Local $aresult = DllCall("kernel32.dll", "bool", "GetProcessAffinityMask", "handle", $hprocess, "dword_ptr*", 0, "dword_ptr*", 0)
  5524. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  5525. Local $amask[3]
  5526. $amask[0] = True
  5527. $amask[1] = $aresult[2]
  5528. $amask[2] = $aresult[3]
  5529. Return $amask
  5530. EndFunc
  5531.  
  5532. Func _winapi_getsavefilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
  5533. Local $ipathlen = 4096
  5534. Local $tofn = DllStructCreate($tagopenfilename)
  5535. Local $afiles[1] = [0]
  5536. Local $iflag = $iflags
  5537. Local $asflines = StringSplit($sfilter, "|")
  5538. Local $asfilter[$asflines[0] * 2 + 1]
  5539. Local $istart, $ifinal, $tagfilter
  5540. $asfilter[0] = $asflines[0] * 2
  5541. For $i = 1 To $asflines[0]
  5542. $istart = StringInStr($asflines[$i], "(", 0, 1)
  5543. $ifinal = StringInStr($asflines[$i], ")", 0, -1)
  5544. $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), $str_stripleading + $str_striptrailing)
  5545. $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), $str_stripleading + $str_striptrailing)
  5546. $tagfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
  5547. Next
  5548. Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
  5549. Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
  5550. Local $tfilter = DllStructCreate($tagfilter & "wchar")
  5551. Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
  5552. Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
  5553. For $i = 1 To $asfilter[0]
  5554. DllStructSetData($tfilter, $i, $asfilter[$i])
  5555. Next
  5556. DllStructSetData($ttitle, "Title", $stitle)
  5557. DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
  5558. DllStructSetData($tpath, "Path", $sdefaultfile)
  5559. DllStructSetData($textn, "Extension", $sdefaultext)
  5560. DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
  5561. DllStructSetData($tofn, "hwndOwner", $hwndowner)
  5562. DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
  5563. DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
  5564. DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
  5565. DllStructSetData($tofn, "nMaxFile", $ipathlen)
  5566. DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
  5567. DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
  5568. DllStructSetData($tofn, "Flags", $iflag)
  5569. DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
  5570. DllStructSetData($tofn, "FlagsEx", $iflagsex)
  5571. Local $ares = DllCall("comdlg32.dll", "bool", "GetSaveFileNameW", "struct*", $tofn)
  5572. If @error OR NOT $ares[0] Then Return SetError(@error + 10, @extended, $afiles)
  5573. Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  5574. EndFunc
  5575.  
  5576. Func _winapi_getstockobject($iobject)
  5577. Local $aresult = DllCall("gdi32.dll", "handle", "GetStockObject", "int", $iobject)
  5578. If @error Then Return SetError(@error, @extended, 0)
  5579. Return $aresult[0]
  5580. EndFunc
  5581.  
  5582. Func _winapi_getstdhandle($istdhandle)
  5583. If $istdhandle < 0 OR $istdhandle > 2 Then Return SetError(2, 0, -1)
  5584. Local Const $ahandle[3] = [-10, -11, -12]
  5585. Local $aresult = DllCall("kernel32.dll", "handle", "GetStdHandle", "dword", $ahandle[$istdhandle])
  5586. If @error Then Return SetError(@error, @extended, -1)
  5587. Return $aresult[0]
  5588. EndFunc
  5589.  
  5590. Func _winapi_getsyscolor($iindex)
  5591. Local $aresult = DllCall("user32.dll", "INT", "GetSysColor", "int", $iindex)
  5592. If @error Then Return SetError(@error, @extended, 0)
  5593. Return $aresult[0]
  5594. EndFunc
  5595.  
  5596. Func _winapi_getsyscolorbrush($iindex)
  5597. Local $aresult = DllCall("user32.dll", "handle", "GetSysColorBrush", "int", $iindex)
  5598. If @error Then Return SetError(@error, @extended, 0)
  5599. Return $aresult[0]
  5600. EndFunc
  5601.  
  5602. Func _winapi_getsystemmetrics($iindex)
  5603. Local $aresult = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $iindex)
  5604. If @error Then Return SetError(@error, @extended, 0)
  5605. Return $aresult[0]
  5606. EndFunc
  5607.  
  5608. Func _winapi_gettextextentpoint32($hdc, $stext)
  5609. Local $tsize = DllStructCreate($tagsize)
  5610. Local $isize = StringLen($stext)
  5611. Local $aret = DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hdc, "wstr", $stext, "int", $isize, "struct*", $tsize)
  5612. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5613. Return $tsize
  5614. EndFunc
  5615.  
  5616. Func _winapi_gettextmetrics($hdc)
  5617. Local $ttextmetric = DllStructCreate($tagtextmetric)
  5618. Local $aret = DllCall("gdi32.dll", "bool", "GetTextMetricsW", "handle", $hdc, "struct*", $ttextmetric)
  5619. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5620. Return $ttextmetric
  5621. EndFunc
  5622.  
  5623. Func _winapi_getwindow($hwnd, $icmd)
  5624. Local $aresult = DllCall("user32.dll", "hwnd", "GetWindow", "hwnd", $hwnd, "uint", $icmd)
  5625. If @error Then Return SetError(@error, @extended, 0)
  5626. Return $aresult[0]
  5627. EndFunc
  5628.  
  5629. Func _winapi_getwindowdc($hwnd)
  5630. Local $aresult = DllCall("user32.dll", "handle", "GetWindowDC", "hwnd", $hwnd)
  5631. If @error Then Return SetError(@error, @extended, 0)
  5632. Return $aresult[0]
  5633. EndFunc
  5634.  
  5635. Func _winapi_getwindowheight($hwnd)
  5636. Local $trect = _winapi_getwindowrect($hwnd)
  5637. If @error Then Return SetError(@error, @extended, 0)
  5638. Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
  5639. EndFunc
  5640.  
  5641. Func _winapi_getwindowlong($hwnd, $iindex)
  5642. Local $sfuncname = "GetWindowLongW"
  5643. If @AutoItX64 Then $sfuncname = "GetWindowLongPtrW"
  5644. Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex)
  5645. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  5646. Return $aresult[0]
  5647. EndFunc
  5648.  
  5649. Func _winapi_getwindowplacement($hwnd)
  5650. Local $twindowplacement = DllStructCreate($tagwindowplacement)
  5651. DllStructSetData($twindowplacement, "length", DllStructGetSize($twindowplacement))
  5652. Local $aret = DllCall("user32.dll", "bool", "GetWindowPlacement", "hwnd", $hwnd, "struct*", $twindowplacement)
  5653. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5654. Return $twindowplacement
  5655. EndFunc
  5656.  
  5657. Func _winapi_getwindowrect($hwnd)
  5658. Local $trect = DllStructCreate($tagrect)
  5659. Local $aret = DllCall("user32.dll", "bool", "GetWindowRect", "hwnd", $hwnd, "struct*", $trect)
  5660. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5661. Return $trect
  5662. EndFunc
  5663.  
  5664. Func _winapi_getwindowrgn($hwnd, $hrgn)
  5665. Local $aresult = DllCall("user32.dll", "int", "GetWindowRgn", "hwnd", $hwnd, "handle", $hrgn)
  5666. If @error Then Return SetError(@error, @extended, 0)
  5667. Return $aresult[0]
  5668. EndFunc
  5669.  
  5670. Func _winapi_getwindowtext($hwnd)
  5671. Local $aresult = DllCall("user32.dll", "int", "GetWindowTextW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  5672. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  5673. Return SetExtended($aresult[0], $aresult[2])
  5674. EndFunc
  5675.  
  5676. Func _winapi_getwindowthreadprocessid($hwnd, ByRef $ipid)
  5677. Local $aresult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
  5678. If @error Then Return SetError(@error, @extended, 0)
  5679. $ipid = $aresult[2]
  5680. Return $aresult[0]
  5681. EndFunc
  5682.  
  5683. Func _winapi_getwindowwidth($hwnd)
  5684. Local $trect = _winapi_getwindowrect($hwnd)
  5685. If @error Then Return SetError(@error, @extended, 0)
  5686. Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  5687. EndFunc
  5688.  
  5689. Func _winapi_getxyfrompoint(ByRef $tpoint, ByRef $ix, ByRef $iy)
  5690. $ix = DllStructGetData($tpoint, "X")
  5691. $iy = DllStructGetData($tpoint, "Y")
  5692. EndFunc
  5693.  
  5694. Func _winapi_globalmemorystatus()
  5695. Local $tmem = DllStructCreate($tagmemorystatusex)
  5696. DllStructSetData($tmem, 1, DllStructGetSize($tmem))
  5697. Local $aret = DllCall("kernel32.dll", "bool", "GlobalMemoryStatusEx", "struct*", $tmem)
  5698. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5699. Local $amem[7]
  5700. $amem[0] = DllStructGetData($tmem, 2)
  5701. $amem[1] = DllStructGetData($tmem, 3)
  5702. $amem[2] = DllStructGetData($tmem, 4)
  5703. $amem[3] = DllStructGetData($tmem, 5)
  5704. $amem[4] = DllStructGetData($tmem, 6)
  5705. $amem[5] = DllStructGetData($tmem, 7)
  5706. $amem[6] = DllStructGetData($tmem, 8)
  5707. Return $amem
  5708. EndFunc
  5709.  
  5710. Func _winapi_guidfromstring($sguid)
  5711. Local $tguid = DllStructCreate($tagguid)
  5712. _winapi_guidfromstringex($sguid, $tguid)
  5713. If @error Then Return SetError(@error + 10, @extended, 0)
  5714. Return $tguid
  5715. EndFunc
  5716.  
  5717. Func _winapi_guidfromstringex($sguid, $tguid)
  5718. Local $aresult = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sguid, "struct*", $tguid)
  5719. If @error Then Return SetError(@error, @extended, False)
  5720. Return $aresult[0]
  5721. EndFunc
  5722.  
  5723. Func _winapi_hiword($ilong)
  5724. Return BitShift($ilong, 16)
  5725. EndFunc
  5726.  
  5727. Func _winapi_inprocess($hwnd, ByRef $hlastwnd)
  5728. If $hwnd = $hlastwnd Then Return True
  5729. For $ii = $__g_ainprocess_winapi[0][0] To 1 Step -1
  5730. If $hwnd = $__g_ainprocess_winapi[$ii][0] Then
  5731. If $__g_ainprocess_winapi[$ii][1] Then
  5732. $hlastwnd = $hwnd
  5733. Return True
  5734. Else
  5735. Return False
  5736. EndIf
  5737. EndIf
  5738. Next
  5739. Local $ipid
  5740. _winapi_getwindowthreadprocessid($hwnd, $ipid)
  5741. Local $icount = $__g_ainprocess_winapi[0][0] + 1
  5742. If $icount >= 64 Then $icount = 1
  5743. $__g_ainprocess_winapi[0][0] = $icount
  5744. $__g_ainprocess_winapi[$icount][0] = $hwnd
  5745. $__g_ainprocess_winapi[$icount][1] = ($ipid = @AutoItPID)
  5746. Return $__g_ainprocess_winapi[$icount][1]
  5747. EndFunc
  5748.  
  5749. Func _winapi_inttofloat($iint)
  5750. Local $tint = DllStructCreate("int")
  5751. Local $tfloat = DllStructCreate("float", DllStructGetPtr($tint))
  5752. DllStructSetData($tint, 1, $iint)
  5753. Return DllStructGetData($tfloat, 1)
  5754. EndFunc
  5755.  
  5756. Func _winapi_isclassname($hwnd, $sclassname)
  5757. Local $sseparator = Opt("GUIDataSeparatorChar")
  5758. Local $aclassname = StringSplit($sclassname, $sseparator)
  5759. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  5760. Local $sclasscheck = _winapi_getclassname($hwnd)
  5761. For $x = 1 To UBound($aclassname) - 1
  5762. If StringUpper(StringMid($sclasscheck, 1, StringLen($aclassname[$x]))) = StringUpper($aclassname[$x]) Then Return True
  5763. Next
  5764. Return False
  5765. EndFunc
  5766.  
  5767. Func _winapi_iswindow($hwnd)
  5768. Local $aresult = DllCall("user32.dll", "bool", "IsWindow", "hwnd", $hwnd)
  5769. If @error Then Return SetError(@error, @extended, 0)
  5770. Return $aresult[0]
  5771. EndFunc
  5772.  
  5773. Func _winapi_iswindowvisible($hwnd)
  5774. Local $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
  5775. If @error Then Return SetError(@error, @extended, 0)
  5776. Return $aresult[0]
  5777. EndFunc
  5778.  
  5779. Func _winapi_invalidaterect($hwnd, $trect = 0, $berase = True)
  5780. Local $aresult = DllCall("user32.dll", "bool", "InvalidateRect", "hwnd", $hwnd, "struct*", $trect, "bool", $berase)
  5781. If @error Then Return SetError(@error, @extended, False)
  5782. Return $aresult[0]
  5783. EndFunc
  5784.  
  5785. Func _winapi_lineto($hdc, $ix, $iy)
  5786. Local $aresult = DllCall("gdi32.dll", "bool", "LineTo", "handle", $hdc, "int", $ix, "int", $iy)
  5787. If @error Then Return SetError(@error, @extended, False)
  5788. Return $aresult[0]
  5789. EndFunc
  5790.  
  5791. Func _winapi_loadbitmap($hinstance, $sbitmap)
  5792. Local $sbitmaptype = "int"
  5793. If IsString($sbitmap) Then $sbitmaptype = "wstr"
  5794. Local $aresult = DllCall("user32.dll", "handle", "LoadBitmapW", "handle", $hinstance, $sbitmaptype, $sbitmap)
  5795. If @error Then Return SetError(@error, @extended, 0)
  5796. Return $aresult[0]
  5797. EndFunc
  5798.  
  5799. Func _winapi_loadimage($hinstance, $simage, $itype, $ixdesired, $iydesired, $iload)
  5800. Local $aresult, $simagetype = "int"
  5801. If IsString($simage) Then $simagetype = "wstr"
  5802. $aresult = DllCall("user32.dll", "handle", "LoadImageW", "handle", $hinstance, $simagetype, $simage, "uint", $itype, "int", $ixdesired, "int", $iydesired, "uint", $iload)
  5803. If @error Then Return SetError(@error, @extended, 0)
  5804. Return $aresult[0]
  5805. EndFunc
  5806.  
  5807. Func _winapi_loadlibrary($sfilename)
  5808. Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sfilename)
  5809. If @error Then Return SetError(@error, @extended, 0)
  5810. Return $aresult[0]
  5811. EndFunc
  5812.  
  5813. Func _winapi_loadlibraryex($sfilename, $iflags = 0)
  5814. Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryExW", "wstr", $sfilename, "ptr", 0, "dword", $iflags)
  5815. If @error Then Return SetError(@error, @extended, 0)
  5816. Return $aresult[0]
  5817. EndFunc
  5818.  
  5819. Func _winapi_loadshell32icon($iiconid)
  5820. Local $ticons = DllStructCreate("ptr Data")
  5821. Local $iicons = _winapi_extracticonex("shell32.dll", $iiconid, 0, $ticons, 1)
  5822. If @error Then Return SetError(@error, @extended, 0)
  5823. If $iicons <= 0 Then Return SetError(10, 0, 0)
  5824. Return DllStructGetData($ticons, "Data")
  5825. EndFunc
  5826.  
  5827. Func _winapi_loadstring($hinstance, $istringid)
  5828. Local $aresult = DllCall("user32.dll", "int", "LoadStringW", "handle", $hinstance, "uint", $istringid, "wstr", "", "int", 4096)
  5829. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  5830. Return SetExtended($aresult[0], $aresult[3])
  5831. EndFunc
  5832.  
  5833. Func _winapi_localfree($hmemory)
  5834. Local $aresult = DllCall("kernel32.dll", "handle", "LocalFree", "handle", $hmemory)
  5835. If @error Then Return SetError(@error, @extended, False)
  5836. Return $aresult[0]
  5837. EndFunc
  5838.  
  5839. Func _winapi_loword($ilong)
  5840. Return BitAND($ilong, 65535)
  5841. EndFunc
  5842.  
  5843. Func _winapi_makelangid($ilngidprimary, $ilngidsub)
  5844. Return BitOR(BitShift($ilngidsub, -10), $ilngidprimary)
  5845. EndFunc
  5846.  
  5847. Func _winapi_makelcid($ilngid, $isortid)
  5848. Return BitOR(BitShift($isortid, -16), $ilngid)
  5849. EndFunc
  5850.  
  5851. Func _winapi_makelong($ilo, $ihi)
  5852. Return BitOR(BitShift($ihi, -16), BitAND($ilo, 65535))
  5853. EndFunc
  5854.  
  5855. Func _winapi_makeqword($ilodword, $ihidword)
  5856. Local $tint64 = DllStructCreate("uint64")
  5857. Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
  5858. DllStructSetData($tdwords, 1, $ilodword)
  5859. DllStructSetData($tdwords, 2, $ihidword)
  5860. Return DllStructGetData($tint64, 1)
  5861. EndFunc
  5862.  
  5863. Func _winapi_messagebeep($itype = 1)
  5864. Local $isound
  5865. Switch $itype
  5866. Case 1
  5867. $isound = 0
  5868. Case 2
  5869. $isound = 16
  5870. Case 3
  5871. $isound = 32
  5872. Case 4
  5873. $isound = 48
  5874. Case 5
  5875. $isound = 64
  5876. Case Else
  5877. $isound = -1
  5878. EndSwitch
  5879. Local $aresult = DllCall("user32.dll", "bool", "MessageBeep", "uint", $isound)
  5880. If @error Then Return SetError(@error, @extended, False)
  5881. Return $aresult[0]
  5882. EndFunc
  5883.  
  5884. Func _winapi_msgbox($iflags, $stitle, $stext)
  5885. BlockInput(0)
  5886. MsgBox($iflags, $stitle, $stext & " ")
  5887. EndFunc
  5888.  
  5889. Func _winapi_mouse_event($iflags, $ix = 0, $iy = 0, $idata = 0, $iextrainfo = 0)
  5890. DllCall("user32.dll", "none", "mouse_event", "dword", $iflags, "dword", $ix, "dword", $iy, "dword", $idata, "ulong_ptr", $iextrainfo)
  5891. If @error Then Return SetError(@error, @extended)
  5892. EndFunc
  5893.  
  5894. Func _winapi_moveto($hdc, $ix, $iy)
  5895. Local $aresult = DllCall("gdi32.dll", "bool", "MoveToEx", "handle", $hdc, "int", $ix, "int", $iy, "ptr", 0)
  5896. If @error Then Return SetError(@error, @extended, False)
  5897. Return $aresult[0]
  5898. EndFunc
  5899.  
  5900. Func _winapi_movewindow($hwnd, $ix, $iy, $iwidth, $iheight, $brepaint = True)
  5901. Local $aresult = DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hwnd, "int", $ix, "int", $iy, "int", $iwidth, "int", $iheight, "bool", $brepaint)
  5902. If @error Then Return SetError(@error, @extended, False)
  5903. Return $aresult[0]
  5904. EndFunc
  5905.  
  5906. Func _winapi_muldiv($inumber, $inumerator, $idenominator)
  5907. Local $aresult = DllCall("kernel32.dll", "int", "MulDiv", "int", $inumber, "int", $inumerator, "int", $idenominator)
  5908. If @error Then Return SetError(@error, @extended, -1)
  5909. Return $aresult[0]
  5910. EndFunc
  5911.  
  5912. Func _winapi_multibytetowidechar($vtext, $icodepage = 0, $iflags = 0, $bretstring = False)
  5913. Local $stexttype = "str"
  5914. If NOT IsString($vtext) Then $stexttype = "struct*"
  5915. Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "ptr", 0, "int", 0)
  5916. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  5917. Local $iout = $aresult[0]
  5918. Local $tout = DllStructCreate("wchar[" & $iout & "]")
  5919. $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "struct*", $tout, "int", $iout)
  5920. If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, 0)
  5921. If $bretstring Then Return DllStructGetData($tout, 1)
  5922. Return $tout
  5923. EndFunc
  5924.  
  5925. Func _winapi_multibytetowidecharex($stext, $ptext, $icodepage = 0, $iflags = 0)
  5926. Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, "STR", $stext, "int", -1, "struct*", $ptext, "int", (StringLen($stext) + 1) * 2)
  5927. If @error Then Return SetError(@error, @extended, False)
  5928. Return $aresult[0]
  5929. EndFunc
  5930.  
  5931. Func _winapi_openprocess($iaccess, $binherit, $ipid, $bdebugpriv = False)
  5932. Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
  5933. If @error Then Return SetError(@error, @extended, 0)
  5934. If $aresult[0] Then Return $aresult[0]
  5935. If NOT $bdebugpriv Then Return SetError(100, 0, 0)
  5936. Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  5937. If @error Then Return SetError(@error + 10, @extended, 0)
  5938. _security__setprivilege($htoken, "SeDebugPrivilege", True)
  5939. Local $ierror = @error
  5940. Local $iextended = @extended
  5941. Local $iret = 0
  5942. If NOT @error Then
  5943. $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
  5944. $ierror = @error
  5945. $iextended = @extended
  5946. If $aresult[0] Then $iret = $aresult[0]
  5947. _security__setprivilege($htoken, "SeDebugPrivilege", False)
  5948. If @error Then
  5949. $ierror = @error + 20
  5950. $iextended = @extended
  5951. EndIf
  5952. Else
  5953. $ierror = @error + 30
  5954. EndIf
  5955. _winapi_closehandle($htoken)
  5956. Return SetError($ierror, $iextended, $iret)
  5957. EndFunc
  5958.  
  5959. Func __winapi_parsefiledialogpath($spath)
  5960. Local $afiles[3]
  5961. $afiles[0] = 2
  5962. Local $stemp = StringMid($spath, 1, StringInStr($spath, "\", 0, -1) - 1)
  5963. $afiles[1] = $stemp
  5964. $afiles[2] = StringMid($spath, StringInStr($spath, "\", 0, -1) + 1)
  5965. Return $afiles
  5966. EndFunc
  5967.  
  5968. Func _winapi_pathfindonpath(Const $sfilepath, $aextrapaths = "", Const $spathdelimiter = @LF)
  5969. Local $iextracount = 0
  5970. If IsString($aextrapaths) Then
  5971. If StringLen($aextrapaths) Then
  5972. $aextrapaths = StringSplit($aextrapaths, $spathdelimiter, $str_entiresplit + $str_nocount)
  5973. $iextracount = UBound($aextrapaths, $ubound_rows)
  5974. EndIf
  5975. ElseIf IsArray($aextrapaths) Then
  5976. $iextracount = UBound($aextrapaths)
  5977. EndIf
  5978. Local $tpaths, $tpathptrs
  5979. If $iextracount Then
  5980. Local $tagstruct = ""
  5981. For $path In $aextrapaths
  5982. $tagstruct &= "wchar[" & StringLen($path) + 1 & "];"
  5983. Next
  5984. $tpaths = DllStructCreate($tagstruct)
  5985. $tpathptrs = DllStructCreate("ptr[" & $iextracount + 1 & "]")
  5986. For $i = 1 To $iextracount
  5987. DllStructSetData($tpaths, $i, $aextrapaths[$i - 1])
  5988. DllStructSetData($tpathptrs, 1, DllStructGetPtr($tpaths, $i), $i)
  5989. Next
  5990. DllStructSetData($tpathptrs, 1, Ptr(0), $iextracount + 1)
  5991. EndIf
  5992. Local $aresult = DllCall("shlwapi.dll", "bool", "PathFindOnPathW", "wstr", $sfilepath, "struct*", $tpathptrs)
  5993. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, $sfilepath)
  5994. Return $aresult[1]
  5995. EndFunc
  5996.  
  5997. Func _winapi_pointfromrect(ByRef $trect, $bcenter = True)
  5998. Local $ix1 = DllStructGetData($trect, "Left")
  5999. Local $iy1 = DllStructGetData($trect, "Top")
  6000. Local $ix2 = DllStructGetData($trect, "Right")
  6001. Local $iy2 = DllStructGetData($trect, "Bottom")
  6002. If $bcenter Then
  6003. $ix1 = $ix1 + (($ix2 - $ix1) / 2)
  6004. $iy1 = $iy1 + (($iy2 - $iy1) / 2)
  6005. EndIf
  6006. Local $tpoint = DllStructCreate($tagpoint)
  6007. DllStructSetData($tpoint, "X", $ix1)
  6008. DllStructSetData($tpoint, "Y", $iy1)
  6009. Return $tpoint
  6010. EndFunc
  6011.  
  6012. Func _winapi_postmessage($hwnd, $imsg, $wparam, $lparam)
  6013. Local $aresult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
  6014. If @error Then Return SetError(@error, @extended, False)
  6015. Return $aresult[0]
  6016. EndFunc
  6017.  
  6018. Func _winapi_primarylangid($ilngid)
  6019. Return BitAND($ilngid, 1023)
  6020. EndFunc
  6021.  
  6022. Func _winapi_ptinrect(ByRef $trect, ByRef $tpoint)
  6023. Local $aresult = DllCall("user32.dll", "bool", "PtInRect", "struct*", $trect, "struct", $tpoint)
  6024. If @error Then Return SetError(@error, @extended, False)
  6025. Return $aresult[0]
  6026. EndFunc
  6027.  
  6028. Func _winapi_readfile($hfile, $pbuffer, $itoread, ByRef $iread, $toverlapped = 0)
  6029. Local $aresult = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $pbuffer, "dword", $itoread, "dword*", 0, "struct*", $toverlapped)
  6030. If @error Then Return SetError(@error, @extended, False)
  6031. $iread = $aresult[4]
  6032. Return $aresult[0]
  6033. EndFunc
  6034.  
  6035. Func _winapi_readprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iread)
  6036. Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, "struct*", $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  6037. If @error Then Return SetError(@error, @extended, False)
  6038. $iread = $aresult[5]
  6039. Return $aresult[0]
  6040. EndFunc
  6041.  
  6042. Func _winapi_rectisempty(ByRef $trect)
  6043. Return (DllStructGetData($trect, "Left") = 0) AND (DllStructGetData($trect, "Top") = 0) AND (DllStructGetData($trect, "Right") = 0) AND (DllStructGetData($trect, "Bottom") = 0)
  6044. EndFunc
  6045.  
  6046. Func _winapi_redrawwindow($hwnd, $trect = 0, $hregion = 0, $iflags = 5)
  6047. Local $aresult = DllCall("user32.dll", "bool", "RedrawWindow", "hwnd", $hwnd, "struct*", $trect, "handle", $hregion, "uint", $iflags)
  6048. If @error Then Return SetError(@error, @extended, False)
  6049. Return $aresult[0]
  6050. EndFunc
  6051.  
  6052. Func _winapi_registerwindowmessage($smessage)
  6053. Local $aresult = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $smessage)
  6054. If @error Then Return SetError(@error, @extended, 0)
  6055. Return $aresult[0]
  6056. EndFunc
  6057.  
  6058. Func _winapi_releasecapture()
  6059. Local $aresult = DllCall("user32.dll", "bool", "ReleaseCapture")
  6060. If @error Then Return SetError(@error, @extended, False)
  6061. Return $aresult[0]
  6062. EndFunc
  6063.  
  6064. Func _winapi_releasedc($hwnd, $hdc)
  6065. Local $aresult = DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
  6066. If @error Then Return SetError(@error, @extended, False)
  6067. Return $aresult[0]
  6068. EndFunc
  6069.  
  6070. Func _winapi_screentoclient($hwnd, ByRef $tpoint)
  6071. Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient", "hwnd", $hwnd, "struct*", $tpoint)
  6072. If @error Then Return SetError(@error, @extended, False)
  6073. Return $aresult[0]
  6074. EndFunc
  6075.  
  6076. Func _winapi_selectobject($hdc, $hgdiobj)
  6077. Local $aresult = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hgdiobj)
  6078. If @error Then Return SetError(@error, @extended, False)
  6079. Return $aresult[0]
  6080. EndFunc
  6081.  
  6082. Func _winapi_setbkcolor($hdc, $icolor)
  6083. Local $aresult = DllCall("gdi32.dll", "INT", "SetBkColor", "handle", $hdc, "INT", $icolor)
  6084. If @error Then Return SetError(@error, @extended, -1)
  6085. Return $aresult[0]
  6086. EndFunc
  6087.  
  6088. Func _winapi_setbkmode($hdc, $ibkmode)
  6089. Local $aresult = DllCall("gdi32.dll", "int", "SetBkMode", "handle", $hdc, "int", $ibkmode)
  6090. If @error Then Return SetError(@error, @extended, 0)
  6091. Return $aresult[0]
  6092. EndFunc
  6093.  
  6094. Func _winapi_setcapture($hwnd)
  6095. Local $aresult = DllCall("user32.dll", "hwnd", "SetCapture", "hwnd", $hwnd)
  6096. If @error Then Return SetError(@error, @extended, 0)
  6097. Return $aresult[0]
  6098. EndFunc
  6099.  
  6100. Func _winapi_setcursor($hcursor)
  6101. Local $aresult = DllCall("user32.dll", "handle", "SetCursor", "handle", $hcursor)
  6102. If @error Then Return SetError(@error, @extended, 0)
  6103. Return $aresult[0]
  6104. EndFunc
  6105.  
  6106. Func _winapi_setdefaultprinter($sprinter)
  6107. Local $aresult = DllCall("winspool.drv", "bool", "SetDefaultPrinterW", "wstr", $sprinter)
  6108. If @error Then Return SetError(@error, @extended, False)
  6109. Return $aresult[0]
  6110. EndFunc
  6111.  
  6112. Func _winapi_setdibits($hdc, $hbitmap, $istartscan, $iscanlines, $pbits, $tbmi, $icoloruse = 0)
  6113. Local $aresult = DllCall("gdi32.dll", "int", "SetDIBits", "handle", $hdc, "handle", $hbitmap, "uint", $istartscan, "uint", $iscanlines, "struct*", $pbits, "struct*", $tbmi, "INT", $icoloruse)
  6114. If @error Then Return SetError(@error, @extended, False)
  6115. Return $aresult[0]
  6116. EndFunc
  6117.  
  6118. Func _winapi_setendoffile($hfile)
  6119. Local $aresult = DllCall("kernel32.dll", "bool", "SetEndOfFile", "handle", $hfile)
  6120. If @error Then Return SetError(@error, @extended, False)
  6121. Return $aresult[0]
  6122. EndFunc
  6123.  
  6124. Func _winapi_setevent($hevent)
  6125. Local $aresult = DllCall("kernel32.dll", "bool", "SetEvent", "handle", $hevent)
  6126. If @error Then Return SetError(@error, @extended, False)
  6127. Return $aresult[0]
  6128. EndFunc
  6129.  
  6130. Func _winapi_setfilepointer($hfile, $ipos, $imethod = 0)
  6131. Local $aresult = DllCall("kernel32.dll", "INT", "SetFilePointer", "handle", $hfile, "long", $ipos, "ptr", 0, "long", $imethod)
  6132. If @error Then Return SetError(@error, @extended, -1)
  6133. Return $aresult[0]
  6134. EndFunc
  6135.  
  6136. Func _winapi_setfocus($hwnd)
  6137. Local $aresult = DllCall("user32.dll", "hwnd", "SetFocus", "hwnd", $hwnd)
  6138. If @error Then Return SetError(@error, @extended, 0)
  6139. Return $aresult[0]
  6140. EndFunc
  6141.  
  6142. Func _winapi_setfont($hwnd, $hfont, $bredraw = True)
  6143. _sendmessage($hwnd, $__winapiconstant_wm_setfont, $hfont, $bredraw, 0, "hwnd")
  6144. EndFunc
  6145.  
  6146. Func _winapi_sethandleinformation($hobject, $imask, $iflags)
  6147. Local $aresult = DllCall("kernel32.dll", "bool", "SetHandleInformation", "handle", $hobject, "dword", $imask, "dword", $iflags)
  6148. If @error Then Return SetError(@error, @extended, False)
  6149. Return $aresult[0]
  6150. EndFunc
  6151.  
  6152. Func _winapi_setlayeredwindowattributes($hwnd, $itranscolor, $itransgui = 255, $iflags = 3, $bcolorref = False)
  6153. If $iflags = Default OR $iflags = "" OR $iflags < 0 Then $iflags = 3
  6154. If NOT $bcolorref Then
  6155. $itranscolor = Int(BinaryMid($itranscolor, 3, 1) & BinaryMid($itranscolor, 2, 1) & BinaryMid($itranscolor, 1, 1))
  6156. EndIf
  6157. Local $aresult = DllCall("user32.dll", "bool", "SetLayeredWindowAttributes", "hwnd", $hwnd, "INT", $itranscolor, "byte", $itransgui, "dword", $iflags)
  6158. If @error Then Return SetError(@error, @extended, False)
  6159. Return $aresult[0]
  6160. EndFunc
  6161.  
  6162. Func _winapi_setparent($hwndchild, $hwndparent)
  6163. Local $aresult = DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hwndchild, "hwnd", $hwndparent)
  6164. If @error Then Return SetError(@error, @extended, 0)
  6165. Return $aresult[0]
  6166. EndFunc
  6167.  
  6168. Func _winapi_setprocessaffinitymask($hprocess, $imask)
  6169. Local $aresult = DllCall("kernel32.dll", "bool", "SetProcessAffinityMask", "handle", $hprocess, "ulong_ptr", $imask)
  6170. If @error Then Return SetError(@error, @extended, False)
  6171. Return $aresult[0]
  6172. EndFunc
  6173.  
  6174. Func _winapi_setsyscolors($velements, $vcolors)
  6175. Local $bisearray = IsArray($velements), $biscarray = IsArray($vcolors)
  6176. Local $ielementnum
  6177. If NOT $biscarray AND NOT $bisearray Then
  6178. $ielementnum = 1
  6179. ElseIf $biscarray OR $bisearray Then
  6180. If NOT $biscarray OR NOT $bisearray Then Return SetError(-1, -1, False)
  6181. If UBound($velements) <> UBound($vcolors) Then Return SetError(-1, -1, False)
  6182. $ielementnum = UBound($velements)
  6183. EndIf
  6184. Local $telements = DllStructCreate("int Element[" & $ielementnum & "]")
  6185. Local $tcolors = DllStructCreate("INT NewColor[" & $ielementnum & "]")
  6186. If NOT $bisearray Then
  6187. DllStructSetData($telements, "Element", $velements, 1)
  6188. Else
  6189. For $x = 0 To $ielementnum - 1
  6190. DllStructSetData($telements, "Element", $velements[$x], $x + 1)
  6191. Next
  6192. EndIf
  6193. If NOT $biscarray Then
  6194. DllStructSetData($tcolors, "NewColor", $vcolors, 1)
  6195. Else
  6196. For $x = 0 To $ielementnum - 1
  6197. DllStructSetData($tcolors, "NewColor", $vcolors[$x], $x + 1)
  6198. Next
  6199. EndIf
  6200. Local $aresult = DllCall("user32.dll", "bool", "SetSysColors", "int", $ielementnum, "struct*", $telements, "struct*", $tcolors)
  6201. If @error Then Return SetError(@error, @extended, False)
  6202. Return $aresult[0]
  6203. EndFunc
  6204.  
  6205. Func _winapi_settextcolor($hdc, $icolor)
  6206. Local $aresult = DllCall("gdi32.dll", "INT", "SetTextColor", "handle", $hdc, "INT", $icolor)
  6207. If @error Then Return SetError(@error, @extended, -1)
  6208. Return $aresult[0]
  6209. EndFunc
  6210.  
  6211. Func _winapi_setwindowlong($hwnd, $iindex, $ivalue)
  6212. _winapi_setlasterror(0)
  6213. Local $sfuncname = "SetWindowLongW"
  6214. If @AutoItX64 Then $sfuncname = "SetWindowLongPtrW"
  6215. Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex, "long_ptr", $ivalue)
  6216. If @error Then Return SetError(@error, @extended, 0)
  6217. Return $aresult[0]
  6218. EndFunc
  6219.  
  6220. Func _winapi_setwindowplacement($hwnd, $twindowplacement)
  6221. Local $aresult = DllCall("user32.dll", "bool", "SetWindowPlacement", "hwnd", $hwnd, "struct*", $twindowplacement)
  6222. If @error Then Return SetError(@error, @extended, False)
  6223. Return $aresult[0]
  6224. EndFunc
  6225.  
  6226. Func _winapi_setwindowpos($hwnd, $hafter, $ix, $iy, $icx, $icy, $iflags)
  6227. Local $aresult = DllCall("user32.dll", "bool", "SetWindowPos", "hwnd", $hwnd, "hwnd", $hafter, "int", $ix, "int", $iy, "int", $icx, "int", $icy, "uint", $iflags)
  6228. If @error Then Return SetError(@error, @extended, False)
  6229. Return $aresult[0]
  6230. EndFunc
  6231.  
  6232. Func _winapi_setwindowrgn($hwnd, $hrgn, $bredraw = True)
  6233. Local $aresult = DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hwnd, "handle", $hrgn, "bool", $bredraw)
  6234. If @error Then Return SetError(@error, @extended, False)
  6235. Return $aresult[0]
  6236. EndFunc
  6237.  
  6238. Func _winapi_setwindowshookex($ihook, $pproc, $hdll, $ithreadid = 0)
  6239. Local $aresult = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", $ihook, "ptr", $pproc, "handle", $hdll, "dword", $ithreadid)
  6240. If @error Then Return SetError(@error, @extended, 0)
  6241. Return $aresult[0]
  6242. EndFunc
  6243.  
  6244. Func _winapi_setwindowtext($hwnd, $stext)
  6245. Local $aresult = DllCall("user32.dll", "bool", "SetWindowTextW", "hwnd", $hwnd, "wstr", $stext)
  6246. If @error Then Return SetError(@error, @extended, False)
  6247. Return $aresult[0]
  6248. EndFunc
  6249.  
  6250. Func _winapi_showcursor($bshow)
  6251. Local $aresult = DllCall("user32.dll", "int", "ShowCursor", "bool", $bshow)
  6252. If @error Then Return SetError(@error, @extended, 0)
  6253. Return $aresult[0]
  6254. EndFunc
  6255.  
  6256. Func _winapi_showerror($stext, $bexit = True)
  6257. _winapi_msgbox($mb_systemmodal, "Error", $stext)
  6258. If $bexit Then Exit
  6259. EndFunc
  6260.  
  6261. Func _winapi_showmsg($stext)
  6262. _winapi_msgbox($mb_systemmodal, "Information", $stext)
  6263. EndFunc
  6264.  
  6265. Func _winapi_showwindow($hwnd, $icmdshow = 5)
  6266. Local $aresult = DllCall("user32.dll", "bool", "ShowWindow", "hwnd", $hwnd, "int", $icmdshow)
  6267. If @error Then Return SetError(@error, @extended, False)
  6268. Return $aresult[0]
  6269. EndFunc
  6270.  
  6271. Func _winapi_stringfromguid($tguid)
  6272. Local $aresult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $tguid, "wstr", "", "int", 40)
  6273. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
  6274. Return SetExtended($aresult[0], $aresult[2])
  6275. EndFunc
  6276.  
  6277. Func _winapi_stringlena(Const ByRef $tstring)
  6278. Local $aresult = DllCall("kernel32.dll", "int", "lstrlenA", "struct*", $tstring)
  6279. If @error Then Return SetError(@error, @extended, 0)
  6280. Return $aresult[0]
  6281. EndFunc
  6282.  
  6283. Func _winapi_stringlenw(Const ByRef $tstring)
  6284. Local $aresult = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $tstring)
  6285. If @error Then Return SetError(@error, @extended, 0)
  6286. Return $aresult[0]
  6287. EndFunc
  6288.  
  6289. Func _winapi_sublangid($ilngid)
  6290. Return BitShift($ilngid, 10)
  6291. EndFunc
  6292.  
  6293. Func _winapi_systemparametersinfo($iaction, $iparam = 0, $vparam = 0, $iwinini = 0)
  6294. Local $aresult = DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", $iaction, "uint", $iparam, "struct*", $vparam, "uint", $iwinini)
  6295. If @error Then Return SetError(@error, @extended, False)
  6296. Return $aresult[0]
  6297. EndFunc
  6298.  
  6299. Func _winapi_twipsperpixelx()
  6300. Local $hdc, $itwipsperpixelx
  6301. $hdc = _winapi_getdc(0)
  6302. $itwipsperpixelx = 1440 / _winapi_getdevicecaps($hdc, $__winapiconstant_logpixelsx)
  6303. _winapi_releasedc(0, $hdc)
  6304. Return $itwipsperpixelx
  6305. EndFunc
  6306.  
  6307. Func _winapi_twipsperpixely()
  6308. Local $hdc, $itwipsperpixely
  6309. $hdc = _winapi_getdc(0)
  6310. $itwipsperpixely = 1440 / _winapi_getdevicecaps($hdc, $__winapiconstant_logpixelsy)
  6311. _winapi_releasedc(0, $hdc)
  6312. Return $itwipsperpixely
  6313. EndFunc
  6314.  
  6315. Func _winapi_unhookwindowshookex($hhook)
  6316. Local $aresult = DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $hhook)
  6317. If @error Then Return SetError(@error, @extended, False)
  6318. Return $aresult[0]
  6319. EndFunc
  6320.  
  6321. Func _winapi_updatelayeredwindow($hwnd, $hdestdc, $tptdest, $tsize, $hsrcdc, $tptsrce, $irgb, $tblend, $iflags)
  6322. Local $aresult = DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $hwnd, "handle", $hdestdc, "struct*", $tptdest, "struct*", $tsize, "handle", $hsrcdc, "struct*", $tptsrce, "dword", $irgb, "struct*", $tblend, "dword", $iflags)
  6323. If @error Then Return SetError(@error, @extended, False)
  6324. Return $aresult[0]
  6325. EndFunc
  6326.  
  6327. Func _winapi_updatewindow($hwnd)
  6328. Local $aresult = DllCall("user32.dll", "bool", "UpdateWindow", "hwnd", $hwnd)
  6329. If @error Then Return SetError(@error, @extended, False)
  6330. Return $aresult[0]
  6331. EndFunc
  6332.  
  6333. Func _winapi_waitforinputidle($hprocess, $itimeout = -1)
  6334. Local $aresult = DllCall("user32.dll", "dword", "WaitForInputIdle", "handle", $hprocess, "dword", $itimeout)
  6335. If @error Then Return SetError(@error, @extended, False)
  6336. Return $aresult[0]
  6337. EndFunc
  6338.  
  6339. Func _winapi_waitformultipleobjects($icount, $pahandles, $bwaitall = False, $itimeout = -1)
  6340. Local $aresult = DllCall("kernel32.dll", "INT", "WaitForMultipleObjects", "dword", $icount, "struct*", $pahandles, "bool", $bwaitall, "dword", $itimeout)
  6341. If @error Then Return SetError(@error, @extended, -1)
  6342. Return $aresult[0]
  6343. EndFunc
  6344.  
  6345. Func _winapi_waitforsingleobject($hhandle, $itimeout = -1)
  6346. Local $aresult = DllCall("kernel32.dll", "INT", "WaitForSingleObject", "handle", $hhandle, "dword", $itimeout)
  6347. If @error Then Return SetError(@error, @extended, -1)
  6348. Return $aresult[0]
  6349. EndFunc
  6350.  
  6351. Func _winapi_widechartomultibyte($vunicode, $icodepage = 0, $bretstring = True)
  6352. Local $sunicodetype = "wstr"
  6353. If NOT IsString($vunicode) Then $sunicodetype = "struct*"
  6354. Local $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "ptr", 0, "int", 0, "ptr", 0, "ptr", 0)
  6355. If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, "")
  6356. Local $tmultibyte = DllStructCreate("char[" & $aresult[0] & "]")
  6357. $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "struct*", $tmultibyte, "int", $aresult[0], "ptr", 0, "ptr", 0)
  6358. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  6359. If $bretstring Then Return DllStructGetData($tmultibyte, 1)
  6360. Return $tmultibyte
  6361. EndFunc
  6362.  
  6363. Func _winapi_windowfrompoint(ByRef $tpoint)
  6364. Local $aresult = DllCall("user32.dll", "hwnd", "WindowFromPoint", "struct", $tpoint)
  6365. If @error Then Return SetError(@error, @extended, 0)
  6366. Return $aresult[0]
  6367. EndFunc
  6368.  
  6369. Func _winapi_writeconsole($hconsole, $stext)
  6370. Local $aresult = DllCall("kernel32.dll", "bool", "WriteConsoleW", "handle", $hconsole, "wstr", $stext, "dword", StringLen($stext), "dword*", 0, "ptr", 0)
  6371. If @error Then Return SetError(@error, @extended, False)
  6372. Return $aresult[0]
  6373. EndFunc
  6374.  
  6375. Func _winapi_writefile($hfile, $pbuffer, $itowrite, ByRef $iwritten, $toverlapped = 0)
  6376. Local $aresult = DllCall("kernel32.dll", "bool", "WriteFile", "handle", $hfile, "struct*", $pbuffer, "dword", $itowrite, "dword*", 0, "struct*", $toverlapped)
  6377. If @error Then Return SetError(@error, @extended, False)
  6378. $iwritten = $aresult[4]
  6379. Return $aresult[0]
  6380. EndFunc
  6381.  
  6382. Func _winapi_writeprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iwritten, $sbuffer = "ptr")
  6383. Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, $sbuffer, $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  6384. If @error Then Return SetError(@error, @extended, False)
  6385. $iwritten = $aresult[5]
  6386. Return $aresult[0]
  6387. EndFunc
  6388.  
  6389. Global Const $_udf_globalids_offset = 2
  6390. Global Const $_udf_globalid_max_win = 16
  6391. Global Const $_udf_startid = 10000
  6392. Global Const $_udf_globalid_max_ids = 55535
  6393. Global Const $__udfguiconstant_ws_tabstop = 65536
  6394. Global Const $__udfguiconstant_ws_visible = 268435456
  6395. Global Const $__udfguiconstant_ws_child = 1073741824
  6396. Global $__g_audf_globalids_used[$_udf_globalid_max_win][$_udf_globalid_max_ids + $_udf_globalids_offset + 1]
  6397.  
  6398. Func __udf_getnextglobalid($hwnd)
  6399. Local $nctrlid, $iusedindex = -1, $ballused = True
  6400. If NOT WinExists($hwnd) Then Return SetError(-1, -1, 0)
  6401. For $iindex = 0 To $_udf_globalid_max_win - 1
  6402. If $__g_audf_globalids_used[$iindex][0] <> 0 Then
  6403. If NOT WinExists($__g_audf_globalids_used[$iindex][0]) Then
  6404. For $x = 0 To UBound($__g_audf_globalids_used, $ubound_columns) - 1
  6405. $__g_audf_globalids_used[$iindex][$x] = 0
  6406. Next
  6407. $__g_audf_globalids_used[$iindex][1] = $_udf_startid
  6408. $ballused = False
  6409. EndIf
  6410. EndIf
  6411. Next
  6412. For $iindex = 0 To $_udf_globalid_max_win - 1
  6413. If $__g_audf_globalids_used[$iindex][0] = $hwnd Then
  6414. $iusedindex = $iindex
  6415. ExitLoop
  6416. EndIf
  6417. Next
  6418. If $iusedindex = -1 Then
  6419. For $iindex = 0 To $_udf_globalid_max_win - 1
  6420. If $__g_audf_globalids_used[$iindex][0] = 0 Then
  6421. $__g_audf_globalids_used[$iindex][0] = $hwnd
  6422. $__g_audf_globalids_used[$iindex][1] = $_udf_startid
  6423. $ballused = False
  6424. $iusedindex = $iindex
  6425. ExitLoop
  6426. EndIf
  6427. Next
  6428. EndIf
  6429. If $iusedindex = -1 AND $ballused Then Return SetError(16, 0, 0)
  6430. If $__g_audf_globalids_used[$iusedindex][1] = $_udf_startid + $_udf_globalid_max_ids Then
  6431. For $iidindex = $_udf_globalids_offset To UBound($__g_audf_globalids_used, $ubound_columns) - 1
  6432. If $__g_audf_globalids_used[$iusedindex][$iidindex] = 0 Then
  6433. $nctrlid = ($iidindex - $_udf_globalids_offset) + 10000
  6434. $__g_audf_globalids_used[$iusedindex][$iidindex] = $nctrlid
  6435. Return $nctrlid
  6436. EndIf
  6437. Next
  6438. Return SetError(-1, $_udf_globalid_max_ids, 0)
  6439. EndIf
  6440. $nctrlid = $__g_audf_globalids_used[$iusedindex][1]
  6441. $__g_audf_globalids_used[$iusedindex][1] += 1
  6442. $__g_audf_globalids_used[$iusedindex][($nctrlid - 10000) + $_udf_globalids_offset] = $nctrlid
  6443. Return $nctrlid
  6444. EndFunc
  6445.  
  6446. Func __udf_freeglobalid($hwnd, $iglobalid)
  6447. If $iglobalid - $_udf_startid < 0 OR $iglobalid - $_udf_startid > $_udf_globalid_max_ids Then Return SetError(-1, 0, False)
  6448. For $iindex = 0 To $_udf_globalid_max_win - 1
  6449. If $__g_audf_globalids_used[$iindex][0] = $hwnd Then
  6450. For $x = $_udf_globalids_offset To UBound($__g_audf_globalids_used, $ubound_columns) - 1
  6451. If $__g_audf_globalids_used[$iindex][$x] = $iglobalid Then
  6452. $__g_audf_globalids_used[$iindex][$x] = 0
  6453. Return True
  6454. EndIf
  6455. Next
  6456. Return SetError(-3, 0, False)
  6457. EndIf
  6458. Next
  6459. Return SetError(-2, 0, False)
  6460. EndFunc
  6461.  
  6462. Global $__g_hsblastwnd
  6463. Global Const $__statusbarconstant_classname = "msctls_statusbar32"
  6464. Global Const $__statusbarconstant_wm_size = 5
  6465. Global Const $__statusbarconstant_clr_default = -16777216
  6466. Global Const $tagborders = "int BX;int BY;int RX"
  6467.  
  6468. Func _guictrlstatusbar_create($hwnd, $vpartedge = -1, $vparttext = "", $istyles = -1, $iexstyles = 0)
  6469. If NOT IsHWnd($hwnd) Then Return SetError(1, 0, 0)
  6470. Local $istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconstant_ws_visible)
  6471. If $istyles = -1 Then $istyles = 0
  6472. If $iexstyles = -1 Then $iexstyles = 0
  6473. Local $apartwidth[1], $aparttext[1]
  6474. If @NumParams > 1 Then
  6475. If IsArray($vpartedge) Then
  6476. $apartwidth = $vpartedge
  6477. Else
  6478. $apartwidth[0] = $vpartedge
  6479. EndIf
  6480. If @NumParams = 2 Then
  6481. ReDim $aparttext[UBound($apartwidth)]
  6482. Else
  6483. If IsArray($vparttext) Then
  6484. $aparttext = $vparttext
  6485. Else
  6486. $aparttext[0] = $vparttext
  6487. EndIf
  6488. If UBound($apartwidth) <> UBound($aparttext) Then
  6489. Local $ilast
  6490. If UBound($apartwidth) > UBound($aparttext) Then
  6491. $ilast = UBound($aparttext)
  6492. ReDim $aparttext[UBound($apartwidth)]
  6493. Else
  6494. $ilast = UBound($apartwidth)
  6495. ReDim $apartwidth[UBound($aparttext)]
  6496. For $x = $ilast To UBound($apartwidth) - 1
  6497. $apartwidth[$x] = $apartwidth[$x - 1] + 75
  6498. Next
  6499. $apartwidth[UBound($aparttext) - 1] = -1
  6500. EndIf
  6501. EndIf
  6502. EndIf
  6503. If NOT IsHWnd($hwnd) Then $hwnd = HWnd($hwnd)
  6504. If @NumParams > 3 Then $istyle = BitOR($istyle, $istyles)
  6505. EndIf
  6506. Local $nctrlid = __udf_getnextglobalid($hwnd)
  6507. If @error Then Return SetError(@error, @extended, 0)
  6508. Local $hwndsbar = _winapi_createwindowex($iexstyles, $__statusbarconstant_classname, "", $istyle, 0, 0, 0, 0, $hwnd, $nctrlid)
  6509. If @error Then Return SetError(@error, @extended, 0)
  6510. If @NumParams > 1 Then
  6511. _guictrlstatusbar_setparts($hwndsbar, UBound($apartwidth), $apartwidth)
  6512. For $x = 0 To UBound($aparttext) - 1
  6513. _guictrlstatusbar_settext($hwndsbar, $aparttext[$x], $x)
  6514. Next
  6515. EndIf
  6516. Return $hwndsbar
  6517. EndFunc
  6518.  
  6519. Func _guictrlstatusbar_destroy(ByRef $hwnd)
  6520. If NOT _winapi_isclassname($hwnd, $__statusbarconstant_classname) Then Return SetError(2, 2, False)
  6521. Local $idestroyed = 0
  6522. If IsHWnd($hwnd) Then
  6523. If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
  6524. Local $nctrlid = _winapi_getdlgctrlid($hwnd)
  6525. Local $hparent = _winapi_getparent($hwnd)
  6526. $idestroyed = _winapi_destroywindow($hwnd)
  6527. Local $iret = __udf_freeglobalid($hparent, $nctrlid)
  6528. If NOT $iret Then
  6529. EndIf
  6530. Else
  6531. Return SetError(1, 1, False)
  6532. EndIf
  6533. EndIf
  6534. If $idestroyed Then $hwnd = 0
  6535. Return $idestroyed <> 0
  6536. EndFunc
  6537.  
  6538. Func _guictrlstatusbar_embedcontrol($hwnd, $ipart, $hcontrol, $ifit = 4)
  6539. Local $arect = _guictrlstatusbar_getrect($hwnd, $ipart)
  6540. Local $ibarx = $arect[0]
  6541. Local $ibary = $arect[1]
  6542. Local $ibarw = $arect[2] - $ibarx
  6543. Local $ibarh = $arect[3] - $ibary
  6544. Local $iconx = $ibarx
  6545. Local $icony = $ibary
  6546. Local $iconw = _winapi_getwindowwidth($hcontrol)
  6547. Local $iconh = _winapi_getwindowheight($hcontrol)
  6548. If $iconw > $ibarw Then $iconw = $ibarw
  6549. If $iconh > $ibarh Then $iconh = $ibarh
  6550. Local $ipadx = ($ibarw - $iconw) / 2
  6551. Local $ipady = ($ibarh - $iconh) / 2
  6552. If $ipadx < 0 Then $ipadx = 0
  6553. If $ipady < 0 Then $ipady = 0
  6554. If BitAND($ifit, 1) = 1 Then $iconx = $ibarx + $ipadx
  6555. If BitAND($ifit, 2) = 2 Then $icony = $ibary + $ipady
  6556. If BitAND($ifit, 4) = 4 Then
  6557. $ipadx = _guictrlstatusbar_getbordersrect($hwnd)
  6558. $ipady = _guictrlstatusbar_getbordersvert($hwnd)
  6559. $iconx = $ibarx
  6560. If _guictrlstatusbar_issimple($hwnd) Then $iconx += $ipadx
  6561. $icony = $ibary + $ipady
  6562. $iconw = $ibarw - ($ipadx * 2)
  6563. $iconh = $ibarh - ($ipady * 2)
  6564. EndIf
  6565. _winapi_setparent($hcontrol, $hwnd)
  6566. _winapi_movewindow($hcontrol, $iconx, $icony, $iconw, $iconh)
  6567. EndFunc
  6568.  
  6569. Func _guictrlstatusbar_getborders($hwnd)
  6570. Local $tborders = DllStructCreate($tagborders)
  6571. Local $iret
  6572. If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
  6573. $iret = _sendmessage($hwnd, $sb_getborders, 0, $tborders, 0, "wparam", "struct*")
  6574. Else
  6575. Local $isize = DllStructGetSize($tborders)
  6576. Local $tmemmap
  6577. Local $pmemory = _meminit($hwnd, $isize, $tmemmap)
  6578. $iret = _sendmessage($hwnd, $sb_getborders, 0, $pmemory, 0, "wparam", "ptr")
  6579. _memread($tmemmap, $pmemory, $tborders, $isize)
  6580. _memfree($tmemmap)
  6581. EndIf
  6582. Local $aborders[3]
  6583. If $iret = 0 Then Return SetError(-1, -1, $aborders)
  6584. $aborders[0] = DllStructGetData($tborders, "BX")
  6585. $aborders[1] = DllStructGetData($tborders, "BY")
  6586. $aborders[2] = DllStructGetData($tborders, "RX")
  6587. Return $aborders
  6588. EndFunc
  6589.  
  6590. Func _guictrlstatusbar_getbordershorz($hwnd)
  6591. Local $aborders = _guictrlstatusbar_getborders($hwnd)
  6592. Return SetError(@error, @extended, $aborders[0])
  6593. EndFunc
  6594.  
  6595. Func _guictrlstatusbar_getbordersrect($hwnd)
  6596. Local $aborders = _guictrlstatusbar_getborders($hwnd)
  6597. Return SetError(@error, @extended, $aborders[2])
  6598. EndFunc
  6599.  
  6600. Func _guictrlstatusbar_getbordersvert($hwnd)
  6601. Local $aborders = _guictrlstatusbar_getborders($hwnd)
  6602. Return SetError(@error, @extended, $aborders[1])
  6603. EndFunc
  6604.  
  6605. Func _guictrlstatusbar_getcount($hwnd)
  6606. Return _sendmessage($hwnd, $sb_getparts)
  6607. EndFunc
  6608.  
  6609. Func _guictrlstatusbar_getheight($hwnd)
  6610. Local $trect = _guictrlstatusbar_getrectex($hwnd, 0)
  6611. Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top") - (_guictrlstatusbar_getbordersvert($hwnd) * 2)
  6612. EndFunc
  6613.  
  6614. Func _guictrlstatusbar_geticon($hwnd, $iindex = 0)
  6615. Return _sendmessage($hwnd, $sb_geticon, $iindex, 0, 0, "wparam", "lparam", "handle")
  6616. EndFunc
  6617.  
  6618. Func _guictrlstatusbar_getparts($hwnd)
  6619. Local $icount = _guictrlstatusbar_getcount($hwnd)
  6620. Local $tparts = DllStructCreate("int[" & $icount & "]")
  6621. Local $aparts[$icount + 1]
  6622. If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
  6623. $aparts[0] = _sendmessage($hwnd, $sb_getparts, $icount, $tparts, 0, "wparam", "struct*")
  6624. Else
  6625. Local $iparts = DllStructGetSize($tparts)
  6626. Local $tmemmap
  6627. Local $pmemory = _meminit($hwnd, $iparts, $tmemmap)
  6628. $aparts[0] = _sendmessage($hwnd, $sb_getparts, $icount, $pmemory, 0, "wparam", "ptr")
  6629. _memread($tmemmap, $pmemory, $tparts, $iparts)
  6630. _memfree($tmemmap)
  6631. EndIf
  6632. For $ii = 1 To $icount
  6633. $aparts[$ii] = DllStructGetData($tparts, 1, $ii)
  6634. Next
  6635. Return $aparts
  6636. EndFunc
  6637.  
  6638. Func _guictrlstatusbar_getrect($hwnd, $ipart)
  6639. Local $trect = _guictrlstatusbar_getrectex($hwnd, $ipart)
  6640. If @error Then Return SetError(@error, 0, 0)
  6641. Local $arect[4]
  6642. $arect[0] = DllStructGetData($trect, "Left")
  6643. $arect[1] = DllStructGetData($trect, "Top")
  6644. $arect[2] = DllStructGetData($trect, "Right")
  6645. $arect[3] = DllStructGetData($trect, "Bottom")
  6646. Return $arect
  6647. EndFunc
  6648.  
  6649. Func _guictrlstatusbar_getrectex($hwnd, $ipart)
  6650. Local $trect = DllStructCreate($tagrect)
  6651. Local $iret
  6652. If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
  6653. $iret = _sendmessage($hwnd, $sb_getrect, $ipart, $trect, 0, "wparam", "struct*")
  6654. Else
  6655. Local $irect = DllStructGetSize($trect)
  6656. Local $tmemmap
  6657. Local $pmemory = _meminit($hwnd, $irect, $tmemmap)
  6658. $iret = _sendmessage($hwnd, $sb_getrect, $ipart, $pmemory, 0, "wparam", "ptr")
  6659. _memread($tmemmap, $pmemory, $trect, $irect)
  6660. _memfree($tmemmap)
  6661. EndIf
  6662. Return SetError($iret = 0, 0, $trect)
  6663. EndFunc
  6664.  
  6665. Func _guictrlstatusbar_gettext($hwnd, $ipart)
  6666. Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)
  6667. Local $ibuffer = _guictrlstatusbar_gettextlength($hwnd, $ipart) + 1
  6668. If $ibuffer = 1 Then Return SetError(1, 0, "")
  6669. Local $tbuffer
  6670. If $bunicode Then
  6671. $tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]")
  6672. $ibuffer *= 2
  6673. Else
  6674. $tbuffer = DllStructCreate("char Text[" & $ibuffer & "]")
  6675. EndIf
  6676. If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
  6677. _sendmessage($hwnd, $sb_gettextw, $ipart, $tbuffer, 0, "wparam", "struct*")
  6678. Else
  6679. Local $tmemmap
  6680. Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
  6681. If $bunicode Then
  6682. _sendmessage($hwnd, $sb_gettextw, $ipart, $pmemory, 0, "wparam", "ptr")
  6683. Else
  6684. _sendmessage($hwnd, $sb_gettext, $ipart, $pmemory, 0, "wparam", "ptr")
  6685. EndIf
  6686. _memread($tmemmap, $pmemory, $tbuffer, $ibuffer)
  6687. _memfree($tmemmap)
  6688. EndIf
  6689. Return DllStructGetData($tbuffer, "Text")
  6690. EndFunc
  6691.  
  6692. Func _guictrlstatusbar_gettextflags($hwnd, $ipart)
  6693. If _guictrlstatusbar_getunicodeformat($hwnd) Then
  6694. Return _sendmessage($hwnd, $sb_gettextlengthw, $ipart)
  6695. Else
  6696. Return _sendmessage($hwnd, $sb_gettextlength, $ipart)
  6697. EndIf
  6698. EndFunc
  6699.  
  6700. Func _guictrlstatusbar_gettextlength($hwnd, $ipart)
  6701. Return _winapi_loword(_guictrlstatusbar_gettextflags($hwnd, $ipart))
  6702. EndFunc
  6703.  
  6704. Func _guictrlstatusbar_gettextlengthex($hwnd, $ipart)
  6705. Return _winapi_hiword(_guictrlstatusbar_gettextflags($hwnd, $ipart))
  6706. EndFunc
  6707.  
  6708. Func _guictrlstatusbar_gettiptext($hwnd, $ipart)
  6709. Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)
  6710. Local $tbuffer
  6711. If $bunicode Then
  6712. $tbuffer = DllStructCreate("wchar Text[4096]")
  6713. Else
  6714. $tbuffer = DllStructCreate("char Text[4096]")
  6715. EndIf
  6716. If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
  6717. _sendmessage($hwnd, $sb_gettiptextw, _winapi_makelong($ipart, 4096), $tbuffer, 0, "wparam", "struct*")
  6718. Else
  6719. Local $tmemmap
  6720. Local $pmemory = _meminit($hwnd, 4096, $tmemmap)
  6721. If $bunicode Then
  6722. _sendmessage($hwnd, $sb_gettiptextw, _winapi_makelong($ipart, 4096), $pmemory, 0, "wparam", "ptr")
  6723. Else
  6724. _sendmessage($hwnd, $sb_gettiptexta, _winapi_makelong($ipart, 4096), $pmemory, 0, "wparam", "ptr")
  6725. EndIf
  6726. _memread($tmemmap, $pmemory, $tbuffer, 4096)
  6727. _memfree($tmemmap)
  6728. EndIf
  6729. Return DllStructGetData($tbuffer, "Text")
  6730. EndFunc
  6731.  
  6732. Func _guictrlstatusbar_getunicodeformat($hwnd)
  6733. Return _sendmessage($hwnd, $sb_getunicodeformat) <> 0
  6734. EndFunc
  6735.  
  6736. Func _guictrlstatusbar_getwidth($hwnd, $ipart)
  6737. Local $trect = _guictrlstatusbar_getrectex($hwnd, $ipart)
  6738. Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left") - (_guictrlstatusbar_getbordershorz($hwnd) * 2)
  6739. EndFunc
  6740.  
  6741. Func _guictrlstatusbar_issimple($hwnd)
  6742. Return _sendmessage($hwnd, $sb_issimple) <> 0
  6743. EndFunc
  6744.  
  6745. Func _guictrlstatusbar_resize($hwnd)
  6746. _sendmessage($hwnd, $__statusbarconstant_wm_size)
  6747. EndFunc
  6748.  
  6749. Func _guictrlstatusbar_setbkcolor($hwnd, $icolor)
  6750. $icolor = _sendmessage($hwnd, $sb_setbkcolor, 0, $icolor)
  6751. If $icolor = $__statusbarconstant_clr_default Then Return "0x" & Hex($__statusbarconstant_clr_default)
  6752. Return $icolor
  6753. EndFunc
  6754.  
  6755. Func _guictrlstatusbar_seticon($hwnd, $ipart, $hicon = -1, $siconfile = "")
  6756. If $hicon = -1 Then Return _sendmessage($hwnd, $sb_seticon, $ipart, $hicon, 0, "wparam", "handle") <> 0
  6757. If StringLen($siconfile) <= 0 Then Return _sendmessage($hwnd, $sb_seticon, $ipart, $hicon) <> 0
  6758. Local $ticon = DllStructCreate("handle")
  6759. Local $vresult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $siconfile, "int", $hicon, "ptr", 0, "struct*", $ticon, "uint", 1)
  6760. If @error Then Return SetError(@error, @extended, False)
  6761. $vresult = $vresult[0]
  6762. If $vresult > 0 Then $vresult = _sendmessage($hwnd, $sb_seticon, $ipart, DllStructGetData($ticon, 1), 0, "wparam", "handle")
  6763. DllCall("user32.dll", "bool", "DestroyIcon", "handle", DllStructGetData($ticon, 1))
  6764. Return $vresult
  6765. EndFunc
  6766.  
  6767. Func _guictrlstatusbar_setminheight($hwnd, $iminheight)
  6768. _sendmessage($hwnd, $sb_setminheight, $iminheight)
  6769. _guictrlstatusbar_resize($hwnd)
  6770. EndFunc
  6771.  
  6772. Func _guictrlstatusbar_setparts($hwnd, $aparts = -1, $apartwidth = 25)
  6773. Local $tparts, $iparts = 1
  6774. If IsArray($aparts) <> 0 Then
  6775. $aparts[UBound($aparts) - 1] = -1
  6776. $iparts = UBound($aparts)
  6777. $tparts = DllStructCreate("int[" & $iparts & "]")
  6778. For $x = 0 To $iparts - 2
  6779. DllStructSetData($tparts, 1, $aparts[$x], $x + 1)
  6780. Next
  6781. DllStructSetData($tparts, 1, -1, $iparts)
  6782. ElseIf IsArray($apartwidth) <> 0 Then
  6783. $iparts = UBound($apartwidth)
  6784. $tparts = DllStructCreate("int[" & $iparts & "]")
  6785. For $x = 0 To $iparts - 2
  6786. DllStructSetData($tparts, 1, $apartwidth[$x], $x + 1)
  6787. Next
  6788. DllStructSetData($tparts, 1, -1, $iparts)
  6789. ElseIf $aparts > 1 Then
  6790. $iparts = $aparts
  6791. $tparts = DllStructCreate("int[" & $iparts & "]")
  6792. For $x = 1 To $iparts - 1
  6793. DllStructSetData($tparts, 1, $apartwidth * $x, $x)
  6794. Next
  6795. DllStructSetData($tparts, 1, -1, $iparts)
  6796. Else
  6797. $tparts = DllStructCreate("int")
  6798. DllStructSetData($tparts, $iparts, -1)
  6799. EndIf
  6800. If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
  6801. _sendmessage($hwnd, $sb_setparts, $iparts, $tparts, 0, "wparam", "struct*")
  6802. Else
  6803. Local $isize = DllStructGetSize($tparts)
  6804. Local $tmemmap
  6805. Local $pmemory = _meminit($hwnd, $isize, $tmemmap)
  6806. _memwrite($tmemmap, $tparts)
  6807. _sendmessage($hwnd, $sb_setparts, $iparts, $pmemory, 0, "wparam", "ptr")
  6808. _memfree($tmemmap)
  6809. EndIf
  6810. _guictrlstatusbar_resize($hwnd)
  6811. Return True
  6812. EndFunc
  6813.  
  6814. Func _guictrlstatusbar_setsimple($hwnd, $bsimple = True)
  6815. _sendmessage($hwnd, $sb_simple, $bsimple)
  6816. EndFunc
  6817.  
  6818. Func _guictrlstatusbar_settext($hwnd, $stext = "", $ipart = 0, $iuflag = 0)
  6819. Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)
  6820. Local $ibuffer = StringLen($stext) + 1
  6821. Local $ttext
  6822. If $bunicode Then
  6823. $ttext = DllStructCreate("wchar Text[" & $ibuffer & "]")
  6824. $ibuffer *= 2
  6825. Else
  6826. $ttext = DllStructCreate("char Text[" & $ibuffer & "]")
  6827. EndIf
  6828. DllStructSetData($ttext, "Text", $stext)
  6829. If _guictrlstatusbar_issimple($hwnd) Then $ipart = $sb_simpleid
  6830. Local $iret
  6831. If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
  6832. $iret = _sendmessage($hwnd, $sb_settextw, BitOR($ipart, $iuflag), $ttext, 0, "wparam", "struct*")
  6833. Else
  6834. Local $tmemmap
  6835. Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
  6836. _memwrite($tmemmap, $ttext)
  6837. If $bunicode Then
  6838. $iret = _sendmessage($hwnd, $sb_settextw, BitOR($ipart, $iuflag), $pmemory, 0, "wparam", "ptr")
  6839. Else
  6840. $iret = _sendmessage($hwnd, $sb_settext, BitOR($ipart, $iuflag), $pmemory, 0, "wparam", "ptr")
  6841. EndIf
  6842. _memfree($tmemmap)
  6843. EndIf
  6844. Return $iret <> 0
  6845. EndFunc
  6846.  
  6847. Func _guictrlstatusbar_settiptext($hwnd, $ipart, $stext)
  6848. Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)
  6849. Local $ibuffer = StringLen($stext) + 1
  6850. Local $ttext
  6851. If $bunicode Then
  6852. $ttext = DllStructCreate("wchar TipText[" & $ibuffer & "]")
  6853. $ibuffer *= 2
  6854. Else
  6855. $ttext = DllStructCreate("char TipText[" & $ibuffer & "]")
  6856. EndIf
  6857. DllStructSetData($ttext, "TipText", $stext)
  6858. If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
  6859. _sendmessage($hwnd, $sb_settiptextw, $ipart, $ttext, 0, "wparam", "struct*")
  6860. Else
  6861. Local $tmemmap
  6862. Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
  6863. _memwrite($tmemmap, $ttext, $pmemory, $ibuffer)
  6864. If $bunicode Then
  6865. _sendmessage($hwnd, $sb_settiptextw, $ipart, $pmemory, 0, "wparam", "ptr")
  6866. Else
  6867. _sendmessage($hwnd, $sb_settiptexta, $ipart, $pmemory, 0, "wparam", "ptr")
  6868. EndIf
  6869. _memfree($tmemmap)
  6870. EndIf
  6871. EndFunc
  6872.  
  6873. Func _guictrlstatusbar_setunicodeformat($hwnd, $bunicode = True)
  6874. Return _sendmessage($hwnd, $sb_setunicodeformat, $bunicode)
  6875. EndFunc
  6876.  
  6877. Func _guictrlstatusbar_showhide($hwnd, $istate)
  6878. If $istate <> @SW_HIDE AND $istate <> @SW_SHOW Then Return SetError(1, 1, False)
  6879. Return _winapi_showwindow($hwnd, $istate)
  6880. EndFunc
  6881.  
  6882. Global Const $ttf_idishwnd = 1
  6883. Global Const $ttf_centertip = 2
  6884. Global Const $ttf_rtlreading = 4
  6885. Global Const $ttf_subclass = 16
  6886. Global Const $ttf_track = 32
  6887. Global Const $ttf_absolute = 128
  6888. Global Const $ttf_transparent = 256
  6889. Global Const $ttf_parselinks = 4096
  6890. Global Const $ttf_di_setitem = 32768
  6891. Global Const $__tooltipconstants_wm_user = 1024
  6892. Global Const $ttm_activate = $__tooltipconstants_wm_user + 1
  6893. Global Const $ttm_setdelaytime = $__tooltipconstants_wm_user + 3
  6894. Global Const $ttm_addtool = $__tooltipconstants_wm_user + 4
  6895. Global Const $ttm_deltool = $__tooltipconstants_wm_user + 5
  6896. Global Const $ttm_newtoolrect = $__tooltipconstants_wm_user + 6
  6897. Global Const $ttm_gettoolinfo = $__tooltipconstants_wm_user + 8
  6898. Global Const $ttm_settoolinfo = $__tooltipconstants_wm_user + 9
  6899. Global Const $ttm_hittest = $__tooltipconstants_wm_user + 10
  6900. Global Const $ttm_gettext = $__tooltipconstants_wm_user + 11
  6901. Global Const $ttm_updatetiptext = $__tooltipconstants_wm_user + 12
  6902. Global Const $ttm_gettoolcount = $__tooltipconstants_wm_user + 13
  6903. Global Const $ttm_enumtools = $__tooltipconstants_wm_user + 14
  6904. Global Const $ttm_getcurrenttool = $__tooltipconstants_wm_user + 15
  6905. Global Const $ttm_windowfrompoint = $__tooltipconstants_wm_user + 16
  6906. Global Const $ttm_trackactivate = $__tooltipconstants_wm_user + 17
  6907. Global Const $ttm_trackposition = $__tooltipconstants_wm_user + 18
  6908. Global Const $ttm_settipbkcolor = $__tooltipconstants_wm_user + 19
  6909. Global Const $ttm_settiptextcolor = $__tooltipconstants_wm_user + 20
  6910. Global Const $ttm_getdelaytime = $__tooltipconstants_wm_user + 21
  6911. Global Const $ttm_gettipbkcolor = $__tooltipconstants_wm_user + 22
  6912. Global Const $ttm_gettiptextcolor = $__tooltipconstants_wm_user + 23
  6913. Global Const $ttm_setmaxtipwidth = $__tooltipconstants_wm_user + 24
  6914. Global Const $ttm_getmaxtipwidth = $__tooltipconstants_wm_user + 25
  6915. Global Const $ttm_setmargin = $__tooltipconstants_wm_user + 26
  6916. Global Const $ttm_getmargin = $__tooltipconstants_wm_user + 27
  6917. Global Const $ttm_pop = $__tooltipconstants_wm_user + 28
  6918. Global Const $ttm_update = $__tooltipconstants_wm_user + 29
  6919. Global Const $ttm_getbubblesize = $__tooltipconstants_wm_user + 30
  6920. Global Const $ttm_adjustrect = $__tooltipconstants_wm_user + 31
  6921. Global Const $ttm_settitle = $__tooltipconstants_wm_user + 32
  6922. Global Const $ttm_settitlew = $__tooltipconstants_wm_user + 33
  6923. Global Const $ttm_popup = $__tooltipconstants_wm_user + 34
  6924. Global Const $ttm_gettitle = $__tooltipconstants_wm_user + 35
  6925. Global Const $ttm_addtoolw = $__tooltipconstants_wm_user + 50
  6926. Global Const $ttm_deltoolw = $__tooltipconstants_wm_user + 51
  6927. Global Const $ttm_newtoolrectw = $__tooltipconstants_wm_user + 52
  6928. Global Const $ttm_gettoolinfow = $__tooltipconstants_wm_user + 53
  6929. Global Const $ttm_settoolinfow = $__tooltipconstants_wm_user + 54
  6930. Global Const $ttm_hittestw = $__tooltipconstants_wm_user + 55
  6931. Global Const $ttm_gettextw = $__tooltipconstants_wm_user + 56
  6932. Global Const $ttm_updatetiptextw = $__tooltipconstants_wm_user + 57
  6933. Global Const $ttm_enumtoolsw = $__tooltipconstants_wm_user + 58
  6934. Global Const $ttm_getcurrenttoolw = $__tooltipconstants_wm_user + 59
  6935. Global Const $ttm_setwindowtheme = 8192 + 11
  6936. Global Const $ttn_first = -520
  6937. Global Const $ttn_getdispinfo = $ttn_first + 0
  6938. Global Const $ttn_show = $ttn_first - 1
  6939. Global Const $ttn_pop = $ttn_first - 2
  6940. Global Const $ttn_linkclick = $ttn_first - 3
  6941. Global Const $ttn_getdispinfow = $ttn_first - 10
  6942. Global Const $tts_alwaystip = 1
  6943. Global Const $tts_noprefix = 2
  6944. Global Const $tts_noanimate = 16
  6945. Global Const $tts_nofade = 32
  6946. Global Const $tts_balloon = 64
  6947. Global Const $tts_close = 128
  6948. Global Const $tts_usevisualstyle = 256
  6949. Global Const $ttdt_automatic = 0
  6950. Global Const $ttdt_reshow = 1
  6951. Global Const $ttdt_autopop = 2
  6952. Global Const $ttdt_initial = 3
  6953. Global Enum $tti_none, $tti_info, $tti_warning, $tti_error, $tti_info_large, $tti_warning_large, $tti_error_large
  6954. Global $__g_heditlastwnd
  6955. Global Const $__editconstant_classname = "Edit"
  6956. Global Const $__editconstant_gui_checked = 1
  6957. Global Const $__editconstant_gui_hide = 32
  6958. Global Const $__editconstant_gui_event_close = -3
  6959. Global Const $__editconstant_gui_enable = 64
  6960. Global Const $__editconstant_gui_disable = 128
  6961. Global Const $__editconstant_ss_center = 1
  6962. Global Const $__editconstant_wm_setredraw = 11
  6963. Global Const $__editconstant_ws_caption = 12582912
  6964. Global Const $__editconstant_ws_popup = -2147483648
  6965. Global Const $__editconstant_ws_sysmenu = 524288
  6966. Global Const $__editconstant_ws_minimizebox = 131072
  6967. Global Const $__editconstant_default_gui_font = 17
  6968. Global Const $__editconstant_wm_setfont = 48
  6969. Global Const $__editconstant_wm_gettextlength = 14
  6970. Global Const $__editconstant_wm_gettext = 13
  6971. Global Const $__editconstant_wm_settext = 12
  6972. Global Const $__editconstant_sb_lineup = 0
  6973. Global Const $__editconstant_sb_linedown = 1
  6974. Global Const $__editconstant_sb_pagedown = 3
  6975. Global Const $__editconstant_sb_pageup = 2
  6976. Global Const $__editconstant_sb_scrollcaret = 4
  6977. Global Const $__tageditballoontip = "dword Size;ptr Title;ptr Text;int Icon"
  6978.  
  6979. Func _guictrledit_appendtext($hwnd, $stext)
  6980. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  6981. Local $ilength = _guictrledit_gettextlen($hwnd)
  6982. _guictrledit_setsel($hwnd, $ilength, $ilength)
  6983. _sendmessage($hwnd, $em_replacesel, True, $stext, 0, "wparam", "wstr")
  6984. EndFunc
  6985.  
  6986. Func _guictrledit_beginupdate($hwnd)
  6987. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  6988. Return _sendmessage($hwnd, $__editconstant_wm_setredraw, False) = 0
  6989. EndFunc
  6990.  
  6991. Func _guictrledit_canundo($hwnd)
  6992. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  6993. Return _sendmessage($hwnd, $em_canundo) <> 0
  6994. EndFunc
  6995.  
  6996. Func _guictrledit_charfrompos($hwnd, $ix, $iy)
  6997. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  6998. Local $areturn[2]
  6999. Local $iret = _sendmessage($hwnd, $em_charfrompos, 0, _winapi_makelong($ix, $iy))
  7000. $areturn[0] = _winapi_loword($iret)
  7001. $areturn[1] = _winapi_hiword($iret)
  7002. Return $areturn
  7003. EndFunc
  7004.  
  7005. Func _guictrledit_create($hwnd, $stext, $ix, $iy, $iwidth = 150, $iheight = 150, $istyle = 3150020, $iexstyle = 512)
  7006. If NOT IsHWnd($hwnd) Then Return SetError(1, 0, 0)
  7007. If NOT IsString($stext) Then Return SetError(2, 0, 0)
  7008. If $iwidth = -1 Then $iwidth = 150
  7009. If $iheight = -1 Then $iheight = 150
  7010. If $istyle = -1 Then $istyle = 3150020
  7011. If $iexstyle = -1 Then $iexstyle = 512
  7012. If BitAND($istyle, $es_readonly) = $es_readonly Then
  7013. $istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconstant_ws_visible, $istyle)
  7014. Else
  7015. $istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconstant_ws_visible, $__udfguiconstant_ws_tabstop, $istyle)
  7016. EndIf
  7017. Local $nctrlid = __udf_getnextglobalid($hwnd)
  7018. If @error Then Return SetError(@error, @extended, 0)
  7019. Local $hedit = _winapi_createwindowex($iexstyle, $__editconstant_classname, "", $istyle, $ix, $iy, $iwidth, $iheight, $hwnd, $nctrlid)
  7020. _sendmessage($hedit, $__editconstant_wm_setfont, _winapi_getstockobject($__editconstant_default_gui_font), True)
  7021. _guictrledit_settext($hedit, $stext)
  7022. _guictrledit_setlimittext($hedit, 0)
  7023. Return $hedit
  7024. EndFunc
  7025.  
  7026. Func _guictrledit_destroy(ByRef $hwnd)
  7027. If NOT _winapi_isclassname($hwnd, $__editconstant_classname) Then Return SetError(2, 2, False)
  7028. Local $idestroyed = 0
  7029. If IsHWnd($hwnd) Then
  7030. If _winapi_inprocess($hwnd, $__g_heditlastwnd) Then
  7031. Local $nctrlid = _winapi_getdlgctrlid($hwnd)
  7032. Local $hparent = _winapi_getparent($hwnd)
  7033. $idestroyed = _winapi_destroywindow($hwnd)
  7034. Local $iret = __udf_freeglobalid($hparent, $nctrlid)
  7035. If NOT $iret Then
  7036. EndIf
  7037. Else
  7038. Return SetError(1, 1, False)
  7039. EndIf
  7040. Else
  7041. $idestroyed = GUICtrlDelete($hwnd)
  7042. EndIf
  7043. If $idestroyed Then $hwnd = 0
  7044. Return $idestroyed <> 0
  7045. EndFunc
  7046.  
  7047. Func _guictrledit_emptyundobuffer($hwnd)
  7048. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7049. _sendmessage($hwnd, $em_emptyundobuffer)
  7050. EndFunc
  7051.  
  7052. Func _guictrledit_endupdate($hwnd)
  7053. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7054. Return _sendmessage($hwnd, $__editconstant_wm_setredraw, True) = 0
  7055. EndFunc
  7056.  
  7057. Func _guictrledit_fmtlines($hwnd, $bsoftbreak = False)
  7058. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7059. Return _sendmessage($hwnd, $em_fmtlines, $bsoftbreak)
  7060. EndFunc
  7061.  
  7062. Func _guictrledit_find($hwnd, $breplace = False)
  7063. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7064. Local $ipos = 0, $icase, $ioccurance = 0, $ireplacements = 0
  7065. Local $apartsrightedge[3] = [125, 225, -1]
  7066. Local $ioldmode = Opt("GUIOnEventMode", 0)
  7067. Local $asel = _guictrledit_getsel($hwnd)
  7068. Local $stext = _guictrledit_gettext($hwnd)
  7069. Local $hguisearch = GUICreate("Find", 349, 177, -1, -1, BitOR($__udfguiconstant_ws_child, $__editconstant_ws_minimizebox, $__editconstant_ws_caption, $__editconstant_ws_popup, $__editconstant_ws_sysmenu))
  7070. Local $idstatusbar1 = _guictrlstatusbar_create($hguisearch, $apartsrightedge)
  7071. _guictrlstatusbar_settext($idstatusbar1, "Find: ")
  7072. GUISetIcon(@SystemDir & "\shell32.dll", 22, $hguisearch)
  7073. GUICtrlCreateLabel("Find what:", 9, 10, 53, 16, $__editconstant_ss_center)
  7074. Local $idinputsearch = GUICtrlCreateInput("", 80, 8, 257, 21)
  7075. Local $idlblreplace = GUICtrlCreateLabel("Replace with:", 9, 42, 69, 17, $__editconstant_ss_center)
  7076. Local $idinputreplace = GUICtrlCreateInput("", 80, 40, 257, 21)
  7077. Local $idchkwholeonly = GUICtrlCreateCheckbox("Match whole word only", 9, 72, 145, 17)
  7078. Local $idchkmatchcase = GUICtrlCreateCheckbox("Match case", 9, 96, 145, 17)
  7079. Local $idbtnfindnext = GUICtrlCreateButton("Find Next", 168, 72, 161, 21, 0)
  7080. Local $idbtnreplace = GUICtrlCreateButton("Replace", 168, 96, 161, 21, 0)
  7081. Local $idbtnclose = GUICtrlCreateButton("Close", 104, 130, 161, 21, 0)
  7082. If (IsArray($asel) AND $asel <> $ec_err) Then
  7083. GUICtrlSetData($idinputsearch, StringMid($stext, $asel[0] + 1, $asel[1] - $asel[0]))
  7084. If $asel[0] <> $asel[1] Then
  7085. $ipos = $asel[0]
  7086. If BitAND(GUICtrlRead($idchkmatchcase), $__editconstant_gui_checked) = $__editconstant_gui_checked Then $icase = 1
  7087. $ioccurance = 1
  7088. Local $itpose
  7089. While 1
  7090. $itpose = StringInStr($stext, GUICtrlRead($idinputsearch), $icase, $ioccurance)
  7091. If NOT $itpose Then
  7092. $ioccurance = 0
  7093. ExitLoop
  7094. ElseIf $itpose = $ipos + 1 Then
  7095. ExitLoop
  7096. EndIf
  7097. $ioccurance += 1
  7098. WEnd
  7099. EndIf
  7100. _guictrlstatusbar_settext($idstatusbar1, "Find: " & GUICtrlRead($idinputsearch))
  7101. EndIf
  7102. If $breplace = False Then
  7103. GUICtrlSetState($idlblreplace, $__editconstant_gui_hide)
  7104. GUICtrlSetState($idinputreplace, $__editconstant_gui_hide)
  7105. GUICtrlSetState($idbtnreplace, $__editconstant_gui_hide)
  7106. Else
  7107. _guictrlstatusbar_settext($idstatusbar1, "Replacements: " & $ireplacements, 1)
  7108. _guictrlstatusbar_settext($idstatusbar1, "With: ", 2)
  7109. EndIf
  7110. GUISetState(@SW_SHOW)
  7111. Local $imsgfind
  7112. While 1
  7113. $imsgfind = GUIGetMsg()
  7114. Select
  7115. Case $imsgfind = $__editconstant_gui_event_close OR $imsgfind = $idbtnclose
  7116. ExitLoop
  7117. Case $imsgfind = $idbtnfindnext
  7118. GUICtrlSetState($idbtnfindnext, $__editconstant_gui_disable)
  7119. GUICtrlSetCursor($idbtnfindnext, 15)
  7120. Sleep(100)
  7121. _guictrlstatusbar_settext($idstatusbar1, "Find: " & GUICtrlRead($idinputsearch))
  7122. If $breplace = True Then
  7123. _guictrlstatusbar_settext($idstatusbar1, "Find: " & GUICtrlRead($idinputsearch))
  7124. _guictrlstatusbar_settext($idstatusbar1, "With: " & GUICtrlRead($idinputreplace), 2)
  7125. EndIf
  7126. __guictrledit_findtext($hwnd, $idinputsearch, $idchkmatchcase, $idchkwholeonly, $ipos, $ioccurance, $ireplacements)
  7127. Sleep(100)
  7128. GUICtrlSetState($idbtnfindnext, $__editconstant_gui_enable)
  7129. GUICtrlSetCursor($idbtnfindnext, 2)
  7130. Case $imsgfind = $idbtnreplace
  7131. GUICtrlSetState($idbtnreplace, $__editconstant_gui_disable)
  7132. GUICtrlSetCursor($idbtnreplace, 15)
  7133. Sleep(100)
  7134. _guictrlstatusbar_settext($idstatusbar1, "Find: " & GUICtrlRead($idinputsearch))
  7135. _guictrlstatusbar_settext($idstatusbar1, "With: " & GUICtrlRead($idinputreplace), 2)
  7136. If $ipos Then
  7137. _guictrledit_replacesel($hwnd, GUICtrlRead($idinputreplace))
  7138. $ireplacements += 1
  7139. $ioccurance -= 1
  7140. _guictrlstatusbar_settext($idstatusbar1, "Replacements: " & $ireplacements, 1)
  7141. EndIf
  7142. __guictrledit_findtext($hwnd, $idinputsearch, $idchkmatchcase, $idchkwholeonly, $ipos, $ioccurance, $ireplacements)
  7143. Sleep(100)
  7144. GUICtrlSetState($idbtnreplace, $__editconstant_gui_enable)
  7145. GUICtrlSetCursor($idbtnreplace, 2)
  7146. EndSelect
  7147. WEnd
  7148. GUIDelete($hguisearch)
  7149. Opt("GUIOnEventMode", $ioldmode)
  7150. EndFunc
  7151.  
  7152. Func _guictrledit_getcuebanner($hwnd)
  7153. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7154. Local $ttext = DllStructCreate("wchar[4096]")
  7155. If _sendmessage($hwnd, $em_getcuebanner, $ttext, 4096, 0, "struct*") <> 1 Then Return SetError(-1, 0, "")
  7156. Return _winapi_widechartomultibyte($ttext)
  7157. EndFunc
  7158.  
  7159. Func __guictrledit_findtext($hwnd, $idinputsearch, $idchkmatchcase, $idchkwholeonly, ByRef $ipos, ByRef $ioccurance, ByRef $ireplacements)
  7160. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7161. Local $icase = 0, $iwhole = 0
  7162. Local $bexact = False
  7163. Local $sfind = GUICtrlRead($idinputsearch)
  7164. Local $stext = _guictrledit_gettext($hwnd)
  7165. If BitAND(GUICtrlRead($idchkmatchcase), $__editconstant_gui_checked) = $__editconstant_gui_checked Then $icase = 1
  7166. If BitAND(GUICtrlRead($idchkwholeonly), $__editconstant_gui_checked) = $__editconstant_gui_checked Then $iwhole = 1
  7167. If $sfind <> "" Then
  7168. $ioccurance += 1
  7169. $ipos = StringInStr($stext, $sfind, $icase, $ioccurance)
  7170. If $iwhole AND $ipos Then
  7171. Local $s_compare2 = StringMid($stext, $ipos + StringLen($sfind), 1)
  7172. If $ipos = 1 Then
  7173. If ($ipos + StringLen($sfind)) - 1 = StringLen($stext) OR ($s_compare2 = " " OR $s_compare2 = @LF OR $s_compare2 = @CR OR $s_compare2 = @CRLF OR $s_compare2 = @TAB) Then $bexact = True
  7174. Else
  7175. Local $s_compare1 = StringMid($stext, $ipos - 1, 1)
  7176. If ($ipos + StringLen($sfind)) - 1 = StringLen($stext) Then
  7177. If ($s_compare1 = " " OR $s_compare1 = @LF OR $s_compare1 = @CR OR $s_compare1 = @CRLF OR $s_compare1 = @TAB) Then $bexact = True
  7178. Else
  7179. If ($s_compare1 = " " OR $s_compare1 = @LF OR $s_compare1 = @CR OR $s_compare1 = @CRLF OR $s_compare1 = @TAB) AND ($s_compare2 = " " OR $s_compare2 = @LF OR $s_compare2 = @CR OR $s_compare2 = @CRLF OR $s_compare2 = @TAB) Then $bexact = True
  7180. EndIf
  7181. EndIf
  7182. If $bexact = False Then
  7183. __guictrledit_findtext($hwnd, $idinputsearch, $idchkmatchcase, $idchkwholeonly, $ipos, $ioccurance, $ireplacements)
  7184. Else
  7185. _guictrledit_setsel($hwnd, $ipos - 1, ($ipos + StringLen($sfind)) - 1)
  7186. _guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
  7187. EndIf
  7188. ElseIf $iwhole AND NOT $ipos Then
  7189. $ioccurance = 0
  7190. MsgBox($mb_systemmodal, "Find", "Reached End of document, Can not find the string '" & $sfind & "'")
  7191. ElseIf NOT $iwhole Then
  7192. If NOT $ipos Then
  7193. $ioccurance = 1
  7194. _guictrledit_setsel($hwnd, -1, 0)
  7195. _guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
  7196. $ipos = StringInStr($stext, $sfind, $icase, $ioccurance)
  7197. If NOT $ipos Then
  7198. $ioccurance = 0
  7199. MsgBox($mb_systemmodal, "Find", "Reached End of document, Can not find the string '" & $sfind & "'")
  7200. Else
  7201. _guictrledit_setsel($hwnd, $ipos - 1, ($ipos + StringLen($sfind)) - 1)
  7202. _guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
  7203. EndIf
  7204. Else
  7205. _guictrledit_setsel($hwnd, $ipos - 1, ($ipos + StringLen($sfind)) - 1)
  7206. _guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
  7207. EndIf
  7208. EndIf
  7209. EndIf
  7210. EndFunc
  7211.  
  7212. Func _guictrledit_getfirstvisibleline($hwnd)
  7213. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7214. Return _sendmessage($hwnd, $em_getfirstvisibleline)
  7215. EndFunc
  7216.  
  7217. Func _guictrledit_gethandle($hwnd)
  7218. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7219. Return Ptr(_sendmessage($hwnd, $em_gethandle))
  7220. EndFunc
  7221.  
  7222. Func _guictrledit_getimestatus($hwnd)
  7223. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7224. Return _sendmessage($hwnd, $em_getimestatus, $emsis_compositionstring)
  7225. EndFunc
  7226.  
  7227. Func _guictrledit_getlimittext($hwnd)
  7228. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7229. Return _sendmessage($hwnd, $em_getlimittext)
  7230. EndFunc
  7231.  
  7232. Func _guictrledit_getline($hwnd, $iline)
  7233. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7234. Local $ilength = _guictrledit_linelength($hwnd, $iline)
  7235. If $ilength = 0 Then Return ""
  7236. Local $tbuffer = DllStructCreate("short Len;wchar Text[" & $ilength & "]")
  7237. DllStructSetData($tbuffer, "Len", $ilength + 1)
  7238. Local $iret = _sendmessage($hwnd, $em_getline, $iline, $tbuffer, 0, "wparam", "struct*")
  7239. If $iret = 0 Then Return SetError($ec_err, $ec_err, "")
  7240. Local $ttext = DllStructCreate("wchar Text[" & $ilength & "]", DllStructGetPtr($tbuffer))
  7241. Return DllStructGetData($ttext, "Text")
  7242. EndFunc
  7243.  
  7244. Func _guictrledit_getlinecount($hwnd)
  7245. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7246. Return _sendmessage($hwnd, $em_getlinecount)
  7247. EndFunc
  7248.  
  7249. Func _guictrledit_getmargins($hwnd)
  7250. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7251. Local $amargins[2]
  7252. Local $imargins = _sendmessage($hwnd, $em_getmargins)
  7253. $amargins[0] = _winapi_loword($imargins)
  7254. $amargins[1] = _winapi_hiword($imargins)
  7255. Return $amargins
  7256. EndFunc
  7257.  
  7258. Func _guictrledit_getmodify($hwnd)
  7259. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7260. Return _sendmessage($hwnd, $em_getmodify) <> 0
  7261. EndFunc
  7262.  
  7263. Func _guictrledit_getpasswordchar($hwnd)
  7264. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7265. Return _sendmessage($hwnd, $em_getpasswordchar)
  7266. EndFunc
  7267.  
  7268. Func _guictrledit_getrect($hwnd)
  7269. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7270. Local $arect[4]
  7271. Local $trect = _guictrledit_getrectex($hwnd)
  7272. $arect[0] = DllStructGetData($trect, "Left")
  7273. $arect[1] = DllStructGetData($trect, "Top")
  7274. $arect[2] = DllStructGetData($trect, "Right")
  7275. $arect[3] = DllStructGetData($trect, "Bottom")
  7276. Return $arect
  7277. EndFunc
  7278.  
  7279. Func _guictrledit_getrectex($hwnd)
  7280. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7281. Local $trect = DllStructCreate($tagrect)
  7282. _sendmessage($hwnd, $em_getrect, 0, $trect, 0, "wparam", "struct*")
  7283. Return $trect
  7284. EndFunc
  7285.  
  7286. Func _guictrledit_getsel($hwnd)
  7287. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7288. Local $asel[2]
  7289. Local $tstart = DllStructCreate("uint Start")
  7290. Local $tend = DllStructCreate("uint End")
  7291. _sendmessage($hwnd, $em_getsel, $tstart, $tend, 0, "struct*", "struct*")
  7292. $asel[0] = DllStructGetData($tstart, "Start")
  7293. $asel[1] = DllStructGetData($tend, "End")
  7294. Return $asel
  7295. EndFunc
  7296.  
  7297. Func _guictrledit_gettext($hwnd)
  7298. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7299. Local $itextlen = _guictrledit_gettextlen($hwnd) + 1
  7300. Local $ttext = DllStructCreate("wchar Text[" & $itextlen & "]")
  7301. _sendmessage($hwnd, $__editconstant_wm_gettext, $itextlen, $ttext, 0, "wparam", "struct*")
  7302. Return DllStructGetData($ttext, "Text")
  7303. EndFunc
  7304.  
  7305. Func _guictrledit_gettextlen($hwnd)
  7306. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7307. Return _sendmessage($hwnd, $__editconstant_wm_gettextlength)
  7308. EndFunc
  7309.  
  7310. Func _guictrledit_getthumb($hwnd)
  7311. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7312. Return _sendmessage($hwnd, $em_getthumb)
  7313. EndFunc
  7314.  
  7315. Func _guictrledit_getwordbreakproc($hwnd)
  7316. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7317. Return _sendmessage($hwnd, $em_getwordbreakproc)
  7318. EndFunc
  7319.  
  7320. Func _guictrledit_hideballoontip($hwnd)
  7321. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7322. Return _sendmessage($hwnd, $em_hideballoontip) <> 0
  7323. EndFunc
  7324.  
  7325. Func _guictrledit_inserttext($hwnd, $stext, $iindex = -1)
  7326. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7327. If $iindex = -1 Then
  7328. _guictrledit_appendtext($hwnd, $stext)
  7329. Else
  7330. _guictrledit_setsel($hwnd, $iindex, $iindex)
  7331. _sendmessage($hwnd, $em_replacesel, True, $stext, 0, "wparam", "wstr")
  7332. EndIf
  7333. EndFunc
  7334.  
  7335. Func _guictrledit_linefromchar($hwnd, $iindex = -1)
  7336. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7337. Return _sendmessage($hwnd, $em_linefromchar, $iindex)
  7338. EndFunc
  7339.  
  7340. Func _guictrledit_lineindex($hwnd, $iindex = -1)
  7341. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7342. Return _sendmessage($hwnd, $em_lineindex, $iindex)
  7343. EndFunc
  7344.  
  7345. Func _guictrledit_linelength($hwnd, $iindex = -1)
  7346. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7347. Local $icharindex = _guictrledit_lineindex($hwnd, $iindex)
  7348. Return _sendmessage($hwnd, $em_linelength, $icharindex)
  7349. EndFunc
  7350.  
  7351. Func _guictrledit_linescroll($hwnd, $ihoriz, $ivert)
  7352. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7353. Return _sendmessage($hwnd, $em_linescroll, $ihoriz, $ivert) <> 0
  7354. EndFunc
  7355.  
  7356. Func _guictrledit_posfromchar($hwnd, $iindex)
  7357. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7358. Local $acoord[2]
  7359. Local $iret = _sendmessage($hwnd, $em_posfromchar, $iindex)
  7360. $acoord[0] = _winapi_loword($iret)
  7361. $acoord[1] = _winapi_hiword($iret)
  7362. Return $acoord
  7363. EndFunc
  7364.  
  7365. Func _guictrledit_replacesel($hwnd, $stext, $bundo = True)
  7366. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7367. _sendmessage($hwnd, $em_replacesel, $bundo, $stext, 0, "wparam", "wstr")
  7368. EndFunc
  7369.  
  7370. Func _guictrledit_scroll($hwnd, $idirection)
  7371. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7372. If BitAND($idirection, $__editconstant_sb_linedown) <> $__editconstant_sb_linedown AND BitAND($idirection, $__editconstant_sb_lineup) <> $__editconstant_sb_lineup AND BitAND($idirection, $__editconstant_sb_pagedown) <> $__editconstant_sb_pagedown AND BitAND($idirection, $__editconstant_sb_pageup) <> $__editconstant_sb_pageup AND BitAND($idirection, $__editconstant_sb_scrollcaret) <> $__editconstant_sb_scrollcaret Then Return 0
  7373. If $idirection == $__editconstant_sb_scrollcaret Then
  7374. Return _sendmessage($hwnd, $em_scrollcaret)
  7375. Else
  7376. Return _sendmessage($hwnd, $em_scroll, $idirection)
  7377. EndIf
  7378. EndFunc
  7379.  
  7380. Func _guictrledit_setcuebanner($hwnd, $stext, $bonfocus = False)
  7381. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7382. Local $ttext = _winapi_multibytetowidechar($stext)
  7383. Return _sendmessage($hwnd, $em_setcuebanner, $bonfocus, $ttext, 0, "wparam", "struct*") = 1
  7384. EndFunc
  7385.  
  7386. Func _guictrledit_sethandle($hwnd, $hmemory)
  7387. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7388. _sendmessage($hwnd, $em_sethandle, $hmemory, 0, 0, "handle")
  7389. EndFunc
  7390.  
  7391. Func _guictrledit_setimestatus($hwnd, $icomposition)
  7392. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7393. Return _sendmessage($hwnd, $em_setimestatus, $emsis_compositionstring, $icomposition)
  7394. EndFunc
  7395.  
  7396. Func _guictrledit_setlimittext($hwnd, $ilimit)
  7397. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7398. _sendmessage($hwnd, $em_setlimittext, $ilimit)
  7399. EndFunc
  7400.  
  7401. Func _guictrledit_setmargins($hwnd, $imargin = 1, $ileft = 65535, $iright = 65535)
  7402. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7403. _sendmessage($hwnd, $em_setmargins, $imargin, _winapi_makelong($ileft, $iright))
  7404. EndFunc
  7405.  
  7406. Func _guictrledit_setmodify($hwnd, $bmodified)
  7407. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7408. _sendmessage($hwnd, $em_setmodify, $bmodified)
  7409. EndFunc
  7410.  
  7411. Func _guictrledit_setpasswordchar($hwnd, $sdisplaychar = "0")
  7412. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7413. $sdisplaychar = StringLeft($sdisplaychar, 1)
  7414. If Asc($sdisplaychar) = 48 Then
  7415. _sendmessage($hwnd, $em_setpasswordchar)
  7416. Else
  7417. _sendmessage($hwnd, $em_setpasswordchar, Asc($sdisplaychar))
  7418. EndIf
  7419. EndFunc
  7420.  
  7421. Func _guictrledit_setreadonly($hwnd, $breadonly)
  7422. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7423. Return _sendmessage($hwnd, $em_setreadonly, $breadonly) <> 0
  7424. EndFunc
  7425.  
  7426. Func _guictrledit_setrect($hwnd, $arect)
  7427. Local $trect = DllStructCreate($tagrect)
  7428. DllStructSetData($trect, "Left", $arect[0])
  7429. DllStructSetData($trect, "Top", $arect[1])
  7430. DllStructSetData($trect, "Right", $arect[2])
  7431. DllStructSetData($trect, "Bottom", $arect[3])
  7432. _guictrledit_setrectex($hwnd, $trect)
  7433. EndFunc
  7434.  
  7435. Func _guictrledit_setrectex($hwnd, $trect)
  7436. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7437. _sendmessage($hwnd, $em_setrect, 0, $trect, 0, "wparam", "struct*")
  7438. EndFunc
  7439.  
  7440. Func _guictrledit_setrectnp($hwnd, $arect)
  7441. Local $trect = DllStructCreate($tagrect)
  7442. DllStructSetData($trect, "Left", $arect[0])
  7443. DllStructSetData($trect, "Top", $arect[1])
  7444. DllStructSetData($trect, "Right", $arect[2])
  7445. DllStructSetData($trect, "Bottom", $arect[3])
  7446. _guictrledit_setrectnpex($hwnd, $trect)
  7447. EndFunc
  7448.  
  7449. Func _guictrledit_setrectnpex($hwnd, $trect)
  7450. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7451. _sendmessage($hwnd, $em_setrectnp, 0, $trect, 0, "wparam", "struct*")
  7452. EndFunc
  7453.  
  7454. Func _guictrledit_setsel($hwnd, $istart, $iend)
  7455. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7456. _sendmessage($hwnd, $em_setsel, $istart, $iend)
  7457. EndFunc
  7458.  
  7459. Func _guictrledit_settabstops($hwnd, $atabstops)
  7460. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7461. If NOT IsArray($atabstops) Then Return SetError(-1, -1, False)
  7462. Local $stabstops = ""
  7463. Local $inumtabstops = UBound($atabstops)
  7464. For $x = 0 To $inumtabstops - 1
  7465. $stabstops &= "int;"
  7466. Next
  7467. $stabstops = StringTrimRight($stabstops, 1)
  7468. Local $ttabstops = DllStructCreate($stabstops)
  7469. For $x = 0 To $inumtabstops - 1
  7470. DllStructSetData($ttabstops, $x + 1, $atabstops[$x])
  7471. Next
  7472. Local $iret = _sendmessage($hwnd, $em_settabstops, $inumtabstops, $ttabstops, 0, "wparam", "struct*") <> 0
  7473. _winapi_invalidaterect($hwnd)
  7474. Return $iret
  7475. EndFunc
  7476.  
  7477. Func _guictrledit_settext($hwnd, $stext)
  7478. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7479. _sendmessage($hwnd, $__editconstant_wm_settext, 0, $stext, 0, "wparam", "wstr")
  7480. EndFunc
  7481.  
  7482. Func _guictrledit_setwordbreakproc($hwnd, $iaddressfunc)
  7483. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7484. _sendmessage($hwnd, $em_setwordbreakproc, 0, $iaddressfunc)
  7485. EndFunc
  7486.  
  7487. Func _guictrledit_showballoontip($hwnd, $stitle, $stext, $iicon)
  7488. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7489. Local $ttitle = _winapi_multibytetowidechar($stitle)
  7490. Local $ttext = _winapi_multibytetowidechar($stext)
  7491. Local $ttt = DllStructCreate($__tageditballoontip)
  7492. DllStructSetData($ttt, "Size", DllStructGetSize($ttt))
  7493. DllStructSetData($ttt, "Title", DllStructGetPtr($ttitle))
  7494. DllStructSetData($ttt, "Text", DllStructGetPtr($ttext))
  7495. DllStructSetData($ttt, "Icon", $iicon)
  7496. Return _sendmessage($hwnd, $em_showballoontip, 0, $ttt, 0, "wparam", "struct*") <> 0
  7497. EndFunc
  7498.  
  7499. Func _guictrledit_undo($hwnd)
  7500. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  7501. Return _sendmessage($hwnd, $em_undo) <> 0
  7502. EndFunc
  7503.  
  7504. Func _filecountlines($sfilepath)
  7505. Local $hfileopen = FileOpen($sfilepath, $fo_read)
  7506. If $hfileopen = -1 Then Return SetError(1, 0, 0)
  7507. Local $sfileread = StringStripWS(FileRead($hfileopen), $str_striptrailing)
  7508. FileClose($hfileopen)
  7509. Return UBound(StringRegExp($sfileread, "\R", $str_regexparrayglobalmatch)) + 1 - Int($sfileread = "")
  7510. EndFunc
  7511.  
  7512. Func _filecreate($sfilepath)
  7513. Local $hfileopen = FileOpen($sfilepath, BitOR($fo_overwrite, $fo_createpath))
  7514. If $hfileopen = -1 Then Return SetError(1, 0, 0)
  7515. Local $ifilewrite = FileWrite($hfileopen, "")
  7516. FileClose($hfileopen)
  7517. If NOT $ifilewrite Then Return SetError(2, 0, 0)
  7518. Return 1
  7519. EndFunc
  7520.  
  7521. Func _filelisttoarray($sfilepath, $sfilter = "*", $iflag = $flta_filesfolders, $breturnpath = False)
  7522. Local $sdelimiter = "|", $sfilelist = "", $sfilename = "", $sfullpath = ""
  7523. $sfilepath = StringRegExpReplace($sfilepath, "[\\/]+$", "") & "\"
  7524. If $iflag = Default Then $iflag = $flta_filesfolders
  7525. If $breturnpath Then $sfullpath = $sfilepath
  7526. If $sfilter = Default Then $sfilter = "*"
  7527. If NOT FileExists($sfilepath) Then Return SetError(1, 0, 0)
  7528. If StringRegExp($sfilter, "[\\/:><\|]|(?s)^\s*$") Then Return SetError(2, 0, 0)
  7529. If NOT ($iflag = 0 OR $iflag = 1 OR $iflag = 2) Then Return SetError(3, 0, 0)
  7530. Local $hsearch = FileFindFirstFile($sfilepath & $sfilter)
  7531. If @error Then Return SetError(4, 0, 0)
  7532. While 1
  7533. $sfilename = FileFindNextFile($hsearch)
  7534. If @error Then ExitLoop
  7535. If ($iflag + @extended = 2) Then ContinueLoop
  7536. $sfilelist &= $sdelimiter & $sfullpath & $sfilename
  7537. WEnd
  7538. FileClose($hsearch)
  7539. If $sfilelist = "" Then Return SetError(4, 0, 0)
  7540. Return StringSplit(StringTrimLeft($sfilelist, 1), $sdelimiter)
  7541. EndFunc
  7542.  
  7543. Func _filelisttoarrayrec($sfilepath, $smask = "*", $ireturn = $fltar_filesfolders, $irecur = $fltar_norecur, $isort = $fltar_nosort, $ireturnpath = $fltar_relpath)
  7544. If NOT FileExists($sfilepath) Then Return SetError(1, 1, "")
  7545. If $smask = Default Then $smask = "*"
  7546. If $ireturn = Default Then $ireturn = $fltar_filesfolders
  7547. If $irecur = Default Then $irecur = $fltar_norecur
  7548. If $isort = Default Then $isort = $fltar_nosort
  7549. If $ireturnpath = Default Then $ireturnpath = $fltar_relpath
  7550. If $irecur > 1 OR NOT IsInt($irecur) Then Return SetError(1, 6, "")
  7551. Local $blongpath = False
  7552. If StringLeft($sfilepath, 4) == "\\?\" Then
  7553. $blongpath = True
  7554. EndIf
  7555. Local $sfolderslash = ""
  7556. If StringRight($sfilepath, 1) = "\" Then
  7557. $sfolderslash = "\"
  7558. Else
  7559. $sfilepath = $sfilepath & "\"
  7560. EndIf
  7561. Local $asfoldersearchlist[100] = [1]
  7562. $asfoldersearchlist[1] = $sfilepath
  7563. Local $ihide_hs = 0, $shide_hs = ""
  7564. If BitAND($ireturn, 4) Then
  7565. $ihide_hs += 2
  7566. $shide_hs &= "H"
  7567. $ireturn -= 4
  7568. EndIf
  7569. If BitAND($ireturn, 8) Then
  7570. $ihide_hs += 4
  7571. $shide_hs &= "S"
  7572. $ireturn -= 8
  7573. EndIf
  7574. Local $ihide_link = 0
  7575. If BitAND($ireturn, 16) Then
  7576. $ihide_link = 1024
  7577. $ireturn -= 16
  7578. EndIf
  7579. Local $imaxlevel = 0
  7580. If $irecur < 0 Then
  7581. StringReplace($sfilepath, "\", "", 0, $str_nocasesensebasic)
  7582. $imaxlevel = @extended - $irecur
  7583. EndIf
  7584. Local $sexclude_list = "", $sexclude_list_folder = "", $sinclude_list = "*"
  7585. Local $amasksplit = StringSplit($smask, "|")
  7586. Switch $amasksplit[0]
  7587. Case 3
  7588. $sexclude_list_folder = $amasksplit[3]
  7589. ContinueCase
  7590. Case 2
  7591. $sexclude_list = $amasksplit[2]
  7592. ContinueCase
  7593. Case 1
  7594. $sinclude_list = $amasksplit[1]
  7595. EndSwitch
  7596. Local $sinclude_file_mask = ".+"
  7597. If $sinclude_list <> "*" Then
  7598. If NOT __fltar_listtomask($sinclude_file_mask, $sinclude_list) Then Return SetError(1, 2, "")
  7599. EndIf
  7600. Local $sinclude_folder_mask = ".+"
  7601. Switch $ireturn
  7602. Case 0
  7603. Switch $irecur
  7604. Case 0
  7605. $sinclude_folder_mask = $sinclude_file_mask
  7606. EndSwitch
  7607. Case 2
  7608. $sinclude_folder_mask = $sinclude_file_mask
  7609. EndSwitch
  7610. Local $sexclude_file_mask = ":"
  7611. If $sexclude_list <> "" Then
  7612. If NOT __fltar_listtomask($sexclude_file_mask, $sexclude_list) Then Return SetError(1, 3, "")
  7613. EndIf
  7614. Local $sexclude_folder_mask = ":"
  7615. If $irecur Then
  7616. If $sexclude_list_folder Then
  7617. If NOT __fltar_listtomask($sexclude_folder_mask, $sexclude_list_folder) Then Return SetError(1, 4, "")
  7618. EndIf
  7619. If $ireturn = 2 Then
  7620. $sexclude_folder_mask = $sexclude_file_mask
  7621. EndIf
  7622. Else
  7623. $sexclude_folder_mask = $sexclude_file_mask
  7624. EndIf
  7625. If NOT ($ireturn = 0 OR $ireturn = 1 OR $ireturn = 2) Then Return SetError(1, 5, "")
  7626. If NOT ($isort = 0 OR $isort = 1 OR $isort = 2) Then Return SetError(1, 7, "")
  7627. If NOT ($ireturnpath = 0 OR $ireturnpath = 1 OR $ireturnpath = 2) Then Return SetError(1, 8, "")
  7628. If $ihide_link Then
  7629. Local $tfile_data = DllStructCreate("struct;align 4;dword FileAttributes;uint64 CreationTime;uint64 LastAccessTime;uint64 LastWriteTime;" & "dword FileSizeHigh;dword FileSizeLow;dword Reserved0;dword Reserved1;wchar FileName[260];wchar AlternateFileName[14];endstruct")
  7630. Local $hdll = DllOpen("kernel32.dll"), $adll_ret
  7631. EndIf
  7632. Local $asreturnlist[100] = [0]
  7633. Local $asfilematchlist = $asreturnlist, $asrootfilematchlist = $asreturnlist, $asfoldermatchlist = $asreturnlist
  7634. Local $bfolder = False, $hsearch = 0, $scurrentpath = "", $sname = "", $sretpath = ""
  7635. Local $iattribs = 0, $sattribs = ""
  7636. Local $asfolderfilesectionlist[100][2] = [[0, 0]]
  7637. While $asfoldersearchlist[0] > 0
  7638. $scurrentpath = $asfoldersearchlist[$asfoldersearchlist[0]]
  7639. $asfoldersearchlist[0] -= 1
  7640. Switch $ireturnpath
  7641. Case 1
  7642. $sretpath = StringReplace($scurrentpath, $sfilepath, "")
  7643. Case 2
  7644. If $blongpath Then
  7645. $sretpath = StringTrimLeft($scurrentpath, 4)
  7646. Else
  7647. $sretpath = $scurrentpath
  7648. EndIf
  7649. EndSwitch
  7650. If $ihide_link Then
  7651. $adll_ret = DllCall($hdll, "handle", "FindFirstFileW", "wstr", $scurrentpath & "*", "struct*", $tfile_data)
  7652. If @error OR NOT $adll_ret[0] Then
  7653. ContinueLoop
  7654. EndIf
  7655. $hsearch = $adll_ret[0]
  7656. Else
  7657. $hsearch = FileFindFirstFile($scurrentpath & "*")
  7658. If $hsearch = -1 Then
  7659. ContinueLoop
  7660. EndIf
  7661. EndIf
  7662. If $ireturn = 0 AND $isort AND $ireturnpath Then
  7663. __fltar_addtolist($asfolderfilesectionlist, $sretpath, $asfilematchlist[0] + 1)
  7664. EndIf
  7665. $sattribs = ""
  7666. While 1
  7667. If $ihide_link Then
  7668. $adll_ret = DllCall($hdll, "int", "FindNextFileW", "handle", $hsearch, "struct*", $tfile_data)
  7669. If @error OR NOT $adll_ret[0] Then
  7670. ExitLoop
  7671. EndIf
  7672. $sname = DllStructGetData($tfile_data, "FileName")
  7673. If $sname = ".." Then
  7674. ContinueLoop
  7675. EndIf
  7676. $iattribs = DllStructGetData($tfile_data, "FileAttributes")
  7677. If $ihide_hs AND BitAND($iattribs, $ihide_hs) Then
  7678. ContinueLoop
  7679. EndIf
  7680. If BitAND($iattribs, $ihide_link) Then
  7681. ContinueLoop
  7682. EndIf
  7683. $bfolder = False
  7684. If BitAND($iattribs, 16) Then
  7685. $bfolder = True
  7686. EndIf
  7687. Else
  7688. $bfolder = False
  7689. $sname = FileFindNextFile($hsearch, 1)
  7690. If @error Then
  7691. ExitLoop
  7692. EndIf
  7693. $sattribs = @extended
  7694. If StringInStr($sattribs, "D") Then
  7695. $bfolder = True
  7696. EndIf
  7697. If StringRegExp($sattribs, "[" & $shide_hs & "]") Then
  7698. ContinueLoop
  7699. EndIf
  7700. EndIf
  7701. If $bfolder Then
  7702. Select
  7703. Case $irecur < 0
  7704. StringReplace($scurrentpath, "\", "", 0, $str_nocasesensebasic)
  7705. If @extended < $imaxlevel Then
  7706. ContinueCase
  7707. EndIf
  7708. Case $irecur = 1
  7709. If NOT StringRegExp($sname, $sexclude_folder_mask) Then
  7710. __fltar_addtolist($asfoldersearchlist, $scurrentpath & $sname & "\")
  7711. EndIf
  7712. EndSelect
  7713. EndIf
  7714. If $isort Then
  7715. If $bfolder Then
  7716. If StringRegExp($sname, $sinclude_folder_mask) AND NOT StringRegExp($sname, $sexclude_folder_mask) Then
  7717. __fltar_addtolist($asfoldermatchlist, $sretpath & $sname & $sfolderslash)
  7718. EndIf
  7719. Else
  7720. If StringRegExp($sname, $sinclude_file_mask) AND NOT StringRegExp($sname, $sexclude_file_mask) Then
  7721. If $scurrentpath = $sfilepath Then
  7722. __fltar_addtolist($asrootfilematchlist, $sretpath & $sname)
  7723. Else
  7724. __fltar_addtolist($asfilematchlist, $sretpath & $sname)
  7725. EndIf
  7726. EndIf
  7727. EndIf
  7728. Else
  7729. If $bfolder Then
  7730. If $ireturn <> 1 AND StringRegExp($sname, $sinclude_folder_mask) AND NOT StringRegExp($sname, $sexclude_folder_mask) Then
  7731. __fltar_addtolist($asreturnlist, $sretpath & $sname & $sfolderslash)
  7732. EndIf
  7733. Else
  7734. If $ireturn <> 2 AND StringRegExp($sname, $sinclude_file_mask) AND NOT StringRegExp($sname, $sexclude_file_mask) Then
  7735. __fltar_addtolist($asreturnlist, $sretpath & $sname)
  7736. EndIf
  7737. EndIf
  7738. EndIf
  7739. WEnd
  7740. If $ihide_link Then
  7741. DllCall($hdll, "int", "FindClose", "ptr", $hsearch)
  7742. Else
  7743. FileClose($hsearch)
  7744. EndIf
  7745. WEnd
  7746. If $ihide_link Then
  7747. DllClose($hdll)
  7748. EndIf
  7749. If $isort Then
  7750. Switch $ireturn
  7751. Case 2
  7752. If $asfoldermatchlist[0] = 0 Then Return SetError(1, 9, "")
  7753. ReDim $asfoldermatchlist[$asfoldermatchlist[0] + 1]
  7754. $asreturnlist = $asfoldermatchlist
  7755. __arraydualpivotsort($asreturnlist, 1, $asreturnlist[0])
  7756. Case 1
  7757. If $asrootfilematchlist[0] = 0 AND $asfilematchlist[0] = 0 Then Return SetError(1, 9, "")
  7758. If $ireturnpath = 0 Then
  7759. __fltar_addfilelists($asreturnlist, $asrootfilematchlist, $asfilematchlist)
  7760. __arraydualpivotsort($asreturnlist, 1, $asreturnlist[0])
  7761. Else
  7762. __fltar_addfilelists($asreturnlist, $asrootfilematchlist, $asfilematchlist, 1)
  7763. EndIf
  7764. Case 0
  7765. If $asrootfilematchlist[0] = 0 AND $asfoldermatchlist[0] = 0 Then Return SetError(1, 9, "")
  7766. If $ireturnpath = 0 Then
  7767. __fltar_addfilelists($asreturnlist, $asrootfilematchlist, $asfilematchlist)
  7768. $asreturnlist[0] += $asfoldermatchlist[0]
  7769. ReDim $asfoldermatchlist[$asfoldermatchlist[0] + 1]
  7770. _arrayconcatenate($asreturnlist, $asfoldermatchlist, 1)
  7771. __arraydualpivotsort($asreturnlist, 1, $asreturnlist[0])
  7772. Else
  7773. Local $asreturnlist[$asfilematchlist[0] + $asrootfilematchlist[0] + $asfoldermatchlist[0] + 1]
  7774. $asreturnlist[0] = $asfilematchlist[0] + $asrootfilematchlist[0] + $asfoldermatchlist[0]
  7775. __arraydualpivotsort($asrootfilematchlist, 1, $asrootfilematchlist[0])
  7776. For $i = 1 To $asrootfilematchlist[0]
  7777. $asreturnlist[$i] = $asrootfilematchlist[$i]
  7778. Next
  7779. Local $inextinsertionindex = $asrootfilematchlist[0] + 1
  7780. __arraydualpivotsort($asfoldermatchlist, 1, $asfoldermatchlist[0])
  7781. Local $sfoldertofind = ""
  7782. For $i = 1 To $asfoldermatchlist[0]
  7783. $asreturnlist[$inextinsertionindex] = $asfoldermatchlist[$i]
  7784. $inextinsertionindex += 1
  7785. If $sfolderslash Then
  7786. $sfoldertofind = $asfoldermatchlist[$i]
  7787. Else
  7788. $sfoldertofind = $asfoldermatchlist[$i] & "\"
  7789. EndIf
  7790. Local $ifilesectionendindex = 0, $ifilesectionstartindex = 0
  7791. For $j = 1 To $asfolderfilesectionlist[0][0]
  7792. If $sfoldertofind = $asfolderfilesectionlist[$j][0] Then
  7793. $ifilesectionstartindex = $asfolderfilesectionlist[$j][1]
  7794. If $j = $asfolderfilesectionlist[0][0] Then
  7795. $ifilesectionendindex = $asfilematchlist[0]
  7796. Else
  7797. $ifilesectionendindex = $asfolderfilesectionlist[$j + 1][1] - 1
  7798. EndIf
  7799. If $isort = 1 Then
  7800. __arraydualpivotsort($asfilematchlist, $ifilesectionstartindex, $ifilesectionendindex)
  7801. EndIf
  7802. For $k = $ifilesectionstartindex To $ifilesectionendindex
  7803. $asreturnlist[$inextinsertionindex] = $asfilematchlist[$k]
  7804. $inextinsertionindex += 1
  7805. Next
  7806. ExitLoop
  7807. EndIf
  7808. Next
  7809. Next
  7810. EndIf
  7811. EndSwitch
  7812. Else
  7813. If $asreturnlist[0] = 0 Then Return SetError(1, 9, "")
  7814. ReDim $asreturnlist[$asreturnlist[0] + 1]
  7815. EndIf
  7816. Return $asreturnlist
  7817. EndFunc
  7818.  
  7819. Func __fltar_addfilelists(ByRef $astarget, $assource_1, $assource_2, $isort = 0)
  7820. ReDim $assource_1[$assource_1[0] + 1]
  7821. If $isort = 1 Then __arraydualpivotsort($assource_1, 1, $assource_1[0])
  7822. $astarget = $assource_1
  7823. $astarget[0] += $assource_2[0]
  7824. ReDim $assource_2[$assource_2[0] + 1]
  7825. If $isort = 1 Then __arraydualpivotsort($assource_2, 1, $assource_2[0])
  7826. _arrayconcatenate($astarget, $assource_2, 1)
  7827. EndFunc
  7828.  
  7829. Func __fltar_addtolist(ByRef $alist, $vvalue_0, $vvalue_1 = -1)
  7830. If $vvalue_1 = -1 Then
  7831. $alist[0] += 1
  7832. If UBound($alist) <= $alist[0] Then ReDim $alist[UBound($alist) * 2]
  7833. $alist[$alist[0]] = $vvalue_0
  7834. Else
  7835. $alist[0][0] += 1
  7836. If UBound($alist) <= $alist[0][0] Then ReDim $alist[UBound($alist) * 2][2]
  7837. $alist[$alist[0][0]][0] = $vvalue_0
  7838. $alist[$alist[0][0]][1] = $vvalue_1
  7839. EndIf
  7840. EndFunc
  7841.  
  7842. Func __fltar_listtomask(ByRef $smask, $slist)
  7843. If StringRegExp($slist, "\\|/|:|\<|\>|\|") Then Return 0
  7844. $slist = StringReplace(StringStripWS(StringRegExpReplace($slist, "\s*;\s*", ";"), $str_stripleading + $str_striptrailing), ";", "|")
  7845. $slist = StringReplace(StringReplace(StringRegExpReplace($slist, "[][$^.{}()+\-]", "\\$0"), "?", "."), "*", ".*?")
  7846. $smask = "(?i)^(" & $slist & ")\z"
  7847. Return 1
  7848. EndFunc
  7849.  
  7850. Func _fileprint($sfilepath, $ishow = @SW_HIDE)
  7851. If $ishow = Default Then $ishow = @SW_HIDE
  7852. Return ShellExecute($sfilepath, "", @WorkingDir, "print", $ishow)
  7853. EndFunc
  7854.  
  7855. Func _filereadtoarray($sfilepath, ByRef $vreturn, $iflags = $frta_count, $sdelimiter = "")
  7856. $vreturn = 0
  7857. If $iflags = Default Then $iflags = $frta_count
  7858. If $sdelimiter = Default Then $sdelimiter = ""
  7859. Local $bexpand = True
  7860. If BitAND($iflags, $frta_intarrays) Then
  7861. $bexpand = False
  7862. $iflags -= $frta_intarrays
  7863. EndIf
  7864. Local $ientire = $str_chrsplit
  7865. If BitAND($iflags, $frta_entiresplit) Then
  7866. $ientire = $str_entiresplit
  7867. $iflags -= $frta_entiresplit
  7868. EndIf
  7869. Local $inocount = 0
  7870. If $iflags <> $frta_count Then
  7871. $iflags = $frta_nocount
  7872. $inocount = $str_nocount
  7873. EndIf
  7874. If $sdelimiter Then
  7875. Local $alines = FILEREADTOARRAY($sfilepath)
  7876. If @error Then Return SetError(@error, 0, 0)
  7877. Local $idim_1 = UBound($alines) + $iflags
  7878. If $bexpand Then
  7879. Local $idim_2 = UBound(StringSplit($alines[0], $sdelimiter, $ientire + $str_nocount))
  7880. Local $atemp_array[$idim_1][$idim_2]
  7881. Local $ifields, $asplit
  7882. For $i = 0 To $idim_1 - $iflags - 1
  7883. $asplit = StringSplit($alines[$i], $sdelimiter, $ientire + $str_nocount)
  7884. $ifields = UBound($asplit)
  7885. If $ifields <> $idim_2 Then
  7886. Return SetError(3, 0, 0)
  7887. EndIf
  7888. For $j = 0 To $ifields - 1
  7889. $atemp_array[$i + $iflags][$j] = $asplit[$j]
  7890. Next
  7891. Next
  7892. If $idim_2 < 2 Then Return SetError(4, 0, 0)
  7893. If $iflags Then
  7894. $atemp_array[0][0] = $idim_1 - $iflags
  7895. $atemp_array[0][1] = $idim_2
  7896. EndIf
  7897. Else
  7898. Local $atemp_array[$idim_1]
  7899. For $i = 0 To $idim_1 - $iflags - 1
  7900. $atemp_array[$i + $iflags] = StringSplit($alines[$i], $sdelimiter, $ientire + $inocount)
  7901. Next
  7902. If $iflags Then
  7903. $atemp_array[0] = $idim_1 - $iflags
  7904. EndIf
  7905. EndIf
  7906. $vreturn = $atemp_array
  7907. Else
  7908. If $iflags Then
  7909. Local $hfileopen = FileOpen($sfilepath, $fo_read)
  7910. If $hfileopen = -1 Then Return SetError(1, 0, 0)
  7911. Local $sfileread = FileRead($hfileopen)
  7912. FileClose($hfileopen)
  7913. If StringLen($sfileread) Then
  7914. $vreturn = StringRegExp(@LF & $sfileread, "(?|(\N+)\z|(\N*)(?:\R))", 3)
  7915. $vreturn[0] = UBound($vreturn) - 1
  7916. Else
  7917. Return SetError(2, 0, 0)
  7918. EndIf
  7919. Else
  7920. $vreturn = FILEREADTOARRAY($sfilepath)
  7921. If @error Then
  7922. $vreturn = 0
  7923. Return SetError(@error, 0, 0)
  7924. EndIf
  7925. EndIf
  7926. EndIf
  7927. Return 1
  7928. EndFunc
  7929.  
  7930. Func _filewritefromarray($sfilepath, Const ByRef $aarray, $ibase = Default, $iubound = Default, $sdelimiter = "|")
  7931. Local $ireturn = 0
  7932. If NOT IsArray($aarray) Then Return SetError(2, 0, $ireturn)
  7933. Local $idims = UBound($aarray, $ubound_dimensions)
  7934. If $idims > 2 Then Return SetError(4, 0, 0)
  7935. Local $ilast = UBound($aarray) - 1
  7936. If $iubound = Default OR $iubound > $ilast Then $iubound = $ilast
  7937. If $ibase < 0 OR $ibase = Default Then $ibase = 0
  7938. If $ibase > $iubound Then Return SetError(5, 0, $ireturn)
  7939. If $sdelimiter = Default Then $sdelimiter = "|"
  7940. Local $hfileopen = $sfilepath
  7941. If IsString($sfilepath) Then
  7942. $hfileopen = FileOpen($sfilepath, $fo_overwrite)
  7943. If $hfileopen = -1 Then Return SetError(1, 0, $ireturn)
  7944. EndIf
  7945. Local $ierror = 0
  7946. $ireturn = 1
  7947. Switch $idims
  7948. Case 1
  7949. For $i = $ibase To $iubound
  7950. If NOT FileWrite($hfileopen, $aarray[$i] & @CRLF) Then
  7951. $ierror = 3
  7952. $ireturn = 0
  7953. ExitLoop
  7954. EndIf
  7955. Next
  7956. Case 2
  7957. Local $stemp = ""
  7958. For $i = $ibase To $iubound
  7959. $stemp = $aarray[$i][0]
  7960. For $j = 1 To UBound($aarray, $ubound_columns) - 1
  7961. $stemp &= $sdelimiter & $aarray[$i][$j]
  7962. Next
  7963. If NOT FileWrite($hfileopen, $stemp & @CRLF) Then
  7964. $ierror = 3
  7965. $ireturn = 0
  7966. ExitLoop
  7967. EndIf
  7968. Next
  7969. EndSwitch
  7970. If IsString($sfilepath) Then FileClose($hfileopen)
  7971. Return SetError($ierror, 0, $ireturn)
  7972. EndFunc
  7973.  
  7974. Func _filewritelog($slogpath, $slogmsg, $iflag = -1)
  7975. Local $iopenmode = $fo_append
  7976. Local $sdatenow = @YEAR & "-" & @MON & "-" & @MDAY
  7977. Local $stimenow = @HOUR & ":" & @MIN & ":" & @SEC
  7978. Local $smsg = $sdatenow & " " & $stimenow & " : " & $slogmsg
  7979. If $iflag = Default Then $iflag = -1
  7980. If $iflag <> -1 Then
  7981. $iopenmode = $fo_overwrite
  7982. $smsg &= @CRLF & FileRead($slogpath)
  7983. EndIf
  7984. Local $hfileopen = $slogpath
  7985. If IsString($slogpath) Then
  7986. $hfileopen = FileOpen($slogpath, $iopenmode)
  7987. EndIf
  7988. If $hfileopen = -1 Then Return SetError(1, 0, 0)
  7989. Local $ireturn = FileWriteLine($hfileopen, $smsg)
  7990. If IsString($slogpath) Then $ireturn = FileClose($hfileopen)
  7991. If $ireturn <= 0 Then Return SetError(2, $ireturn, 0)
  7992. Return $ireturn
  7993. EndFunc
  7994.  
  7995. Func _filewritetoline($sfilepath, $iline, $stext, $boverwrite = False)
  7996. If $iline <= 0 Then Return SetError(4, 0, 0)
  7997. If NOT IsString($stext) Then
  7998. $stext = String($stext)
  7999. If $stext = "" Then Return SetError(6, 0, 0)
  8000. EndIf
  8001. If $boverwrite = Default Then $boverwrite = False
  8002. If NOT (IsBool($boverwrite) OR $boverwrite = 0 OR $boverwrite = 1) Then Return SetError(5, 0, 0)
  8003. If NOT FileExists($sfilepath) Then Return SetError(2, 0, 0)
  8004. Local $aarray = FILEREADTOARRAY($sfilepath)
  8005. Local $iubound = UBound($aarray) - 1
  8006. If ($iubound + 1) < $iline Then Return SetError(1, 0, 0)
  8007. Local $hfileopen = FileOpen($sfilepath, FileGetEncoding($sfilepath) + $fo_overwrite)
  8008. If $hfileopen = -1 Then Return SetError(3, 0, 0)
  8009. Local $sdata = ""
  8010. $iline -= 1
  8011. For $i = 0 To $iubound
  8012. If $i = $iline Then
  8013. If $boverwrite Then
  8014. If $stext Then $sdata &= $stext & @CRLF
  8015. Else
  8016. $sdata &= $stext & @CRLF & $aarray[$i] & @CRLF
  8017. EndIf
  8018. ElseIf $i < $iubound Then
  8019. $sdata &= $aarray[$i] & @CRLF
  8020. ElseIf $i = $iubound Then
  8021. $sdata &= $aarray[$i]
  8022. EndIf
  8023. Next
  8024. FileWrite($hfileopen, $sdata)
  8025. FileClose($hfileopen)
  8026. Return 1
  8027. EndFunc
  8028.  
  8029. Func _pathfull($srelativepath, $sbasepath = @WorkingDir)
  8030. If NOT $srelativepath OR $srelativepath = "." Then Return $sbasepath
  8031. Local $sfullpath = StringReplace($srelativepath, "/", "\")
  8032. Local Const $sfullpathconst = $sfullpath
  8033. Local $spath
  8034. Local $brootonly = StringLeft($sfullpath, 1) = "\" AND StringMid($sfullpath, 2, 1) <> "\"
  8035. If $sbasepath = Default Then $sbasepath = @WorkingDir
  8036. For $i = 1 To 2
  8037. $spath = StringLeft($sfullpath, 2)
  8038. If $spath = "\\" Then
  8039. $sfullpath = StringTrimLeft($sfullpath, 2)
  8040. Local $nserverlen = StringInStr($sfullpath, "\") - 1
  8041. $spath = "\\" & StringLeft($sfullpath, $nserverlen)
  8042. $sfullpath = StringTrimLeft($sfullpath, $nserverlen)
  8043. ExitLoop
  8044. ElseIf StringRight($spath, 1) = ":" Then
  8045. $sfullpath = StringTrimLeft($sfullpath, 2)
  8046. ExitLoop
  8047. Else
  8048. $sfullpath = $sbasepath & "\" & $sfullpath
  8049. EndIf
  8050. Next
  8051. If StringLeft($sfullpath, 1) <> "\" Then
  8052. If StringLeft($sfullpathconst, 2) = StringLeft($sbasepath, 2) Then
  8053. $sfullpath = $sbasepath & "\" & $sfullpath
  8054. Else
  8055. $sfullpath = "\" & $sfullpath
  8056. EndIf
  8057. EndIf
  8058. Local $atemp = StringSplit($sfullpath, "\")
  8059. Local $apathparts[$atemp[0]], $j = 0
  8060. For $i = 2 To $atemp[0]
  8061. If $atemp[$i] = ".." Then
  8062. If $j Then $j -= 1
  8063. ElseIf NOT ($atemp[$i] = "" AND $i <> $atemp[0]) AND $atemp[$i] <> "." Then
  8064. $apathparts[$j] = $atemp[$i]
  8065. $j += 1
  8066. EndIf
  8067. Next
  8068. $sfullpath = $spath
  8069. If NOT $brootonly Then
  8070. For $i = 0 To $j - 1
  8071. $sfullpath &= "\" & $apathparts[$i]
  8072. Next
  8073. Else
  8074. $sfullpath &= $sfullpathconst
  8075. If StringInStr($sfullpath, "..") Then $sfullpath = _pathfull($sfullpath)
  8076. EndIf
  8077. Do
  8078. $sfullpath = StringReplace($sfullpath, ".\", "\")
  8079. Until @extended = 0
  8080. Return $sfullpath
  8081. EndFunc
  8082.  
  8083. Func _pathgetrelative($sfrom, $sto)
  8084. If StringRight($sfrom, 1) <> "\" Then $sfrom &= "\"
  8085. If StringRight($sto, 1) <> "\" Then $sto &= "\"
  8086. If $sfrom = $sto Then Return SetError(1, 0, StringTrimRight($sto, 1))
  8087. Local $asfrom = StringSplit($sfrom, "\")
  8088. Local $asto = StringSplit($sto, "\")
  8089. If $asfrom[1] <> $asto[1] Then Return SetError(2, 0, StringTrimRight($sto, 1))
  8090. Local $i = 2
  8091. Local $idiff = 1
  8092. While 1
  8093. If $asfrom[$i] <> $asto[$i] Then
  8094. $idiff = $i
  8095. ExitLoop
  8096. EndIf
  8097. $i += 1
  8098. WEnd
  8099. $i = 1
  8100. Local $srelpath = ""
  8101. For $j = 1 To $asto[0]
  8102. If $i >= $idiff Then
  8103. $srelpath &= "\" & $asto[$i]
  8104. EndIf
  8105. $i += 1
  8106. Next
  8107. $srelpath = StringTrimLeft($srelpath, 1)
  8108. $i = 1
  8109. For $j = 1 To $asfrom[0]
  8110. If $i > $idiff Then
  8111. $srelpath = "..\" & $srelpath
  8112. EndIf
  8113. $i += 1
  8114. Next
  8115. If StringRight($srelpath, 1) == "\" Then $srelpath = StringTrimRight($srelpath, 1)
  8116. Return $srelpath
  8117. EndFunc
  8118.  
  8119. Func _pathmake($sdrive, $sdir, $sfilename, $sextension)
  8120. If StringLen($sdrive) Then
  8121. If NOT (StringLeft($sdrive, 2) = "\\") Then $sdrive = StringLeft($sdrive, 1) & ":"
  8122. EndIf
  8123. If StringLen($sdir) Then
  8124. If NOT (StringRight($sdir, 1) = "\") AND NOT (StringRight($sdir, 1) = "/") Then $sdir = $sdir & "\"
  8125. Else
  8126. $sdir = "\"
  8127. EndIf
  8128. If StringLen($sdir) Then
  8129. If NOT (StringLeft($sdir, 1) = "\") AND NOT (StringLeft($sdir, 1) = "/") Then $sdir = "\" & $sdir
  8130. EndIf
  8131. If StringLen($sextension) Then
  8132. If NOT (StringLeft($sextension, 1) = ".") Then $sextension = "." & $sextension
  8133. EndIf
  8134. Return $sdrive & $sdir & $sfilename & $sextension
  8135. EndFunc
  8136.  
  8137. Func _pathsplit($sfilepath, ByRef $sdrive, ByRef $sdir, ByRef $sfilename, ByRef $sextension)
  8138. Local $aarray = StringRegExp($sfilepath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $str_regexparraymatch)
  8139. If @error Then
  8140. ReDim $aarray[5]
  8141. $aarray[0] = $sfilepath
  8142. EndIf
  8143. $sdrive = $aarray[1]
  8144. If StringLeft($aarray[2], 1) == "/" Then
  8145. $sdir = StringRegExpReplace($aarray[2], "\h*[\/\\]+\h*", "\/")
  8146. Else
  8147. $sdir = StringRegExpReplace($aarray[2], "\h*[\/\\]+\h*", "\\")
  8148. EndIf
  8149. $aarray[2] = $sdir
  8150. $sfilename = $aarray[3]
  8151. $sextension = $aarray[4]
  8152. Return $aarray
  8153. EndFunc
  8154.  
  8155. Func _replacestringinfile($sfilepath, $ssearchstring, $sreplacestring, $icasesensitive = 0, $ioccurance = 1)
  8156. If StringInStr(FileGetAttrib($sfilepath), "R") Then Return SetError(1, 0, -1)
  8157. Local $hfileopen = FileOpen($sfilepath, $fo_read)
  8158. If $hfileopen = -1 Then Return SetError(2, 0, -1)
  8159. Local $sfileread = FileRead($hfileopen)
  8160. FileClose($hfileopen)
  8161. If $icasesensitive = Default Then $icasesensitive = 0
  8162. If $ioccurance = Default Then $ioccurance = 1
  8163. $sfileread = StringReplace($sfileread, $ssearchstring, $sreplacestring, 1 - $ioccurance, $icasesensitive)
  8164. Local $ireturn = @extended
  8165. If $ireturn Then
  8166. Local $ifileencoding = FileGetEncoding($sfilepath)
  8167. $hfileopen = FileOpen($sfilepath, $ifileencoding + $fo_overwrite)
  8168. If $hfileopen = -1 Then Return SetError(3, 0, -1)
  8169. FileWrite($hfileopen, $sfileread)
  8170. FileClose($hfileopen)
  8171. EndIf
  8172. Return $ireturn
  8173. EndFunc
  8174.  
  8175. Func _tempfile($sdirectoryname = @TempDir, $sfileprefix = "~", $sfileextension = ".tmp", $irandomlength = 7)
  8176. If $irandomlength = Default OR $irandomlength <= 0 Then $irandomlength = 7
  8177. If $sdirectoryname = Default OR (NOT FileExists($sdirectoryname)) Then $sdirectoryname = @TempDir
  8178. If $sfileextension = Default Then $sfileextension = ".tmp"
  8179. If $sfileprefix = Default Then $sfileprefix = "~"
  8180. If NOT FileExists($sdirectoryname) Then $sdirectoryname = @ScriptDir
  8181. $sdirectoryname = StringRegExpReplace($sdirectoryname, "[\\/]+$", "")
  8182. $sfileextension = StringRegExpReplace($sfileextension, "^\.+", "")
  8183. $sfileprefix = StringRegExpReplace($sfileprefix, '[\\/:*?"<>|]', "")
  8184. Local $stempname = ""
  8185. Do
  8186. $stempname = ""
  8187. While StringLen($stempname) < $irandomlength
  8188. $stempname &= Chr(Random(97, 122, 1))
  8189. WEnd
  8190. $stempname = $sdirectoryname & "\" & $sfileprefix & $stempname & "." & $sfileextension
  8191. Until NOT FileExists($stempname)
  8192. Return $stempname
  8193. EndFunc
  8194.  
  8195. Global Const $dts_shortdateformat = 0
  8196. Global Const $dts_updown = 1
  8197. Global Const $dts_shownone = 2
  8198. Global Const $dts_longdateformat = 4
  8199. Global Const $dts_timeformat = 9
  8200. Global Const $dts_rightalign = 32
  8201. Global Const $dts_shortdatecenturyformat = 12
  8202. Global Const $dts_appcanparse = 16
  8203. Global Const $dmw_longname = 0
  8204. Global Const $dmw_shortname = 1
  8205. Global Const $dmw_locale_longname = 2
  8206. Global Const $dmw_locale_shortname = 3
  8207. Global Const $gdt_error = -1
  8208. Global Const $gdt_valid = 0
  8209. Global Const $gdt_none = 1
  8210. Global Const $gdtr_min = 1
  8211. Global Const $gdtr_max = 2
  8212. Global Const $mcht_nowhere = 0
  8213. Global Const $mcht_title = 65536
  8214. Global Const $mcht_calendar = 131072
  8215. Global Const $mcht_todaylink = 196608
  8216. Global Const $mcht_next = 16777216
  8217. Global Const $mcht_prev = 33554432
  8218. Global Const $mcht_titlebk = 65536
  8219. Global Const $mcht_titlemonth = 65537
  8220. Global Const $mcht_titleyear = 65538
  8221. Global Const $mcht_titlebtnnext = 16842755
  8222. Global Const $mcht_titlebtnprev = 33619971
  8223. Global Const $mcht_calendarbk = 131072
  8224. Global Const $mcht_calendardate = 131073
  8225. Global Const $mcht_calendarday = 131074
  8226. Global Const $mcht_calendarweeknum = 131075
  8227. Global Const $mcht_calendardatenext = 16908288
  8228. Global Const $mcht_calendardateprev = 33685504
  8229. Global Const $mcs_daystate = 1
  8230. Global Const $mcs_multiselect = 2
  8231. Global Const $mcs_weeknumbers = 4
  8232. Global Const $mcs_notodaycircle = 8
  8233. Global Const $mcs_notoday = 16
  8234. Global Const $mcs_notrailingdates = 64
  8235. Global Const $mcs_shortdaysofweek = 128
  8236. Global Const $mcs_noselchangeonnav = 256
  8237. Global Const $mcm_first = 4096
  8238. Global Const $mcm_getcalendarborder = ($mcm_first + 31)
  8239. Global Const $mcm_getcalendarcount = ($mcm_first + 23)
  8240. Global Const $mcm_getcalendargridinfo = ($mcm_first + 24)
  8241. Global Const $mcm_getcalid = ($mcm_first + 27)
  8242. Global Const $mcm_getcolor = ($mcm_first + 11)
  8243. Global Const $mcm_getcurrentview = ($mcm_first + 22)
  8244. Global Const $mcm_getcursel = ($mcm_first + 1)
  8245. Global Const $mcm_getfirstdayofweek = ($mcm_first + 16)
  8246. Global Const $mcm_getmaxselcount = ($mcm_first + 3)
  8247. Global Const $mcm_getmaxtodaywidth = ($mcm_first + 21)
  8248. Global Const $mcm_getminreqrect = ($mcm_first + 9)
  8249. Global Const $mcm_getmonthdelta = ($mcm_first + 19)
  8250. Global Const $mcm_getmonthrange = ($mcm_first + 7)
  8251. Global Const $mcm_getrange = ($mcm_first + 17)
  8252. Global Const $mcm_getselrange = ($mcm_first + 5)
  8253. Global Const $mcm_gettoday = ($mcm_first + 13)
  8254. Global Const $mcm_getunicodeformat = 8192 + 6
  8255. Global Const $mcm_hittest = ($mcm_first + 14)
  8256. Global Const $mcm_setcalendarborder = ($mcm_first + 30)
  8257. Global Const $mcm_setcalid = ($mcm_first + 28)
  8258. Global Const $mcm_setcolor = ($mcm_first + 10)
  8259. Global Const $mcm_setcurrentview = ($mcm_first + 32)
  8260. Global Const $mcm_setcursel = ($mcm_first + 2)
  8261. Global Const $mcm_setdaystate = ($mcm_first + 8)
  8262. Global Const $mcm_setfirstdayofweek = ($mcm_first + 15)
  8263. Global Const $mcm_setmaxselcount = ($mcm_first + 4)
  8264. Global Const $mcm_setmonthdelta = ($mcm_first + 20)
  8265. Global Const $mcm_setrange = ($mcm_first + 18)
  8266. Global Const $mcm_setselrange = ($mcm_first + 6)
  8267. Global Const $mcm_settoday = ($mcm_first + 12)
  8268. Global Const $mcm_setunicodeformat = 8192 + 5
  8269. Global Const $mcm_sizerecttomin = ($mcm_first + 29)
  8270. Global Const $mcn_first = -746
  8271. Global Const $mcn_selchange = ($mcn_first - 3)
  8272. Global Const $mcn_getdaystate = ($mcn_first - 1)
  8273. Global Const $mcn_select = ($mcn_first)
  8274. Global Const $mcn_viewchange = ($mcn_first - 4)
  8275. Global Const $mcsc_background = 0
  8276. Global Const $mcsc_monthbk = 4
  8277. Global Const $mcsc_text = 1
  8278. Global Const $mcsc_titlebk = 2
  8279. Global Const $mcsc_titletext = 3
  8280. Global Const $mcsc_trailingtext = 5
  8281. Global Const $dtm_first = 4096
  8282. Global Const $dtm_getsystemtime = $dtm_first + 1
  8283. Global Const $dtm_setsystemtime = $dtm_first + 2
  8284. Global Const $dtm_getrange = $dtm_first + 3
  8285. Global Const $dtm_setrange = $dtm_first + 4
  8286. Global Const $dtm_setformat = $dtm_first + 5
  8287. Global Const $dtm_setmccolor = $dtm_first + 6
  8288. Global Const $dtm_getmccolor = $dtm_first + 7
  8289. Global Const $dtm_getmonthcal = $dtm_first + 8
  8290. Global Const $dtm_setmcfont = $dtm_first + 9
  8291. Global Const $dtm_getmcfont = $dtm_first + 10
  8292. Global Const $dtm_setformatw = $dtm_first + 50
  8293. Global Const $dtn_first = -740
  8294. Global Const $dtn_first2 = -753
  8295. Global Const $dtn_datetimechange = $dtn_first2 - 6
  8296. Global Const $dtn_userstring = $dtn_first2 - 5
  8297. Global Const $dtn_wmkeydown = $dtn_first2 - 4
  8298. Global Const $dtn_format = $dtn_first2 - 3
  8299. Global Const $dtn_formatquery = $dtn_first2 - 2
  8300. Global Const $dtn_dropdown = $dtn_first2 - 1
  8301. Global Const $dtn_closeup = $dtn_first2 + 0
  8302. Global Const $dtn_userstringw = $dtn_first - 5
  8303. Global Const $dtn_wmkeydownw = $dtn_first - 4
  8304. Global Const $dtn_formatw = $dtn_first - 3
  8305. Global Const $dtn_formatqueryw = $dtn_first - 2
  8306. Global Const $gui_ss_default_date = $dts_longdateformat
  8307. Global Const $gui_ss_default_monthcal = 0
  8308. Global Const $linguistic_ignorecase = 16
  8309. Global Const $linguistic_ignorediacritic = 32
  8310. Global Const $norm_ignorecase = 1
  8311. Global Const $norm_ignorekanatype = 65536
  8312. Global Const $norm_ignorenonspace = 2
  8313. Global Const $norm_ignoresymbols = 4
  8314. Global Const $norm_ignorewidth = 131072
  8315. Global Const $norm_linguistic_casing = 134217728
  8316. Global Const $sort_digitsasnumbers = 8
  8317. Global Const $sort_stringsort = 4096
  8318. Global Const $cstr_less_than = 1
  8319. Global Const $cstr_equal = 2
  8320. Global Const $cstr_greater_than = 3
  8321. Global Const $mui_language_id = 4
  8322. Global Const $mui_language_name = 8
  8323. Global Const $date_autolayout = 64
  8324. Global Const $date_longdate = 2
  8325. Global Const $date_ltrreading = 16
  8326. Global Const $date_shortdate = 1
  8327. Global Const $date_rtlreading = 32
  8328. Global Const $date_use_alt_calendar = 4
  8329. Global Const $date_yearmonth = 8
  8330. Global Const $geo_nation = 1
  8331. Global Const $geo_latitude = 2
  8332. Global Const $geo_longitude = 3
  8333. Global Const $geo_iso2 = 4
  8334. Global Const $geo_iso3 = 5
  8335. Global Const $geo_rfc1766 = 6
  8336. Global Const $geo_lcid = 7
  8337. Global Const $geo_friendlyname = 8
  8338. Global Const $geo_officialname = 9
  8339. Global Const $geo_timezones = 10
  8340. Global Const $geo_officiallanguages = 11
  8341. Global Const $geo_iso_un_number = 12
  8342. Global Const $geo_parent = 13
  8343. Global Const $locale_ilanguage = 1
  8344. Global Const $locale_slanguage = 2
  8345. Global Const $locale_senglanguage = 4097
  8346. Global Const $locale_sabbrevlangname = 3
  8347. Global Const $locale_snativelangname = 4
  8348. Global Const $locale_icountry = 5
  8349. Global Const $locale_scountry = 6
  8350. Global Const $locale_sengcountry = 4098
  8351. Global Const $locale_sabbrevctryname = 7
  8352. Global Const $locale_snativectryname = 8
  8353. Global Const $locale_idefaultlanguage = 9
  8354. Global Const $locale_idefaultcountry = 10
  8355. Global Const $locale_idefaultcodepage = 11
  8356. Global Const $locale_idefaultansicodepage = 4100
  8357. Global Const $locale_idefaultmaccodepage = 4113
  8358. Global Const $locale_slist = 12
  8359. Global Const $locale_imeasure = 13
  8360. Global Const $locale_sdecimal = 14
  8361. Global Const $locale_sthousand = 15
  8362. Global Const $locale_sgrouping = 16
  8363. Global Const $locale_idigits = 17
  8364. Global Const $locale_ilzero = 18
  8365. Global Const $locale_inegnumber = 4112
  8366. Global Const $locale_snativedigits = 19
  8367. Global Const $locale_scurrency = 20
  8368. Global Const $locale_sintlsymbol = 21
  8369. Global Const $locale_smondecimalsep = 22
  8370. Global Const $locale_smonthousandsep = 23
  8371. Global Const $locale_smongrouping = 24
  8372. Global Const $locale_icurrdigits = 25
  8373. Global Const $locale_iintlcurrdigits = 26
  8374. Global Const $locale_icurrency = 27
  8375. Global Const $locale_inegcurr = 28
  8376. Global Const $locale_sdate = 29
  8377. Global Const $locale_stime = 30
  8378. Global Const $locale_sshortdate = 31
  8379. Global Const $locale_slongdate = 32
  8380. Global Const $locale_stimeformat = 4099
  8381. Global Const $locale_idate = 33
  8382. Global Const $locale_ildate = 34
  8383. Global Const $locale_itime = 35
  8384. Global Const $locale_itimemarkposn = 4101
  8385. Global Const $locale_icentury = 36
  8386. Global Const $locale_itlzero = 37
  8387. Global Const $locale_idaylzero = 38
  8388. Global Const $locale_imonlzero = 39
  8389. Global Const $locale_s1159 = 40
  8390. Global Const $locale_s2359 = 41
  8391. Global Const $locale_icalendartype = 4105
  8392. Global Const $locale_ioptionalcalendar = 4107
  8393. Global Const $locale_ifirstdayofweek = 4108
  8394. Global Const $locale_ifirstweekofyear = 4109
  8395. Global Const $locale_sdayname1 = 42
  8396. Global Const $locale_sdayname2 = 43
  8397. Global Const $locale_sdayname3 = 44
  8398. Global Const $locale_sdayname4 = 45
  8399. Global Const $locale_sdayname5 = 46
  8400. Global Const $locale_sdayname6 = 47
  8401. Global Const $locale_sdayname7 = 48
  8402. Global Const $locale_sabbrevdayname1 = 49
  8403. Global Const $locale_sabbrevdayname2 = 50
  8404. Global Const $locale_sabbrevdayname3 = 51
  8405. Global Const $locale_sabbrevdayname4 = 52
  8406. Global Const $locale_sabbrevdayname5 = 53
  8407. Global Const $locale_sabbrevdayname6 = 54
  8408. Global Const $locale_sabbrevdayname7 = 55
  8409. Global Const $locale_smonthname1 = 56
  8410. Global Const $locale_smonthname2 = 57
  8411. Global Const $locale_smonthname3 = 58
  8412. Global Const $locale_smonthname4 = 59
  8413. Global Const $locale_smonthname5 = 60
  8414. Global Const $locale_smonthname6 = 61
  8415. Global Const $locale_smonthname7 = 62
  8416. Global Const $locale_smonthname8 = 63
  8417. Global Const $locale_smonthname9 = 64
  8418. Global Const $locale_smonthname10 = 65
  8419. Global Const $locale_smonthname11 = 66
  8420. Global Const $locale_smonthname12 = 67
  8421. Global Const $locale_smonthname13 = 4110
  8422. Global Const $locale_sabbrevmonthname1 = 68
  8423. Global Const $locale_sabbrevmonthname2 = 69
  8424. Global Const $locale_sabbrevmonthname3 = 70
  8425. Global Const $locale_sabbrevmonthname4 = 71
  8426. Global Const $locale_sabbrevmonthname5 = 72
  8427. Global Const $locale_sabbrevmonthname6 = 73
  8428. Global Const $locale_sabbrevmonthname7 = 74
  8429. Global Const $locale_sabbrevmonthname8 = 75
  8430. Global Const $locale_sabbrevmonthname9 = 76
  8431. Global Const $locale_sabbrevmonthname10 = 77
  8432. Global Const $locale_sabbrevmonthname11 = 78
  8433. Global Const $locale_sabbrevmonthname12 = 79
  8434. Global Const $locale_sabbrevmonthname13 = 4111
  8435. Global Const $locale_spositivesign = 80
  8436. Global Const $locale_snegativesign = 81
  8437. Global Const $locale_ipossignposn = 82
  8438. Global Const $locale_inegsignposn = 83
  8439. Global Const $locale_ipossymprecedes = 84
  8440. Global Const $locale_ipossepbyspace = 85
  8441. Global Const $locale_inegsymprecedes = 86
  8442. Global Const $locale_inegsepbyspace = 87
  8443. Global Const $locale_fontsignature = 88
  8444. Global Const $locale_siso639langname = 89
  8445. Global Const $locale_siso3166ctryname = 90
  8446. Global Const $locale_idefaultebcdiccodepage = 4114
  8447. Global Const $locale_ipapersize = 4106
  8448. Global Const $locale_sengcurrname = 4103
  8449. Global Const $locale_snativecurrname = 4104
  8450. Global Const $locale_syearmonth = 4102
  8451. Global Const $locale_ssortname = 4115
  8452. Global Const $locale_idigitsubstitution = 4116
  8453. Global Const $locale_custom_default = 3072
  8454. Global Const $locale_custom_ui_default = 5120
  8455. Global Const $locale_custom_unspecified = 4096
  8456. Global Const $locale_invariant = 127
  8457. Global Const $locale_system_default = 2048
  8458. Global Const $locale_user_default = 1024
  8459. Global Const $time_force24hourformat = 8
  8460. Global Const $time_nominutesorseconds = 1
  8461. Global Const $time_noseconds = 2
  8462. Global Const $time_notimemarker = 4
  8463. Global Const $lcid_installed = 1
  8464. Global Const $lcid_supported = 2
  8465. #Region Global Variables and Constants
  8466. Global $__g_venum, $__g_vext = 0
  8467. Global $__g_hheap = 0, $__g_irgbmode = 1
  8468. Global Const $tagosversioninfo = "struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct"
  8469. Global Const $__winver = __winver()
  8470. #EndRegion Global Variables and Constants
  8471. #Region Functions list
  8472. #EndRegion Functions list
  8473. #Region Public Functions
  8474.  
  8475. Func _winapi_arraytostruct(Const ByRef $adata, $istart = 0, $iend = -1)
  8476. If __checkerrorarraybounds($adata, $istart, $iend) Then Return SetError(@error + 10, @extended, 0)
  8477. Local $tagstruct = ""
  8478. For $i = $istart To $iend
  8479. $tagstruct &= "wchar[" & (StringLen($adata[$i]) + 1) & "];"
  8480. Next
  8481. Local $tdata = DllStructCreate($tagstruct & "wchar[1]")
  8482. Local $icount = 1
  8483. For $i = $istart To $iend
  8484. DllStructSetData($tdata, $icount, $adata[$i])
  8485. $icount += 1
  8486. Next
  8487. DllStructSetData($tdata, $icount, ChrW(0))
  8488. Return $tdata
  8489. EndFunc
  8490.  
  8491. Func _winapi_createmargins($ileftwidth, $irightwidth, $itopheight, $ibottomheight)
  8492. Local $tmargins = DllStructCreate($tagmargins)
  8493. DllStructSetData($tmargins, 1, $ileftwidth)
  8494. DllStructSetData($tmargins, 2, $irightwidth)
  8495. DllStructSetData($tmargins, 3, $itopheight)
  8496. DllStructSetData($tmargins, 4, $ibottomheight)
  8497. Return $tmargins
  8498. EndFunc
  8499.  
  8500. Func _winapi_createpoint($ix, $iy)
  8501. Local $tpoint = DllStructCreate($tagpoint)
  8502. DllStructSetData($tpoint, 1, $ix)
  8503. DllStructSetData($tpoint, 2, $iy)
  8504. Return $tpoint
  8505. EndFunc
  8506.  
  8507. Func _winapi_createrect($ileft, $itop, $iright, $ibottom)
  8508. Local $trect = DllStructCreate($tagrect)
  8509. DllStructSetData($trect, 1, $ileft)
  8510. DllStructSetData($trect, 2, $itop)
  8511. DllStructSetData($trect, 3, $iright)
  8512. DllStructSetData($trect, 4, $ibottom)
  8513. Return $trect
  8514. EndFunc
  8515.  
  8516. Func _winapi_createrectex($ix, $iy, $iwidth, $iheight)
  8517. Local $trect = DllStructCreate($tagrect)
  8518. DllStructSetData($trect, 1, $ix)
  8519. DllStructSetData($trect, 2, $iy)
  8520. DllStructSetData($trect, 3, $ix + $iwidth)
  8521. DllStructSetData($trect, 4, $iy + $iheight)
  8522. Return $trect
  8523. EndFunc
  8524.  
  8525. Func _winapi_createsize($iwidth, $iheight)
  8526. Local $tsize = DllStructCreate($tagsize)
  8527. DllStructSetData($tsize, 1, $iwidth)
  8528. DllStructSetData($tsize, 2, $iheight)
  8529. Return $tsize
  8530. EndFunc
  8531.  
  8532. Func _winapi_fatalexit($icode)
  8533. DllCall("kernel32.dll", "none", "FatalExit", "int", $icode)
  8534. If @error Then Return SetError(@error, @extended)
  8535. EndFunc
  8536.  
  8537. Func _winapi_getbitmapdimension($hbitmap)
  8538. Local Const $tagbitmap = "struct;long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;endstruct"
  8539. Local $tobj = DllStructCreate($tagbitmap)
  8540. Local $aret = DllCall("gdi32.dll", "int", "GetObject", "handle", $hbitmap, "int", DllStructGetSize($tobj), "struct*", $tobj)
  8541. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  8542. Return _winapi_createsize(DllStructGetData($tobj, "bmWidth"), DllStructGetData($tobj, "bmHeight"))
  8543. EndFunc
  8544.  
  8545. Func _winapi_getstring($pstring, $bunicode = True)
  8546. Local $ilength = _winapi_strlen($pstring, $bunicode)
  8547. If @error OR NOT $ilength Then Return SetError(@error + 10, @extended, "")
  8548. Local $tstring = DllStructCreate(__iif($bunicode, "wchar", "char") & "[" & ($ilength + 1) & "]", $pstring)
  8549. If @error Then Return SetError(@error, @extended, "")
  8550. Return SetExtended($ilength, DllStructGetData($tstring, 1))
  8551. EndFunc
  8552.  
  8553. Func _winapi_isbadreadptr($paddress, $ilength)
  8554. Local $aret = DllCall("kernel32.dll", "bool", "IsBadReadPtr", "struct*", $paddress, "uint_ptr", $ilength)
  8555. If @error Then Return SetError(@error, @extended, False)
  8556. Return $aret[0]
  8557. EndFunc
  8558.  
  8559. Func _winapi_isbadwriteptr($paddress, $ilength)
  8560. Local $aret = DllCall("kernel32.dll", "bool", "IsBadWritePtr", "struct*", $paddress, "uint_ptr", $ilength)
  8561. If @error Then Return SetError(@error, @extended, False)
  8562. Return $aret[0]
  8563. EndFunc
  8564.  
  8565. Func _winapi_iswow64process($ipid = 0)
  8566. If NOT $ipid Then $ipid = @AutoItPID
  8567. Local $hprocess = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", __iif($__winver < 1536, 1024, 4096), "bool", 0, "dword", $ipid)
  8568. If @error OR NOT $hprocess[0] Then Return SetError(@error + 20, @extended, False)
  8569. Local $aret = DllCall("kernel32.dll", "bool", "IsWow64Process", "handle", $hprocess[0], "bool*", 0)
  8570. If __checkerrorclosehandle($aret, $hprocess[0]) Then Return SetError(@error, @extended, False)
  8571. Return $aret[2]
  8572. EndFunc
  8573.  
  8574. Func _winapi_movememory($pdestination, $psource, $ilength)
  8575. If _winapi_isbadreadptr($psource, $ilength) Then Return SetError(10, @extended, 0)
  8576. If _winapi_isbadwriteptr($pdestination, $ilength) Then Return SetError(11, @extended, 0)
  8577. DllCall("ntdll.dll", "none", "RtlMoveMemory", "struct*", $pdestination, "struct*", $psource, "ulong_ptr", $ilength)
  8578. If @error Then Return SetError(@error, @extended, 0)
  8579. Return 1
  8580. EndFunc
  8581.  
  8582. Func _winapi_pathisdirectory($sfilepath)
  8583. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsDirectoryW", "wstr", $sfilepath)
  8584. If @error Then Return SetError(@error, @extended, False)
  8585. Return $aret[0]
  8586. EndFunc
  8587.  
  8588. Func _winapi_strlen($pstring, $bunicode = True)
  8589. Local $w = ""
  8590. If $bunicode Then $w = "W"
  8591. Local $aret = DllCall("kernel32.dll", "int", "lstrlen" & $w, "struct*", $pstring)
  8592. If @error Then Return SetError(@error, @extended, 0)
  8593. Return $aret[0]
  8594. EndFunc
  8595.  
  8596. Func _winapi_structtoarray(ByRef $tstruct, $iitems = 0)
  8597. Local $isize = 2 * Floor(DllStructGetSize($tstruct) / 2)
  8598. Local $pstruct = DllStructGetPtr($tstruct)
  8599. If NOT $isize OR NOT $pstruct Then Return SetError(1, 0, 0)
  8600. Local $tdata, $ilength, $ioffset = 0
  8601. Local $aresult[101] = [0]
  8602. While 1
  8603. $ilength = _winapi_strlen($pstruct + $ioffset)
  8604. If NOT $ilength Then
  8605. ExitLoop
  8606. EndIf
  8607. If 2 * (1 + $ilength) + $ioffset > $isize Then Return SetError(3, 0, 0)
  8608. $tdata = DllStructCreate("wchar[" & (1 + $ilength) & "]", $pstruct + $ioffset)
  8609. If @error Then Return SetError(@error + 10, 0, 0)
  8610. __inc($aresult)
  8611. $aresult[$aresult[0]] = DllStructGetData($tdata, 1)
  8612. If $aresult[0] = $iitems Then
  8613. ExitLoop
  8614. EndIf
  8615. $ioffset += 2 * (1 + $ilength)
  8616. If $ioffset >= $isize Then Return SetError(3, 0, 0)
  8617. WEnd
  8618. If NOT $aresult[0] Then Return SetError(2, 0, 0)
  8619. __inc($aresult, -1)
  8620. Return $aresult
  8621. EndFunc
  8622.  
  8623. Func _winapi_swapdword($ivalue)
  8624. Local $tstruct1 = DllStructCreate("dword;dword")
  8625. Local $tstruct2 = DllStructCreate("byte[4];byte[4]", DllStructGetPtr($tstruct1))
  8626. DllStructSetData($tstruct1, 1, $ivalue)
  8627. For $i = 1 To 4
  8628. DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 5 - $i), $i)
  8629. Next
  8630. Return DllStructGetData($tstruct1, 2)
  8631. EndFunc
  8632.  
  8633. Func _winapi_swapqword($ivalue)
  8634. Local $tstruct1 = DllStructCreate("int64;int64")
  8635. Local $tstruct2 = DllStructCreate("byte[8];byte[8]", DllStructGetPtr($tstruct1))
  8636. DllStructSetData($tstruct1, 1, $ivalue)
  8637. For $i = 1 To 8
  8638. DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 9 - $i), $i)
  8639. Next
  8640. Return DllStructGetData($tstruct1, 2)
  8641. EndFunc
  8642.  
  8643. Func _winapi_swapword($ivalue)
  8644. Local $tstruct1 = DllStructCreate("word;word")
  8645. Local $tstruct2 = DllStructCreate("byte[2];byte[2]", DllStructGetPtr($tstruct1))
  8646. DllStructSetData($tstruct1, 1, $ivalue)
  8647. For $i = 1 To 2
  8648. DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 3 - $i), $i)
  8649. Next
  8650. Return DllStructGetData($tstruct1, 2)
  8651. EndFunc
  8652.  
  8653. Func _winapi_switchcolor($icolor)
  8654. If $icolor = -1 Then Return $icolor
  8655. Return BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
  8656. EndFunc
  8657.  
  8658. Func _winapi_zeromemory($pmemory, $ilength)
  8659. If _winapi_isbadwriteptr($pmemory, $ilength) Then Return SetError(11, @extended, 0)
  8660. DllCall("ntdll.dll", "none", "RtlZeroMemory", "struct*", $pmemory, "ulong_ptr", $ilength)
  8661. If @error Then Return SetError(@error, @extended, 0)
  8662. Return 1
  8663. EndFunc
  8664.  
  8665. #EndRegion Public Functions
  8666. #Region Internal Functions
  8667.  
  8668. Func __checkerrorarraybounds(Const ByRef $adata, ByRef $istart, ByRef $iend, $ndim = 1, $idim = $ubound_dimensions)
  8669. If NOT IsArray($adata) Then Return SetError(1, 0, 1)
  8670. If UBound($adata, $idim) <> $ndim Then Return SetError(2, 0, 1)
  8671. If $istart < 0 Then $istart = 0
  8672. Local $iubound = UBound($adata) - 1
  8673. If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  8674. If $istart > $iend Then Return SetError(4, 0, 1)
  8675. Return 0
  8676. EndFunc
  8677.  
  8678. Func __checkerrorclosehandle($aret, $hfile, $blasterror = 0, $icurerr = @error, $icurext = @extended)
  8679. If NOT $icurerr AND NOT $aret[0] Then $icurerr = 10
  8680. Local $ilasterror = _winapi_getlasterror()
  8681. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
  8682. If $icurerr Then _winapi_setlasterror($ilasterror)
  8683. If $blasterror Then $icurext = $ilasterror
  8684. Return SetError($icurerr, $icurext, $icurerr)
  8685. EndFunc
  8686.  
  8687. Func __dll($spath, $bpin = False)
  8688. Local $aret = DllCall("kernel32.dll", "bool", "GetModuleHandleExW", "dword", __iif($bpin, 1, 2), "wstr", $spath, "ptr*", 0)
  8689. If NOT $aret[3] Then
  8690. Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $spath)
  8691. If NOT $aresult[0] Then Return 0
  8692. EndIf
  8693. Return 1
  8694. EndFunc
  8695.  
  8696. Func __enumwindowsproc($hwnd, $bvisible)
  8697. Local $aresult
  8698. If $bvisible Then
  8699. $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
  8700. If NOT $aresult[0] Then
  8701. Return 1
  8702. EndIf
  8703. EndIf
  8704. __inc($__g_venum)
  8705. $__g_venum[$__g_venum[0][0]][0] = $hwnd
  8706. $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  8707. $__g_venum[$__g_venum[0][0]][1] = $aresult[2]
  8708. Return 1
  8709. EndFunc
  8710.  
  8711. Func __fatalexit($icode, $stext = "")
  8712. If $stext Then MsgBox($mb_systemmodal, "AutoIt", $stext)
  8713. _winapi_fatalexit($icode)
  8714. EndFunc
  8715.  
  8716. Func __heapalloc($isize, $babort = False)
  8717. Local $aret
  8718. If NOT $__g_hheap Then
  8719. $aret = DllCall("kernel32.dll", "handle", "HeapCreate", "dword", 0, "ulong_ptr", 0, "ulong_ptr", 0)
  8720. If @error OR NOT $aret[0] Then __fatalexit(1, "Error allocating memory.")
  8721. $__g_hheap = $aret[0]
  8722. EndIf
  8723. $aret = DllCall("kernel32.dll", "ptr", "HeapAlloc", "handle", $__g_hheap, "dword", 8, "ulong_ptr", $isize)
  8724. If @error OR NOT $aret[0] Then
  8725. If $babort Then __fatalexit(1, "Error allocating memory.")
  8726. Return SetError(@error + 30, @extended, 0)
  8727. EndIf
  8728. Return $aret[0]
  8729. EndFunc
  8730.  
  8731. Func __heapfree(ByRef $pmemory, $bcheck = False, $icurerr = @error, $icurext = @extended)
  8732. If $bcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
  8733. Local $aret = DllCall("kernel32.dll", "int", "HeapFree", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
  8734. If @error OR NOT $aret[0] Then Return SetError(@error + 40, @extended, 0)
  8735. $pmemory = 0
  8736. Return SetError($icurerr, $icurext, 1)
  8737. EndFunc
  8738.  
  8739. Func __heaprealloc($pmemory, $isize, $bamount = False, $babort = False)
  8740. Local $aret, $pret
  8741. If __heapvalidate($pmemory) Then
  8742. If $bamount AND (__heapsize($pmemory) >= $isize) Then Return SetExtended(1, Ptr($pmemory))
  8743. $aret = DllCall("kernel32.dll", "ptr", "HeapReAlloc", "handle", $__g_hheap, "dword", 8, "ptr", $pmemory, "ulong_ptr", $isize)
  8744. If @error OR NOT $aret[0] Then
  8745. If $babort Then __fatalexit(1, "Error allocating memory.")
  8746. Return SetError(@error + 20, @extended, Ptr($pmemory))
  8747. EndIf
  8748. $pret = $aret[0]
  8749. Else
  8750. $pret = __heapalloc($isize, $babort)
  8751. If @error Then Return SetError(@error, @extended, 0)
  8752. EndIf
  8753. Return $pret
  8754. EndFunc
  8755.  
  8756. Func __heapsize($pmemory, $bcheck = False)
  8757. If $bcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
  8758. Local $aret = DllCall("kernel32.dll", "ulong_ptr", "HeapSize", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
  8759. If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@error + 50, @extended, 0)
  8760. Return $aret[0]
  8761. EndFunc
  8762.  
  8763. Func __heapvalidate($pmemory)
  8764. If (NOT $__g_hheap) OR (NOT Ptr($pmemory)) Then Return SetError(9, 0, False)
  8765. Local $aret = DllCall("kernel32.dll", "int", "HeapValidate", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
  8766. If @error Then Return SetError(@error, @extended, False)
  8767. Return $aret[0]
  8768. EndFunc
  8769.  
  8770. Func __inc(ByRef $adata, $iincrement = 100)
  8771. Select
  8772. Case UBound($adata, $ubound_columns)
  8773. If $iincrement < 0 Then
  8774. ReDim $adata[$adata[0][0] + 1][UBound($adata, $ubound_columns)]
  8775. Else
  8776. $adata[0][0] += 1
  8777. If $adata[0][0] > UBound($adata) - 1 Then
  8778. ReDim $adata[$adata[0][0] + $iincrement][UBound($adata, $ubound_columns)]
  8779. EndIf
  8780. EndIf
  8781. Case UBound($adata, $ubound_rows)
  8782. If $iincrement < 0 Then
  8783. ReDim $adata[$adata[0] + 1]
  8784. Else
  8785. $adata[0] += 1
  8786. If $adata[0] > UBound($adata) - 1 Then
  8787. ReDim $adata[$adata[0] + $iincrement]
  8788. EndIf
  8789. EndIf
  8790. Case Else
  8791. Return 0
  8792. EndSelect
  8793. Return 1
  8794. EndFunc
  8795.  
  8796. Func __iif($btest, $vtrue, $vfalse)
  8797. Return $btest ? $vtrue : $vfalse
  8798. EndFunc
  8799.  
  8800. Func __init($ddata)
  8801. Local $ilength = BinaryLen($ddata)
  8802. Local $aret = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", $ilength, "dword", 4096, "dword", 64)
  8803. If @error OR NOT $aret[0] Then __fatalexit(1, "Error allocating memory.")
  8804. Local $tdata = DllStructCreate("byte[" & $ilength & "]", $aret[0])
  8805. DllStructSetData($tdata, 1, $ddata)
  8806. Return $aret[0]
  8807. EndFunc
  8808.  
  8809. Func __rgb($icolor)
  8810. If $__g_irgbmode Then
  8811. $icolor = _winapi_switchcolor($icolor)
  8812. EndIf
  8813. Return $icolor
  8814. EndFunc
  8815.  
  8816. Func __winver()
  8817. Local $tosvi = DllStructCreate($tagosversioninfo)
  8818. DllStructSetData($tosvi, 1, DllStructGetSize($tosvi))
  8819. Local $aret = DllCall("kernel32.dll", "bool", "GetVersionExW", "struct*", $tosvi)
  8820. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  8821. Return BitOR(BitShift(DllStructGetData($tosvi, 2), -8), DllStructGetData($tosvi, 3))
  8822. EndFunc
  8823.  
  8824. #EndRegion Internal Functions
  8825. #Region Global Variables and Constants
  8826. Global Const $tagnumberfmt = "uint NumDigits;uint LeadingZero;uint Grouping;ptr DecimalSep;ptr ThousandSep;uint NegativeOrder"
  8827. #EndRegion Global Variables and Constants
  8828. #Region Functions list
  8829. #EndRegion Functions list
  8830. #Region Public Functions
  8831.  
  8832. Func _winapi_comparestring($ilcid, $sstring1, $sstring2, $iflags = 0)
  8833. Local $aret = DllCall("kernel32.dll", "int", "CompareStringW", "dword", $ilcid, "dword", $iflags, "wstr", $sstring1, "int", -1, "wstr", $sstring2, "int", -1)
  8834. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  8835. Return $aret[0]
  8836. EndFunc
  8837.  
  8838. Func _winapi_createnumberformatinfo($inumdigits, $ileadingzero, $igrouping, $sdecimalsep, $sthousandsep, $inegativeorder)
  8839. Local $tfmt = DllStructCreate($tagnumberfmt & ";wchar[" & (StringLen($sdecimalsep) + 1) & "];wchar[" & (StringLen($sthousandsep) + 1) & "]")
  8840. DllStructSetData($tfmt, 1, $inumdigits)
  8841. DllStructSetData($tfmt, 2, $ileadingzero)
  8842. DllStructSetData($tfmt, 3, $igrouping)
  8843. DllStructSetData($tfmt, 4, DllStructGetPtr($tfmt, 7))
  8844. DllStructSetData($tfmt, 5, DllStructGetPtr($tfmt, 8))
  8845. DllStructSetData($tfmt, 6, $inegativeorder)
  8846. DllStructSetData($tfmt, 7, $sdecimalsep)
  8847. DllStructSetData($tfmt, 8, $sthousandsep)
  8848. Return $tfmt
  8849. EndFunc
  8850.  
  8851. Func _winapi_enumsystemgeoid()
  8852. Local $henumproc = DllCallbackRegister("__EnumGeoIDProc", "bool", "long")
  8853. Dim $__g_venum[101] = [0]
  8854. Local $aret = DllCall("kernel32.dll", "bool", "EnumSystemGeoID", "dword", 16, "long", 0, "ptr", DllCallbackGetPtr($henumproc))
  8855. If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
  8856. $__g_venum = @error + 10
  8857. EndIf
  8858. DllCallbackFree($henumproc)
  8859. If $__g_venum Then Return SetError($__g_venum, 0, 0)
  8860. __inc($__g_venum, -1)
  8861. Return $__g_venum
  8862. EndFunc
  8863.  
  8864. Func _winapi_enumsystemlocales($iflag)
  8865. Local $henumproc = DllCallbackRegister("__EnumLocalesProc", "bool", "ptr")
  8866. Dim $__g_venum[101] = [0]
  8867. Local $aret = DllCall("kernel32.dll", "bool", "EnumSystemLocalesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag)
  8868. If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
  8869. $__g_venum = @error + 10
  8870. EndIf
  8871. DllCallbackFree($henumproc)
  8872. If $__g_venum Then Return SetError($__g_venum, 0, 0)
  8873. __inc($__g_venum, -1)
  8874. Return $__g_venum
  8875. EndFunc
  8876.  
  8877. Func _winapi_enumuilanguages($iflag = 0)
  8878. Local $henumproc = DllCallbackRegister("__EnumUILanguagesProc", "bool", "ptr;long_ptr")
  8879. Local $iid = 1
  8880. If $__winver >= 1536 Then
  8881. If BitAND($iflag, 8) Then
  8882. $iid = 0
  8883. EndIf
  8884. Else
  8885. $iflag = 0
  8886. EndIf
  8887. Dim $__g_venum[101] = [0]
  8888. Local $aret = DllCall("kernel32.dll", "bool", "EnumUILanguagesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag, "long_ptr", $iid)
  8889. If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
  8890. $__g_venum = @error + 10
  8891. EndIf
  8892. DllCallbackFree($henumproc)
  8893. If $__g_venum Then Return SetError($__g_venum, 0, 0)
  8894. __inc($__g_venum, -1)
  8895. Return $__g_venum
  8896. EndFunc
  8897.  
  8898. Func _winapi_getdateformat($ilcid = 0, $tsystemtime = 0, $iflags = 0, $sformat = "")
  8899. If NOT $ilcid Then $ilcid = 1024
  8900. Local $stypeofformat = "wstr"
  8901. If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
  8902. $stypeofformat = "ptr"
  8903. $sformat = 0
  8904. EndIf
  8905. Local $aret = DllCall("kernel32.dll", "int", "GetDateFormatW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofformat, $sformat, "wstr", "", "int", 2048)
  8906. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  8907. Return $aret[5]
  8908. EndFunc
  8909.  
  8910. Func _winapi_getdurationformat($ilcid, $iduration, $sformat = "")
  8911. If NOT $ilcid Then $ilcid = 1024
  8912. Local $pst, $ival
  8913. If IsDllStruct($iduration) Then
  8914. $pst = DllStructGetPtr($iduration)
  8915. $ival = 0
  8916. Else
  8917. $pst = 0
  8918. $ival = $iduration
  8919. EndIf
  8920. Local $stypeofformat = "wstr"
  8921. If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
  8922. $stypeofformat = "ptr"
  8923. $sformat = 0
  8924. EndIf
  8925. Local $aret = DllCall("kernel32.dll", "int", "GetDurationFormat", "dword", $ilcid, "dword", 0, "ptr", $pst, "uint64", $ival, $stypeofformat, $sformat, "wstr", "", "int", 2048)
  8926. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  8927. Return $aret[6]
  8928. EndFunc
  8929.  
  8930. Func _winapi_getgeoinfo($igeoid, $itype, $ilanguage = 0)
  8931. Local $aret = DllCall("kernel32.dll", "int", "GetGeoInfoW", "long", $igeoid, "dword", $itype, "wstr", "", "int", 4096, "word", $ilanguage)
  8932. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  8933. Return $aret[3]
  8934. EndFunc
  8935.  
  8936. Func _winapi_getlocaleinfo($ilcid, $itype)
  8937. Local $aret = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", $ilcid, "dword", $itype, "wstr", "", "int", 2048)
  8938. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  8939. Return $aret[3]
  8940. EndFunc
  8941.  
  8942. Func _winapi_getnumberformat($ilcid, $snumber, $tnumberfmt = 0)
  8943. If NOT $ilcid Then $ilcid = 1024
  8944. Local $aret = DllCall("kernel32.dll", "int", "GetNumberFormatW", "dword", $ilcid, "dword", 0, "wstr", $snumber, "struct*", $tnumberfmt, "wstr", "", "int", 2048)
  8945. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  8946. Return $aret[5]
  8947. EndFunc
  8948.  
  8949. Func _winapi_getsystemdefaultlangid()
  8950. Local $aret = DllCall("kernel32.dll", "word", "GetSystemDefaultLangID")
  8951. If @error Then Return SetError(@error, @extended, 0)
  8952. Return $aret[0]
  8953. EndFunc
  8954.  
  8955. Func _winapi_getsystemdefaultlcid()
  8956. Local $aret = DllCall("kernel32.dll", "dword", "GetSystemDefaultLCID")
  8957. If @error Then Return SetError(@error, @extended, 0)
  8958. Return $aret[0]
  8959. EndFunc
  8960.  
  8961. Func _winapi_getsystemdefaultuilanguage()
  8962. Local $aret = DllCall("kernel32.dll", "word", "GetSystemDefaultUILanguage")
  8963. If @error Then Return SetError(@error, @extended, 0)
  8964. Return $aret[0]
  8965. EndFunc
  8966.  
  8967. Func _winapi_getthreadlocale()
  8968. Local $aret = DllCall("kernel32.dll", "dword", "GetThreadLocale")
  8969. If @error Then Return SetError(@error, @extended, 0)
  8970. Return $aret[0]
  8971. EndFunc
  8972.  
  8973. Func _winapi_getthreaduilanguage()
  8974. Local $aret = DllCall("kernel32.dll", "word", "GetThreadUILanguage")
  8975. If @error Then Return SetError(@error, @extended, 0)
  8976. Return $aret[0]
  8977. EndFunc
  8978.  
  8979. Func _winapi_gettimeformat($ilcid = 0, $tsystemtime = 0, $iflags = 0, $sformat = "")
  8980. If NOT $ilcid Then $ilcid = 1024
  8981. Local $stypeofformat = "wstr"
  8982. If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
  8983. $stypeofformat = "ptr"
  8984. $sformat = 0
  8985. EndIf
  8986. Local $aret = DllCall("kernel32.dll", "int", "GetTimeFormatW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofformat, $sformat, "wstr", "", "int", 2048)
  8987. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  8988. Return $aret[5]
  8989. EndFunc
  8990.  
  8991. Func _winapi_getuserdefaultlangid()
  8992. Local $aret = DllCall("kernel32.dll", "word", "GetUserDefaultLangID")
  8993. If @error Then Return SetError(@error, @extended, 0)
  8994. Return $aret[0]
  8995. EndFunc
  8996.  
  8997. Func _winapi_getuserdefaultlcid()
  8998. Local $aret = DllCall("kernel32.dll", "dword", "GetUserDefaultLCID")
  8999. If @error Then Return SetError(@error, @extended, 0)
  9000. Return $aret[0]
  9001. EndFunc
  9002.  
  9003. Func _winapi_getuserdefaultuilanguage()
  9004. Local $aret = DllCall("kernel32.dll", "word", "GetUserDefaultUILanguage")
  9005. If @error Then Return SetError(@error, @extended, 0)
  9006. Return $aret[0]
  9007. EndFunc
  9008.  
  9009. Func _winapi_getusergeoid()
  9010. Local $aret = DllCall("kernel32.dll", "long", "GetUserGeoID", "uint", 16)
  9011. If @error Then Return SetError(@error, @extended, -1)
  9012. Return $aret[0]
  9013. EndFunc
  9014.  
  9015. Func _winapi_isvalidlocale($ilcid, $iflag = 0)
  9016. Local $aret = DllCall("kernel32.dll", "bool", "IsValidLocale", "dword", $ilcid, "dword", $iflag)
  9017. If @error Then Return SetError(@error, @extended, False)
  9018. Return $aret[0]
  9019. EndFunc
  9020.  
  9021. Func _winapi_setlocaleinfo($ilcid, $itype, $sdata)
  9022. Local $aret = DllCall("kernel32.dll", "bool", "SetLocaleInfoW", "dword", $ilcid, "dword", $itype, "wstr", $sdata)
  9023. If @error Then Return SetError(@error, @extended, False)
  9024. Return $aret[0]
  9025. EndFunc
  9026.  
  9027. Func _winapi_setthreadlocale($ilcid)
  9028. Local $aret = DllCall("kernel32.dll", "bool", "SetThreadLocale", "dword", $ilcid)
  9029. If @error Then Return SetError(@error, @extended, False)
  9030. Return $aret[0]
  9031. EndFunc
  9032.  
  9033. Func _winapi_setthreaduilanguage($ilanguage)
  9034. Local $aret = DllCall("kernel32.dll", "word", "SetThreadUILanguage", "word", $ilanguage)
  9035. If @error Then Return SetError(@error, @extended, False)
  9036. Return ($aret[0] = $aret[1])
  9037. EndFunc
  9038.  
  9039. Func _winapi_setusergeoid($igeoid)
  9040. Local $aret = DllCall("kernel32.dll", "bool", "SetUserGeoID", "long", $igeoid)
  9041. If @error Then Return SetError(@error, @extended, False)
  9042. Return $aret[0]
  9043. EndFunc
  9044.  
  9045. #EndRegion Public Functions
  9046. #Region Internal Functions
  9047.  
  9048. Func __enumgeoidproc($iid)
  9049. __inc($__g_venum)
  9050. $__g_venum[$__g_venum[0]] = $iid
  9051. Return 1
  9052. EndFunc
  9053.  
  9054. Func __enumlocalesproc($plocale)
  9055. __inc($__g_venum)
  9056. $__g_venum[$__g_venum[0]] = Dec(DllStructGetData(DllStructCreate("wchar[" & (_winapi_strlen($plocale) + 1) & "]", $plocale), 1))
  9057. Return 1
  9058. EndFunc
  9059.  
  9060. Func __enumuilanguagesproc($planguage, $iid)
  9061. __inc($__g_venum)
  9062. $__g_venum[$__g_venum[0]] = DllStructGetData(DllStructCreate("wchar[" & (_winapi_strlen($planguage) + 1) & "]", $planguage), 1)
  9063. If $iid Then
  9064. $__g_venum[$__g_venum[0]] = Dec($__g_venum[$__g_venum[0]])
  9065. EndIf
  9066. Return 1
  9067. EndFunc
  9068.  
  9069. #EndRegion Internal Functions
  9070.  
  9071. Func _dateadd($stype, $inumber, $sdate)
  9072. Local $astimepart[4]
  9073. Local $asdatepart[4]
  9074. Local $ijuliandate
  9075. $stype = StringLeft($stype, 1)
  9076. If StringInStr("D,M,Y,w,h,n,s", $stype) = 0 OR $stype = "" Then
  9077. Return SetError(1, 0, 0)
  9078. EndIf
  9079. If NOT StringIsInt($inumber) Then
  9080. Return SetError(2, 0, 0)
  9081. EndIf
  9082. If NOT _dateisvalid($sdate) Then
  9083. Return SetError(3, 0, 0)
  9084. EndIf
  9085. _datetimesplit($sdate, $asdatepart, $astimepart)
  9086. If $stype = "d" OR $stype = "w" Then
  9087. If $stype = "w" Then $inumber = $inumber * 7
  9088. $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $inumber
  9089. _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
  9090. EndIf
  9091. If $stype = "m" Then
  9092. $asdatepart[2] = $asdatepart[2] + $inumber
  9093. While $asdatepart[2] > 12
  9094. $asdatepart[2] = $asdatepart[2] - 12
  9095. $asdatepart[1] = $asdatepart[1] + 1
  9096. WEnd
  9097. While $asdatepart[2] < 1
  9098. $asdatepart[2] = $asdatepart[2] + 12
  9099. $asdatepart[1] = $asdatepart[1] - 1
  9100. WEnd
  9101. EndIf
  9102. If $stype = "y" Then
  9103. $asdatepart[1] = $asdatepart[1] + $inumber
  9104. EndIf
  9105. If $stype = "h" OR $stype = "n" OR $stype = "s" Then
  9106. Local $itimeval = _timetoticks($astimepart[1], $astimepart[2], $astimepart[3]) / 1000
  9107. If $stype = "h" Then $itimeval = $itimeval + $inumber * 3600
  9108. If $stype = "n" Then $itimeval = $itimeval + $inumber * 60
  9109. If $stype = "s" Then $itimeval = $itimeval + $inumber
  9110. Local $iday2add = Int($itimeval / (24 * 60 * 60))
  9111. $itimeval = $itimeval - $iday2add * 24 * 60 * 60
  9112. If $itimeval < 0 Then
  9113. $iday2add = $iday2add - 1
  9114. $itimeval = $itimeval + 24 * 60 * 60
  9115. EndIf
  9116. $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $iday2add
  9117. _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
  9118. _tickstotime($itimeval * 1000, $astimepart[1], $astimepart[2], $astimepart[3])
  9119. EndIf
  9120. Local $inumdays = _daysinmonth($asdatepart[1])
  9121. If $inumdays[$asdatepart[2]] < $asdatepart[3] Then $asdatepart[3] = $inumdays[$asdatepart[2]]
  9122. $sdate = $asdatepart[1] & "/" & StringRight("0" & $asdatepart[2], 2) & "/" & StringRight("0" & $asdatepart[3], 2)
  9123. If $astimepart[0] > 0 Then
  9124. If $astimepart[0] > 2 Then
  9125. $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2) & ":" & StringRight("0" & $astimepart[3], 2)
  9126. Else
  9127. $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2)
  9128. EndIf
  9129. EndIf
  9130. Return $sdate
  9131. EndFunc
  9132.  
  9133. Func _datedayofweek($idaynum, $iformat = Default)
  9134. Local Const $monday_is_no1 = 128
  9135. If $iformat = Default Then $iformat = 0
  9136. $idaynum = Int($idaynum)
  9137. If $idaynum < 1 OR $idaynum > 7 Then Return SetError(1, 0, "")
  9138. Local $tsystemtime = DllStructCreate($tagsystemtime)
  9139. DllStructSetData($tsystemtime, "Year", BitAND($iformat, $monday_is_no1) ? 2007 : 2006)
  9140. DllStructSetData($tsystemtime, "Month", 1)
  9141. DllStructSetData($tsystemtime, "Day", $idaynum)
  9142. Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longname) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat, $dmw_shortname) ? "ddd" : "dddd")
  9143. EndFunc
  9144.  
  9145. Func _datedaysinmonth($iyear, $imonthnum)
  9146. $imonthnum = Int($imonthnum)
  9147. $iyear = Int($iyear)
  9148. Return __dateismonth($imonthnum) AND __dateisyear($iyear) ? _daysinmonth($iyear)[$imonthnum] : SetError(1, 0, 0)
  9149. EndFunc
  9150.  
  9151. Func _datediff($stype, $sstartdate, $senddate)
  9152. $stype = StringLeft($stype, 1)
  9153. If StringInStr("d,m,y,w,h,n,s", $stype) = 0 OR $stype = "" Then
  9154. Return SetError(1, 0, 0)
  9155. EndIf
  9156. If NOT _dateisvalid($sstartdate) Then
  9157. Return SetError(2, 0, 0)
  9158. EndIf
  9159. If NOT _dateisvalid($senddate) Then
  9160. Return SetError(3, 0, 0)
  9161. EndIf
  9162. Local $asstartdatepart[4], $asstarttimepart[4], $asenddatepart[4], $asendtimepart[4]
  9163. _datetimesplit($sstartdate, $asstartdatepart, $asstarttimepart)
  9164. _datetimesplit($senddate, $asenddatepart, $asendtimepart)
  9165. Local $adaysdiff = _datetodayvalue($asenddatepart[1], $asenddatepart[2], $asenddatepart[3]) - _datetodayvalue($asstartdatepart[1], $asstartdatepart[2], $asstartdatepart[3])
  9166. Local $itimediff, $iyeardiff, $istarttimeinsecs, $iendtimeinsecs
  9167. If $asstarttimepart[0] > 1 AND $asendtimepart[0] > 1 Then
  9168. $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  9169. $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  9170. $itimediff = $iendtimeinsecs - $istarttimeinsecs
  9171. If $itimediff < 0 Then
  9172. $adaysdiff = $adaysdiff - 1
  9173. $itimediff = $itimediff + 24 * 60 * 60
  9174. EndIf
  9175. Else
  9176. $itimediff = 0
  9177. EndIf
  9178. Select
  9179. Case $stype = "d"
  9180. Return $adaysdiff
  9181. Case $stype = "m"
  9182. $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
  9183. Local $imonthdiff = $asenddatepart[2] - $asstartdatepart[2] + $iyeardiff * 12
  9184. If $asenddatepart[3] < $asstartdatepart[3] Then $imonthdiff = $imonthdiff - 1
  9185. $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  9186. $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  9187. $itimediff = $iendtimeinsecs - $istarttimeinsecs
  9188. If $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $imonthdiff = $imonthdiff - 1
  9189. Return $imonthdiff
  9190. Case $stype = "y"
  9191. $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
  9192. If $asenddatepart[2] < $asstartdatepart[2] Then $iyeardiff = $iyeardiff - 1
  9193. If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] < $asstartdatepart[3] Then $iyeardiff = $iyeardiff - 1
  9194. $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  9195. $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  9196. $itimediff = $iendtimeinsecs - $istarttimeinsecs
  9197. If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $iyeardiff = $iyeardiff - 1
  9198. Return $iyeardiff
  9199. Case $stype = "w"
  9200. Return Int($adaysdiff / 7)
  9201. Case $stype = "h"
  9202. Return $adaysdiff * 24 + Int($itimediff / 3600)
  9203. Case $stype = "n"
  9204. Return $adaysdiff * 24 * 60 + Int($itimediff / 60)
  9205. Case $stype = "s"
  9206. Return $adaysdiff * 24 * 60 * 60 + $itimediff
  9207. EndSelect
  9208. EndFunc
  9209.  
  9210. Func _dateisleapyear($iyear)
  9211. If StringIsInt($iyear) Then
  9212. Select
  9213. Case Mod($iyear, 4) = 0 AND Mod($iyear, 100) <> 0
  9214. Return 1
  9215. Case Mod($iyear, 400) = 0
  9216. Return 1
  9217. Case Else
  9218. Return 0
  9219. EndSelect
  9220. EndIf
  9221. Return SetError(1, 0, 0)
  9222. EndFunc
  9223.  
  9224. Func __dateismonth($inumber)
  9225. $inumber = Int($inumber)
  9226. Return $inumber >= 1 AND $inumber <= 12
  9227. EndFunc
  9228.  
  9229. Func _dateisvalid($sdate)
  9230. Local $asdatepart[4], $astimepart[4]
  9231. _datetimesplit($sdate, $asdatepart, $astimepart)
  9232. If NOT StringIsInt($asdatepart[1]) Then Return 0
  9233. If NOT StringIsInt($asdatepart[2]) Then Return 0
  9234. If NOT StringIsInt($asdatepart[3]) Then Return 0
  9235. $asdatepart[1] = Int($asdatepart[1])
  9236. $asdatepart[2] = Int($asdatepart[2])
  9237. $asdatepart[3] = Int($asdatepart[3])
  9238. Local $inumdays = _daysinmonth($asdatepart[1])
  9239. If $asdatepart[1] < 1000 OR $asdatepart[1] > 2999 Then Return 0
  9240. If $asdatepart[2] < 1 OR $asdatepart[2] > 12 Then Return 0
  9241. If $asdatepart[3] < 1 OR $asdatepart[3] > $inumdays[$asdatepart[2]] Then Return 0
  9242. If $astimepart[0] < 1 Then Return 1
  9243. If $astimepart[0] < 2 Then Return 0
  9244. If $astimepart[0] = 2 Then $astimepart[3] = "00"
  9245. If NOT StringIsInt($astimepart[1]) Then Return 0
  9246. If NOT StringIsInt($astimepart[2]) Then Return 0
  9247. If NOT StringIsInt($astimepart[3]) Then Return 0
  9248. $astimepart[1] = Int($astimepart[1])
  9249. $astimepart[2] = Int($astimepart[2])
  9250. $astimepart[3] = Int($astimepart[3])
  9251. If $astimepart[1] < 0 OR $astimepart[1] > 23 Then Return 0
  9252. If $astimepart[2] < 0 OR $astimepart[2] > 59 Then Return 0
  9253. If $astimepart[3] < 0 OR $astimepart[3] > 59 Then Return 0
  9254. Return 1
  9255. EndFunc
  9256.  
  9257. Func __dateisyear($inumber)
  9258. Return StringLen($inumber) = 4
  9259. EndFunc
  9260.  
  9261. Func _datelastweekdaynum($iweekdaynum)
  9262. Select
  9263. Case NOT StringIsInt($iweekdaynum)
  9264. Return SetError(1, 0, 0)
  9265. Case $iweekdaynum < 1 OR $iweekdaynum > 7
  9266. Return SetError(2, 0, 0)
  9267. Case Else
  9268. Local $ilastweekdaynum
  9269. If $iweekdaynum = 1 Then
  9270. $ilastweekdaynum = 7
  9271. Else
  9272. $ilastweekdaynum = $iweekdaynum - 1
  9273. EndIf
  9274. Return $ilastweekdaynum
  9275. EndSelect
  9276. EndFunc
  9277.  
  9278. Func _datelastmonthnum($imonthnum)
  9279. Select
  9280. Case NOT StringIsInt($imonthnum)
  9281. Return SetError(1, 0, 0)
  9282. Case NOT __dateismonth($imonthnum)
  9283. Return SetError(2, 0, 0)
  9284. Case Else
  9285. Local $ilastmonthnum
  9286. If $imonthnum = 1 Then
  9287. $ilastmonthnum = 12
  9288. Else
  9289. $ilastmonthnum = $imonthnum - 1
  9290. EndIf
  9291. $ilastmonthnum = StringFormat("%02d", $ilastmonthnum)
  9292. Return $ilastmonthnum
  9293. EndSelect
  9294. EndFunc
  9295.  
  9296. Func _datelastmonthyear($imonthnum, $iyear)
  9297. Select
  9298. Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
  9299. Return SetError(1, 0, 0)
  9300. Case NOT __dateismonth($imonthnum)
  9301. Return SetError(2, 0, 0)
  9302. Case Else
  9303. Local $ilastyear
  9304. If $imonthnum = 1 Then
  9305. $ilastyear = $iyear - 1
  9306. Else
  9307. $ilastyear = $iyear
  9308. EndIf
  9309. $ilastyear = StringFormat("%04d", $ilastyear)
  9310. Return $ilastyear
  9311. EndSelect
  9312. EndFunc
  9313.  
  9314. Func _datenextweekdaynum($iweekdaynum)
  9315. Select
  9316. Case NOT StringIsInt($iweekdaynum)
  9317. Return SetError(1, 0, 0)
  9318. Case $iweekdaynum < 1 OR $iweekdaynum > 7
  9319. Return SetError(2, 0, 0)
  9320. Case Else
  9321. Local $inextweekdaynum
  9322. If $iweekdaynum = 7 Then
  9323. $inextweekdaynum = 1
  9324. Else
  9325. $inextweekdaynum = $iweekdaynum + 1
  9326. EndIf
  9327. Return $inextweekdaynum
  9328. EndSelect
  9329. EndFunc
  9330.  
  9331. Func _datenextmonthnum($imonthnum)
  9332. Select
  9333. Case NOT StringIsInt($imonthnum)
  9334. Return SetError(1, 0, 0)
  9335. Case NOT __dateismonth($imonthnum)
  9336. Return SetError(2, 0, 0)
  9337. Case Else
  9338. Local $inextmonthnum
  9339. If $imonthnum = 12 Then
  9340. $inextmonthnum = 1
  9341. Else
  9342. $inextmonthnum = $imonthnum + 1
  9343. EndIf
  9344. $inextmonthnum = StringFormat("%02d", $inextmonthnum)
  9345. Return $inextmonthnum
  9346. EndSelect
  9347. EndFunc
  9348.  
  9349. Func _datenextmonthyear($imonthnum, $iyear)
  9350. Select
  9351. Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
  9352. Return SetError(1, 0, 0)
  9353. Case NOT __dateismonth($imonthnum)
  9354. Return SetError(2, 0, 0)
  9355. Case Else
  9356. Local $inextyear
  9357. If $imonthnum = 12 Then
  9358. $inextyear = $iyear + 1
  9359. Else
  9360. $inextyear = $iyear
  9361. EndIf
  9362. $inextyear = StringFormat("%04d", $inextyear)
  9363. Return $inextyear
  9364. EndSelect
  9365. EndFunc
  9366.  
  9367. Func _datetimeformat($sdate, $stype)
  9368. Local $asdatepart[4], $astimepart[4]
  9369. Local $stempdate = "", $stemptime = ""
  9370. Local $sam, $spm, $stempstring = ""
  9371. If NOT _dateisvalid($sdate) Then
  9372. Return SetError(1, 0, "")
  9373. EndIf
  9374. If $stype < 0 OR $stype > 5 OR NOT IsInt($stype) Then
  9375. Return SetError(2, 0, "")
  9376. EndIf
  9377. _datetimesplit($sdate, $asdatepart, $astimepart)
  9378. Switch $stype
  9379. Case 0
  9380. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sshortdate)
  9381. If NOT @error AND NOT ($stempstring = "") Then
  9382. $stempdate = $stempstring
  9383. Else
  9384. $stempdate = "M/d/yyyy"
  9385. EndIf
  9386. If $astimepart[0] > 1 Then
  9387. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stimeformat)
  9388. If NOT @error AND NOT ($stempstring = "") Then
  9389. $stemptime = $stempstring
  9390. Else
  9391. $stemptime = "h:mm:ss tt"
  9392. EndIf
  9393. EndIf
  9394. Case 1
  9395. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_slongdate)
  9396. If NOT @error AND NOT ($stempstring = "") Then
  9397. $stempdate = $stempstring
  9398. Else
  9399. $stempdate = "dddd, MMMM dd, yyyy"
  9400. EndIf
  9401. Case 2
  9402. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sshortdate)
  9403. If NOT @error AND NOT ($stempstring = "") Then
  9404. $stempdate = $stempstring
  9405. Else
  9406. $stempdate = "M/d/yyyy"
  9407. EndIf
  9408. Case 3
  9409. If $astimepart[0] > 1 Then
  9410. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stimeformat)
  9411. If NOT @error AND NOT ($stempstring = "") Then
  9412. $stemptime = $stempstring
  9413. Else
  9414. $stemptime = "h:mm:ss tt"
  9415. EndIf
  9416. EndIf
  9417. Case 4
  9418. If $astimepart[0] > 1 Then
  9419. $stemptime = "hh:mm"
  9420. EndIf
  9421. Case 5
  9422. If $astimepart[0] > 1 Then
  9423. $stemptime = "hh:mm:ss"
  9424. EndIf
  9425. EndSwitch
  9426. If $stempdate <> "" Then
  9427. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sdate)
  9428. If NOT @error AND NOT ($stempstring = "") Then
  9429. $stempdate = StringReplace($stempdate, "/", $stempstring)
  9430. EndIf
  9431. Local $iwday = _datetodayofweek($asdatepart[1], $asdatepart[2], $asdatepart[3])
  9432. $asdatepart[3] = StringRight("0" & $asdatepart[3], 2)
  9433. $asdatepart[2] = StringRight("0" & $asdatepart[2], 2)
  9434. $stempdate = StringReplace($stempdate, "d", "@")
  9435. $stempdate = StringReplace($stempdate, "m", "#")
  9436. $stempdate = StringReplace($stempdate, "y", "&")
  9437. $stempdate = StringReplace($stempdate, "@@@@", _datedayofweek($iwday, 0))
  9438. $stempdate = StringReplace($stempdate, "@@@", _datedayofweek($iwday, 1))
  9439. $stempdate = StringReplace($stempdate, "@@", $asdatepart[3])
  9440. $stempdate = StringReplace($stempdate, "@", StringReplace(StringLeft($asdatepart[3], 1), "0", "") & StringRight($asdatepart[3], 1))
  9441. $stempdate = StringReplace($stempdate, "####", _datetomonth($asdatepart[2], 0))
  9442. $stempdate = StringReplace($stempdate, "###", _datetomonth($asdatepart[2], 1))
  9443. $stempdate = StringReplace($stempdate, "##", $asdatepart[2])
  9444. $stempdate = StringReplace($stempdate, "#", StringReplace(StringLeft($asdatepart[2], 1), "0", "") & StringRight($asdatepart[2], 1))
  9445. $stempdate = StringReplace($stempdate, "&&&&", $asdatepart[1])
  9446. $stempdate = StringReplace($stempdate, "&&", StringRight($asdatepart[1], 2))
  9447. EndIf
  9448. If $stemptime <> "" Then
  9449. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_s1159)
  9450. If NOT @error AND NOT ($stempstring = "") Then
  9451. $sam = $stempstring
  9452. Else
  9453. $sam = "AM"
  9454. EndIf
  9455. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_s2359)
  9456. If NOT @error AND NOT ($stempstring = "") Then
  9457. $spm = $stempstring
  9458. Else
  9459. $spm = "PM"
  9460. EndIf
  9461. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stime)
  9462. If NOT @error AND NOT ($stempstring = "") Then
  9463. $stemptime = StringReplace($stemptime, ":", $stempstring)
  9464. EndIf
  9465. If StringInStr($stemptime, "tt") Then
  9466. If $astimepart[1] < 12 Then
  9467. $stemptime = StringReplace($stemptime, "tt", $sam)
  9468. If $astimepart[1] = 0 Then $astimepart[1] = 12
  9469. Else
  9470. $stemptime = StringReplace($stemptime, "tt", $spm)
  9471. If $astimepart[1] > 12 Then $astimepart[1] = $astimepart[1] - 12
  9472. EndIf
  9473. EndIf
  9474. $astimepart[1] = StringRight("0" & $astimepart[1], 2)
  9475. $astimepart[2] = StringRight("0" & $astimepart[2], 2)
  9476. $astimepart[3] = StringRight("0" & $astimepart[3], 2)
  9477. $stemptime = StringReplace($stemptime, "hh", StringFormat("%02d", $astimepart[1]))
  9478. $stemptime = StringReplace($stemptime, "h", StringReplace(StringLeft($astimepart[1], 1), "0", "") & StringRight($astimepart[1], 1))
  9479. $stemptime = StringReplace($stemptime, "mm", StringFormat("%02d", $astimepart[2]))
  9480. $stemptime = StringReplace($stemptime, "ss", StringFormat("%02d", $astimepart[3]))
  9481. $stempdate = StringStripWS($stempdate & " " & $stemptime, $str_stripleading + $str_striptrailing)
  9482. EndIf
  9483. Return $stempdate
  9484. EndFunc
  9485.  
  9486. Func _datetimesplit($sdate, ByRef $adatepart, ByRef $itimepart)
  9487. Local $sdatetime = StringSplit($sdate, " T")
  9488. If $sdatetime[0] > 0 Then $adatepart = StringSplit($sdatetime[1], "/-.")
  9489. If $sdatetime[0] > 1 Then
  9490. $itimepart = StringSplit($sdatetime[2], ":")
  9491. If UBound($itimepart) < 4 Then ReDim $itimepart[4]
  9492. Else
  9493. Dim $itimepart[4]
  9494. EndIf
  9495. If UBound($adatepart) < 4 Then ReDim $adatepart[4]
  9496. For $x = 1 To 3
  9497. If StringIsInt($adatepart[$x]) Then
  9498. $adatepart[$x] = Int($adatepart[$x])
  9499. Else
  9500. $adatepart[$x] = -1
  9501. EndIf
  9502. If StringIsInt($itimepart[$x]) Then
  9503. $itimepart[$x] = Int($itimepart[$x])
  9504. Else
  9505. $itimepart[$x] = 0
  9506. EndIf
  9507. Next
  9508. Return 1
  9509. EndFunc
  9510.  
  9511. Func _datetodayofweek($iyear, $imonth, $iday)
  9512. If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then
  9513. Return SetError(1, 0, "")
  9514. EndIf
  9515. Local $i_factora = Int((14 - $imonth) / 12)
  9516. Local $i_factory = $iyear - $i_factora
  9517. Local $i_factorm = $imonth + (12 * $i_factora) - 2
  9518. Local $i_factord = Mod($iday + $i_factory + Int($i_factory / 4) - Int($i_factory / 100) + Int($i_factory / 400) + Int((31 * $i_factorm) / 12), 7)
  9519. Return $i_factord + 1
  9520. EndFunc
  9521.  
  9522. Func _datetodayofweekiso($iyear, $imonth, $iday)
  9523. Local $idow = _datetodayofweek($iyear, $imonth, $iday)
  9524. If @error Then
  9525. Return SetError(1, 0, "")
  9526. EndIf
  9527. If $idow >= 2 Then Return $idow - 1
  9528. Return 7
  9529. EndFunc
  9530.  
  9531. Func _datetodayvalue($iyear, $imonth, $iday)
  9532. If NOT _dateisvalid(StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)) Then
  9533. Return SetError(1, 0, "")
  9534. EndIf
  9535. If $imonth < 3 Then
  9536. $imonth = $imonth + 12
  9537. $iyear = $iyear - 1
  9538. EndIf
  9539. Local $i_factora = Int($iyear / 100)
  9540. Local $i_factorb = Int($i_factora / 4)
  9541. Local $i_factorc = 2 - $i_factora + $i_factorb
  9542. Local $i_factore = Int(1461 * ($iyear + 4716) / 4)
  9543. Local $i_factorf = Int(153 * ($imonth + 1) / 5)
  9544. Local $ijuliandate = $i_factorc + $iday + $i_factore + $i_factorf - 1524.5
  9545. Return $ijuliandate
  9546. EndFunc
  9547.  
  9548. Func _datetomonth($imonnum, $iformat = Default)
  9549. If $iformat = Default Then $iformat = 0
  9550. $imonnum = Int($imonnum)
  9551. If NOT __dateismonth($imonnum) Then Return SetError(1, 0, "")
  9552. Local $tsystemtime = DllStructCreate($tagsystemtime)
  9553. DllStructSetData($tsystemtime, "Year", @YEAR)
  9554. DllStructSetData($tsystemtime, "Month", $imonnum)
  9555. DllStructSetData($tsystemtime, "Day", 1)
  9556. Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longname) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat, $dmw_shortname) ? "MMM" : "MMMM")
  9557. EndFunc
  9558.  
  9559. Func _dayvaluetodate($ijuliandate, ByRef $iyear, ByRef $imonth, ByRef $iday)
  9560. If $ijuliandate < 0 OR NOT IsNumber($ijuliandate) Then
  9561. Return SetError(1, 0, 0)
  9562. EndIf
  9563. Local $i_factorz = Int($ijuliandate + 0.5)
  9564. Local $i_factorw = Int(($i_factorz - 1867216.25) / 36524.25)
  9565. Local $i_factorx = Int($i_factorw / 4)
  9566. Local $i_factora = $i_factorz + 1 + $i_factorw - $i_factorx
  9567. Local $i_factorb = $i_factora + 1524
  9568. Local $i_factorc = Int(($i_factorb - 122.1) / 365.25)
  9569. Local $i_factord = Int(365.25 * $i_factorc)
  9570. Local $i_factore = Int(($i_factorb - $i_factord) / 30.6001)
  9571. Local $i_factorf = Int(30.6001 * $i_factore)
  9572. $iday = $i_factorb - $i_factord - $i_factorf
  9573. If $i_factore - 1 < 13 Then
  9574. $imonth = $i_factore - 1
  9575. Else
  9576. $imonth = $i_factore - 13
  9577. EndIf
  9578. If $imonth < 3 Then
  9579. $iyear = $i_factorc - 4715
  9580. Else
  9581. $iyear = $i_factorc - 4716
  9582. EndIf
  9583. $iyear = StringFormat("%04d", $iyear)
  9584. $imonth = StringFormat("%02d", $imonth)
  9585. $iday = StringFormat("%02d", $iday)
  9586. Return $iyear & "/" & $imonth & "/" & $iday
  9587. EndFunc
  9588.  
  9589. Func _date_juliandayno($iyear, $imonth, $iday)
  9590. Local $sfulldate = StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)
  9591. If NOT _dateisvalid($sfulldate) Then
  9592. Return SetError(1, 0, "")
  9593. EndIf
  9594. Local $ijday = 0
  9595. Local $aidaysinmonth = _daysinmonth($iyear)
  9596. For $icntr = 1 To $imonth - 1
  9597. $ijday = $ijday + $aidaysinmonth[$icntr]
  9598. Next
  9599. $ijday = ($iyear * 1000) + ($ijday + $iday)
  9600. Return $ijday
  9601. EndFunc
  9602.  
  9603. Func _juliantodate($ijday, $ssep = "/")
  9604. Local $iyear = Int($ijday / 1000)
  9605. Local $idays = Mod($ijday, 1000)
  9606. Local $imaxdays = 365
  9607. If _dateisleapyear($iyear) Then $imaxdays = 366
  9608. If $idays > $imaxdays Then
  9609. Return SetError(1, 0, "")
  9610. EndIf
  9611. Local $aidaysinmonth = _daysinmonth($iyear)
  9612. Local $imonth = 1
  9613. While $idays > $aidaysinmonth[$imonth]
  9614. $idays = $idays - $aidaysinmonth[$imonth]
  9615. $imonth = $imonth + 1
  9616. WEnd
  9617. Return StringFormat("%04d%s%02d%s%02d", $iyear, $ssep, $imonth, $ssep, $idays)
  9618. EndFunc
  9619.  
  9620. Func _now()
  9621. Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, 0)
  9622. EndFunc
  9623.  
  9624. Func _nowcalc()
  9625. Return @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
  9626. EndFunc
  9627.  
  9628. Func _nowcalcdate()
  9629. Return @YEAR & "/" & @MON & "/" & @MDAY
  9630. EndFunc
  9631.  
  9632. Func _nowdate()
  9633. Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY, 0)
  9634. EndFunc
  9635.  
  9636. Func _nowtime($stype = 3)
  9637. If $stype < 3 OR $stype > 5 Then $stype = 3
  9638. Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $stype)
  9639. EndFunc
  9640.  
  9641. Func _setdate($iday, $imonth = 0, $iyear = 0)
  9642. If $iyear = 0 Then $iyear = @YEAR
  9643. If $imonth = 0 Then $imonth = @MON
  9644. If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then Return 1
  9645. Local $tsystemtime = DllStructCreate($tagsystemtime)
  9646. DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
  9647. If @error Then Return SetError(@error, @extended, 0)
  9648. DllStructSetData($tsystemtime, "Day", $iday)
  9649. If $imonth > 0 Then DllStructSetData($tsystemtime, "Month", $imonth)
  9650. If $iyear > 0 Then DllStructSetData($tsystemtime, "Year", $iyear)
  9651. Local $ireturn = _date_time_setlocaltime($tsystemtime)
  9652. If @error Then Return SetError(@error + 10, @extended, 0)
  9653. Return Int($ireturn)
  9654. EndFunc
  9655.  
  9656. Func _settime($ihour, $iminute, $isecond = 0, $imseconds = 0)
  9657. If $ihour < 0 OR $ihour > 23 Then Return 1
  9658. If $iminute < 0 OR $iminute > 59 Then Return 1
  9659. If $isecond < 0 OR $isecond > 59 Then Return 1
  9660. If $imseconds < 0 OR $imseconds > 999 Then Return 1
  9661. Local $tsystemtime = DllStructCreate($tagsystemtime)
  9662. DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
  9663. If @error Then Return SetError(@error, @extended, 0)
  9664. DllStructSetData($tsystemtime, "Hour", $ihour)
  9665. DllStructSetData($tsystemtime, "Minute", $iminute)
  9666. If $isecond > 0 Then DllStructSetData($tsystemtime, "Seconds", $isecond)
  9667. If $imseconds > 0 Then DllStructSetData($tsystemtime, "MSeconds", $imseconds)
  9668. Local $ireturn = _date_time_setlocaltime($tsystemtime)
  9669. If @error Then Return SetError(@error + 10, @extended, 0)
  9670. Return Int($ireturn)
  9671. EndFunc
  9672.  
  9673. Func _tickstotime($iticks, ByRef $ihours, ByRef $imins, ByRef $isecs)
  9674. If Number($iticks) > 0 Then
  9675. $iticks = Int($iticks / 1000)
  9676. $ihours = Int($iticks / 3600)
  9677. $iticks = Mod($iticks, 3600)
  9678. $imins = Int($iticks / 60)
  9679. $isecs = Mod($iticks, 60)
  9680. Return 1
  9681. ElseIf Number($iticks) = 0 Then
  9682. $ihours = 0
  9683. $iticks = 0
  9684. $imins = 0
  9685. $isecs = 0
  9686. Return 1
  9687. Else
  9688. Return SetError(1, 0, 0)
  9689. EndIf
  9690. EndFunc
  9691.  
  9692. Func _timetoticks($ihours = @HOUR, $imins = @MIN, $isecs = @SEC)
  9693. If StringIsInt($ihours) AND StringIsInt($imins) AND StringIsInt($isecs) Then
  9694. Local $iticks = 1000 * ((3600 * $ihours) + (60 * $imins) + $isecs)
  9695. Return $iticks
  9696. Else
  9697. Return SetError(1, 0, 0)
  9698. EndIf
  9699. EndFunc
  9700.  
  9701. Func _weeknumberiso($iyear = @YEAR, $imonth = @MON, $iday = @MDAY)
  9702. If $iday > 31 OR $iday < 1 Then
  9703. Return SetError(1, 0, -1)
  9704. ElseIf NOT __dateismonth($imonth) Then
  9705. Return SetError(2, 0, -1)
  9706. ElseIf $iyear < 1 OR $iyear > 2999 Then
  9707. Return SetError(3, 0, -1)
  9708. EndIf
  9709. Local $idow = _datetodayofweekiso($iyear, $imonth, $iday) - 1
  9710. Local $idow0101 = _datetodayofweekiso($iyear, 1, 1) - 1
  9711. If ($imonth = 1 AND 3 < $idow0101 AND $idow0101 < 7 - ($iday - 1)) Then
  9712. $idow = $idow0101 - 1
  9713. $idow0101 = _datetodayofweekiso($iyear - 1, 1, 1) - 1
  9714. $imonth = 12
  9715. $iday = 31
  9716. $iyear = $iyear - 1
  9717. ElseIf ($imonth = 12 AND 30 - ($iday - 1) < _datetodayofweekiso($iyear + 1, 1, 1) - 1 AND _datetodayofweekiso($iyear + 1, 1, 1) - 1 < 4) Then
  9718. Return 1
  9719. EndIf
  9720. Return Int((_datetodayofweekiso($iyear, 1, 1) - 1 < 4) + 4 * ($imonth - 1) + (2 * ($imonth - 1) + ($iday - 1) + $idow0101 - $idow + 6) * 36 / 256)
  9721. EndFunc
  9722.  
  9723. Func _weeknumber($iyear = @YEAR, $imonth = @MON, $iday = @MDAY, $iweekstart = 1)
  9724. If $iday > 31 OR $iday < 1 Then
  9725. Return SetError(1, 0, -1)
  9726. ElseIf NOT __dateismonth($imonth) Then
  9727. Return SetError(3, 0, -1)
  9728. ElseIf $iyear < 1 OR $iyear > 2999 Then
  9729. Return SetError(4, 0, -1)
  9730. ElseIf $iweekstart < 1 OR $iweekstart > 2 Then
  9731. Return SetError(2, 0, -1)
  9732. EndIf
  9733. Local $istartweek1, $iendweek1
  9734. Local $idow0101 = _datetodayofweekiso($iyear, 1, 1)
  9735. Local $idate = $iyear & "/" & $imonth & "/" & $iday
  9736. If $iweekstart = 1 Then
  9737. If $idow0101 = 6 Then
  9738. $istartweek1 = 0
  9739. Else
  9740. $istartweek1 = -1 * $idow0101 - 1
  9741. EndIf
  9742. $iendweek1 = $istartweek1 + 6
  9743. Else
  9744. $istartweek1 = $idow0101 * -1
  9745. $iendweek1 = $istartweek1 + 6
  9746. EndIf
  9747. Local $istartweek1ny
  9748. Local $iendweek1date = _dateadd("d", $iendweek1, $iyear & "/01/01")
  9749. Local $idow0101ny = _datetodayofweekiso($iyear + 1, 1, 1)
  9750. If $iweekstart = 1 Then
  9751. If $idow0101ny = 6 Then
  9752. $istartweek1ny = 0
  9753. Else
  9754. $istartweek1ny = -1 * $idow0101ny - 1
  9755. EndIf
  9756. Else
  9757. $istartweek1ny = $idow0101ny * -1
  9758. EndIf
  9759. Local $istartweek1dateny = _dateadd("d", $istartweek1ny, $iyear + 1 & "/01/01")
  9760. Local $icurrdatediff = _datediff("d", $iendweek1date, $idate) - 1
  9761. Local $icurrdatediffny = _datediff("d", $istartweek1dateny, $idate)
  9762. If $icurrdatediff >= 0 AND $icurrdatediffny < 0 Then Return 2 + Int($icurrdatediff / 7)
  9763. If $icurrdatediff < 0 OR $icurrdatediffny >= 0 Then Return 1
  9764. EndFunc
  9765.  
  9766. Func _daysinmonth($iyear)
  9767. Local $adays = [12, 31, (_dateisleapyear($iyear) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  9768. Return $adays
  9769. EndFunc
  9770.  
  9771. Func __date_time_clonesystemtime($psystemtime)
  9772. Local $tsystemtime1 = DllStructCreate($tagsystemtime, $psystemtime)
  9773. Local $tsystemtime2 = DllStructCreate($tagsystemtime)
  9774. DllStructSetData($tsystemtime2, "Month", DllStructGetData($tsystemtime1, "Month"))
  9775. DllStructSetData($tsystemtime2, "Day", DllStructGetData($tsystemtime1, "Day"))
  9776. DllStructSetData($tsystemtime2, "Year", DllStructGetData($tsystemtime1, "Year"))
  9777. DllStructSetData($tsystemtime2, "Hour", DllStructGetData($tsystemtime1, "Hour"))
  9778. DllStructSetData($tsystemtime2, "Minute", DllStructGetData($tsystemtime1, "Minute"))
  9779. DllStructSetData($tsystemtime2, "Second", DllStructGetData($tsystemtime1, "Second"))
  9780. DllStructSetData($tsystemtime2, "MSeconds", DllStructGetData($tsystemtime1, "MSeconds"))
  9781. DllStructSetData($tsystemtime2, "DOW", DllStructGetData($tsystemtime1, "DOW"))
  9782. Return $tsystemtime2
  9783. EndFunc
  9784.  
  9785. Func _date_time_comparefiletime($tfiletime1, $tfiletime2)
  9786. Local $aresult = DllCall("kernel32.dll", "long", "CompareFileTime", "struct*", $tfiletime1, "struct*", $tfiletime2)
  9787. If @error Then Return SetError(@error, @extended, 0)
  9788. Return $aresult[0]
  9789. EndFunc
  9790.  
  9791. Func _date_time_dosdatetimetofiletime($ifatdate, $ifattime)
  9792. Local $ttime = DllStructCreate($tagfiletime)
  9793. Local $aresult = DllCall("kernel32.dll", "bool", "DosDateTimeToFileTime", "word", $ifatdate, "word", $ifattime, "struct*", $ttime)
  9794. If @error Then Return SetError(@error, @extended, 0)
  9795. Return SetExtended($aresult[0], $ttime)
  9796. EndFunc
  9797.  
  9798. Func _date_time_dosdatetoarray($idosdate)
  9799. Local $adate[3]
  9800. $adate[0] = BitAND($idosdate, 31)
  9801. $adate[1] = BitAND(BitShift($idosdate, 5), 15)
  9802. $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
  9803. Return $adate
  9804. EndFunc
  9805.  
  9806. Func _date_time_dosdatetimetoarray($idosdate, $idostime)
  9807. Local $adate[6]
  9808. $adate[0] = BitAND($idosdate, 31)
  9809. $adate[1] = BitAND(BitShift($idosdate, 5), 15)
  9810. $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
  9811. $adate[5] = BitAND($idostime, 31) * 2
  9812. $adate[4] = BitAND(BitShift($idostime, 5), 63)
  9813. $adate[3] = BitAND(BitShift($idostime, 11), 31)
  9814. Return $adate
  9815. EndFunc
  9816.  
  9817. Func _date_time_dosdatetimetostr($idosdate, $idostime)
  9818. Local $adate = _date_time_dosdatetimetoarray($idosdate, $idostime)
  9819. Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
  9820. EndFunc
  9821.  
  9822. Func _date_time_dosdatetostr($idosdate)
  9823. Local $adate = _date_time_dosdatetoarray($idosdate)
  9824. Return StringFormat("%02d/%02d/%04d", $adate[0], $adate[1], $adate[2])
  9825. EndFunc
  9826.  
  9827. Func _date_time_dostimetoarray($idostime)
  9828. Local $atime[3]
  9829. $atime[2] = BitAND($idostime, 31) * 2
  9830. $atime[1] = BitAND(BitShift($idostime, 5), 63)
  9831. $atime[0] = BitAND(BitShift($idostime, 11), 31)
  9832. Return $atime
  9833. EndFunc
  9834.  
  9835. Func _date_time_dostimetostr($idostime)
  9836. Local $atime = _date_time_dostimetoarray($idostime)
  9837. Return StringFormat("%02d:%02d:%02d", $atime[0], $atime[1], $atime[2])
  9838. EndFunc
  9839.  
  9840. Func _date_time_encodefiletime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
  9841. Local $tsystemtime = _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour, $iminute, $isecond, $imseconds)
  9842. Return _date_time_systemtimetofiletime($tsystemtime)
  9843. EndFunc
  9844.  
  9845. Func _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
  9846. Local $tsystemtime = DllStructCreate($tagsystemtime)
  9847. DllStructSetData($tsystemtime, "Month", $imonth)
  9848. DllStructSetData($tsystemtime, "Day", $iday)
  9849. DllStructSetData($tsystemtime, "Year", $iyear)
  9850. DllStructSetData($tsystemtime, "Hour", $ihour)
  9851. DllStructSetData($tsystemtime, "Minute", $iminute)
  9852. DllStructSetData($tsystemtime, "Second", $isecond)
  9853. DllStructSetData($tsystemtime, "MSeconds", $imseconds)
  9854. Return $tsystemtime
  9855. EndFunc
  9856.  
  9857. Func _date_time_filetimetoarray(ByRef $tfiletime)
  9858. If ((DllStructGetData($tfiletime, 1) + DllStructGetData($tfiletime, 2)) = 0) Then Return SetError(10, 0, 0)
  9859. Local $tsystemtime = _date_time_filetimetosystemtime($tfiletime)
  9860. If @error Then Return SetError(@error, @extended, 0)
  9861. Return _date_time_systemtimetoarray($tsystemtime)
  9862. EndFunc
  9863.  
  9864. Func _date_time_filetimetostr(ByRef $tfiletime, $ifmt = 0)
  9865. Local $adate = _date_time_filetimetoarray($tfiletime)
  9866. If @error Then Return SetError(@error, @extended, "")
  9867. If $ifmt Then
  9868. Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $adate[2], $adate[0], $adate[1], $adate[3], $adate[4], $adate[5])
  9869. Else
  9870. Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
  9871. EndIf
  9872. EndFunc
  9873.  
  9874. Func _date_time_filetimetodosdatetime($tfiletime)
  9875. Local $adate[2]
  9876. Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToDosDateTime", "struct*", $tfiletime, "word*", 0, "word*", 0)
  9877. If @error Then Return SetError(@error, @extended, $adate)
  9878. $adate[0] = $aresult[2]
  9879. $adate[1] = $aresult[3]
  9880. Return SetExtended($aresult[0], $adate)
  9881. EndFunc
  9882.  
  9883. Func _date_time_filetimetolocalfiletime($tfiletime)
  9884. Local $tlocal = DllStructCreate($tagfiletime)
  9885. Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToLocalFileTime", "struct*", $tfiletime, "struct*", $tlocal)
  9886. If @error Then Return SetError(@error, @extended, 0)
  9887. Return SetExtended($aresult[0], $tlocal)
  9888. EndFunc
  9889.  
  9890. Func _date_time_filetimetosystemtime($tfiletime)
  9891. Local $tsysttime = DllStructCreate($tagsystemtime)
  9892. Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToSystemTime", "struct*", $tfiletime, "struct*", $tsysttime)
  9893. If @error Then Return SetError(@error, @extended, 0)
  9894. Return SetExtended($aresult[0], $tsysttime)
  9895. EndFunc
  9896.  
  9897. Func _date_time_getfiletime($hfile)
  9898. Local $adate[3]
  9899. $adate[0] = DllStructCreate($tagfiletime)
  9900. $adate[1] = DllStructCreate($tagfiletime)
  9901. $adate[2] = DllStructCreate($tagfiletime)
  9902. Local $aresult = DllCall("kernel32.dll", "bool", "GetFileTime", "handle", $hfile, "struct*", $adate[0], "struct*", $adate[1], "struct*", $adate[2])
  9903. If @error Then Return SetError(@error, @extended, 0)
  9904. Return SetExtended($aresult[0], $adate)
  9905. EndFunc
  9906.  
  9907. Func _date_time_getlocaltime()
  9908. Local $tsysttime = DllStructCreate($tagsystemtime)
  9909. DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsysttime)
  9910. If @error Then Return SetError(@error, @extended, 0)
  9911. Return $tsysttime
  9912. EndFunc
  9913.  
  9914. Func _date_time_getsystemtime()
  9915. Local $tsysttime = DllStructCreate($tagsystemtime)
  9916. DllCall("kernel32.dll", "none", "GetSystemTime", "struct*", $tsysttime)
  9917. If @error Then Return SetError(@error, @extended, 0)
  9918. Return $tsysttime
  9919. EndFunc
  9920.  
  9921. Func _date_time_getsystemtimeadjustment()
  9922. Local $ainfo[3]
  9923. Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimeAdjustment", "dword*", 0, "dword*", 0, "bool*", 0)
  9924. If @error Then Return SetError(@error, @extended, 0)
  9925. $ainfo[0] = $aresult[1]
  9926. $ainfo[1] = $aresult[2]
  9927. $ainfo[2] = $aresult[3] <> 0
  9928. Return SetExtended($aresult[0], $ainfo)
  9929. EndFunc
  9930.  
  9931. Func _date_time_getsystemtimeasfiletime()
  9932. Local $tfiletime = DllStructCreate($tagfiletime)
  9933. DllCall("kernel32.dll", "none", "GetSystemTimeAsFileTime", "struct*", $tfiletime)
  9934. If @error Then Return SetError(@error, @extended, 0)
  9935. Return $tfiletime
  9936. EndFunc
  9937.  
  9938. Func _date_time_getsystemtimes()
  9939. Local $ainfo[3]
  9940. $ainfo[0] = DllStructCreate($tagfiletime)
  9941. $ainfo[1] = DllStructCreate($tagfiletime)
  9942. $ainfo[2] = DllStructCreate($tagfiletime)
  9943. Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimes", "struct*", $ainfo[0], "struct*", $ainfo[1], "struct*", $ainfo[2])
  9944. If @error Then Return SetError(@error, @extended, 0)
  9945. Return SetExtended($aresult[0], $ainfo)
  9946. EndFunc
  9947.  
  9948. Func _date_time_gettickcount()
  9949. Local $aresult = DllCall("kernel32.dll", "dword", "GetTickCount")
  9950. If @error Then Return SetError(@error, @extended, 0)
  9951. Return $aresult[0]
  9952. EndFunc
  9953.  
  9954. Func _date_time_gettimezoneinformation()
  9955. Local $ttimezone = DllStructCreate($tagtime_zone_information)
  9956. Local $aresult = DllCall("kernel32.dll", "dword", "GetTimeZoneInformation", "struct*", $ttimezone)
  9957. If @error OR $aresult[0] = -1 Then Return SetError(@error, @extended, 0)
  9958. Local $ainfo[8]
  9959. $ainfo[0] = $aresult[0]
  9960. $ainfo[1] = DllStructGetData($ttimezone, "Bias")
  9961. $ainfo[2] = _winapi_widechartomultibyte(DllStructGetPtr($ttimezone, "StdName"))
  9962. $ainfo[3] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "StdDate"))
  9963. $ainfo[4] = DllStructGetData($ttimezone, "StdBias")
  9964. $ainfo[5] = _winapi_widechartomultibyte(DllStructGetPtr($ttimezone, "DayName"))
  9965. $ainfo[6] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "DayDate"))
  9966. $ainfo[7] = DllStructGetData($ttimezone, "DayBias")
  9967. Return $ainfo
  9968. EndFunc
  9969.  
  9970. Func _date_time_localfiletimetofiletime($tlocaltime)
  9971. Local $tfiletime = DllStructCreate($tagfiletime)
  9972. Local $aresult = DllCall("kernel32.dll", "bool", "LocalFileTimeToFileTime", "struct*", $tlocaltime, "struct*", $tfiletime)
  9973. If @error Then Return SetError(@error, @extended, 0)
  9974. Return SetExtended($aresult[0], $tfiletime)
  9975. EndFunc
  9976.  
  9977. Func _date_time_setfiletime($hfile, $tcreatetime, $tlastaccess, $tlastwrite)
  9978. Local $aresult = DllCall("kernel32.dll", "bool", "SetFileTime", "handle", $hfile, "struct*", $tcreatetime, "struct*", $tlastaccess, "struct*", $tlastwrite)
  9979. If @error Then Return SetError(@error, @extended, False)
  9980. Return $aresult[0]
  9981. EndFunc
  9982.  
  9983. Func _date_time_setlocaltime($tsystemtime)
  9984. Local $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tsystemtime)
  9985. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, False)
  9986. $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tsystemtime)
  9987. If @error Then Return SetError(@error, @extended, False)
  9988. Return $aresult[0]
  9989. EndFunc
  9990.  
  9991. Func _date_time_setsystemtime($tsystemtime)
  9992. Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTime", "struct*", $tsystemtime)
  9993. If @error Then Return SetError(@error, @extended, False)
  9994. Return $aresult[0]
  9995. EndFunc
  9996.  
  9997. Func _date_time_setsystemtimeadjustment($iadjustment, $bdisabled)
  9998. Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  9999. If @error Then Return SetError(@error + 10, @extended, False)
  10000. _security__setprivilege($htoken, "SeSystemtimePrivilege", True)
  10001. Local $ierror = @error
  10002. Local $ilasterror = @extended
  10003. Local $bret = False
  10004. If NOT @error Then
  10005. Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTimeAdjustment", "dword", $iadjustment, "bool", $bdisabled)
  10006. If @error Then
  10007. $ierror = @error
  10008. $ilasterror = @extended
  10009. ElseIf $aresult[0] Then
  10010. $bret = True
  10011. Else
  10012. $ierror = 20
  10013. $ilasterror = _winapi_getlasterror()
  10014. EndIf
  10015. _security__setprivilege($htoken, "SeSystemtimePrivilege", False)
  10016. If NOT $ierror AND @error Then $ierror = 22
  10017. EndIf
  10018. _winapi_closehandle($htoken)
  10019. Return SetError($ierror, $ilasterror, $bret)
  10020. EndFunc
  10021.  
  10022. Func _date_time_settimezoneinformation($ibias, $sstdname, $tstddate, $istdbias, $sdayname, $tdaydate, $idaybias)
  10023. Local $tstdname = _winapi_multibytetowidechar($sstdname)
  10024. Local $tdayname = _winapi_multibytetowidechar($sdayname)
  10025. Local $tzoneinfo = DllStructCreate($tagtime_zone_information)
  10026. DllStructSetData($tzoneinfo, "Bias", $ibias)
  10027. DllStructSetData($tzoneinfo, "StdName", DllStructGetData($tstdname, 1))
  10028. _memmovememory($tstddate, DllStructGetPtr($tzoneinfo, "StdDate"), DllStructGetSize($tstddate))
  10029. DllStructSetData($tzoneinfo, "StdBias", $istdbias)
  10030. DllStructSetData($tzoneinfo, "DayName", DllStructGetData($tdayname, 1))
  10031. _memmovememory($tdaydate, DllStructGetPtr($tzoneinfo, "DayDate"), DllStructGetSize($tdaydate))
  10032. DllStructSetData($tzoneinfo, "DayBias", $idaybias)
  10033. Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  10034. If @error Then Return SetError(@error + 10, @extended, False)
  10035. _security__setprivilege($htoken, "SeSystemtimePrivilege", True)
  10036. Local $ierror = @error
  10037. Local $ilasterror = @extended
  10038. Local $bret = False
  10039. If NOT @error Then
  10040. Local $aresult = DllCall("kernel32.dll", "bool", "SetTimeZoneInformation", "struct*", $tzoneinfo)
  10041. If @error Then
  10042. $ierror = @error
  10043. $ilasterror = @extended
  10044. ElseIf $aresult[0] Then
  10045. $ilasterror = 0
  10046. $bret = True
  10047. Else
  10048. $ierror = 20
  10049. $ilasterror = _winapi_getlasterror()
  10050. EndIf
  10051. _security__setprivilege($htoken, "SeSystemtimePrivilege", False)
  10052. If NOT $ierror AND @error Then $ierror = 22
  10053. EndIf
  10054. _winapi_closehandle($htoken)
  10055. Return SetError($ierror, $ilasterror, $bret)
  10056. EndFunc
  10057.  
  10058. Func _date_time_systemtimetoarray(ByRef $tsystemtime)
  10059. Local $ainfo[8]
  10060. $ainfo[0] = DllStructGetData($tsystemtime, "Month")
  10061. $ainfo[1] = DllStructGetData($tsystemtime, "Day")
  10062. $ainfo[2] = DllStructGetData($tsystemtime, "Year")
  10063. $ainfo[3] = DllStructGetData($tsystemtime, "Hour")
  10064. $ainfo[4] = DllStructGetData($tsystemtime, "Minute")
  10065. $ainfo[5] = DllStructGetData($tsystemtime, "Second")
  10066. $ainfo[6] = DllStructGetData($tsystemtime, "MSeconds")
  10067. $ainfo[7] = DllStructGetData($tsystemtime, "DOW")
  10068. Return $ainfo
  10069. EndFunc
  10070.  
  10071. Func _date_time_systemtimetodatestr(ByRef $tsystemtime, $ifmt = 0)
  10072. Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  10073. If @error Then Return SetError(@error, @extended, "")
  10074. If $ifmt Then
  10075. Return StringFormat("%04d/%02d/%02d", $ainfo[2], $ainfo[0], $ainfo[1])
  10076. Else
  10077. Return StringFormat("%02d/%02d/%04d", $ainfo[0], $ainfo[1], $ainfo[2])
  10078. EndIf
  10079. EndFunc
  10080.  
  10081. Func _date_time_systemtimetodatetimestr(ByRef $tsystemtime, $ifmt = 0)
  10082. Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  10083. If @error Then Return SetError(@error, @extended, "")
  10084. If $ifmt Then
  10085. Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $ainfo[2], $ainfo[0], $ainfo[1], $ainfo[3], $ainfo[4], $ainfo[5])
  10086. Else
  10087. Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $ainfo[0], $ainfo[1], $ainfo[2], $ainfo[3], $ainfo[4], $ainfo[5])
  10088. EndIf
  10089. EndFunc
  10090.  
  10091. Func _date_time_systemtimetofiletime($tsystemtime)
  10092. Local $tfiletime = DllStructCreate($tagfiletime)
  10093. Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToFileTime", "struct*", $tsystemtime, "struct*", $tfiletime)
  10094. If @error Then Return SetError(@error, @extended, 0)
  10095. Return SetExtended($aresult[0], $tfiletime)
  10096. EndFunc
  10097.  
  10098. Func _date_time_systemtimetotimestr(ByRef $tsystemtime)
  10099. Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  10100. Return StringFormat("%02d:%02d:%02d", $ainfo[3], $ainfo[4], $ainfo[5])
  10101. EndFunc
  10102.  
  10103. Func _date_time_systemtimetotzspecificlocaltime($tutc, $ttimezone = 0)
  10104. Local $tlocaltime = DllStructCreate($tagsystemtime)
  10105. Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToTzSpecificLocalTime", "struct*", $ttimezone, "struct*", $tutc, "struct*", $tlocaltime)
  10106. If @error Then Return SetError(@error, @extended, 0)
  10107. Return SetExtended($aresult[0], $tlocaltime)
  10108. EndFunc
  10109.  
  10110. Func _date_time_tzspecificlocaltimetosystemtime($tlocaltime, $ttimezone = 0)
  10111. Local $tutc = DllStructCreate($tagsystemtime)
  10112. Local $aresult = DllCall("kernel32.dll", "bool", "TzSpecificLocalTimeToSystemTime", "struct*", $ttimezone, "struct*", $tlocaltime, "struct*", $tutc)
  10113. If @error Then Return SetError(@error, @extended, 0)
  10114. Return SetExtended($aresult[0], $tutc)
  10115. EndFunc
  10116.  
  10117. Global Const $url_scheme_invalid = -1
  10118. Global Const $url_scheme_unknown = 0
  10119. Global Const $url_scheme_ftp = 1
  10120. Global Const $url_scheme_http = 2
  10121. Global Const $url_scheme_gopher = 3
  10122. Global Const $url_scheme_mailto = 4
  10123. Global Const $url_scheme_news = 5
  10124. Global Const $url_scheme_nntp = 6
  10125. Global Const $url_scheme_telnet = 7
  10126. Global Const $url_scheme_wais = 8
  10127. Global Const $url_scheme_file = 9
  10128. Global Const $url_scheme_mk = 10
  10129. Global Const $url_scheme_https = 11
  10130. Global Const $url_scheme_shell = 12
  10131. Global Const $url_scheme_snews = 13
  10132. Global Const $url_scheme_local = 14
  10133. Global Const $url_scheme_javascript = 15
  10134. Global Const $url_scheme_vbscript = 16
  10135. Global Const $url_scheme_about = 17
  10136. Global Const $url_scheme_res = 18
  10137. Global Const $url_scheme_msshellrooted = 19
  10138. Global Const $url_scheme_msshellidlist = 20
  10139. Global Const $url_scheme_mshelp = 21
  10140. Global Const $url_scheme_msshelldevice = 22
  10141. Global Const $url_scheme_wildcard = 23
  10142. Global Const $url_scheme_search_ms = 24
  10143. Global Const $url_scheme_search = 25
  10144. Global Const $url_scheme_knownfolder = 26
  10145. Global Const $gct_invalid = 0
  10146. Global Const $gct_lfnchar = 1
  10147. Global Const $gct_separator = 8
  10148. Global Const $gct_shortchar = 2
  10149. Global Const $gct_wild = 4
  10150. Global Const $url_apply_default = 1
  10151. Global Const $url_apply_guessscheme = 2
  10152. Global Const $url_apply_guessfile = 4
  10153. Global Const $url_apply_forceapply = 8
  10154. Global Const $url_dont_simplify = 134217728
  10155. Global Const $url_escape_as_utf8 = 262144
  10156. Global Const $url_escape_percent = 4096
  10157. Global Const $url_escape_spaces_only = 67108864
  10158. Global Const $url_escape_unsafe = 536870912
  10159. Global Const $url_no_meta = 134217728
  10160. Global Const $url_pluggable_protocol = 1073741824
  10161. Global Const $url_unescape = 268435456
  10162. Global Const $url_part_hostname = 2
  10163. Global Const $url_part_password = 4
  10164. Global Const $url_part_port = 5
  10165. Global Const $url_part_query = 6
  10166. Global Const $url_part_scheme = 1
  10167. Global Const $url_part_username = 3
  10168. Global Const $urlis_appliable = 4
  10169. Global Const $urlis_directory = 5
  10170. Global Const $urlis_fileurl = 3
  10171. Global Const $urlis_hasquery = 6
  10172. Global Const $urlis_nohistory = 2
  10173. Global Const $urlis_opaque = 1
  10174. Global Const $urlis_url = 0
  10175. #Region Functions list
  10176. #EndRegion Functions list
  10177. #Region Public Functions
  10178.  
  10179. Func _winapi_commandlinetoargv($scmd)
  10180. Local $aresult[1] = [0]
  10181. $scmd = StringStripWS($scmd, $str_stripleading + $str_striptrailing)
  10182. If NOT $scmd Then
  10183. Return $aresult
  10184. EndIf
  10185. Local $aret = DllCall("shell32.dll", "ptr", "CommandLineToArgvW", "wstr", $scmd, "int*", 0)
  10186. If @error OR NOT $aret[0] OR (NOT $aret[2]) Then Return SetError(@error + 10, @extended, 0)
  10187. Local $tptr = DllStructCreate("ptr[" & $aret[2] & "]", $aret[0])
  10188. Dim $aresult[$aret[2] + 1] = [$aret[2]]
  10189. For $i = 1 To $aret[2]
  10190. $aresult[$i] = _winapi_getstring(DllStructGetData($tptr, 1, $i))
  10191. Next
  10192. DllCall("kernel32.dll", "handle", "LocalFree", "handle", $aret[0])
  10193. Return $aresult
  10194. EndFunc
  10195.  
  10196. Func _winapi_isnameinexpression($sstring, $spattern, $bcasesensitive = False)
  10197. If NOT $bcasesensitive Then $spattern = StringUpper($spattern)
  10198. Local $tus1 = __us($spattern)
  10199. Local $tus2 = __us($sstring)
  10200. Local $aret = DllCall("ntdll.dll", "boolean", "RtlIsNameInExpression", "struct*", $tus1, "struct*", $tus2, "boolean", NOT $bcasesensitive, "ptr", 0)
  10201. If @error Then Return SetError(@error, @extended, False)
  10202. Return $aret[0]
  10203. EndFunc
  10204.  
  10205. Func _winapi_parseurl($surl)
  10206. Local $tagparsedurl = "dword Size;ptr Protocol;uint cchProtocol;ptr Suffix;uint cchSuffix;uint Scheme"
  10207. Local $tpurl = DllStructCreate($tagparsedurl)
  10208. DllStructSetData($tpurl, 1, DllStructGetSize($tpurl))
  10209. Local $turl = DllStructCreate("wchar[4096]")
  10210. DllStructSetData($turl, 1, $surl)
  10211. Local $aret = DllCall("shlwapi.dll", "long", "ParseURLW", "struct*", $turl, "struct*", $tpurl)
  10212. If @error Then Return SetError(@error, @extended, "")
  10213. If $aret[0] Then Return SetError(10, $aret[0], "")
  10214. Local $aresult[3]
  10215. $aresult[0] = DllStructGetData(DllStructCreate("wchar[" & DllStructGetData($tpurl, 3) & "]", DllStructGetData($tpurl, 2)), 1)
  10216. $aresult[1] = DllStructGetData(DllStructCreate("wchar[" & DllStructGetData($tpurl, 5) & "]", DllStructGetData($tpurl, 4)), 1)
  10217. $aresult[2] = DllStructGetData($tpurl, 6)
  10218. Return $aresult
  10219. EndFunc
  10220.  
  10221. Func _winapi_parseusername($suser)
  10222. If NOT __dll("credui.dll") Then Return SetError(103, 0, 0)
  10223. Local $aret = DllCall("credui.dll", "dword", "CredUIParseUserNameW", "wstr", $suser, "wstr", "", "ulong", 4096, "wstr", "", "ulong", 4096)
  10224. If @error Then Return SetError(@error, @extended, 0)
  10225. Switch $aret[0]
  10226. Case 0
  10227. Case 1315
  10228. If StringStripWS($suser, $str_stripleading + $str_striptrailing) Then
  10229. $aret[2] = $suser
  10230. $aret[4] = ""
  10231. Else
  10232. ContinueCase
  10233. EndIf
  10234. Case Else
  10235. Return SetError(10, $aret[0], 0)
  10236. EndSwitch
  10237. Local $aresult[2]
  10238. $aresult[0] = $aret[4]
  10239. $aresult[1] = $aret[2]
  10240. Return $aresult
  10241. EndFunc
  10242.  
  10243. Func _winapi_pathaddbackslash($sfilepath)
  10244. Local $tpath = DllStructCreate("wchar[260]")
  10245. DllStructSetData($tpath, 1, $sfilepath)
  10246. Local $aret = DllCall("shlwapi.dll", "ptr", "PathAddBackslashW", "struct*", $tpath)
  10247. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  10248. Return DllStructGetData($tpath, 1)
  10249. EndFunc
  10250.  
  10251. Func _winapi_pathaddextension($sfilepath, $sext = "")
  10252. Local $tpath = DllStructCreate("wchar[260]")
  10253. DllStructSetData($tpath, 1, $sfilepath)
  10254. Local $stypeofext = "wstr"
  10255. If NOT StringStripWS($sext, $str_stripleading + $str_striptrailing) Then
  10256. $stypeofext = "ptr"
  10257. $sext = 0
  10258. EndIf
  10259. Local $aret = DllCall("shlwapi.dll", "bool", "PathAddExtensionW", "struct*", $tpath, $stypeofext, $sext)
  10260. If @error Then Return SetError(@error, @extended, "")
  10261. Return SetExtended($aret[0], DllStructGetData($tpath, 1))
  10262. EndFunc
  10263.  
  10264. Func _winapi_pathappend($sfilepath, $smore)
  10265. Local $tpath = DllStructCreate("wchar[260]")
  10266. DllStructSetData($tpath, 1, $sfilepath)
  10267. Local $aret = DllCall("shlwapi.dll", "bool", "PathAppendW", "struct*", $tpath, "wstr", $smore)
  10268. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  10269. Return DllStructGetData($tpath, 1)
  10270. EndFunc
  10271.  
  10272. Func _winapi_pathbuildroot($idrive)
  10273. Local $aret = DllCall("shlwapi.dll", "ptr", "PathBuildRootW", "wstr", "", "int", $idrive)
  10274. If @error Then Return SetError(@error, @extended, "")
  10275. Return $aret[1]
  10276. EndFunc
  10277.  
  10278. Func _winapi_pathcanonicalize($sfilepath)
  10279. Local $aret = DllCall("shlwapi.dll", "bool", "PathCanonicalizeW", "wstr", "", "wstr", $sfilepath)
  10280. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, $sfilepath)
  10281. Return $aret[1]
  10282. EndFunc
  10283.  
  10284. Func _winapi_pathcommonprefix($spath1, $spath2)
  10285. Local $aret = DllCall("shlwapi.dll", "int", "PathCommonPrefixW", "wstr", $spath1, "wstr", $spath2, "wstr", "")
  10286. If @error Then Return SetError(@error, @extended, "")
  10287. Return SetExtended($aret[0], $aret[3])
  10288. EndFunc
  10289.  
  10290. Func _winapi_pathcompactpath($hwnd, $sfilepath, $iwidth = 0)
  10291. If $iwidth < 1 Then
  10292. Local $trect = DllStructCreate($tagrect)
  10293. DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "struct*", $trect)
  10294. $iwidth += DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  10295. EndIf
  10296. Local $aret = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
  10297. If @error OR NOT $aret[0] Then Return SetError(@error + 20, @extended, $sfilepath)
  10298. Local $hdc = $aret[0]
  10299. Local Const $wm_getfont = 49
  10300. $aret = DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hwnd, "uint", $wm_getfont, "wparam", 0, "lparam", 0)
  10301. Local $hback = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $aret[0])
  10302. Local $ierror = 0
  10303. $aret = DllCall("shlwapi.dll", "bool", "PathCompactPathW", "handle", $hdc, "wstr", $sfilepath, "int", $iwidth)
  10304. If @error OR NOT $aret[0] Then $ierror = @error + 10
  10305. DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hback[0])
  10306. DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
  10307. If $ierror Then Return SetError($ierror, 0, $sfilepath)
  10308. Return $aret[2]
  10309. EndFunc
  10310.  
  10311. Func _winapi_pathcompactpathex($sfilepath, $imax)
  10312. Local $aret = DllCall("shlwapi.dll", "bool", "PathCompactPathExW", "wstr", "", "wstr", $sfilepath, "uint", $imax + 1, "dword", 0)
  10313. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, $sfilepath)
  10314. Return $aret[1]
  10315. EndFunc
  10316.  
  10317. Func _winapi_pathcreatefromurl($surl)
  10318. Local $aret = DllCall("shlwapi.dll", "long", "PathCreateFromUrlW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", 0)
  10319. If @error Then Return SetError(@error, @extended, "")
  10320. If $aret[0] Then Return SetError(10, $aret[0], "")
  10321. Return $aret[2]
  10322. EndFunc
  10323.  
  10324. Func _winapi_pathfindextension($sfilepath)
  10325. Local $aret = DllCall("shlwapi.dll", "wstr", "PathFindExtensionW", "wstr", $sfilepath)
  10326. If @error Then Return SetError(@error, @extended, "")
  10327. Return $aret[0]
  10328. EndFunc
  10329.  
  10330. Func _winapi_pathfindfilename($sfilepath)
  10331. Local $aret = DllCall("shlwapi.dll", "wstr", "PathFindFileNameW", "wstr", $sfilepath)
  10332. If @error Then Return SetError(@error, @extended, $sfilepath)
  10333. Return $aret[0]
  10334. EndFunc
  10335.  
  10336. Func _winapi_pathfindnextcomponent($sfilepath)
  10337. Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
  10338. DllStructSetData($tpath, 1, $sfilepath)
  10339. Local $aret = DllCall("shlwapi.dll", "ptr", "PathFindNextComponentW", "struct*", $tpath)
  10340. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  10341. Return _winapi_getstring($aret[0])
  10342. EndFunc
  10343.  
  10344. Func _winapi_pathgetargs($sfilepath)
  10345. Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
  10346. DllStructSetData($tpath, 1, $sfilepath)
  10347. Local $aret = DllCall("shlwapi.dll", "ptr", "PathGetArgsW", "struct*", $tpath)
  10348. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  10349. Return _winapi_getstring($aret[0])
  10350. EndFunc
  10351.  
  10352. Func _winapi_pathgetchartype($schar)
  10353. Local $aret = DllCall("shlwapi.dll", "uint", "PathGetCharTypeW", "word", AscW($schar))
  10354. If @error Then Return SetError(@error, @extended, -1)
  10355. Return $aret[0]
  10356. EndFunc
  10357.  
  10358. Func _winapi_pathgetdrivenumber($sfilepath)
  10359. Local $aret = DllCall("shlwapi.dll", "int", "PathGetDriveNumberW", "wstr", $sfilepath)
  10360. If @error OR ($aret[0] = -1) Then Return SetError(@error, @extended, "")
  10361. Return Chr($aret[0] + 65) & ":"
  10362. EndFunc
  10363.  
  10364. Func _winapi_pathiscontenttype($sfilepath, $stype)
  10365. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsContentTypeW", "wstr", $sfilepath, "wstr", $stype)
  10366. If @error Then Return SetError(@error, @extended, False)
  10367. Return $aret[0]
  10368. EndFunc
  10369.  
  10370. Func _winapi_pathisexe($sfilepath)
  10371. Local $aret = DllCall("shell32.dll", "bool", "PathIsExe", "wstr", $sfilepath)
  10372. If @error Then Return SetError(@error, @extended, False)
  10373. Return $aret[0]
  10374. EndFunc
  10375.  
  10376. Func _winapi_pathisfilespec($sfilepath)
  10377. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsFileSpecW", "wstr", $sfilepath)
  10378. If @error Then Return SetError(@error, @extended, False)
  10379. Return $aret[0]
  10380. EndFunc
  10381.  
  10382. Func _winapi_pathislfnfilespec($sfilepath)
  10383. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsLFNFileSpecW", "wstr", $sfilepath)
  10384. If @error Then Return SetError(@error, @extended, False)
  10385. Return $aret[0]
  10386. EndFunc
  10387.  
  10388. Func _winapi_pathisrelative($sfilepath)
  10389. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsRelativeW", "wstr", $sfilepath)
  10390. If @error Then Return SetError(@error, @extended, False)
  10391. Return $aret[0]
  10392. EndFunc
  10393.  
  10394. Func _winapi_pathisroot($sfilepath)
  10395. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsRootW", "wstr", $sfilepath)
  10396. If @error Then Return SetError(@error, @extended, False)
  10397. Return $aret[0]
  10398. EndFunc
  10399.  
  10400. Func _winapi_pathissameroot($spath1, $spath2)
  10401. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsSameRootW", "wstr", $spath1, "wstr", $spath2)
  10402. If @error Then Return SetError(@error, @extended, False)
  10403. Return $aret[0]
  10404. EndFunc
  10405.  
  10406. Func _winapi_pathissystemfolder($sfilepath)
  10407. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsSystemFolderW", "wstr", $sfilepath, "dword", 0)
  10408. If @error Then Return SetError(@error, @extended, False)
  10409. Return $aret[0]
  10410. EndFunc
  10411.  
  10412. Func _winapi_pathisunc($sfilepath)
  10413. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCW", "wstr", $sfilepath)
  10414. If @error Then Return SetError(@error, @extended, False)
  10415. Return $aret[0]
  10416. EndFunc
  10417.  
  10418. Func _winapi_pathisuncserver($sfilepath)
  10419. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCServerW", "wstr", $sfilepath)
  10420. If @error Then Return SetError(@error, @extended, False)
  10421. Return $aret[0]
  10422. EndFunc
  10423.  
  10424. Func _winapi_pathisuncservershare($sfilepath)
  10425. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCServerShareW", "wstr", $sfilepath)
  10426. If @error Then Return SetError(@error, @extended, False)
  10427. Return $aret[0]
  10428. EndFunc
  10429.  
  10430. Func _winapi_pathmakesystemfolder($sfilepath)
  10431. Local $aret = DllCall("shlwapi.dll", "bool", "PathMakeSystemFolderW", "wstr", $sfilepath)
  10432. If @error Then Return SetError(@error, @extended, False)
  10433. Return $aret[0]
  10434. EndFunc
  10435.  
  10436. Func _winapi_pathmatchspec($sfilepath, $sspec)
  10437. Local $aret = DllCall("shlwapi.dll", "bool", "PathMatchSpecW", "wstr", $sfilepath, "wstr", $sspec)
  10438. If @error Then Return SetError(@error, @extended, False)
  10439. Return $aret[0]
  10440. EndFunc
  10441.  
  10442. Func _winapi_pathparseiconlocation($sfilepath)
  10443. Local $aret = DllCall("shlwapi.dll", "int", "PathParseIconLocationW", "wstr", $sfilepath)
  10444. If @error Then Return SetError(@error, @extended, 0)
  10445. Local $aresult[2]
  10446. $aresult[0] = $aret[1]
  10447. $aresult[1] = $aret[0]
  10448. Return $aresult
  10449. EndFunc
  10450.  
  10451. Func _winapi_pathrelativepathto($spathfrom, $bdirfrom, $spathto, $bdirto)
  10452. If $bdirfrom Then
  10453. $bdirfrom = 16
  10454. EndIf
  10455. If $bdirto Then
  10456. $bdirto = 16
  10457. EndIf
  10458. Local $aret = DllCall("shlwapi.dll", "bool", "PathRelativePathToW", "wstr", "", "wstr", $spathfrom, "dword", $bdirfrom, "wstr", $spathto, "dword", $bdirto)
  10459. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  10460. Return $aret[1]
  10461. EndFunc
  10462.  
  10463. Func _winapi_pathremoveargs($sfilepath)
  10464. Local $aret = DllCall("shlwapi.dll", "none", "PathRemoveArgsW", "wstr", $sfilepath)
  10465. If @error Then Return SetError(@error, @extended, "")
  10466. Return $aret[1]
  10467. EndFunc
  10468.  
  10469. Func _winapi_pathremovebackslash($sfilepath)
  10470. Local $aret = DllCall("shlwapi.dll", "ptr", "PathRemoveBackslashW", "wstr", $sfilepath)
  10471. If @error Then Return SetError(@error, @extended, "")
  10472. Return $aret[1]
  10473. EndFunc
  10474.  
  10475. Func _winapi_pathremoveextension($sfilepath)
  10476. Local $aret = DllCall("shlwapi.dll", "none", "PathRemoveExtensionW", "wstr", $sfilepath)
  10477. If @error Then Return SetError(@error, @extended, "")
  10478. Return $aret[1]
  10479. EndFunc
  10480.  
  10481. Func _winapi_pathremovefilespec($sfilepath)
  10482. Local $aret = DllCall("shlwapi.dll", "bool", "PathRemoveFileSpecW", "wstr", $sfilepath)
  10483. If @error Then Return SetError(@error, @extended, "")
  10484. Return SetExtended($aret[0], $aret[1])
  10485. EndFunc
  10486.  
  10487. Func _winapi_pathrenameextension($sfilepath, $sext)
  10488. Local $tpath = DllStructCreate("wchar[260]")
  10489. DllStructSetData($tpath, 1, $sfilepath)
  10490. Local $aret = DllCall("shlwapi.dll", "bool", "PathRenameExtensionW", "struct*", $tpath, "wstr", $sext)
  10491. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  10492. Return DllStructGetData($tpath, 1)
  10493. EndFunc
  10494.  
  10495. Func _winapi_pathsearchandqualify($sfilepath, $bexists = False)
  10496. Local $aret = DllCall("shlwapi.dll", "bool", "PathSearchAndQualifyW", "wstr", $sfilepath, "wstr", "", "int", 4096)
  10497. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  10498. If $bexists AND NOT FileExists($aret[2]) Then Return SetError(20, 0, "")
  10499. Return $aret[2]
  10500. EndFunc
  10501.  
  10502. Func _winapi_pathskiproot($sfilepath)
  10503. Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
  10504. DllStructSetData($tpath, 1, $sfilepath)
  10505. Local $aret = DllCall("shlwapi.dll", "ptr", "PathSkipRootW", "struct*", $tpath)
  10506. If @error Then Return SetError(@error, @extended, "")
  10507. If NOT $aret[0] Then Return $sfilepath
  10508. Return _winapi_getstring($aret[0])
  10509. EndFunc
  10510.  
  10511. Func _winapi_pathstrippath($sfilepath)
  10512. Local $aret = DllCall("shlwapi.dll", "none", "PathStripPathW", "wstr", $sfilepath)
  10513. If @error Then Return SetError(@error, @extended, "")
  10514. Return $aret[1]
  10515. EndFunc
  10516.  
  10517. Func _winapi_pathstriptoroot($sfilepath)
  10518. Local $aret = DllCall("shlwapi.dll", "bool", "PathStripToRootW", "wstr", $sfilepath)
  10519. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  10520. Return $aret[1]
  10521. EndFunc
  10522.  
  10523. Func _winapi_pathundecorate($sfilepath)
  10524. Local $aret = DllCall("shlwapi.dll", "none", "PathUndecorateW", "wstr", $sfilepath)
  10525. If @error Then Return SetError(@error, @extended, "")
  10526. Return $aret[1]
  10527. EndFunc
  10528.  
  10529. Func _winapi_pathunexpandenvstrings($sfilepath)
  10530. Local $aret = DllCall("shlwapi.dll", "bool", "PathUnExpandEnvStringsW", "wstr", $sfilepath, "wstr", "", "uint", 4096)
  10531. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  10532. Return $aret[2]
  10533. EndFunc
  10534.  
  10535. Func _winapi_pathunmakesystemfolder($sfilepath)
  10536. Local $aret = DllCall("shlwapi.dll", "bool", "PathUnmakeSystemFolderW", "wstr", $sfilepath)
  10537. If @error Then Return SetError(@error, @extended, False)
  10538. Return $aret[0]
  10539. EndFunc
  10540.  
  10541. Func _winapi_pathunquotespaces($sfilepath)
  10542. Local $aret = DllCall("shlwapi.dll", "none", "PathUnquoteSpacesW", "wstr", $sfilepath)
  10543. If @error Then Return SetError(@error, @extended, "")
  10544. Return $aret[1]
  10545. EndFunc
  10546.  
  10547. Func _winapi_pathyetanothermakeuniquename($sfilepath)
  10548. Local $aret = DllCall("shell32.dll", "int", "PathYetAnotherMakeUniqueName", "wstr", "", "wstr", $sfilepath, "ptr", 0, "ptr", 0)
  10549. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  10550. Return $aret[1]
  10551. EndFunc
  10552.  
  10553. Func _winapi_shellgetimagelist($bsmall = False)
  10554. Local $plarge, $psmall, $tptr = DllStructCreate("ptr")
  10555. If $bsmall Then
  10556. $plarge = 0
  10557. $psmall = DllStructGetPtr($tptr)
  10558. Else
  10559. $plarge = DllStructGetPtr($tptr)
  10560. $psmall = 0
  10561. EndIf
  10562. Local $aret = DllCall("shell32.dll", "int", "Shell_GetImageLists", "ptr", $plarge, "ptr", $psmall)
  10563. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  10564. Return DllStructGetData($tptr, 1)
  10565. EndFunc
  10566.  
  10567. Func _winapi_urlapplyscheme($surl, $iflags = 1)
  10568. Local $aret = DllCall("shlwapi.dll", "long", "UrlApplySchemeW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $iflags)
  10569. If @error Then Return SetError(@error, @extended, "")
  10570. If $aret[0] Then Return SetError(10, $aret[0], "")
  10571. Return $aret[2]
  10572. EndFunc
  10573.  
  10574. Func _winapi_urlcanonicalize($surl, $iflags)
  10575. Local $aret = DllCall("shlwapi.dll", "long", "UrlCanonicalizeW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $iflags)
  10576. If @error Then Return SetError(@error, @extended, "")
  10577. If $aret[0] Then Return SetError(10, $aret[0], "")
  10578. Return $aret[2]
  10579. EndFunc
  10580.  
  10581. Func _winapi_urlcombine($surl, $spart, $iflags = 0)
  10582. Local $aret = DllCall("shlwapi.dll", "long", "UrlCombineW", "wstr", $surl, "wstr", $spart, "wstr", "", "dword*", 4096, "dword", $iflags)
  10583. If @error Then Return SetError(@error, @extended, "")
  10584. If $aret[0] Then Return SetError(10, $aret[0], "")
  10585. Return $aret[3]
  10586. EndFunc
  10587.  
  10588. Func _winapi_urlcompare($surl1, $surl2, $bignoreslash = False)
  10589. Local $aret = DllCall("shlwapi.dll", "int", "UrlCompareW", "wstr", $surl1, "wstr", $surl2, "bool", $bignoreslash)
  10590. If @error Then Return SetError(@error, @extended, 0)
  10591. Return $aret[0]
  10592. EndFunc
  10593.  
  10594. Func _winapi_urlcreatefrompath($sfilepath)
  10595. Local $aret = DllCall("shlwapi.dll", "long", "UrlCreateFromPathW", "wstr", $sfilepath, "wstr", "", "dword*", 4096, "dword", 0)
  10596. If @error Then Return SetError(@error, @extended, "")
  10597. If $aret[0] < 0 OR $aret[0] > 1 Then
  10598. Return SetError(10, $aret[0], "")
  10599. EndIf
  10600. Return $aret[2]
  10601. EndFunc
  10602.  
  10603. Func _winapi_urlfixup($surl)
  10604. Local $aret = DllCall("shlwapi.dll", "long", "UrlFixupW", "wstr", $surl, "wstr", "", "dword", 4096)
  10605. If @error Then Return SetError(@error, @extended, "")
  10606. If $aret[0] Then Return SetError(10, $aret[0], "")
  10607. Return $aret[2]
  10608. EndFunc
  10609.  
  10610. Func _winapi_urlgetpart($surl, $ipart)
  10611. Local $aret = DllCall("shlwapi.dll", "long", "UrlGetPartW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $ipart, "dword", 0)
  10612. If @error Then Return SetError(@error, @extended, "")
  10613. If $aret[0] Then Return SetError(10, $aret[0], "")
  10614. Return $aret[2]
  10615. EndFunc
  10616.  
  10617. Func _winapi_urlhash($surl, $ilength = 32)
  10618. If $ilength <= 0 OR $ilength > 256 Then Return SetError(256, 0, 0)
  10619. Local $tdata = DllStructCreate("byte[" & $ilength & "]")
  10620. Local $aret = DllCall("shlwapi.dll", "long", "UrlHashW", "wstr", $surl, "struct*", $tdata, "dword", $ilength)
  10621. If @error Then Return SetError(@error + 10, @extended, 0)
  10622. If $aret[0] Then Return SetError(10, $aret[0], 0)
  10623. Return DllStructGetData($tdata, 1)
  10624. EndFunc
  10625.  
  10626. Func _winapi_urlis($surl, $itype = 0)
  10627. Local $aret = DllCall("shlwapi.dll", "bool", "UrlIsW", "wstr", $surl, "uint", $itype)
  10628. If @error Then Return SetError(@error, @extended, False)
  10629. Return $aret[0]
  10630. EndFunc
  10631.  
  10632. #EndRegion Public Functions
  10633. #Region Internal Functions
  10634.  
  10635. Func __us($sstring, $ilength = 0)
  10636. If $ilength Then
  10637. $sstring = StringLeft($sstring, $ilength)
  10638. Else
  10639. $ilength = StringLen($sstring)
  10640. EndIf
  10641. Local $tus = DllStructCreate("ushort;ushort;ptr;wchar[" & ($ilength + 1) & "]")
  10642. DllStructSetData($tus, 1, 2 * StringLen($sstring))
  10643. DllStructSetData($tus, 2, 2 * $ilength)
  10644. DllStructSetData($tus, 3, DllStructGetPtr($tus, 4))
  10645. DllStructSetData($tus, 4, $sstring)
  10646. Return $tus
  10647. EndFunc
  10648.  
  10649. #EndRegion Internal Functions
  10650. Local $gui_window
  10651. Local $gui_label_x, $gui_label_y, $gui_label_z, $gui_label_r, $gui_label_hp, $gui_label_exp, $gui_label_bg_game_status
  10652. Local $gui_label_mp, $gui_prog_hp, $gui_prog_mp, $gui_prog_exp, $gui_label_level, $gui_label_current_casting
  10653. Local $gui_label_target, $gui_label_debuff, $gui_label_zoneid, $gui_label_status, $gui_label_bot, $distance
  10654. Local $gui_log, $tstring, $profile_array, $filename
  10655. Local $sdrive = "", $sdir = "", $sfilename = "", $sextension = ""
  10656. Dim $acmdline[1]
  10657. Global $sensdistance = 8
  10658. Global $walkrange = 4
  10659. Global $next = False
  10660. Global $togelx = 3
  10661. Global $wow = 1
  10662. Global $checkpremium = False
  10663. Global $localversion = "1.0.0"
  10664. Global $profileopen = True
  10665. Global $data = "[" & _nowtime(3) & "] Welcome to Ferib's Waypoint Bot!" & @CRLF & "[" & _nowtime(3) & "] Please select a profile first!"
  10666. Global $record = False, $loop = False
  10667. Global $sstatus = "Online"
  10668. Global $pstatus = "Wating for profile"
  10669. ;~ $id = ProcessExists("wow.exe")
  10670. $id = ProcessExists("WoWCircle - 32.exe")
  10671. $openmem = _memoryopen($id)
  10672. Global $baseaddr = _memorymodulegetbaseaddress($id, "wow.exe")
  10673. $gui_window = GUICreate("Ferib's Waypoint Bot", 300, 230, 100, 100, -1, $ws_ex_toolwindow)
  10674. GUICtrlSetState(-1, $gui_dropaccepted)
  10675. GUISetBkColor(51)
  10676. GUICtrlSetDefColor(16777215)
  10677. $gui_label_x = GUICtrlCreateLabel("Attached to: Wow.exe - " & $id, 5, 5, 200, 15)
  10678. $gui_label_y = GUICtrlCreateLabel("Premium user: " & $checkpremium, 5, 21, 200, 15)
  10679. $gui_label_z = GUICtrlCreateLabel("Server Status: " & $sstatus, 5, 37, 200, 15)
  10680. $gui_label_r = GUICtrlCreateLabel("Player Status: " & $pstatus, 5, 54, 180, 15)
  10681. $gui_button_load = GUICtrlCreateButton("Load Profile", 195, 5, 100, 21)
  10682. GUICtrlSetColor(-1, 0)
  10683. $gui_button_save = GUICtrlCreateButton("Record", 195, 26, 100, 21)
  10684. GUICtrlSetColor(-1, 0)
  10685. $gui_button_start = GUICtrlCreateButton("Start", 195, 47, 100, 21)
  10686. GUICtrlSetColor(-1, 0)
  10687. $gui_log = GUICtrlCreateEdit($data, 5, 75, 290, 145, $es_readonly)
  10688. GUICtrlSetState(-1, $gui_dropaccepted)
  10689. GUICtrlSetBkColor(-1, 51)
  10690. GUISetState(@SW_SHOW)
  10691. WinSetOnTop($gui_window, "", 1)
  10692. WinSetTrans($gui_window, "", 200)
  10693. #Region database
  10694. Local $urlbase = "http://www.ferib.nl/database/Ferib_databaseB.txt"
  10695. Local $urlxxx1 = "http://www.ferib.nl/database/Ferib_databaseX1.txt"
  10696. Local $urlxxx2 = "http://www.ferib.nl/database/Ferib_databaseX2.txt"
  10697. Local $urlyyy1 = "http://www.ferib.nl/database/Ferib_databaseY1.txt"
  10698. Local $urlyyy2 = "http://www.ferib.nl/database/Ferib_databaseY2.txt"
  10699. Local $urlzzz1 = "http://www.ferib.nl/database/Ferib_databaseZ1.txt"
  10700. Local $urlzzz2 = "http://www.ferib.nl/database/Ferib_databaseZ2.txt"
  10701. Local $urlctm = "http://www.ferib.nl/database/Ferib_CTM.txt"
  10702. Local $urlctmv = "http://www.ferib.nl/database/Ferib_CTMV.txt"
  10703. Local $urlctmdl = "http://www.ferib.nl/database/Ferib_CTMDL.txt"
  10704. Local $urlctmnn = "http://www.ferib.nl/database/Ferib_CTMNN.txt"
  10705. $httpb = ObjCreate("winhttp.winhttprequest.5.1")
  10706. $httpb.open("GET", $urlbase)
  10707. Sleep(50)
  10708. $httpb.send()
  10709. $httpb.waitforresponse()
  10710. $sourceb = $httpb.responsetext()
  10711. Global $base8 = $sourceb
  10712. $httpctm = ObjCreate("winhttp.winhttprequest.5.1")
  10713. $httpctm.open("GET", $urlctm)
  10714. Sleep(50)
  10715. $httpctm.send()
  10716. $httpctm.waitforresponse()
  10717. $sourcectm = $httpctm.responsetext()
  10718. Global $ctm = $sourcectm
  10719. $httpctmdl = ObjCreate("winhttp.winhttprequest.5.1")
  10720. $httpctmdl.open("GET", $urlctmdl)
  10721. Sleep(50)
  10722. $httpctmdl.send()
  10723. $httpctmdl.waitforresponse()
  10724. $sourcectmdl = $httpctmdl.responsetext()
  10725. Global $download = $sourcectmdl
  10726. $httpctmnn = ObjCreate("winhttp.winhttprequest.5.1")
  10727. $httpctmnn.open("GET", $urlctmnn)
  10728. Sleep(50)
  10729. $httpctmnn.send()
  10730. $httpctmnn.waitforresponse()
  10731. $sourcectmnn = $httpctmnn.responsetext()
  10732. Global $name = $sourcectmnn
  10733. $httpctmv = ObjCreate("winhttp.winhttprequest.5.1")
  10734. $httpctmv.open("GET", $urlctmv)
  10735. Sleep(50)
  10736. $httpctmv.send()
  10737. $httpctmv.waitforresponse()
  10738. $sourcectmv = $httpctmv.responsetext()
  10739. Global $ctmv = $sourcectmv
  10740. $httpxxx1 = ObjCreate("winhttp.winhttprequest.5.1")
  10741. $httpxxx1.open("GET", $urlxxx1)
  10742. Sleep(50)
  10743. $httpxxx1.send()
  10744. $httpxxx1.waitforresponse()
  10745. $sourcexxx1 = $httpxxx1.responsetext()
  10746. Global $xxx1 = $sourcexxx1
  10747. $httpxxx2 = ObjCreate("winhttp.winhttprequest.5.1")
  10748. $httpxxx2.open("GET", $urlxxx2)
  10749. Sleep(50)
  10750. $httpxxx2.send()
  10751. $httpxxx2.waitforresponse()
  10752. $sourcexxx2 = $httpxxx2.responsetext()
  10753. Global $xxx2 = $sourcexxx2
  10754. $httpyyy1 = ObjCreate("winhttp.winhttprequest.5.1")
  10755. $httpyyy1.open("GET", $urlyyy1)
  10756. Sleep(50)
  10757. $httpyyy1.send()
  10758. $httpyyy1.waitforresponse()
  10759. $sourceyyy1 = $httpyyy1.responsetext()
  10760. Global $yyy1 = $sourceyyy1
  10761. $httpyyy2 = ObjCreate("winhttp.winhttprequest.5.1")
  10762. $httpyyy2.open("GET", $urlyyy2)
  10763. Sleep(50)
  10764. $httpyyy2.send()
  10765. $httpyyy2.waitforresponse()
  10766. $sourceyyy2 = $httpyyy2.responsetext()
  10767. Global $yyy2 = $sourceyyy2
  10768. $httpzzz1 = ObjCreate("winhttp.winhttprequest.5.1")
  10769. $httpzzz1.open("GET", $urlzzz1)
  10770. Sleep(50)
  10771. $httpzzz1.send()
  10772. $httpzzz1.waitforresponse()
  10773. $sourcezzz1 = $httpzzz1.responsetext()
  10774. Global $zzz1 = $sourcezzz1
  10775. $httpzzz2 = ObjCreate("winhttp.winhttprequest.5.1")
  10776. $httpzzz2.open("GET", $urlzzz2)
  10777. Sleep(50)
  10778. $httpzzz2.send()
  10779. $httpzzz2.waitforresponse()
  10780. $sourcezzz2 = $httpzzz2.responsetext()
  10781. Global $zzz2 = $sourcezzz2
  10782. #EndRegion
  10783. Global $mem_clicktomove_go = "0x" & Hex($baseaddr + $ctm)
  10784. Global $mem_clicktomove_x = "0x" & Hex($baseaddr + $ctm + 40)
  10785. Global $mem_clicktomove_y = "0x" & Hex($baseaddr + $ctm + 40 + 4)
  10786. Global $mem_clicktomove_z = "0x" & Hex($baseaddr + $ctm + 40 + 4 + 4)
  10787. Global $offsetx[3] = [0, Dec($xxx1), Dec($xxx2)]
  10788. Global $offsety[3] = [0, Dec($yyy1), Dec($yyy2)]
  10789. Global $offsetz[3] = [0, Dec($zzz1), Dec($zzz2)]
  10790. Global $offsetf[3] = [0, Dec("124"), Dec("28")]
  10791. Global $staticoffsetx = $base8
  10792. Global $staticoffsety = $base8
  10793. Global $staticoffsetz = $base8
  10794. Global $staticoffsetf = $base8
  10795. Global $finaladdrx = "0x" & Hex($baseaddr + $staticoffsetx)
  10796. Global $finaladdry = "0x" & Hex($baseaddr + $staticoffsety)
  10797. Global $finaladdrz = "0x" & Hex($baseaddr + $staticoffsetz)
  10798. Global $finaladdrf = "0x" & Hex($baseaddr + $staticoffsetf)
  10799. If $localversion = $ctmv Then
  10800. Else
  10801. $data = GUICtrlRead($gui_log)
  10802. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] New version found! (" & $ctmv & ")")
  10803. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  10804. $data = GUICtrlRead($gui_log)
  10805. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Downloading New Version...")
  10806. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  10807. If FileExists(@ScriptDir & "\" & $name & ".exe") Then
  10808. FileDelete(@ScriptDir & "\" & $name & ".exe")
  10809. EndIf
  10810. $urldownloader = $download
  10811. $directory = @ScriptDir & "\" & $name & ".exe"
  10812. InetGet($urldownloader, $directory, 9)
  10813. $data = GUICtrlRead($gui_log)
  10814. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] New version download!")
  10815. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  10816. Run($directory)
  10817. Sleep(3000)
  10818. Exit
  10819. EndIf
  10820. checkpremium()
  10821.  
  10822. Func checkpremium()
  10823. Local $urlip = "http://www.ferib.nl/IP"
  10824. $httpip = ObjCreate("winhttp.winhttprequest.5.1")
  10825. $httpip.open("GET", $urlip)
  10826. $httpip.send()
  10827. $httpip.waitforresponse()
  10828. $sourceip = $httpip.responsetext()
  10829. Global $ip = $sourceip
  10830. Local $urlo = "http://www.ferib.nl/database/Ferib_Check_License.txt"
  10831. $httpo = ObjCreate("winhttp.winhttprequest.5.1")
  10832. $httpo.open("GET", $urlo)
  10833. $httpo.send()
  10834. $httpo.waitforresponse()
  10835. $sourceo = $httpo.responsetext()
  10836. Global $ipmatch = $sourceo
  10837. Local $iposition = StringInStr($ipmatch, $ip)
  10838. If $iposition > 0 Then
  10839. Global $premium = 1
  10840. Global $checkpremium = True
  10841. GUICtrlSetData($gui_label_y, "Premium user: " & $checkpremium)
  10842. Else
  10843. Global $premium = 0
  10844. Global $checkpremium = False
  10845. EndIf
  10846. If $ipmatch = 0 Then
  10847. Global $premium = 1
  10848. Global $checkpremium = True
  10849. GUICtrlSetData($gui_label_y, "Premium user: " & $checkpremium)
  10850. EndIf
  10851. If $ipmatch = "free" Then
  10852. Global $premium = 1
  10853. Global $checkpremium = True
  10854. GUICtrlSetData($gui_label_y, "Premium user: " & $checkpremium)
  10855. EndIf
  10856. EndFunc
  10857.  
  10858. $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  10859. $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  10860. $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  10861. Local $acmdline = _winapi_commandlinetoargv($cmdlineraw)
  10862. If UBound($acmdline) > 1 Then
  10863. $filename = $acmdline[1]
  10864. If FileExists($filename) Then
  10865. Global $profileopen = False
  10866. load()
  10867. Global $profileopen = True
  10868. EndIf
  10869. EndIf
  10870. While 1
  10871. $nmsg = GUIGetMsg()
  10872. Switch $nmsg
  10873. Case $gui_event_close
  10874. Exit
  10875. Case $gui_button_load
  10876. load()
  10877. Case $gui_button_save
  10878. If FileExists($filename) Then
  10879. If $record = False Then
  10880. $record = True
  10881. Else
  10882. $record = False
  10883. EndIf
  10884. GUICtrlSetData($gui_button_start, "Distance: " & $sensdistance)
  10885. GUICtrlSetData($gui_button_save, "Stop Record")
  10886. record($record)
  10887. EndIf
  10888. Case $gui_button_start
  10889. If FileExists($filename) Then
  10890. GUICtrlSetData($gui_button_start, "Stop")
  10891. If $loop = False Then
  10892. GUICtrlSetData($gui_button_save, "Loop: Off")
  10893. Else
  10894. GUICtrlSetData($gui_button_save, "Loop: On")
  10895. EndIf
  10896. If $premium = 0 Then
  10897. GUICtrlSetState($gui_button_save, $gui_disable)
  10898. EndIf
  10899. EndIf
  10900. startr()
  10901. EndSwitch
  10902. WEnd
  10903.  
  10904. Func move()
  10905. $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  10906. $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  10907. $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  10908. $filehandle = FileOpen($filename)
  10909. $wplist = FileRead($filename)
  10910. $pointliste = _stringbetween($wplist, "|>", @CRLF)
  10911. $imax = UBound($pointliste, 1) - 1
  10912. $iii = 0
  10913. If waypointnearby($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1]) < $imax Then
  10914. $iii = waypointnearby($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1])
  10915. EndIf
  10916. For $i = $iii To $imax
  10917. $point = $i
  10918. $maxpoint = $imax
  10919. If $next = True Then
  10920. $i = waypointnext($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1], $i)
  10921. EndIf
  10922. $wx = _stringbetween($wplist, "<x>", "</x>")
  10923. $wy = _stringbetween($wplist, "<y>", "</y>")
  10924. $wz = _stringbetween($wplist, "<z>", "</z>")
  10925. _waypoint_walk($wx[$i], $wy[$i], $wz[$i])
  10926. $data = GUICtrlRead($gui_log)
  10927. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Running to waypoint...")
  10928. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  10929. For $x = 0 To 1000000
  10930. $nmsg = GUIGetMsg()
  10931. Switch $nmsg
  10932. Case $gui_event_close
  10933. Exit
  10934. Case $gui_button_save
  10935. If $loop = False Then
  10936. $loop = True
  10937. GUICtrlSetData($gui_button_save, "Loop: On")
  10938. Else
  10939. $loop = False
  10940. GUICtrlSetData($gui_button_save, "Loop: Off")
  10941. EndIf
  10942. Case $gui_button_start
  10943. GUICtrlSetData($gui_button_start, "Start")
  10944. GUICtrlSetData($gui_button_save, "Record")
  10945. GUICtrlSetState($gui_button_save, $gui_enable)
  10946. Global $loop = False
  10947. $x = 1000000
  10948. $i = $imax
  10949. $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  10950. $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  10951. $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  10952. _waypoint_walk($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1])
  10953. ExitLoop
  10954. EndSwitch
  10955. $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  10956. $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  10957. $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  10958. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Running...")
  10959. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  10960. $pstatus = "Running... (" & $point & "/" & $maxpoint & ")"
  10961. GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
  10962. Sleep(100)
  10963. If getdistance($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1], $wx[$i], $wy[$i], $wz[$i]) < $walkrange Then
  10964. Sleep(50)
  10965. $x = 1000000
  10966. Else
  10967. $unstuck = _memoryread($mem_clicktomove_go, $openmem, "dword")
  10968. If $unstuck = 13 AND getdistance($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1], $wx[$i], $wy[$i], $wz[$i]) > $walkrange + 1 Then
  10969. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Unstucking player...")
  10970. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  10971. $pstatus = "Unstucking player.. (" & $point & "/" & $maxpoint & ")"
  10972. GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
  10973. $data = GUICtrlRead($gui_log)
  10974. $nmsg = GUIGetMsg()
  10975. Switch $nmsg
  10976. Case $gui_button_start
  10977. GUICtrlSetData($gui_button_start, "Start")
  10978. GUICtrlSetData($gui_button_save, "Record")
  10979. GUICtrlSetState($gui_button_save, $gui_enable)
  10980. Global $loop = False
  10981. $x = 1000000
  10982. $i = $imax
  10983. $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  10984. $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  10985. $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  10986. _waypoint_walk($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1])
  10987. ExitLoop
  10988. EndSwitch
  10989. backw()
  10990. $xxx = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  10991. $yyy = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  10992. $zzz = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  10993. Sleep(900)
  10994. $xx = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  10995. $yy = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  10996. $zz = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  10997. If getdistance($xx, $yy, $zz, $xxx, $yyy, $zzz) < 2 Then
  10998. right()
  10999. Sleep(500)
  11000. $unstuckleft = getdistance($xx, $yy, $zz, $xxx, $yyy, $zzz)
  11001. backw()
  11002. Sleep(500)
  11003. forw()
  11004. Sleep(500)
  11005. $unstuckright = getdistance($xx, $yy, $zz, $xxx, $yyy, $zzz)
  11006. $nmsg = GUIGetMsg()
  11007. Switch $nmsg
  11008. Case $gui_button_start
  11009. GUICtrlSetData($gui_button_start, "Start")
  11010. GUICtrlSetData($gui_button_save, "Record")
  11011. Global $loop = False
  11012. $x = 1000000
  11013. $i = $imax
  11014. $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11015. $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11016. $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  11017. _waypoint_walk($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1])
  11018. ExitLoop
  11019. EndSwitch
  11020. If $unstuckright > $unstuckleft Then
  11021. $togelx = 6
  11022. forw()
  11023. Sleep(800)
  11024. left()
  11025. Sleep(600)
  11026. $togelx = 3
  11027. ToolTip("", 0, 0)
  11028. Else
  11029. $togelx = 8
  11030. backw()
  11031. Sleep(1300)
  11032. right()
  11033. Sleep(600)
  11034. $togelx = 3
  11035. ToolTip("", 0, 0)
  11036. EndIf
  11037. EndIf
  11038. _waypoint_walk($wx[$i], $wy[$i], $wz[$i])
  11039. EndIf
  11040. EndIf
  11041. Next
  11042. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Running to next waypoint...")
  11043. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  11044. $pstatus = "Looking for next waypoint... (" & $point & "/" & $maxpoint & ")"
  11045. GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
  11046. Sleep(50)
  11047. Next
  11048. If $loop = True Then move()
  11049. FileClose($filehandle)
  11050. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Waypoints finished!")
  11051. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  11052. GUICtrlSetData($gui_button_start, "Start")
  11053. GUICtrlSetData($gui_button_save, "Record")
  11054. $pstatus = "Finished! (" & $point & "/" & $maxpoint & ")"
  11055. GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
  11056. EndFunc
  11057.  
  11058. Func record($record)
  11059. If FileExists($filename) Then
  11060. If $record = True Then
  11061. $data = GUICtrlRead($gui_log)
  11062. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Recording Started!")
  11063. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  11064. _addwaypoint()
  11065. $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11066. $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11067. $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  11068. $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11069. $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11070. $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  11071. While 1
  11072. If $record = True Then
  11073. $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11074. $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11075. $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  11076. If getdistance($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1], $x[1], $y[1], $z[1]) > $sensdistance Then
  11077. _addwaypoint()
  11078. $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11079. $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11080. $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  11081. Else
  11082. $nmsg = GUIGetMsg()
  11083. Switch $nmsg
  11084. Case $gui_event_close
  11085. Exit
  11086. Case $gui_button_save
  11087. $record = False
  11088. GUICtrlSetData($gui_button_save, "Record")
  11089. GUICtrlSetData($gui_button_start, "Start")
  11090. record($record)
  11091. Case $gui_button_start
  11092. If $sensdistance = 8 Then
  11093. $sensdistance = 15
  11094. GUICtrlSetData($gui_button_start, "Distance : " & $sensdistance)
  11095. ElseIf $sensdistance = 15 Then
  11096. $sensdistance = 27
  11097. GUICtrlSetData($gui_button_start, "Distance : " & $sensdistance)
  11098. ElseIf $sensdistance = 27 Then
  11099. $sensdistance = 4
  11100. GUICtrlSetData($gui_button_start, "Distance : " & $sensdistance)
  11101. ElseIf $sensdistance = 4 Then
  11102. $sensdistance = 6
  11103. GUICtrlSetData($gui_button_start, "Distance : " & $sensdistance)
  11104. ElseIf $sensdistance = 6 Then
  11105. $sensdistance = 8
  11106. GUICtrlSetData($gui_button_start, "Distance : " & $sensdistance)
  11107. EndIf
  11108. EndSwitch
  11109. EndIf
  11110. Else
  11111. ExitLoop
  11112. EndIf
  11113. WEnd
  11114. Else
  11115. $data = GUICtrlRead($gui_log)
  11116. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Recording ended!")
  11117. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  11118. EndIf
  11119. EndIf
  11120. EndFunc
  11121.  
  11122. Func _waypoint_walk($wx, $wy, $wz)
  11123. _memorywrite($mem_clicktomove_go, $openmem, 5, "dword")
  11124. _memorywrite($mem_clicktomove_x, $openmem, $wx, "float")
  11125. _memorywrite($mem_clicktomove_y, $openmem, $wy, "float")
  11126. _memorywrite($mem_clicktomove_z, $openmem, $wz, "float")
  11127. _memorywrite($mem_clicktomove_x, $openmem, $wx, "float")
  11128. EndFunc
  11129.  
  11130. Func load()
  11131. If NOT FileExists($filename) OR $profileopen = True Then
  11132. Global $filename = FileOpenDialog("Select a Waypoint Profile", @ScriptDir & "\", "WaypointProfile (*.ferib;*.txt)", $fd_filemustexist + $fd_multiselect)
  11133. EndIf
  11134. If FileExists($filename) Then
  11135. $data = GUICtrlRead($gui_log)
  11136. $filenameo = _pathsplit($filename, $sdrive, $sdir, $sfilename, $sextension)
  11137. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Profile: " & $filenameo[3] & " loaded!")
  11138. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  11139. $pstatus = "Reading profile"
  11140. GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
  11141. $filehandle = FileOpen($filename)
  11142. $filedata = FileRead($filehandle)
  11143. $checkloop = _stringbetween($filedata, "<loop>", "</loop>")
  11144. If UBound($checkloop) Then
  11145. If $checkloop[0] = "true" Then
  11146. Global $loop = True
  11147. EndIf
  11148. EndIf
  11149. $checsensd = _stringbetween($filedata, "<distance>", "</distance>")
  11150. If UBound($checsensd) Then
  11151. $sensdistance = $checsensd[0]
  11152. EndIf
  11153. $checwalk = _stringbetween($filedata, "<walk>", "</walk>")
  11154. If UBound($checwalk) Then
  11155. $walkrange = $checwalk[0]
  11156. EndIf
  11157. $checnext = _stringbetween($filedata, "<next>", "</next>")
  11158. If UBound($checnext) Then
  11159. If $checnext[0] = "true" Then
  11160. $next = True
  11161. EndIf
  11162. EndIf
  11163. FileClose($filehandle)
  11164. Else
  11165. $data = GUICtrlRead($gui_log)
  11166. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Profile does not exist!")
  11167. $pstatus = "Unknown file"
  11168. GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
  11169. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  11170. EndIf
  11171. EndFunc
  11172.  
  11173. Func startr()
  11174. If FileExists($filename) Then
  11175. $data = GUICtrlRead($gui_log)
  11176. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] waypoint profile started!")
  11177. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  11178. move()
  11179. Else
  11180. $data = GUICtrlRead($gui_log)
  11181. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Load Profile first")
  11182. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  11183. EndIf
  11184. EndFunc
  11185.  
  11186. Func stopr()
  11187. EndFunc
  11188.  
  11189. Func _addwaypoint()
  11190. If FileExists($filename) Then
  11191. $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11192. $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11193. $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  11194. $data = GUICtrlRead($gui_log)
  11195. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Waypoint added!")
  11196. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  11197. $filehandle = FileOpen($filename, 1)
  11198. $filedata = FileRead($filehandle)
  11199. FileWrite($filehandle, $filedata & "|><x>" & $mem_player_current_x[1] & "</x><y>" & $mem_player_current_y[1] & "</y><z>" & $mem_player_current_z[1] & "</z>" & @CRLF)
  11200. FileClose($filehandle)
  11201. Else
  11202. $data = GUICtrlRead($gui_log)
  11203. GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Load Profile first")
  11204. _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
  11205. EndIf
  11206. EndFunc
  11207.  
  11208. Func _die()
  11209. Exit
  11210. EndFunc
  11211.  
  11212. Func getdistance($x1, $y1, $z1, $x2, $y2, $z2)
  11213. $xf = ($x2 - $x1) * ($x2 - $x1)
  11214. $yf = ($y2 - $y1) * ($y2 - $y1)
  11215. $zf = ($z2 - $z1) * ($z2 - $z1)
  11216. $ff = Sqrt($xf + $yf + $zf)
  11217. Return $ff
  11218. EndFunc
  11219.  
  11220. Func waypointnearby($x, $y, $z)
  11221. Local $distance[0]
  11222. $filehandle = FileOpen($filename)
  11223. $wplist = FileRead($filename)
  11224. $pointliste = _stringbetween($wplist, "|>", @CRLF)
  11225. $jmax = UBound($pointliste, 1) - 1
  11226. For $j = 0 To $jmax
  11227. $wx = _stringbetween($wplist, "<x>", "</x>")
  11228. $wy = _stringbetween($wplist, "<y>", "</y>")
  11229. $wz = _stringbetween($wplist, "<z>", "</z>")
  11230. _arrayadd($distance, getdistance($x, $y, $z, $wx[$j], $wy[$j], $wz[$j]))
  11231. Next
  11232. _arraymin($distance)
  11233. $mindistance = _arraymin($distance)
  11234. $ai = _arraysearch($distance, $mindistance)
  11235. FileClose($filehandle)
  11236. Return $ai
  11237. EndFunc
  11238.  
  11239. Func waypointnext($x, $y, $z, $lastpoint)
  11240. Local $distance[0]
  11241. Local $distance2[0]
  11242. $filehandle = FileOpen($filename)
  11243. $wplist = FileRead($filename)
  11244. $pointliste = _stringbetween($wplist, "|>", @CRLF)
  11245. $jmax = UBound($pointliste, 1) - 1
  11246. For $j = 0 To $jmax
  11247. $wx = _stringbetween($wplist, "<x>", "</x>")
  11248. $wy = _stringbetween($wplist, "<y>", "</y>")
  11249. $wz = _stringbetween($wplist, "<z>", "</z>")
  11250. _arrayadd($distance, getdistance($x, $y, $z, $wx[$j], $wy[$j], $wz[$j]))
  11251. _arrayadd($distance2, getdistance($x, $y, $z, $wx[$j], $wy[$j], $wz[$j]))
  11252. Next
  11253. FileClose($filehandle)
  11254. $ai = _arrayminindex($distance)
  11255. $distance[$ai] = 999999999
  11256. $distance[$lastpoint] = 999999999
  11257. $ai = _arrayminindex($distance)
  11258. ToolTip($ai, 0, 0)
  11259. Return $ai
  11260. EndFunc
  11261.  
  11262. Func forw()
  11263. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11264. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11265. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11266. Global $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  11267. Sleep(5)
  11268. If $f[1] >= "0" AND $f[1] <= "1.575" Then
  11269. Global $f11t = "1.575"-$f[1]
  11270. Global $ff11t = "1.575"-$f11t
  11271. Global $ff11 = $ff11t * $togelx
  11272. Global $f11 = $f11t * $togelx
  11273. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11274. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11275. Global $f11x = $x[1] + $f11
  11276. Global $ff11y = $y[1] + $ff11
  11277. _waypoint_walk($f11x, $ff11y, $z[1])
  11278. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11279. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11280. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11281. ElseIf $f[1] >= "1.575" AND $f[1] <= "3.15" Then
  11282. Global $f2t = "3.15"-$f[1]
  11283. Global $ff2t = "1.575"-$f2t
  11284. Global $ff2 = $ff2t * $togelx
  11285. Global $f2 = $f2t * $togelx
  11286. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11287. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11288. Global $f2x = $x[1] - $ff2
  11289. Global $ff2y = $y[1] + $f2
  11290. _waypoint_walk($f2x, $ff2y, $z[1])
  11291. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11292. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11293. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11294. ElseIf $f[1] >= "3.15" AND $f[1] <= "4.725" Then
  11295. Global $f3t = "4.725"-$f[1]
  11296. Global $ff3t = "1.575"-$f3t
  11297. Global $ff3 = $ff3t * $togelx
  11298. Global $f3 = $f3t * $togelx
  11299. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11300. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11301. Global $f3x = $x[1] - $f3
  11302. Global $ff3y = $y[1] - $ff3
  11303. _waypoint_walk($f3x, $ff3y, $z[1])
  11304. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11305. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11306. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11307. ElseIf $f[1] >= "4.725" AND $f[1] <= "6.3" Then
  11308. Global $f4t = "6.3"-$f[1]
  11309. Global $ff4t = "1.575"-$f4t
  11310. Global $ff4 = $ff4t * $togelx
  11311. Global $f4 = $f4t * $togelx
  11312. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11313. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11314. Global $f4x = $x[1] + $ff4
  11315. Global $ff4y = $y[1] - $f4
  11316. _waypoint_walk($f4x, $ff4y, $z[1])
  11317. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11318. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11319. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11320. EndIf
  11321. EndFunc
  11322.  
  11323. Func backw()
  11324. If $wow = 1 Then
  11325. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11326. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11327. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11328. Global $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  11329. Sleep(5)
  11330. If $f[1] >= "0" AND $f[1] <= "1.575" Then
  11331. Global $f11t = "1.575"-$f[1]
  11332. Global $ff11t = "1.575"-$f11t
  11333. Global $ff11 = $ff11t * $togelx
  11334. Global $f11 = $f11t * $togelx
  11335. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11336. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11337. Global $f11x = $x[1] - $f11
  11338. Global $ff11y = $y[1] - $ff11
  11339. _waypoint_walk($f11x, $ff11y, $z[1])
  11340. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11341. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11342. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11343. ElseIf $f[1] >= "1.575" AND $f[1] <= "3.15" Then
  11344. Global $f2t = "3.15"-$f[1]
  11345. Global $ff2t = "1.575"-$f2t
  11346. Global $ff2 = $ff2t * $togelx
  11347. Global $f2 = $f2t * $togelx
  11348. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11349. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11350. Global $f2x = $x[1] + $ff2
  11351. Global $ff2y = $y[1] - $f2
  11352. _waypoint_walk($f2x, $ff2y, $z[1])
  11353. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11354. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11355. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11356. ElseIf $f[1] >= "3.15" AND $f[1] <= "4.725" Then
  11357. Global $f3t = "4.725"-$f[1]
  11358. Global $ff3t = "1.575"-$f3t
  11359. Global $ff3 = $ff3t * $togelx
  11360. Global $f3 = $f3t * $togelx
  11361. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11362. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11363. Global $f3x = $x[1] + $f3
  11364. Global $ff3y = $y[1] + $ff3
  11365. _waypoint_walk($f3x, $ff3y, $z[1])
  11366. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11367. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11368. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11369. ElseIf $f[1] >= "4.725" AND $f[1] <= "6.3" Then
  11370. Global $f4t = "6.3"-$f[1]
  11371. Global $ff4t = "1.575"-$f4t
  11372. Global $ff4 = $ff4t * $togelx
  11373. Global $f4 = $f4t * $togelx
  11374. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11375. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11376. Global $f4x = $x[1] - $ff4
  11377. Global $ff4y = $y[1] + $f4
  11378. _waypoint_walk($f4x, $ff4y, $z[1])
  11379. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11380. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11381. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11382. EndIf
  11383. EndIf
  11384. EndFunc
  11385.  
  11386. Func left()
  11387. If $wow = 1 Then
  11388. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11389. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11390. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11391. Global $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  11392. Sleep(5)
  11393. If $f[1] >= "0" AND $f[1] <= "1.575" Then
  11394. Global $f11t = "1.575"-$f[1]
  11395. Global $ff11t = "1.575"-$f11t
  11396. Global $ff11 = $ff11t * $togelx
  11397. Global $f11 = $f11t * $togelx
  11398. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11399. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11400. Global $f11x = $x[1] - $ff11
  11401. Global $ff11y = $y[1] + $f11
  11402. _waypoint_walk($f11x, $ff11y, $z[1])
  11403. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11404. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11405. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11406. ElseIf $f[1] >= "1.575" AND $f[1] <= "3.15" Then
  11407. Global $f2t = "3.15"-$f[1]
  11408. Global $ff2t = "1.575"-$f2t
  11409. Global $ff2 = $ff2t * $togelx
  11410. Global $f2 = $f2t * $togelx
  11411. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11412. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11413. Global $f2x = $x[1] - $f2
  11414. Global $ff2y = $y[1] - $ff2
  11415. _waypoint_walk($f2x, $ff2y, $z[1])
  11416. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11417. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11418. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11419. ElseIf $f[1] >= "3.15" AND $f[1] <= "4.725" Then
  11420. Global $f3t = "4.725"-$f[1]
  11421. Global $ff3t = "1.575"-$f3t
  11422. Global $ff3 = $ff3t * $togelx
  11423. Global $f3 = $f3t * $togelx
  11424. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11425. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11426. Global $f3x = $x[1] + $ff3
  11427. Global $ff3y = $y[1] - $f3
  11428. _waypoint_walk($f3x, $ff3y, $z[1])
  11429. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11430. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11431. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11432. ElseIf $f[1] >= "4.725" AND $f[1] <= "6.3" Then
  11433. Global $f4t = "6.3"-$f[1]
  11434. Global $ff4t = "1.575"-$f4t
  11435. Global $ff4 = $ff4t * $togelx
  11436. Global $f4 = $f4t * $togelx
  11437. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11438. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11439. Global $f4x = $x[1] + $f4
  11440. Global $ff4y = $y[1] + $ff4
  11441. _waypoint_walk($f4x, $ff4y, $z[1])
  11442. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11443. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11444. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11445. EndIf
  11446. EndIf
  11447. EndFunc
  11448.  
  11449. Func right()
  11450. If $wow = 1 Then
  11451. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11452. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11453. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11454. Global $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
  11455. Sleep(5)
  11456. If $f[1] >= "0" AND $f[1] <= "1.575" Then
  11457. Global $f11t = "1.575"-$f[1]
  11458. Global $ff11t = "1.575"-$f11t
  11459. Global $ff11 = $ff11t * $togelx
  11460. Global $f11 = $f11t * $togelx
  11461. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11462. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11463. Global $f11x = $x[1] + $ff11
  11464. Global $ff11y = $y[1] - $f11
  11465. _waypoint_walk($f11x, $ff11y, $z[1])
  11466. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11467. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11468. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11469. ElseIf $f[1] >= "1.575" AND $f[1] <= "3.15" Then
  11470. Global $f2t = "3.15"-$f[1]
  11471. Global $ff2t = "1.575"-$f2t
  11472. Global $ff2 = $ff2t * $togelx
  11473. Global $f2 = $f2t * $togelx
  11474. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11475. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11476. Global $f2x = $x[1] + $f2
  11477. Global $ff2y = $y[1] + $ff2
  11478. _waypoint_walk($f2x, $ff2y, $z[1])
  11479. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11480. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11481. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11482. ElseIf $f[1] >= "3.15" AND $f[1] <= "4.725" Then
  11483. Global $f3t = "4.725"-$f[1]
  11484. Global $ff3t = "1.575"-$f3t
  11485. Global $ff3 = $ff3t * $togelx
  11486. Global $f3 = $f3t * $togelx
  11487. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11488. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11489. Global $f3x = $x[1] - $ff3
  11490. Global $ff3y = $y[1] + $f3
  11491. _waypoint_walk($f3x, $ff3y, $z[1])
  11492. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11493. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11494. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11495. ElseIf $f[1] >= "4.725" AND $f[1] <= "6.3" Then
  11496. Global $f4t = "6.3"-$f[1]
  11497. Global $ff4t = "1.575"-$f4t
  11498. Global $ff4 = $ff4t * $togelx
  11499. Global $f4 = $f4t * $togelx
  11500. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11501. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11502. Global $f4x = $x[1] - $f4
  11503. Global $ff4y = $y[1] - $ff4
  11504. _waypoint_walk($f4x, $ff4y, $z[1])
  11505. Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
  11506. Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
  11507. Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
  11508. EndIf
  11509. EndIf
  11510. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement