Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Region
- #AutoIt3Wrapper_Icon=..\..\..\pumpkin icons\Iconka-Wicked-Wall-Pumpkin-Potter.ico
- #EndRegion
- Global Const $gui_event_single = 0
- Global Const $gui_event_array = 1
- Global Const $gui_event_none = 0
- Global Const $gui_event_close = -3
- Global Const $gui_event_minimize = -4
- Global Const $gui_event_restore = -5
- Global Const $gui_event_maximize = -6
- Global Const $gui_event_primarydown = -7
- Global Const $gui_event_primaryup = -8
- Global Const $gui_event_secondarydown = -9
- Global Const $gui_event_secondaryup = -10
- Global Const $gui_event_mousemove = -11
- Global Const $gui_event_resized = -12
- Global Const $gui_event_dropped = -13
- Global Const $gui_rundefmsg = "GUI_RUNDEFMSG"
- Global Const $gui_avistop = 0
- Global Const $gui_avistart = 1
- Global Const $gui_aviclose = 2
- Global Const $gui_checked = 1
- Global Const $gui_indeterminate = 2
- Global Const $gui_unchecked = 4
- Global Const $gui_dropaccepted = 8
- Global Const $gui_nodropaccepted = 4096
- Global Const $gui_acceptfiles = $gui_dropaccepted
- Global Const $gui_show = 16
- Global Const $gui_hide = 32
- Global Const $gui_enable = 64
- Global Const $gui_disable = 128
- Global Const $gui_focus = 256
- Global Const $gui_nofocus = 8192
- Global Const $gui_defbutton = 512
- Global Const $gui_expand = 1024
- Global Const $gui_ontop = 2048
- Global Const $gui_fontnormal = 0
- Global Const $gui_fontitalic = 2
- Global Const $gui_fontunder = 4
- Global Const $gui_fontstrike = 8
- Global Const $gui_dockauto = 1
- Global Const $gui_dockleft = 2
- Global Const $gui_dockright = 4
- Global Const $gui_dockhcenter = 8
- Global Const $gui_docktop = 32
- Global Const $gui_dockbottom = 64
- Global Const $gui_dockvcenter = 128
- Global Const $gui_dockwidth = 256
- Global Const $gui_dockheight = 512
- Global Const $gui_docksize = 768
- Global Const $gui_dockmenubar = 544
- Global Const $gui_dockstatebar = 576
- Global Const $gui_dockall = 802
- Global Const $gui_dockborders = 102
- Global Const $gui_gr_close = 1
- Global Const $gui_gr_line = 2
- Global Const $gui_gr_bezier = 4
- Global Const $gui_gr_move = 6
- Global Const $gui_gr_color = 8
- Global Const $gui_gr_rect = 10
- Global Const $gui_gr_ellipse = 12
- Global Const $gui_gr_pie = 14
- Global Const $gui_gr_dot = 16
- Global Const $gui_gr_pixel = 18
- Global Const $gui_gr_hint = 20
- Global Const $gui_gr_refresh = 22
- Global Const $gui_gr_pensize = 24
- Global Const $gui_gr_nobkcolor = -2
- Global Const $gui_bkcolor_default = -1
- Global Const $gui_bkcolor_transparent = -2
- Global Const $gui_bkcolor_lv_alternate = -33554432
- Global Const $gui_read_default = 0
- Global Const $gui_read_extended = 1
- Global Const $gui_cursor_nooverride = 0
- Global Const $gui_cursor_override = 1
- Global Const $gui_ws_ex_parentdrag = 1048576
- Global Const $wc_animate = "SysAnimate32"
- Global Const $wc_button = "Button"
- Global Const $wc_combobox = "ComboBox"
- Global Const $wc_comboboxex = "ComboBoxEx32"
- Global Const $wc_datetimepick = "SysDateTimePick32"
- Global Const $wc_edit = "Edit"
- Global Const $wc_header = "SysHeader32"
- Global Const $wc_hotkey = "msctls_hotkey32"
- Global Const $wc_ipaddress = "SysIPAddress32"
- Global Const $wc_link = "SysLink"
- Global Const $wc_listbox = "ListBox"
- Global Const $wc_listview = "SysListView32"
- Global Const $wc_monthcal = "SysMonthCal32"
- Global Const $wc_nativefontctl = "NativeFontCtl"
- Global Const $wc_pagescroller = "SysPager"
- Global Const $wc_progress = "msctls_progress32"
- Global Const $wc_rebar = "ReBarWindow32"
- Global Const $wc_scrollbar = "ScrollBar"
- Global Const $wc_static = "Static"
- Global Const $wc_statusbar = "msctls_statusbar32"
- Global Const $wc_tabcontrol = "SysTabControl32"
- Global Const $wc_toolbar = "ToolbarWindow32"
- Global Const $wc_tooltips = "tooltips_class32"
- Global Const $wc_trackbar = "msctls_trackbar32"
- Global Const $wc_treeview = "SysTreeView32"
- Global Const $wc_updown = "msctls_updown32"
- Global Const $ws_overlapped = 0
- Global Const $ws_tiled = $ws_overlapped
- Global Const $ws_maximizebox = 65536
- Global Const $ws_minimizebox = 131072
- Global Const $ws_tabstop = 65536
- Global Const $ws_group = 131072
- Global Const $ws_sizebox = 262144
- Global Const $ws_thickframe = $ws_sizebox
- Global Const $ws_sysmenu = 524288
- Global Const $ws_hscroll = 1048576
- Global Const $ws_vscroll = 2097152
- Global Const $ws_dlgframe = 4194304
- Global Const $ws_border = 8388608
- Global Const $ws_caption = 12582912
- Global Const $ws_overlappedwindow = BitOR($ws_caption, $ws_maximizebox, $ws_minimizebox, $ws_overlapped, $ws_sysmenu, $ws_thickframe)
- Global Const $ws_tiledwindow = $ws_overlappedwindow
- Global Const $ws_maximize = 16777216
- Global Const $ws_clipchildren = 33554432
- Global Const $ws_clipsiblings = 67108864
- Global Const $ws_disabled = 134217728
- Global Const $ws_visible = 268435456
- Global Const $ws_minimize = 536870912
- Global Const $ws_iconic = $ws_minimize
- Global Const $ws_child = 1073741824
- Global Const $ws_childwindow = $ws_child
- Global Const $ws_popup = -2147483648
- Global Const $ws_popupwindow = -2138570752
- Global Const $ds_3dlook = 4
- Global Const $ds_absalign = 1
- Global Const $ds_center = 2048
- Global Const $ds_centermouse = 4096
- Global Const $ds_contexthelp = 8192
- Global Const $ds_control = 1024
- Global Const $ds_fixedsys = 8
- Global Const $ds_localedit = 32
- Global Const $ds_modalframe = 128
- Global Const $ds_nofailcreate = 16
- Global Const $ds_noidlemsg = 256
- Global Const $ds_setfont = 64
- Global Const $ds_setforeground = 512
- Global Const $ds_shellfont = BitOR($ds_fixedsys, $ds_setfont)
- Global Const $ds_sysmodal = 2
- Global Const $ws_ex_acceptfiles = 16
- Global Const $ws_ex_appwindow = 262144
- Global Const $ws_ex_composited = 33554432
- Global Const $ws_ex_controlparent = 65536
- Global Const $ws_ex_clientedge = 512
- Global Const $ws_ex_contexthelp = 1024
- Global Const $ws_ex_dlgmodalframe = 1
- Global Const $ws_ex_layered = 524288
- Global Const $ws_ex_layoutrtl = 4194304
- Global Const $ws_ex_left = 0
- Global Const $ws_ex_leftscrollbar = 16384
- Global Const $ws_ex_ltrreading = 0
- Global Const $ws_ex_mdichild = 64
- Global Const $ws_ex_noactivate = 134217728
- Global Const $ws_ex_noinheritlayout = 1048576
- Global Const $ws_ex_noparentnotify = 4
- Global Const $ws_ex_right = 4096
- Global Const $ws_ex_rightscrollbar = 0
- Global Const $ws_ex_rtlreading = 8192
- Global Const $ws_ex_staticedge = 131072
- Global Const $ws_ex_toolwindow = 128
- Global Const $ws_ex_topmost = 8
- Global Const $ws_ex_transparent = 32
- Global Const $ws_ex_windowedge = 256
- Global Const $ws_ex_overlappedwindow = BitOR($ws_ex_clientedge, $ws_ex_windowedge)
- Global Const $ws_ex_palettewindow = BitOR($ws_ex_toolwindow, $ws_ex_topmost, $ws_ex_windowedge)
- Global Const $wm_null = 0
- Global Const $wm_create = 1
- Global Const $wm_destroy = 2
- Global Const $wm_move = 3
- Global Const $wm_sizewait = 4
- Global Const $wm_size = 5
- Global Const $wm_activate = 6
- Global Const $wm_setfocus = 7
- Global Const $wm_killfocus = 8
- Global Const $wm_setvisible = 9
- Global Const $wm_enable = 10
- Global Const $wm_setredraw = 11
- Global Const $wm_settext = 12
- Global Const $wm_gettext = 13
- Global Const $wm_gettextlength = 14
- Global Const $wm_paint = 15
- Global Const $wm_close = 16
- Global Const $wm_queryendsession = 17
- Global Const $wm_quit = 18
- Global Const $wm_erasebkgnd = 20
- Global Const $wm_queryopen = 19
- Global Const $wm_syscolorchange = 21
- Global Const $wm_endsession = 22
- Global Const $wm_systemerror = 23
- Global Const $wm_showwindow = 24
- Global Const $wm_ctlcolor = 25
- Global Const $wm_settingchange = 26
- Global Const $wm_wininichange = 26
- Global Const $wm_devmodechange = 27
- Global Const $wm_activateapp = 28
- Global Const $wm_fontchange = 29
- Global Const $wm_timechange = 30
- Global Const $wm_cancelmode = 31
- Global Const $wm_setcursor = 32
- Global Const $wm_mouseactivate = 33
- Global Const $wm_childactivate = 34
- Global Const $wm_queuesync = 35
- Global Const $wm_getminmaxinfo = 36
- Global Const $wm_logoff = 37
- Global Const $wm_painticon = 38
- Global Const $wm_iconerasebkgnd = 39
- Global Const $wm_nextdlgctl = 40
- Global Const $wm_alttabactive = 41
- Global Const $wm_spoolerstatus = 42
- Global Const $wm_drawitem = 43
- Global Const $wm_measureitem = 44
- Global Const $wm_deleteitem = 45
- Global Const $wm_vkeytoitem = 46
- Global Const $wm_chartoitem = 47
- Global Const $wm_setfont = 48
- Global Const $wm_getfont = 49
- Global Const $wm_sethotkey = 50
- Global Const $wm_gethotkey = 51
- Global Const $wm_filesyschange = 52
- Global Const $wm_isactiveicon = 53
- Global Const $wm_queryparkicon = 54
- Global Const $wm_querydragicon = 55
- Global Const $wm_winhelp = 56
- Global Const $wm_compareitem = 57
- Global Const $wm_fullscreen = 58
- Global Const $wm_clientshutdown = 59
- Global Const $wm_ddemlevent = 60
- Global Const $wm_getobject = 61
- Global Const $wm_calcscroll = 63
- Global Const $wm_testing = 64
- Global Const $wm_compacting = 65
- Global Const $wm_otherwindowcreated = 66
- Global Const $wm_otherwindowdestroyed = 67
- Global Const $wm_commnotify = 68
- Global Const $wm_mediastatuschange = 69
- Global Const $wm_windowposchanging = 70
- Global Const $wm_windowposchanged = 71
- Global Const $wm_power = 72
- Global Const $wm_copyglobaldata = 73
- Global Const $wm_copydata = 74
- Global Const $wm_canceljournal = 75
- Global Const $wm_logonnotify = 76
- Global Const $wm_keyf1 = 77
- Global Const $wm_notify = 78
- Global Const $wm_access_window = 79
- Global Const $wm_inputlangchangerequest = 80
- Global Const $wm_inputlangchange = 81
- Global Const $wm_tcard = 82
- Global Const $wm_help = 83
- Global Const $wm_userchanged = 84
- Global Const $wm_notifyformat = 85
- Global Const $wm_qm_activate = 96
- Global Const $wm_hook_do_callback = 97
- Global Const $wm_syscopydata = 98
- Global Const $wm_finaldestroy = 112
- Global Const $wm_measureitem_clientdata = 113
- Global Const $wm_contextmenu = 123
- Global Const $wm_stylechanging = 124
- Global Const $wm_stylechanged = 125
- Global Const $wm_displaychange = 126
- Global Const $wm_geticon = 127
- Global Const $wm_seticon = 128
- Global Const $wm_nccreate = 129
- Global Const $wm_ncdestroy = 130
- Global Const $wm_nccalcsize = 131
- Global Const $wm_nchittest = 132
- Global Const $wm_ncpaint = 133
- Global Const $wm_ncactivate = 134
- Global Const $wm_getdlgcode = 135
- Global Const $wm_syncpaint = 136
- Global Const $wm_synctask = 137
- Global Const $wm_kludgeminrect = 139
- Global Const $wm_lpkdrawswitchwnd = 140
- Global Const $wm_uahdestroywindow = 144
- Global Const $wm_uahdrawmenu = 145
- Global Const $wm_uahdrawmenuitem = 146
- Global Const $wm_uahinitmenu = 147
- Global Const $wm_uahmeasuremenuitem = 148
- Global Const $wm_uahncpaintmenupopup = 149
- Global Const $wm_ncmousemove = 160
- Global Const $wm_nclbuttondown = 161
- Global Const $wm_nclbuttonup = 162
- Global Const $wm_nclbuttondblclk = 163
- Global Const $wm_ncrbuttondown = 164
- Global Const $wm_ncrbuttonup = 165
- Global Const $wm_ncrbuttondblclk = 166
- Global Const $wm_ncmbuttondown = 167
- Global Const $wm_ncmbuttonup = 168
- Global Const $wm_ncmbuttondblclk = 169
- Global Const $wm_ncxbuttondown = 171
- Global Const $wm_ncxbuttonup = 172
- Global Const $wm_ncxbuttondblclk = 173
- Global Const $wm_ncuahdrawcaption = 174
- Global Const $wm_ncuahdrawframe = 175
- Global Const $wm_input_device_change = 254
- Global Const $wm_input = 255
- Global Const $wm_keydown = 256
- Global Const $wm_keyfirst = 256
- Global Const $wm_keyup = 257
- Global Const $wm_char = 258
- Global Const $wm_deadchar = 259
- Global Const $wm_syskeydown = 260
- Global Const $wm_syskeyup = 261
- Global Const $wm_syschar = 262
- Global Const $wm_sysdeadchar = 263
- Global Const $wm_yomichar = 264
- Global Const $wm_keylast = 265
- Global Const $wm_unichar = 265
- Global Const $wm_convertrequest = 266
- Global Const $wm_convertresult = 267
- Global Const $wm_im_info = 268
- Global Const $wm_ime_startcomposition = 269
- Global Const $wm_ime_endcomposition = 270
- Global Const $wm_ime_composition = 271
- Global Const $wm_ime_keylast = 271
- Global Const $wm_initdialog = 272
- Global Const $wm_command = 273
- Global Const $wm_syscommand = 274
- Global Const $wm_timer = 275
- Global Const $wm_hscroll = 276
- Global Const $wm_vscroll = 277
- Global Const $wm_initmenu = 278
- Global Const $wm_initmenupopup = 279
- Global Const $wm_systimer = 280
- Global Const $wm_gesture = 281
- Global Const $wm_gesturenotify = 282
- Global Const $wm_gestureinput = 283
- Global Const $wm_gesturenotified = 284
- Global Const $wm_menuselect = 287
- Global Const $wm_menuchar = 288
- Global Const $wm_enteridle = 289
- Global Const $wm_menurbuttonup = 290
- Global Const $wm_menudrag = 291
- Global Const $wm_menugetobject = 292
- Global Const $wm_uninitmenupopup = 293
- Global Const $wm_menucommand = 294
- Global Const $wm_changeuistate = 295
- Global Const $wm_updateuistate = 296
- Global Const $wm_queryuistate = 297
- Global Const $wm_lbtrackpoint = 305
- Global Const $wm_ctlcolormsgbox = 306
- Global Const $wm_ctlcoloredit = 307
- Global Const $wm_ctlcolorlistbox = 308
- Global Const $wm_ctlcolorbtn = 309
- Global Const $wm_ctlcolordlg = 310
- Global Const $wm_ctlcolorscrollbar = 311
- Global Const $wm_ctlcolorstatic = 312
- Global Const $mn_gethmenu = 481
- Global Const $wm_parentnotify = 528
- Global Const $wm_entermenuloop = 529
- Global Const $wm_exitmenuloop = 530
- Global Const $wm_nextmenu = 531
- Global Const $wm_sizing = 532
- Global Const $wm_capturechanged = 533
- Global Const $wm_moving = 534
- Global Const $wm_powerbroadcast = 536
- Global Const $wm_devicechange = 537
- Global Const $wm_mdicreate = 544
- Global Const $wm_mdidestroy = 545
- Global Const $wm_mdiactivate = 546
- Global Const $wm_mdirestore = 547
- Global Const $wm_mdinext = 548
- Global Const $wm_mdimaximize = 549
- Global Const $wm_mditile = 550
- Global Const $wm_mdicascade = 551
- Global Const $wm_mdiiconarrange = 552
- Global Const $wm_mdigetactive = 553
- Global Const $wm_dropobject = 554
- Global Const $wm_querydropobject = 555
- Global Const $wm_begindrag = 556
- Global Const $wm_dragloop = 557
- Global Const $wm_dragselect = 558
- Global Const $wm_dragmove = 559
- Global Const $wm_mdisetmenu = 560
- Global Const $wm_entersizemove = 561
- Global Const $wm_exitsizemove = 562
- Global Const $wm_dropfiles = 563
- Global Const $wm_mdirefreshmenu = 564
- Global Const $wm_touch = 576
- Global Const $wm_ime_setcontext = 641
- Global Const $wm_ime_notify = 642
- Global Const $wm_ime_control = 643
- Global Const $wm_ime_compositionfull = 644
- Global Const $wm_ime_select = 645
- Global Const $wm_ime_char = 646
- Global Const $wm_ime_system = 647
- Global Const $wm_ime_request = 648
- Global Const $wm_ime_keydown = 656
- Global Const $wm_ime_keyup = 657
- Global Const $wm_ncmousehover = 672
- Global Const $wm_mousehover = 673
- Global Const $wm_ncmouseleave = 674
- Global Const $wm_mouseleave = 675
- Global Const $wm_wtssession_change = 689
- Global Const $wm_tablet_first = 704
- Global Const $wm_tablet_last = 735
- Global Const $wm_cut = 768
- Global Const $wm_copy = 769
- Global Const $wm_paste = 770
- Global Const $wm_clear = 771
- Global Const $wm_undo = 772
- Global Const $wm_paletteischanging = 784
- Global Const $wm_hotkey = 786
- Global Const $wm_palettechanged = 785
- Global Const $wm_sysmenu = 787
- Global Const $wm_hookmsg = 788
- Global Const $wm_exitprocess = 789
- Global Const $wm_wakethread = 790
- Global Const $wm_print = 791
- Global Const $wm_printclient = 792
- Global Const $wm_appcommand = 793
- Global Const $wm_querynewpalette = 783
- Global Const $wm_themechanged = 794
- Global Const $wm_uahinit = 795
- Global Const $wm_desktopnotify = 796
- Global Const $wm_clipboardupdate = 797
- Global Const $wm_dwmcompositionchanged = 798
- Global Const $wm_dwmncrenderingchanged = 799
- Global Const $wm_dwmcolorizationcolorchanged = 800
- Global Const $wm_dwmwindowmaximizedchange = 801
- Global Const $wm_dwmexileframe = 802
- Global Const $wm_dwmsendiconicthumbnail = 803
- Global Const $wm_magnification_started = 804
- Global Const $wm_magnification_ended = 805
- Global Const $wm_dwmsendiconiclivepreviewbitmap = 806
- Global Const $wm_dwmthumbnailsizechanged = 807
- Global Const $wm_magnification_output = 808
- Global Const $wm_measurecontrol = 816
- Global Const $wm_getactiontext = 817
- Global Const $wm_forwardkeydown = 819
- Global Const $wm_forwardkeyup = 820
- Global Const $wm_gettitlebarinfoex = 831
- Global Const $wm_notifywow = 832
- Global Const $wm_handheldfirst = 856
- Global Const $wm_handheldlast = 863
- Global Const $wm_afxfirst = 864
- Global Const $wm_afxlast = 895
- Global Const $wm_penwinfirst = 896
- Global Const $wm_penwinlast = 911
- Global Const $wm_dde_initiate = 992
- Global Const $wm_dde_terminate = 993
- Global Const $wm_dde_advise = 994
- Global Const $wm_dde_unadvise = 995
- Global Const $wm_dde_ack = 996
- Global Const $wm_dde_data = 997
- Global Const $wm_dde_request = 998
- Global Const $wm_dde_poke = 999
- Global Const $wm_dde_execute = 1000
- Global Const $wm_dbnotification = 1021
- Global Const $wm_netconnect = 1022
- Global Const $wm_hibernate = 1023
- Global Const $wm_user = 1024
- Global Const $wm_app = 32768
- Global Const $nm_first = 0
- Global Const $nm_outofmemory = $nm_first - 1
- Global Const $nm_click = $nm_first - 2
- Global Const $nm_dblclk = $nm_first - 3
- Global Const $nm_return = $nm_first - 4
- Global Const $nm_rclick = $nm_first - 5
- Global Const $nm_rdblclk = $nm_first - 6
- Global Const $nm_setfocus = $nm_first - 7
- Global Const $nm_killfocus = $nm_first - 8
- Global Const $nm_customdraw = $nm_first - 12
- Global Const $nm_hover = $nm_first - 13
- Global Const $nm_nchittest = $nm_first - 14
- Global Const $nm_keydown = $nm_first - 15
- Global Const $nm_releasedcapture = $nm_first - 16
- Global Const $nm_setcursor = $nm_first - 17
- Global Const $nm_char = $nm_first - 18
- Global Const $nm_tooltipscreated = $nm_first - 19
- Global Const $nm_ldown = $nm_first - 20
- Global Const $nm_rdown = $nm_first - 21
- Global Const $nm_themechanged = $nm_first - 22
- Global Const $wm_mousefirst = 512
- Global Const $wm_mousemove = 512
- Global Const $wm_lbuttondown = 513
- Global Const $wm_lbuttonup = 514
- Global Const $wm_lbuttondblclk = 515
- Global Const $wm_rbuttondown = 516
- Global Const $wm_rbuttonup = 517
- Global Const $wm_rbuttondblclk = 518
- Global Const $wm_mbuttondown = 519
- Global Const $wm_mbuttonup = 520
- Global Const $wm_mbuttondblclk = 521
- Global Const $wm_mousewheel = 522
- Global Const $wm_xbuttondown = 523
- Global Const $wm_xbuttonup = 524
- Global Const $wm_xbuttondblclk = 525
- Global Const $wm_mousehwheel = 526
- Global Const $ps_solid = 0
- Global Const $ps_dash = 1
- Global Const $ps_dot = 2
- Global Const $ps_dashdot = 3
- Global Const $ps_dashdotdot = 4
- Global Const $ps_null = 5
- Global Const $ps_insideframe = 6
- Global Const $ps_userstyle = 7
- Global Const $ps_alternate = 8
- Global Const $ps_endcap_round = 0
- Global Const $ps_endcap_square = 256
- Global Const $ps_endcap_flat = 512
- Global Const $ps_join_bevel = 4096
- Global Const $ps_join_miter = 8192
- Global Const $ps_join_round = 0
- Global Const $ps_geometric = 65536
- Global Const $ps_cosmetic = 0
- Global Const $lwa_alpha = 2
- Global Const $lwa_colorkey = 1
- Global Const $rgn_and = 1
- Global Const $rgn_or = 2
- Global Const $rgn_xor = 3
- Global Const $rgn_diff = 4
- Global Const $rgn_copy = 5
- Global Const $errorregion = 0
- Global Const $nullregion = 1
- Global Const $simpleregion = 2
- Global Const $complexregion = 3
- Global Const $transparent = 1
- Global Const $opaque = 2
- Global Const $ccm_first = 8192
- Global Const $ccm_getunicodeformat = ($ccm_first + 6)
- Global Const $ccm_setunicodeformat = ($ccm_first + 5)
- Global Const $ccm_setbkcolor = $ccm_first + 1
- Global Const $ccm_setcolorscheme = $ccm_first + 2
- Global Const $ccm_getcolorscheme = $ccm_first + 3
- Global Const $ccm_getdroptarget = $ccm_first + 4
- Global Const $ccm_setwindowtheme = $ccm_first + 11
- Global Const $ga_parent = 1
- Global Const $ga_root = 2
- Global Const $ga_rootowner = 3
- Global Const $sm_cxscreen = 0
- Global Const $sm_cyscreen = 1
- Global Const $sm_cxvscroll = 2
- Global Const $sm_cyhscroll = 3
- Global Const $sm_cycaption = 4
- Global Const $sm_cxborder = 5
- Global Const $sm_cyborder = 6
- Global Const $sm_cxdlgframe = 7
- Global Const $sm_cydlgframe = 8
- Global Const $sm_cyvthumb = 9
- Global Const $sm_cxhthumb = 10
- Global Const $sm_cxicon = 11
- Global Const $sm_cyicon = 12
- Global Const $sm_cxcursor = 13
- Global Const $sm_cycursor = 14
- Global Const $sm_cymenu = 15
- Global Const $sm_cxfullscreen = 16
- Global Const $sm_cyfullscreen = 17
- Global Const $sm_cykanjiwindow = 18
- Global Const $sm_mousepresent = 19
- Global Const $sm_cyvscroll = 20
- Global Const $sm_cxhscroll = 21
- Global Const $sm_debug = 22
- Global Const $sm_swapbutton = 23
- Global Const $sm_reserved1 = 24
- Global Const $sm_reserved2 = 25
- Global Const $sm_reserved3 = 26
- Global Const $sm_reserved4 = 27
- Global Const $sm_cxmin = 28
- Global Const $sm_cymin = 29
- Global Const $sm_cxsize = 30
- Global Const $sm_cysize = 31
- Global Const $sm_cxframe = 32
- Global Const $sm_cyframe = 33
- Global Const $sm_cxmintrack = 34
- Global Const $sm_cymintrack = 35
- Global Const $sm_cxdoubleclk = 36
- Global Const $sm_cydoubleclk = 37
- Global Const $sm_cxiconspacing = 38
- Global Const $sm_cyiconspacing = 39
- Global Const $sm_menudropalignment = 40
- Global Const $sm_penwindows = 41
- Global Const $sm_dbcsenabled = 42
- Global Const $sm_cmousebuttons = 43
- Global Const $sm_secure = 44
- Global Const $sm_cxedge = 45
- Global Const $sm_cyedge = 46
- Global Const $sm_cxminspacing = 47
- Global Const $sm_cyminspacing = 48
- Global Const $sm_cxsmicon = 49
- Global Const $sm_cysmicon = 50
- Global Const $sm_cysmcaption = 51
- Global Const $sm_cxsmsize = 52
- Global Const $sm_cysmsize = 53
- Global Const $sm_cxmenusize = 54
- Global Const $sm_cymenusize = 55
- Global Const $sm_arrange = 56
- Global Const $sm_cxminimized = 57
- Global Const $sm_cyminimized = 58
- Global Const $sm_cxmaxtrack = 59
- Global Const $sm_cymaxtrack = 60
- Global Const $sm_cxmaximized = 61
- Global Const $sm_cymaximized = 62
- Global Const $sm_network = 63
- Global Const $sm_cleanboot = 67
- Global Const $sm_cxdrag = 68
- Global Const $sm_cydrag = 69
- Global Const $sm_showsounds = 70
- Global Const $sm_cxmenucheck = 71
- Global Const $sm_cymenucheck = 72
- Global Const $sm_slowmachine = 73
- Global Const $sm_mideastenabled = 74
- Global Const $sm_mousewheelpresent = 75
- Global Const $sm_xvirtualscreen = 76
- Global Const $sm_yvirtualscreen = 77
- Global Const $sm_cxvirtualscreen = 78
- Global Const $sm_cyvirtualscreen = 79
- Global Const $sm_cmonitors = 80
- Global Const $sm_samedisplayformat = 81
- Global Const $sm_immenabled = 82
- Global Const $sm_cxfocusborder = 83
- Global Const $sm_cyfocusborder = 84
- Global Const $sm_tabletpc = 86
- Global Const $sm_mediacenter = 87
- Global Const $sm_starter = 88
- Global Const $sm_serverr2 = 89
- Global Const $sm_cmetrics = 90
- Global Const $sm_remotesession = 4096
- Global Const $sm_shuttingdown = 8192
- Global Const $sm_remotecontrol = 8193
- Global Const $sm_caretblinkingenabled = 8194
- Global Const $blackness = 66
- Global Const $captureblt = 1073741824
- Global Const $dstinvert = 5570569
- Global Const $mergecopy = 12583114
- Global Const $mergepaint = 12255782
- Global Const $nomirrorbitmap = -2147483648
- Global Const $notsrccopy = 3342344
- Global Const $notsrcerase = 1114278
- Global Const $patcopy = 15728673
- Global Const $patinvert = 5898313
- Global Const $patpaint = 16452105
- Global Const $srcand = 8913094
- Global Const $srccopy = 13369376
- Global Const $srcerase = 4457256
- Global Const $srcinvert = 6684742
- Global Const $srcpaint = 15597702
- Global Const $whiteness = 16711778
- Global Const $dt_bottom = 8
- Global Const $dt_calcrect = 1024
- Global Const $dt_center = 1
- Global Const $dt_editcontrol = 8192
- Global Const $dt_end_ellipsis = 32768
- Global Const $dt_expandtabs = 64
- Global Const $dt_externalleading = 512
- Global Const $dt_hideprefix = 1048576
- Global Const $dt_internal = 4096
- Global Const $dt_left = 0
- Global Const $dt_modifystring = 65536
- Global Const $dt_noclip = 256
- Global Const $dt_nofullwidthcharbreak = 524288
- Global Const $dt_noprefix = 2048
- Global Const $dt_path_ellipsis = 16384
- Global Const $dt_prefixonly = 2097152
- Global Const $dt_right = 2
- Global Const $dt_rtlreading = 131072
- Global Const $dt_singleline = 32
- Global Const $dt_tabstop = 128
- Global Const $dt_top = 0
- Global Const $dt_vcenter = 4
- Global Const $dt_wordbreak = 16
- Global Const $dt_word_ellipsis = 262144
- Global Const $rdw_erase = 4
- Global Const $rdw_frame = 1024
- Global Const $rdw_internalpaint = 2
- Global Const $rdw_invalidate = 1
- Global Const $rdw_noerase = 32
- Global Const $rdw_noframe = 2048
- Global Const $rdw_nointernalpaint = 16
- Global Const $rdw_validate = 8
- Global Const $rdw_erasenow = 512
- Global Const $rdw_updatenow = 256
- Global Const $rdw_allchildren = 128
- Global Const $rdw_nochildren = 64
- Global Const $wm_renderformat = 773
- Global Const $wm_renderallformats = 774
- Global Const $wm_destroyclipboard = 775
- Global Const $wm_drawclipboard = 776
- Global Const $wm_paintclipboard = 777
- Global Const $wm_vscrollclipboard = 778
- Global Const $wm_sizeclipboard = 779
- Global Const $wm_askcbformatname = 780
- Global Const $wm_changecbchain = 781
- Global Const $wm_hscrollclipboard = 782
- Global Const $hterror = -2
- Global Const $httransparent = -1
- Global Const $htnowhere = 0
- Global Const $htclient = 1
- Global Const $htcaption = 2
- Global Const $htsysmenu = 3
- Global Const $htgrowbox = 4
- Global Const $htsize = $htgrowbox
- Global Const $htmenu = 5
- Global Const $hthscroll = 6
- Global Const $htvscroll = 7
- Global Const $htminbutton = 8
- Global Const $htmaxbutton = 9
- Global Const $htleft = 10
- Global Const $htright = 11
- Global Const $httop = 12
- Global Const $httopleft = 13
- Global Const $httopright = 14
- Global Const $htbottom = 15
- Global Const $htbottomleft = 16
- Global Const $htbottomright = 17
- Global Const $htborder = 18
- Global Const $htreduce = $htminbutton
- Global Const $htzoom = $htmaxbutton
- Global Const $htsizefirst = $htleft
- Global Const $htsizelast = $htbottomright
- Global Const $htobject = 19
- Global Const $htclose = 20
- Global Const $hthelp = 21
- Global Const $color_scrollbar = 0
- Global Const $color_background = 1
- Global Const $color_activecaption = 2
- Global Const $color_inactivecaption = 3
- Global Const $color_menu = 4
- Global Const $color_window = 5
- Global Const $color_windowframe = 6
- Global Const $color_menutext = 7
- Global Const $color_windowtext = 8
- Global Const $color_captiontext = 9
- Global Const $color_activeborder = 10
- Global Const $color_inactiveborder = 11
- Global Const $color_appworkspace = 12
- Global Const $color_highlight = 13
- Global Const $color_highlighttext = 14
- Global Const $color_btnface = 15
- Global Const $color_btnshadow = 16
- Global Const $color_graytext = 17
- Global Const $color_btntext = 18
- Global Const $color_inactivecaptiontext = 19
- Global Const $color_btnhighlight = 20
- Global Const $color_3ddkshadow = 21
- Global Const $color_3dlight = 22
- Global Const $color_infotext = 23
- Global Const $color_infobk = 24
- Global Const $color_hotlight = 26
- Global Const $color_gradientactivecaption = 27
- Global Const $color_gradientinactivecaption = 28
- Global Const $color_menuhilight = 29
- Global Const $color_menubar = 30
- Global Const $color_desktop = 1
- Global Const $color_3dface = 15
- Global Const $color_3dshadow = 16
- Global Const $color_3dhighlight = 20
- Global Const $color_3dhilight = 20
- Global Const $color_btnhilight = 20
- Global Const $hinst_commctrl = -1
- Global Const $idb_std_small_color = 0
- Global Const $idb_std_large_color = 1
- Global Const $idb_view_small_color = 4
- Global Const $idb_view_large_color = 5
- Global Const $idb_hist_small_color = 8
- Global Const $idb_hist_large_color = 9
- Global Const $startf_forceofffeedback = 128
- Global Const $startf_forceonfeedback = 64
- Global Const $startf_preventpinning = 8192
- Global Const $startf_runfullscreen = 32
- Global Const $startf_titleisappid = 4096
- Global Const $startf_titleislinkname = 2048
- Global Const $startf_usecountchars = 8
- Global Const $startf_usefillattribute = 16
- Global Const $startf_usehotkey = 512
- Global Const $startf_useposition = 4
- Global Const $startf_useshowwindow = 1
- Global Const $startf_usesize = 2
- Global Const $startf_usestdhandles = 256
- Global Const $cdds_prepaint = 1
- Global Const $cdds_postpaint = 2
- Global Const $cdds_preerase = 3
- Global Const $cdds_posterase = 4
- Global Const $cdds_item = 65536
- Global Const $cdds_itemprepaint = 65537
- Global Const $cdds_itempostpaint = 65538
- Global Const $cdds_itempreerase = 65539
- Global Const $cdds_itemposterase = 65540
- Global Const $cdds_subitem = 131072
- Global Const $cdis_selected = 1
- Global Const $cdis_grayed = 2
- Global Const $cdis_disabled = 4
- Global Const $cdis_checked = 8
- Global Const $cdis_focus = 16
- Global Const $cdis_default = 32
- Global Const $cdis_hot = 64
- Global Const $cdis_marked = 128
- Global Const $cdis_indeterminate = 256
- Global Const $cdis_showkeyboardcues = 512
- Global Const $cdis_nearhot = 1024
- Global Const $cdis_othersidehot = 2048
- Global Const $cdis_drophilited = 4096
- Global Const $cdrf_dodefault = 0
- Global Const $cdrf_newfont = 2
- Global Const $cdrf_skipdefault = 4
- Global Const $cdrf_notifypostpaint = 16
- Global Const $cdrf_notifyitemdraw = 32
- Global Const $cdrf_notifysubitemdraw = 32
- Global Const $cdrf_notifyposterase = 64
- Global Const $cdrf_doerase = 8
- Global Const $cdrf_skippostpaint = 256
- Global Const $gui_ss_default_gui = BitOR($ws_minimizebox, $ws_caption, $ws_popup, $ws_sysmenu)
- Global Const $es_left = 0
- Global Const $es_center = 1
- Global Const $es_right = 2
- Global Const $es_multiline = 4
- Global Const $es_uppercase = 8
- Global Const $es_lowercase = 16
- Global Const $es_password = 32
- Global Const $es_autovscroll = 64
- Global Const $es_autohscroll = 128
- Global Const $es_nohidesel = 256
- Global Const $es_oemconvert = 1024
- Global Const $es_readonly = 2048
- Global Const $es_wantreturn = 4096
- Global Const $es_number = 8192
- Global Const $ec_err = -1
- Global Const $ecm_first = 5376
- Global Const $em_canundo = 198
- Global Const $em_charfrompos = 215
- Global Const $em_emptyundobuffer = 205
- Global Const $em_fmtlines = 200
- Global Const $em_getcuebanner = ($ecm_first + 2)
- Global Const $em_getfirstvisibleline = 206
- Global Const $em_gethandle = 189
- Global Const $em_getimestatus = 217
- Global Const $em_getlimittext = 213
- Global Const $em_getline = 196
- Global Const $em_getlinecount = 186
- Global Const $em_getmargins = 212
- Global Const $em_getmodify = 184
- Global Const $em_getpasswordchar = 210
- Global Const $em_getrect = 178
- Global Const $em_getsel = 176
- Global Const $em_getthumb = 190
- Global Const $em_getwordbreakproc = 209
- Global Const $em_hideballoontip = ($ecm_first + 4)
- Global Const $em_limittext = 197
- Global Const $em_linefromchar = 201
- Global Const $em_lineindex = 187
- Global Const $em_linelength = 193
- Global Const $em_linescroll = 182
- Global Const $em_posfromchar = 214
- Global Const $em_replacesel = 194
- Global Const $em_scroll = 181
- Global Const $em_scrollcaret = 183
- Global Const $em_setcuebanner = ($ecm_first + 1)
- Global Const $em_sethandle = 188
- Global Const $em_setimestatus = 216
- Global Const $em_setlimittext = $em_limittext
- Global Const $em_setmargins = 211
- Global Const $em_setmodify = 185
- Global Const $em_setpasswordchar = 204
- Global Const $em_setreadonly = 207
- Global Const $em_setrect = 179
- Global Const $em_setrectnp = 180
- Global Const $em_setsel = 177
- Global Const $em_settabstops = 203
- Global Const $em_setwordbreakproc = 208
- Global Const $em_showballoontip = ($ecm_first + 3)
- Global Const $em_undo = 199
- Global Const $ec_leftmargin = 1
- Global Const $ec_rightmargin = 2
- Global Const $ec_usefontinfo = 65535
- Global Const $emsis_compositionstring = 1
- Global Const $eimes_getcompstratonce = 1
- Global Const $eimes_cancelcompstrinfocus = 2
- Global Const $eimes_completecompstrkillfocus = 4
- Global Const $en_align_ltr_ec = 1792
- Global Const $en_align_rtl_ec = 1793
- Global Const $en_change = 768
- Global Const $en_errspace = 1280
- Global Const $en_hscroll = 1537
- Global Const $en_killfocus = 512
- Global Const $en_maxtext = 1281
- Global Const $en_setfocus = 256
- Global Const $en_update = 1024
- Global Const $en_vscroll = 1538
- Global Const $gui_ss_default_edit = 3150016
- Global Const $gui_ss_default_input = 128
- #Region _Memory
- Func _memoryopen($iv_pid, $iv_desiredaccess = 2035711, $if_inherithandle = 1)
- If NOT ProcessExists($iv_pid) Then
- SetError(1)
- Return 0
- EndIf
- Local $ah_handle[2] = [DllOpen("kernel32.dll")]
- If @error Then
- SetError(2)
- Return 0
- EndIf
- Local $av_openprocess = DllCall($ah_handle[0], "int", "OpenProcess", "int", $iv_desiredaccess, "int", $if_inherithandle, "int", $iv_pid)
- If @error Then
- DllClose($ah_handle[0])
- SetError(3)
- Return 0
- EndIf
- $ah_handle[1] = $av_openprocess[0]
- Return $ah_handle
- EndFunc
- Func _memoryread($iv_address, $ah_handle, $sv_type = "dword")
- If NOT IsArray($ah_handle) Then
- SetError(1)
- Return 0
- EndIf
- Local $v_buffer = DllStructCreate($sv_type)
- If @error Then
- SetError(@error + 1)
- Return 0
- EndIf
- DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
- If NOT @error Then
- Local $v_value = DllStructGetData($v_buffer, 1)
- Return $v_value
- Else
- SetError(6)
- Return 0
- EndIf
- EndFunc
- Func _memorywrite($iv_address, $ah_handle, $v_data, $sv_type = "dword")
- If NOT IsArray($ah_handle) Then
- SetError(1)
- Return 0
- EndIf
- Local $v_buffer = DllStructCreate($sv_type)
- If @error Then
- SetError(@error + 1)
- Return 0
- Else
- DllStructSetData($v_buffer, 1, $v_data)
- If @error Then
- SetError(6)
- Return 0
- EndIf
- EndIf
- DllCall($ah_handle[0], "int", "WriteProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
- If NOT @error Then
- Return 1
- Else
- SetError(7)
- Return 0
- EndIf
- EndFunc
- Func _memoryclose($ah_handle)
- If NOT IsArray($ah_handle) Then
- SetError(1)
- Return 0
- EndIf
- DllCall($ah_handle[0], "int", "CloseHandle", "int", $ah_handle[1])
- If NOT @error Then
- DllClose($ah_handle[0])
- Return 1
- Else
- DllClose($ah_handle[0])
- SetError(2)
- Return 0
- EndIf
- EndFunc
- Func _memorypointerread($iv_address, $ah_handle, $av_offset, $sv_type = "dword")
- If IsArray($av_offset) Then
- If IsArray($ah_handle) Then
- Local $iv_pointercount = UBound($av_offset) - 1
- Else
- SetError(2)
- Return 0
- EndIf
- Else
- SetError(1)
- Return 0
- EndIf
- Local $iv_data[2], $i
- Local $v_buffer = DllStructCreate("dword")
- For $i = 0 To $iv_pointercount
- If $i = $iv_pointercount Then
- $v_buffer = DllStructCreate($sv_type)
- If @error Then
- SetError(@error + 2)
- Return 0
- EndIf
- $iv_address = "0x" & Hex($iv_data[1] + $av_offset[$i])
- DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
- If @error Then
- SetError(7)
- Return 0
- EndIf
- $iv_data[1] = DllStructGetData($v_buffer, 1)
- ElseIf $i = 0 Then
- DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
- If @error Then
- SetError(7)
- Return 0
- EndIf
- $iv_data[1] = DllStructGetData($v_buffer, 1)
- Else
- $iv_address = "0x" & Hex($iv_data[1] + $av_offset[$i])
- DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
- If @error Then
- SetError(7)
- Return 0
- EndIf
- $iv_data[1] = DllStructGetData($v_buffer, 1)
- EndIf
- Next
- $iv_data[0] = $iv_address
- Return $iv_data
- EndFunc
- Func _memorypointerwrite($iv_address, $ah_handle, $av_offset, $v_data, $sv_type = "dword")
- If IsArray($av_offset) Then
- If IsArray($ah_handle) Then
- Local $iv_pointercount = UBound($av_offset) - 1
- Else
- SetError(2)
- Return 0
- EndIf
- Else
- SetError(1)
- Return 0
- EndIf
- Local $iv_structdata, $i
- Local $v_buffer = DllStructCreate("dword")
- For $i = 0 To $iv_pointercount
- If $i = $iv_pointercount Then
- $v_buffer = DllStructCreate($sv_type)
- If @error Then
- SetError(@error + 3)
- Return 0
- EndIf
- DllStructSetData($v_buffer, 1, $v_data)
- If @error Then
- SetError(8)
- Return 0
- EndIf
- $iv_address = "0x" & Hex($iv_structdata + $av_offset[$i])
- DllCall($ah_handle[0], "int", "WriteProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
- If @error Then
- SetError(9)
- Return 0
- Else
- Return $iv_address
- EndIf
- ElseIf $i = 0 Then
- DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
- If @error Then
- SetError(3)
- Return 0
- EndIf
- $iv_structdata = DllStructGetData($v_buffer, 1)
- Else
- $iv_address = "0x" & Hex($iv_structdata + $av_offset[$i])
- DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
- If @error Then
- SetError(3)
- Return 0
- EndIf
- $iv_structdata = DllStructGetData($v_buffer, 1)
- EndIf
- Next
- EndFunc
- Func setprivilege($privilege, $benable)
- Const $token_adjust_privileges = 32
- Const $token_query = 8
- Const $se_privilege_enabled = 2
- Local $htoken, $sp_auxret, $sp_ret, $hcurrprocess, $ntokens, $ntokenindex, $priv
- $ntokens = 1
- $luid = DllStructCreate("dword;int")
- If IsArray($privilege) Then $ntokens = UBound($privilege)
- $token_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
- $newtoken_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
- $hcurrprocess = DllCall("kernel32.dll", "hwnd", "GetCurrentProcess")
- $sp_auxret = DllCall("advapi32.dll", "int", "OpenProcessToken", "hwnd", $hcurrprocess[0], "int", BitOR($token_adjust_privileges, $token_query), "int*", 0)
- If $sp_auxret[0] Then
- $htoken = $sp_auxret[3]
- DllStructSetData($token_privileges, 1, 1)
- $ntokenindex = 1
- While $ntokenindex <= $ntokens
- If IsArray($privilege) Then
- $priv = $privilege[$ntokenindex - 1]
- Else
- $priv = $privilege
- EndIf
- $ret = DllCall("advapi32.dll", "int", "LookupPrivilegeValue", "str", "", "str", $priv, "ptr", DllStructGetPtr($luid))
- If $ret[0] Then
- If $benable Then
- DllStructSetData($token_privileges, 2, $se_privilege_enabled, (3 * $ntokenindex))
- Else
- DllStructSetData($token_privileges, 2, 0, (3 * $ntokenindex))
- EndIf
- DllStructSetData($token_privileges, 2, DllStructGetData($luid, 1), (3 * ($ntokenindex - 1)) + 1)
- DllStructSetData($token_privileges, 2, DllStructGetData($luid, 2), (3 * ($ntokenindex - 1)) + 2)
- DllStructSetData($luid, 1, 0)
- DllStructSetData($luid, 2, 0)
- EndIf
- $ntokenindex += 1
- WEnd
- $ret = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "hwnd", $htoken, "int", 0, "ptr", DllStructGetPtr($token_privileges), "int", DllStructGetSize($newtoken_privileges), "ptr", DllStructGetPtr($newtoken_privileges), "int*", 0)
- $f = DllCall("kernel32.dll", "int", "GetLastError")
- EndIf
- $newtoken_privileges = 0
- $token_privileges = 0
- $luid = 0
- If $sp_auxret[0] = 0 Then Return 0
- $sp_auxret = DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $htoken)
- If NOT $ret[0] AND NOT $sp_auxret[0] Then Return 0
- Return $ret[0]
- EndFunc
- Func _memorygetbaseaddress($ah_handle, $ihexdec = 0)
- Local $iv_address = 1048576
- Local $v_buffer = DllStructCreate("dword;dword;dword;dword;dword;dword;dword")
- Local $vdata
- Local $vtype
- If NOT IsArray($ah_handle) Then
- SetError(1)
- Return 0
- EndIf
- DllCall($ah_handle[0], "int", "VirtualQueryEx", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer))
- If NOT @error Then
- $vdata = Hex(DllStructGetData($v_buffer, 2))
- $vtype = Hex(DllStructGetData($v_buffer, 3))
- While $vtype <> "00000080"
- DllCall($ah_handle[0], "int", "VirtualQueryEx", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer))
- $vdata = Hex(DllStructGetData($v_buffer, 2))
- $vtype = Hex(DllStructGetData($v_buffer, 3))
- If Hex($iv_address) = "01000000" Then ExitLoop
- $iv_address += 65536
- WEnd
- If $vtype = "00000080" Then
- SetError(0)
- If $ihexdec = 1 Then
- Return Dec($vdata)
- Else
- Return $vdata
- EndIf
- Else
- SetError(2)
- Return 0
- EndIf
- Else
- SetError(3)
- Return 0
- EndIf
- EndFunc
- Func _memorymodulegetbaseaddress($ipid, $smodule)
- If NOT ProcessExists($ipid) Then Return SetError(1, 0, 0)
- If NOT IsString($smodule) Then Return SetError(2, 0, 0)
- Local $psapi = DllOpen("psapi.dll")
- Local $hprocess
- Local $permission = BitOR(2, 1024, 8, 16, 32)
- If $ipid > 0 Then
- Local $hprocess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $permission, "int", 0, "dword", $ipid)
- If $hprocess[0] Then
- $hprocess = $hprocess[0]
- EndIf
- EndIf
- Local $modules = DllStructCreate("ptr[1024]")
- Local $acall = DllCall($psapi, "int", "EnumProcessModules", "ptr", $hprocess, "ptr", DllStructGetPtr($modules), "dword", DllStructGetSize($modules), "dword*", 0)
- If $acall[4] > 0 Then
- Local $imodnum = $acall[4] / 4
- Local $atemp
- For $i = 1 To $imodnum
- $atemp = DllCall($psapi, "dword", "GetModuleBaseNameW", "ptr", $hprocess, "ptr", Ptr(DllStructGetData($modules, 1, $i)), "wstr", "", "dword", 260)
- If $atemp[3] = $smodule Then
- DllClose($psapi)
- Return Ptr(DllStructGetData($modules, 1, $i))
- EndIf
- Next
- EndIf
- DllClose($psapi)
- Return SetError(-1, 0, 0)
- EndFunc
- #EndRegion
- Global Const $math_isnotdivisible = 1
- Global Const $math_isdivisible = 2
- Global Const $math_degrees = 57.2957795130823
- Func _degree($iradians)
- Return IsNumber($iradians) ? $iradians * $math_degrees : SetError(1, 0, "")
- EndFunc
- Func _mathcheckdiv($inum1, $inum2 = 2)
- If NOT (IsInt($inum1) AND IsInt($inum2)) Then
- Return SetError(1, 0, -1)
- EndIf
- Return (Mod($inum1, $inum2) = 0) ? $math_isdivisible : $math_isnotdivisible
- EndFunc
- Func _max($inum1, $inum2)
- If NOT IsNumber($inum1) Then Return SetError(1, 0, 0)
- If NOT IsNumber($inum2) Then Return SetError(2, 0, 0)
- Return ($inum1 > $inum2) ? $inum1 : $inum2
- EndFunc
- Func _min($inum1, $inum2)
- If NOT IsNumber($inum1) Then Return SetError(1, 0, 0)
- If NOT IsNumber($inum2) Then Return SetError(2, 0, 0)
- Return ($inum1 > $inum2) ? $inum2 : $inum1
- EndFunc
- Func _radian($idegrees)
- Return Number($idegrees) ? $idegrees / $math_degrees : SetError(1, 0, "")
- EndFunc
- Global Const $str_nocasesense = 0
- Global Const $str_casesense = 1
- Global Const $str_nocasesensebasic = 2
- Global Const $str_stripleading = 1
- Global Const $str_striptrailing = 2
- Global Const $str_stripspaces = 4
- Global Const $str_stripall = 8
- Global Const $str_chrsplit = 0
- Global Const $str_entiresplit = 1
- Global Const $str_nocount = 2
- Global Const $str_regexpmatch = 0
- Global Const $str_regexparraymatch = 1
- Global Const $str_regexparrayfullmatch = 2
- Global Const $str_regexparrayglobalmatch = 3
- Global Const $str_regexparrayglobalfullmatch = 4
- Global Const $str_endisstart = 0
- Global Const $str_endnotstart = 1
- Global Const $sb_ansi = 1
- Global Const $sb_utf16le = 2
- Global Const $sb_utf16be = 3
- Global Const $sb_utf8 = 4
- Global Const $se_utf16 = 0
- Global Const $se_ansi = 1
- Global Const $se_utf8 = 2
- Global Const $str_utf16 = 0
- Global Const $str_ucs2 = 1
- Func _hextostring($shex)
- If NOT (StringLeft($shex, 2) == "0x") Then $shex = "0x" & $shex
- Return BinaryToString($shex, $sb_utf8)
- EndFunc
- Func _stringbetween($sstring, $sstart, $send, $imode = $str_endisstart, $bcase = False)
- $sstart = $sstart ? "\Q" & $sstart & "\E" : "\A"
- If $imode <> $str_endnotstart Then $imode = $str_endisstart
- If $imode = $str_endisstart Then
- $send = $send ? "(?=\Q" & $send & "\E)" : "\z"
- Else
- $send = $send ? "\Q" & $send & "\E" : "\z"
- EndIf
- If $bcase = Default Then
- $bcase = False
- EndIf
- Local $areturn = StringRegExp($sstring, "(?s" & (NOT $bcase ? "i" : "") & ")" & $sstart & "(.*?)" & $send, $str_regexparrayglobalmatch)
- If @error Then Return SetError(1, 0, 0)
- Return $areturn
- EndFunc
- Func _stringexplode($sstring, $sdelimiter, $ilimit = 0)
- If $ilimit = Default Then $ilimit = 0
- If $ilimit > 0 Then
- Local Const $null = Chr(0)
- $sstring = StringReplace($sstring, $sdelimiter, $null, $ilimit)
- $sdelimiter = $null
- ElseIf $ilimit < 0 Then
- Local $iindex = StringInStr($sstring, $sdelimiter, 0, $ilimit)
- If $iindex Then
- $sstring = StringLeft($sstring, $iindex - 1)
- EndIf
- EndIf
- Return StringSplit($sstring, $sdelimiter, $str_entiresplit + $str_nocount)
- EndFunc
- Func _stringinsert($sstring, $sinsertstring, $iposition)
- Local $ilength = StringLen($sstring)
- $iposition = Int($iposition)
- If $iposition < 0 Then $iposition = $ilength + $iposition
- If $ilength < $iposition OR $iposition < 0 Then Return SetError(1, 0, $sstring)
- Return StringLeft($sstring, $iposition) & $sinsertstring & StringRight($sstring, $ilength - $iposition)
- EndFunc
- Func _stringproper($sstring)
- Local $bcapnext = True, $schr = "", $sreturn = ""
- For $i = 1 To StringLen($sstring)
- $schr = StringMid($sstring, $i, 1)
- Select
- Case $bcapnext = True
- If StringRegExp($schr, "[a-zA-ZГЂ-ГїЕЎЕ“ЕѕЕё]") Then
- $schr = StringUpper($schr)
- $bcapnext = False
- EndIf
- Case NOT StringRegExp($schr, "[a-zA-ZГЂ-ГїЕЎЕ“ЕѕЕё]")
- $bcapnext = True
- Case Else
- $schr = StringLower($schr)
- EndSelect
- $sreturn &= $schr
- Next
- Return $sreturn
- EndFunc
- Func _stringrepeat($sstring, $irepeatcount)
- $irepeatcount = Int($irepeatcount)
- If $irepeatcount = 0 Then Return ""
- If StringLen($sstring) < 1 OR $irepeatcount < 0 Then Return SetError(1, 0, "")
- Local $sresult = ""
- While $irepeatcount > 1
- If BitAND($irepeatcount, 1) Then $sresult &= $sstring
- $sstring &= $sstring
- $irepeatcount = BitShift($irepeatcount, 1)
- WEnd
- Return $sstring & $sresult
- EndFunc
- Func _stringtitlecase($sstring)
- Local $bcapnext = True, $schr = "", $sreturn = ""
- For $i = 1 To StringLen($sstring)
- $schr = StringMid($sstring, $i, 1)
- Select
- Case $bcapnext = True
- If StringRegExp($schr, "[a-zA-Z\xC0-\xFF0-9]") Then
- $schr = StringUpper($schr)
- $bcapnext = False
- EndIf
- Case NOT StringRegExp($schr, "[a-zA-Z\xC0-\xFF'0-9]")
- $bcapnext = True
- Case Else
- $schr = StringLower($schr)
- EndSelect
- $sreturn &= $schr
- Next
- Return $sreturn
- EndFunc
- Func _stringtohex($sstring)
- Return Hex(StringToBinary($sstring, $sb_utf8))
- EndFunc
- Global Const $opt_coordsrelative = 0
- Global Const $opt_coordsabsolute = 1
- Global Const $opt_coordsclient = 2
- Global Const $opt_errorsilent = 0
- Global Const $opt_errorfatal = 1
- Global Const $opt_capsnostore = 0
- Global Const $opt_capsstore = 1
- Global Const $opt_matchstart = 1
- Global Const $opt_matchany = 2
- Global Const $opt_matchexact = 3
- Global Const $opt_matchadvanced = 4
- Global Const $ccs_top = 1
- Global Const $ccs_nomovey = 2
- Global Const $ccs_bottom = 3
- Global Const $ccs_noresize = 4
- Global Const $ccs_noparentalign = 8
- Global Const $ccs_nohilite = 16
- Global Const $ccs_adjustable = 32
- Global Const $ccs_nodivider = 64
- Global Const $ccs_vert = 128
- Global Const $ccs_left = 129
- Global Const $ccs_nomovex = 130
- Global Const $ccs_right = 131
- Global Const $dt_drivetype = 1
- Global Const $dt_ssdstatus = 2
- Global Const $dt_bustype = 3
- Global Const $proxy_ie = 0
- Global Const $proxy_none = 1
- Global Const $proxy_specified = 2
- Global Const $objid_window = 0
- Global Const $objid_titlebar = -2
- Global Const $objid_sizegrip = -7
- Global Const $objid_caret = -8
- Global Const $objid_cursor = -9
- Global Const $objid_alert = -10
- Global Const $objid_sound = -11
- Global Const $dlg_centerontop = 0
- Global Const $dlg_notitle = 1
- Global Const $dlg_notontop = 2
- Global Const $dlg_textleft = 4
- Global Const $dlg_textright = 8
- Global Const $dlg_moveable = 16
- Global Const $dlg_textvcenter = 32
- Global Const $idc_unknown = 0
- Global Const $idc_appstarting = 1
- Global Const $idc_arrow = 2
- Global Const $idc_cross = 3
- Global Const $idc_hand = 32649
- Global Const $idc_help = 4
- Global Const $idc_ibeam = 5
- Global Const $idc_icon = 6
- Global Const $idc_no = 7
- Global Const $idc_size = 8
- Global Const $idc_sizeall = 9
- Global Const $idc_sizenesw = 10
- Global Const $idc_sizens = 11
- Global Const $idc_sizenwse = 12
- Global Const $idc_sizewe = 13
- Global Const $idc_uparrow = 14
- Global Const $idc_wait = 15
- Global Const $idi_application = 32512
- Global Const $idi_asterisk = 32516
- Global Const $idi_exclamation = 32515
- Global Const $idi_hand = 32513
- Global Const $idi_question = 32514
- Global Const $idi_winlogo = 32517
- Global Const $idi_shield = 32518
- Global Const $idi_error = $idi_hand
- Global Const $idi_information = $idi_asterisk
- Global Const $idi_warning = $idi_exclamation
- Global Const $sd_logoff = 0
- Global Const $sd_shutdown = 1
- Global Const $sd_reboot = 2
- Global Const $sd_force = 4
- Global Const $sd_powerdown = 8
- Global Const $sd_forcehung = 16
- Global Const $sd_standby = 32
- Global Const $sd_hibernate = 64
- Global Const $stdin_child = 1
- Global Const $stdout_child = 2
- Global Const $stderr_child = 4
- Global Const $stderr_merged = 8
- Global Const $stdio_inherit_parent = 16
- Global Const $run_create_new_console = 65536
- Global Const $ubound_dimensions = 0
- Global Const $ubound_rows = 1
- Global Const $ubound_columns = 2
- Global Const $mouseeventf_absolute = 32768
- Global Const $mouseeventf_move = 1
- Global Const $mouseeventf_leftdown = 2
- Global Const $mouseeventf_leftup = 4
- Global Const $mouseeventf_rightdown = 8
- Global Const $mouseeventf_rightup = 16
- Global Const $mouseeventf_middledown = 32
- Global Const $mouseeventf_middleup = 64
- Global Const $mouseeventf_wheel = 2048
- Global Const $mouseeventf_xdown = 128
- Global Const $mouseeventf_xup = 256
- Global Const $reg_none = 0
- Global Const $reg_sz = 1
- Global Const $reg_expand_sz = 2
- Global Const $reg_binary = 3
- Global Const $reg_dword = 4
- Global Const $reg_dword_little_endian = 4
- Global Const $reg_dword_big_endian = 5
- Global Const $reg_link = 6
- Global Const $reg_multi_sz = 7
- Global Const $reg_resource_list = 8
- Global Const $reg_full_resource_descriptor = 9
- Global Const $reg_resource_requirements_list = 10
- Global Const $reg_qword = 11
- Global Const $reg_qword_little_endian = 11
- Global Const $hwnd_bottom = 1
- Global Const $hwnd_notopmost = -2
- Global Const $hwnd_top = 0
- Global Const $hwnd_topmost = -1
- Global Const $swp_nosize = 1
- Global Const $swp_nomove = 2
- Global Const $swp_nozorder = 4
- Global Const $swp_noredraw = 8
- Global Const $swp_noactivate = 16
- Global Const $swp_framechanged = 32
- Global Const $swp_drawframe = 32
- Global Const $swp_showwindow = 64
- Global Const $swp_hidewindow = 128
- Global Const $swp_nocopybits = 256
- Global Const $swp_noownerzorder = 512
- Global Const $swp_noreposition = 512
- Global Const $swp_nosendchanging = 1024
- Global Const $swp_defererase = 8192
- Global Const $swp_asyncwindowpos = 16384
- Global Const $keyword_default = 1
- Global Const $keyword_null = 2
- Global Const $declared_local = -1
- Global Const $declared_unknown = 0
- Global Const $declared_global = 1
- Global Const $assign_create = 0
- Global Const $assign_forcelocal = 1
- Global Const $assign_forceglobal = 2
- Global Const $assign_existfail = 4
- Global Const $bi_enable = 0
- Global Const $bi_disable = 1
- Global Const $break_enable = 1
- Global Const $break_disable = 0
- Global Const $cdtray_open = "open"
- Global Const $cdtray_closed = "closed"
- Global Const $send_default = 0
- Global Const $send_raw = 1
- Global Const $dir_default = 0
- Global Const $dir_extended = 1
- Global Const $dir_norecurse = 2
- Global Const $dir_remove = 1
- Global Const $dt_all = "ALL"
- Global Const $dt_cdrom = "CDROM"
- Global Const $dt_removable = "REMOVABLE"
- Global Const $dt_fixed = "FIXED"
- Global Const $dt_network = "NETWORK"
- Global Const $dt_ramdisk = "RAMDISK"
- Global Const $dt_unknown = "UNKNOWN"
- Global Const $dt_undefined = 1
- Global Const $dt_fat = "FAT"
- Global Const $dt_fat32 = "FAT32"
- Global Const $dt_exfat = "exFAT"
- Global Const $dt_ntfs = "NTFS"
- Global Const $dt_nwfs = "NWFS"
- Global Const $dt_cdfs = "CDFS"
- Global Const $dt_udf = "UDF"
- Global Const $dma_default = 0
- Global Const $dma_persistent = 1
- Global Const $dma_authentication = 8
- Global Const $ds_unknown = "UNKNOWN"
- Global Const $ds_ready = "READY"
- Global Const $ds_notready = "NOTREADY"
- Global Const $ds_invalid = "INVALID"
- Global Const $mouse_click_left = "left"
- Global Const $mouse_click_right = "right"
- Global Const $mouse_click_middle = "middle"
- Global Const $mouse_click_main = "main"
- Global Const $mouse_click_menu = "menu"
- Global Const $mouse_click_primary = "primary"
- Global Const $mouse_click_secondary = "secondary"
- Global Const $mouse_wheel_up = "up"
- Global Const $mouse_wheel_down = "down"
- Global Const $number_auto = 0
- Global Const $number_32bit = 1
- Global Const $number_64bit = 2
- Global Const $number_double = 3
- Global Const $obj_name = 1
- Global Const $obj_string = 2
- Global Const $obj_progid = 3
- Global Const $obj_file = 4
- Global Const $obj_module = 5
- Global Const $obj_clsid = 6
- Global Const $obj_iid = 7
- Global Const $exitclose_normal = 0
- Global Const $exitclose_byexit = 1
- Global Const $exitclose_byclick = 2
- Global Const $exitclose_bylogoff = 3
- Global Const $exitclose_bysutdown = 4
- Global Const $process_stats_memory = 0
- Global Const $process_stats_io = 1
- Global Const $process_low = 0
- Global Const $process_belownormal = 1
- Global Const $process_normal = 2
- Global Const $process_abovenormal = 3
- Global Const $process_high = 4
- Global Const $process_realtime = 5
- Global Const $run_logon_noprofile = 0
- Global Const $run_logon_profile = 1
- Global Const $run_logon_network = 2
- Global Const $run_logon_inherit = 4
- Global Const $sound_nowait = 0
- Global Const $sound_wait = 1
- Global Const $shex_open = "open"
- Global Const $shex_edit = "edit"
- Global Const $shex_print = "print"
- Global Const $shex_properties = "properties"
- Global Const $tcp_data_default = 0
- Global Const $tcp_data_binary = 1
- Global Const $udp_open_default = 0
- Global Const $udp_open_broadcast = 1
- Global Const $udp_data_default = 0
- Global Const $udp_data_binary = 1
- Global Const $udp_data_array = 2
- Global Const $tip_noicon = 0
- Global Const $tip_infoicon = 1
- Global Const $tip_warningicon = 2
- Global Const $tip_erroricon = 3
- Global Const $tip_balloon = 1
- Global Const $tip_center = 2
- Global Const $tip_forcevisible = 4
- Global Const $windows_noontop = 0
- Global Const $windows_ontop = 1
- Global Const $mb_ok = 0
- Global Const $mb_okcancel = 1
- Global Const $mb_abortretryignore = 2
- Global Const $mb_yesnocancel = 3
- Global Const $mb_yesno = 4
- Global Const $mb_retrycancel = 5
- Global Const $mb_canceltrycontinue = 6
- Global Const $mb_help = 16384
- Global Const $mb_iconstop = 16
- Global Const $mb_iconerror = 16
- Global Const $mb_iconhand = 16
- Global Const $mb_iconquestion = 32
- Global Const $mb_iconexclamation = 48
- Global Const $mb_iconwarning = 48
- Global Const $mb_iconinformation = 64
- Global Const $mb_iconasterisk = 64
- Global Const $mb_usericon = 128
- Global Const $mb_defbutton1 = 0
- Global Const $mb_defbutton2 = 256
- Global Const $mb_defbutton3 = 512
- Global Const $mb_defbutton4 = 768
- Global Const $mb_applmodal = 0
- Global Const $mb_systemmodal = 4096
- Global Const $mb_taskmodal = 8192
- Global Const $mb_default_desktop_only = 131072
- Global Const $mb_right = 524288
- Global Const $mb_rtlreading = 1048576
- Global Const $mb_setforeground = 65536
- Global Const $mb_topmost = 262144
- Global Const $mb_service_notification = 2097152
- Global Const $mb_rightjustified = $mb_right
- Global Const $idtimeout = -1
- Global Const $idok = 1
- Global Const $idcancel = 2
- Global Const $idabort = 3
- Global Const $idretry = 4
- Global Const $idignore = 5
- Global Const $idyes = 6
- Global Const $idno = 7
- Global Const $idclose = 8
- Global Const $idhelp = 9
- Global Const $idtryagain = 10
- Global Const $idcontinue = 11
- Global Enum $arrayfill_force_default, $arrayfill_force_singleitem, $arrayfill_force_int, $arrayfill_force_number, $arrayfill_force_ptr, $arrayfill_force_hwnd, $arrayfill_force_string
- Global Enum $arrayunique_nocount, $arrayunique_count
- Global Enum $arrayunique_auto, $arrayunique_force32, $arrayunique_force64, $arrayunique_match, $arrayunique_distinct
- Func _arrayadd(ByRef $aarray, $vvalue, $istart = 0, $sdelim_item = "|", $sdelim_row = @CRLF, $iforce = $arrayfill_force_default)
- If $istart = Default Then $istart = 0
- If $sdelim_item = Default Then $sdelim_item = "|"
- If $sdelim_row = Default Then $sdelim_row = @CRLF
- If $iforce = Default Then $iforce = $arrayfill_force_default
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray, $ubound_rows)
- Local $hdatatype = 0
- Switch $iforce
- Case $arrayfill_force_int
- $hdatatype = Int
- Case $arrayfill_force_number
- $hdatatype = Number
- Case $arrayfill_force_ptr
- $hdatatype = Ptr
- Case $arrayfill_force_hwnd
- $hdatatype = HWnd
- Case $arrayfill_force_string
- $hdatatype = String
- EndSwitch
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- If $iforce = $arrayfill_force_singleitem Then
- ReDim $aarray[$idim_1 + 1]
- $aarray[$idim_1] = $vvalue
- Return $idim_1
- EndIf
- If IsArray($vvalue) Then
- If UBound($vvalue, $ubound_dimensions) <> 1 Then Return SetError(5, 0, -1)
- $hdatatype = 0
- Else
- Local $atmp = StringSplit($vvalue, $sdelim_item, $str_nocount + $str_entiresplit)
- If UBound($atmp, $ubound_rows) = 1 Then
- $atmp[0] = $vvalue
- EndIf
- $vvalue = $atmp
- EndIf
- Local $iadd = UBound($vvalue, $ubound_rows)
- ReDim $aarray[$idim_1 + $iadd]
- For $i = 0 To $iadd - 1
- If IsFunc($hdatatype) Then
- $aarray[$idim_1 + $i] = $hdatatype($vvalue[$i])
- Else
- $aarray[$idim_1 + $i] = $vvalue[$i]
- EndIf
- Next
- Return $idim_1 + $iadd - 1
- Case 2
- Local $idim_2 = UBound($aarray, $ubound_columns)
- If $istart < 0 OR $istart > $idim_2 - 1 Then Return SetError(4, 0, -1)
- Local $ivaldim_1, $ivaldim_2 = 0, $icolcount
- If IsArray($vvalue) Then
- If UBound($vvalue, $ubound_dimensions) <> 2 Then Return SetError(5, 0, -1)
- $ivaldim_1 = UBound($vvalue, $ubound_rows)
- $ivaldim_2 = UBound($vvalue, $ubound_columns)
- $hdatatype = 0
- Else
- Local $asplit_1 = StringSplit($vvalue, $sdelim_row, $str_nocount + $str_entiresplit)
- $ivaldim_1 = UBound($asplit_1, $ubound_rows)
- Local $atmp[$ivaldim_1][0], $asplit_2
- For $i = 0 To $ivaldim_1 - 1
- $asplit_2 = StringSplit($asplit_1[$i], $sdelim_item, $str_nocount + $str_entiresplit)
- $icolcount = UBound($asplit_2)
- If $icolcount > $ivaldim_2 Then
- $ivaldim_2 = $icolcount
- ReDim $atmp[$ivaldim_1][$ivaldim_2]
- EndIf
- For $j = 0 To $icolcount - 1
- $atmp[$i][$j] = $asplit_2[$j]
- Next
- Next
- $vvalue = $atmp
- EndIf
- If UBound($vvalue, $ubound_columns) + $istart > UBound($aarray, $ubound_columns) Then Return SetError(3, 0, -1)
- ReDim $aarray[$idim_1 + $ivaldim_1][$idim_2]
- For $iwriteto_index = 0 To $ivaldim_1 - 1
- For $j = 0 To $idim_2 - 1
- If $j < $istart Then
- $aarray[$iwriteto_index + $idim_1][$j] = ""
- ElseIf $j - $istart > $ivaldim_2 - 1 Then
- $aarray[$iwriteto_index + $idim_1][$j] = ""
- Else
- If IsFunc($hdatatype) Then
- $aarray[$iwriteto_index + $idim_1][$j] = $hdatatype($vvalue[$iwriteto_index][$j - $istart])
- Else
- $aarray[$iwriteto_index + $idim_1][$j] = $vvalue[$iwriteto_index][$j - $istart]
- EndIf
- EndIf
- Next
- Next
- Case Else
- Return SetError(2, 0, -1)
- EndSwitch
- Return UBound($aarray, $ubound_rows) - 1
- EndFunc
- Func _arraybinarysearch(Const ByRef $aarray, $vvalue, $istart = 0, $iend = 0, $icolumn = 0)
- If $istart = Default Then $istart = 0
- If $iend = Default Then $iend = 0
- If $icolumn = Default Then $icolumn = 0
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray, $ubound_rows)
- If $idim_1 = 0 Then Return SetError(6, 0, -1)
- If $iend < 1 OR $iend > $idim_1 - 1 Then $iend = $idim_1 - 1
- If $istart < 0 Then $istart = 0
- If $istart > $iend Then Return SetError(4, 0, -1)
- Local $imid = Int(($iend + $istart) / 2)
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- If $aarray[$istart] > $vvalue OR $aarray[$iend] < $vvalue Then Return SetError(2, 0, -1)
- While $istart <= $imid AND $vvalue <> $aarray[$imid]
- If $vvalue < $aarray[$imid] Then
- $iend = $imid - 1
- Else
- $istart = $imid + 1
- EndIf
- $imid = Int(($iend + $istart) / 2)
- WEnd
- If $istart > $iend Then Return SetError(3, 0, -1)
- Case 2
- Local $idim_2 = UBound($aarray, $ubound_columns) - 1
- If $icolumn < 0 OR $icolumn > $idim_2 Then Return SetError(7, 0, -1)
- If $aarray[$istart][$icolumn] > $vvalue OR $aarray[$iend][$icolumn] < $vvalue Then Return SetError(2, 0, -1)
- While $istart <= $imid AND $vvalue <> $aarray[$imid][$icolumn]
- If $vvalue < $aarray[$imid][$icolumn] Then
- $iend = $imid - 1
- Else
- $istart = $imid + 1
- EndIf
- $imid = Int(($iend + $istart) / 2)
- WEnd
- If $istart > $iend Then Return SetError(3, 0, -1)
- Case Else
- Return SetError(5, 0, -1)
- EndSwitch
- Return $imid
- EndFunc
- Func _arraycoldelete(ByRef $aarray, $icolumn, $bconvert = False)
- If $bconvert = Default Then $bconvert = False
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray, $ubound_rows)
- If UBound($aarray, $ubound_dimensions) <> 2 Then Return SetError(2, 0, -1)
- Local $idim_2 = UBound($aarray, $ubound_columns)
- Switch $idim_2
- Case 2
- If $icolumn < 0 OR $icolumn > 1 Then Return SetError(3, 0, -1)
- If $bconvert Then
- Local $atemparray[$idim_1]
- For $i = 0 To $idim_1 - 1
- $atemparray[$i] = $aarray[$i][(NOT $icolumn)]
- Next
- $aarray = $atemparray
- Else
- ContinueCase
- EndIf
- Case Else
- If $icolumn < 0 OR $icolumn > $idim_2 - 1 Then Return SetError(3, 0, -1)
- For $i = 0 To $idim_1 - 1
- For $j = $icolumn To $idim_2 - 2
- $aarray[$i][$j] = $aarray[$i][$j + 1]
- Next
- Next
- ReDim $aarray[$idim_1][$idim_2 - 1]
- EndSwitch
- Return UBound($aarray, $ubound_columns)
- EndFunc
- Func _arraycolinsert(ByRef $aarray, $icolumn)
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray, $ubound_rows)
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- Local $atemparray[$idim_1][2]
- Switch $icolumn
- Case 0, 1
- For $i = 0 To $idim_1 - 1
- $atemparray[$i][(NOT $icolumn)] = $aarray[$i]
- Next
- Case Else
- Return SetError(3, 0, -1)
- EndSwitch
- $aarray = $atemparray
- Case 2
- Local $idim_2 = UBound($aarray, $ubound_columns)
- If $icolumn < 0 OR $icolumn > $idim_2 Then Return SetError(3, 0, -1)
- ReDim $aarray[$idim_1][$idim_2 + 1]
- For $i = 0 To $idim_1 - 1
- For $j = $idim_2 To $icolumn + 1 Step -1
- $aarray[$i][$j] = $aarray[$i][$j - 1]
- Next
- $aarray[$i][$icolumn] = ""
- Next
- Case Else
- Return SetError(2, 0, -1)
- EndSwitch
- Return UBound($aarray, $ubound_columns)
- EndFunc
- Func _arraycombinations(Const ByRef $aarray, $iset, $sdelimiter = "")
- If $sdelimiter = Default Then $sdelimiter = ""
- If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
- If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError(2, 0, 0)
- Local $in = UBound($aarray)
- Local $ir = $iset
- Local $aidx[$ir]
- For $i = 0 To $ir - 1
- $aidx[$i] = $i
- Next
- Local $itotal = __array_combinations($in, $ir)
- Local $ileft = $itotal
- Local $aresult[$itotal + 1]
- $aresult[0] = $itotal
- Local $icount = 1
- While $ileft > 0
- __array_getnext($in, $ir, $ileft, $itotal, $aidx)
- For $i = 0 To $iset - 1
- $aresult[$icount] &= $aarray[$aidx[$i]] & $sdelimiter
- Next
- If $sdelimiter <> "" Then $aresult[$icount] = StringTrimRight($aresult[$icount], 1)
- $icount += 1
- WEnd
- Return $aresult
- EndFunc
- Func _arrayconcatenate(ByRef $aarraytarget, Const ByRef $aarraysource, $istart = 0)
- If $istart = Default Then $istart = 0
- If NOT IsArray($aarraytarget) Then Return SetError(1, 0, -1)
- If NOT IsArray($aarraysource) Then Return SetError(2, 0, -1)
- Local $idim_total_tgt = UBound($aarraytarget, $ubound_dimensions)
- Local $idim_total_src = UBound($aarraysource, $ubound_dimensions)
- Local $idim_1_tgt = UBound($aarraytarget, $ubound_rows)
- Local $idim_1_src = UBound($aarraysource, $ubound_rows)
- If $istart < 0 OR $istart > $idim_1_src - 1 Then Return SetError(6, 0, -1)
- Switch $idim_total_tgt
- Case 1
- If $idim_total_src <> 1 Then Return SetError(4, 0, -1)
- ReDim $aarraytarget[$idim_1_tgt + $idim_1_src - $istart]
- For $i = $istart To $idim_1_src - 1
- $aarraytarget[$idim_1_tgt + $i - $istart] = $aarraysource[$i]
- Next
- Case 2
- If $idim_total_src <> 2 Then Return SetError(4, 0, -1)
- Local $idim_2_tgt = UBound($aarraytarget, $ubound_columns)
- If UBound($aarraysource, $ubound_columns) <> $idim_2_tgt Then Return SetError(5, 0, -1)
- ReDim $aarraytarget[$idim_1_tgt + $idim_1_src - $istart][$idim_2_tgt]
- For $i = $istart To $idim_1_src - 1
- For $j = 0 To $idim_2_tgt - 1
- $aarraytarget[$idim_1_tgt + $i - $istart][$j] = $aarraysource[$i][$j]
- Next
- Next
- Case Else
- Return SetError(3, 0, -1)
- EndSwitch
- Return UBound($aarraytarget, $ubound_rows)
- EndFunc
- Func _arraydelete(ByRef $aarray, $vrange)
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray, $ubound_rows) - 1
- If IsArray($vrange) Then
- If UBound($vrange, $ubound_dimensions) <> 1 OR UBound($vrange, $ubound_rows) < 2 Then Return SetError(4, 0, -1)
- Else
- Local $inumber, $asplit_1, $asplit_2
- $vrange = StringStripWS($vrange, 8)
- $asplit_1 = StringSplit($vrange, ";")
- $vrange = ""
- For $i = 1 To $asplit_1[0]
- If NOT StringRegExp($asplit_1[$i], "^\d+(-\d+)?$") Then Return SetError(3, 0, -1)
- $asplit_2 = StringSplit($asplit_1[$i], "-")
- Switch $asplit_2[0]
- Case 1
- $vrange &= $asplit_2[1] & ";"
- Case 2
- If Number($asplit_2[2]) >= Number($asplit_2[1]) Then
- $inumber = $asplit_2[1] - 1
- Do
- $inumber += 1
- $vrange &= $inumber & ";"
- Until $inumber = $asplit_2[2]
- EndIf
- EndSwitch
- Next
- $vrange = StringSplit(StringTrimRight($vrange, 1), ";")
- EndIf
- If $vrange[1] < 0 OR $vrange[$vrange[0]] > $idim_1 Then Return SetError(5, 0, -1)
- Local $icopyto_index = 0
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- For $i = 1 To $vrange[0]
- $aarray[$vrange[$i]] = ChrW(64177)
- Next
- For $ireadfrom_index = 0 To $idim_1
- If $aarray[$ireadfrom_index] == ChrW(64177) Then
- ContinueLoop
- Else
- If $ireadfrom_index <> $icopyto_index Then
- $aarray[$icopyto_index] = $aarray[$ireadfrom_index]
- EndIf
- $icopyto_index += 1
- EndIf
- Next
- ReDim $aarray[$idim_1 - $vrange[0] + 1]
- Case 2
- Local $idim_2 = UBound($aarray, $ubound_columns) - 1
- For $i = 1 To $vrange[0]
- $aarray[$vrange[$i]][0] = ChrW(64177)
- Next
- For $ireadfrom_index = 0 To $idim_1
- If $aarray[$ireadfrom_index][0] == ChrW(64177) Then
- ContinueLoop
- Else
- If $ireadfrom_index <> $icopyto_index Then
- For $j = 0 To $idim_2
- $aarray[$icopyto_index][$j] = $aarray[$ireadfrom_index][$j]
- Next
- EndIf
- $icopyto_index += 1
- EndIf
- Next
- ReDim $aarray[$idim_1 - $vrange[0] + 1][$idim_2 + 1]
- Case Else
- Return SetError(2, 0, False)
- EndSwitch
- Return UBound($aarray, $ubound_rows)
- EndFunc
- 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)
- If $stitle = Default Then $stitle = "ArrayDisplay"
- If $sarrayrange = Default Then $sarrayrange = ""
- If $iflags = Default Then $iflags = 0
- If $vuser_separator = Default Then $vuser_separator = ""
- If $sheader = Default Then $sheader = ""
- If $imax_colwidth = Default Then $imax_colwidth = 350
- If $ialt_color = Default Then $ialt_color = 0
- If $huser_function = Default Then $huser_function = 0
- Local $itranspose = BitAND($iflags, 1)
- Local $icolalign = BitAND($iflags, 6)
- Local $iverbose = BitAND($iflags, 8)
- Local $ibuttonmargin = ((BitAND($iflags, 32)) ? (0) : ((BitAND($iflags, 16)) ? (20) : (40)))
- Local $inorow = BitAND($iflags, 64)
- Local $smsg = "", $iret = 1
- If IsArray($aarray) Then
- Local $idimension = UBound($aarray, $ubound_dimensions), $irowcount = UBound($aarray, $ubound_rows), $icolcount = UBound($aarray, $ubound_columns)
- If $idimension > 2 Then
- $smsg = "Larger than 2D array passed to function"
- $iret = 2
- EndIf
- Else
- $smsg = "No array variable passed to function"
- EndIf
- If $smsg Then
- If $iverbose AND MsgBox($mb_systemmodal + $mb_iconerror + $mb_yesno, "ArrayDisplay Error: " & $stitle, $smsg & @CRLF & @CRLF & "Exit the script?") = $idyes Then
- Exit
- Else
- Return SetError($iret, 0, "")
- EndIf
- EndIf
- Local $icw_colwidth = Number($vuser_separator)
- Local $sad_separator = ChrW(64177)
- Local $scurr_separator = Opt("GUIDataSeparatorChar", $sad_separator)
- If $vuser_separator = "" Then $vuser_separator = $scurr_separator
- Local $vtmp, $irowlimit = 65525, $icollimit = 250
- Local $idatarow = $irowcount
- Local $idatacol = $icolcount
- Local $iitem_start = 0, $iitem_end = $irowcount - 1, $isubitem_start = 0, $isubitem_end = (($idimension = 2) ? ($icolcount - 1) : (0))
- Local $brange_flag = False, $avrangesplit
- If $sarrayrange Then
- Local $aarray_range = StringRegExp($sarrayrange & "||", "(?U)(.*)\|", 3)
- If $aarray_range[0] Then
- $avrangesplit = StringSplit($aarray_range[0], ":")
- If @error Then
- $iitem_end = Number($avrangesplit[1])
- Else
- $iitem_start = Number($avrangesplit[1])
- $iitem_end = Number($avrangesplit[2])
- EndIf
- EndIf
- If $iitem_start > $iitem_end Then
- $vtmp = $iitem_start
- $iitem_start = $iitem_end
- $iitem_end = $vtmp
- EndIf
- If $iitem_start < 0 Then $iitem_start = 0
- If $iitem_end > $irowcount - 1 Then $iitem_end = $irowcount - 1
- If $iitem_start <> 0 OR $iitem_end <> $irowcount - 1 Then $brange_flag = True
- If $idimension = 2 AND $aarray_range[1] Then
- $avrangesplit = StringSplit($aarray_range[1], ":")
- If @error Then
- $isubitem_end = Number($avrangesplit[1])
- Else
- $isubitem_start = Number($avrangesplit[1])
- $isubitem_end = Number($avrangesplit[2])
- EndIf
- If $isubitem_start > $isubitem_end Then
- $vtmp = $isubitem_start
- $isubitem_start = $isubitem_end
- $isubitem_end = $vtmp
- EndIf
- If $isubitem_start < 0 Then $isubitem_start = 0
- If $isubitem_end > $icolcount - 1 Then $isubitem_end = $icolcount - 1
- If $isubitem_start <> 0 OR $isubitem_end <> $icolcount - 1 Then $brange_flag = True
- EndIf
- EndIf
- Local $sdisplaydata = "[" & $idatarow
- Local $btruncated = False
- If $itranspose Then
- If $iitem_end - $iitem_start > $icollimit Then
- $btruncated = True
- $iitem_end = $iitem_start + $icollimit - 1
- EndIf
- Else
- If $iitem_end - $iitem_start > $irowlimit Then
- $btruncated = True
- $iitem_end = $iitem_start + $irowlimit - 1
- EndIf
- EndIf
- If $btruncated Then
- $sdisplaydata &= "*]"
- Else
- $sdisplaydata &= "]"
- EndIf
- If $idimension = 2 Then
- $sdisplaydata &= " [" & $idatacol
- If $itranspose Then
- If $isubitem_end - $isubitem_start > $irowlimit Then
- $btruncated = True
- $isubitem_end = $isubitem_start + $irowlimit - 1
- EndIf
- Else
- If $isubitem_end - $isubitem_start > $icollimit Then
- $btruncated = True
- $isubitem_end = $isubitem_start + $icollimit - 1
- EndIf
- EndIf
- If $btruncated Then
- $sdisplaydata &= "*]"
- Else
- $sdisplaydata &= "]"
- EndIf
- EndIf
- Local $stipdata = ""
- If $btruncated Then $stipdata &= "Truncated"
- If $brange_flag Then
- If $stipdata Then $stipdata &= " - "
- $stipdata &= "Range set"
- EndIf
- If $itranspose Then
- If $stipdata Then $stipdata &= " - "
- $stipdata &= "Transposed"
- EndIf
- Local $asheader = StringSplit($sheader, $scurr_separator, $str_nocount)
- If UBound($asheader) = 0 Then Local $asheader[1] = [""]
- $sheader = "Row"
- Local $iindex = $isubitem_start
- If $itranspose Then
- For $j = $iitem_start To $iitem_end
- $sheader &= $sad_separator & "Col " & $j
- Next
- Else
- If $asheader[0] Then
- For $iindex = $isubitem_start To $isubitem_end
- If $iindex >= UBound($asheader) Then ExitLoop
- $sheader &= $sad_separator & $asheader[$iindex]
- Next
- EndIf
- For $j = $iindex To $isubitem_end
- $sheader &= $sad_separator & "Col " & $j
- Next
- EndIf
- If $inorow Then $sheader = StringTrimLeft($sheader, 4)
- If $iverbose AND ($iitem_end - $iitem_start + 1) * ($isubitem_end - $isubitem_start + 1) > 10000 Then
- SplashTextOn("ArrayDisplay", "Preparing display" & @CRLF & @CRLF & "Please be patient", 300, 100)
- EndIf
- Local $ibuffer = 4094
- If $itranspose Then
- $vtmp = $iitem_start
- $iitem_start = $isubitem_start
- $isubitem_start = $vtmp
- $vtmp = $iitem_end
- $iitem_end = $isubitem_end
- $isubitem_end = $vtmp
- EndIf
- Local $avarraytext[$iitem_end - $iitem_start + 1]
- For $i = $iitem_start To $iitem_end
- If NOT $inorow Then $avarraytext[$i - $iitem_start] = "[" & $i & "]"
- For $j = $isubitem_start To $isubitem_end
- If $idimension = 1 Then
- If $itranspose Then
- Switch VarGetType($aarray[$j])
- Case "Array"
- $vtmp = "{Array}"
- Case Else
- $vtmp = $aarray[$j]
- EndSwitch
- Else
- Switch VarGetType($aarray[$i])
- Case "Array"
- $vtmp = "{Array}"
- Case Else
- $vtmp = $aarray[$i]
- EndSwitch
- EndIf
- Else
- If $itranspose Then
- Switch VarGetType($aarray[$j][$i])
- Case "Array"
- $vtmp = "{Array}"
- Case Else
- $vtmp = $aarray[$j][$i]
- EndSwitch
- Else
- Switch VarGetType($aarray[$i][$j])
- Case "Array"
- $vtmp = "{Array}"
- Case Else
- $vtmp = $aarray[$i][$j]
- EndSwitch
- EndIf
- EndIf
- If StringLen($vtmp) > $ibuffer Then $vtmp = StringLeft($vtmp, $ibuffer)
- $avarraytext[$i - $iitem_start] &= $sad_separator & $vtmp
- Next
- If $inorow Then $avarraytext[$i - $iitem_start] = StringTrimLeft($avarraytext[$i - $iitem_start], 1)
- Next
- Local Const $_arrayconstant_gui_dockbottom = 64
- Local Const $_arrayconstant_gui_dockborders = 102
- Local Const $_arrayconstant_gui_dockheight = 512
- Local Const $_arrayconstant_gui_dockleft = 2
- Local Const $_arrayconstant_gui_dockright = 4
- Local Const $_arrayconstant_gui_dockhcenter = 8
- Local Const $_arrayconstant_gui_event_close = -3
- Local Const $_arrayconstant_gui_focus = 256
- Local Const $_arrayconstant_gui_bkcolor_lv_alternate = -33554432
- Local Const $_arrayconstant_ss_center = 1
- Local Const $_arrayconstant_ss_centerimage = 512
- Local Const $_arrayconstant_lvm_getitemcount = (4096 + 4)
- Local Const $_arrayconstant_lvm_getitemrect = (4096 + 14)
- Local Const $_arrayconstant_lvm_getcolumnwidth = (4096 + 29)
- Local Const $_arrayconstant_lvm_setcolumnwidth = (4096 + 30)
- Local Const $_arrayconstant_lvm_getitemstate = (4096 + 44)
- Local Const $_arrayconstant_lvm_getselectedcount = (4096 + 50)
- Local Const $_arrayconstant_lvm_setextendedlistviewstyle = (4096 + 54)
- Local Const $_arrayconstant_lvs_ex_gridlines = 1
- Local Const $_arrayconstant_lvis_selected = 2
- Local Const $_arrayconstant_lvs_showselalways = 8
- Local Const $_arrayconstant_lvs_ex_fullrowselect = 32
- Local Const $_arrayconstant_ws_ex_clientedge = 512
- Local Const $_arrayconstant_ws_maximizebox = 65536
- Local Const $_arrayconstant_ws_minimizebox = 131072
- Local Const $_arrayconstant_ws_sizebox = 262144
- Local Const $_arrayconstant_wm_setredraw = 11
- Local Const $_arrayconstant_lvscw_autosize = -1
- Local $icoordmode = Opt("GUICoordMode", 1)
- Local $iorgwidth = 210, $iheight = 200, $iminsize = 250
- Local $hgui = GUICreate($stitle, $iorgwidth, $iheight, Default, Default, BitOR($_arrayconstant_ws_sizebox, $_arrayconstant_ws_minimizebox, $_arrayconstant_ws_maximizebox))
- Local $aiguisize = WinGetClientSize($hgui)
- Local $ibuttonwidth_2 = $aiguisize[0] / 2
- Local $ibuttonwidth_3 = $aiguisize[0] / 3
- Local $idlistview = GUICtrlCreateListView($sheader, 0, 0, $aiguisize[0], $aiguisize[1] - $ibuttonmargin, $_arrayconstant_lvs_showselalways)
- GUICtrlSetBkColor($idlistview, $_arrayconstant_gui_bkcolor_lv_alternate)
- GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_lvs_ex_gridlines, $_arrayconstant_lvs_ex_gridlines)
- GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_lvs_ex_fullrowselect, $_arrayconstant_lvs_ex_fullrowselect)
- GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_ws_ex_clientedge, $_arrayconstant_ws_ex_clientedge)
- Local $idcopy_id = 9999, $idcopy_data = 99999, $iddata_label = 99999, $iduser_func = 99999, $idexit_script = 99999
- If $ibuttonmargin Then
- $idcopy_id = GUICtrlCreateButton("Copy Data && Hdr/Row", 0, $aiguisize[1] - $ibuttonmargin, $ibuttonwidth_2, 20)
- $idcopy_data = GUICtrlCreateButton("Copy Data Only", $ibuttonwidth_2, $aiguisize[1] - $ibuttonmargin, $ibuttonwidth_2, 20)
- If $ibuttonmargin = 40 Then
- Local $ibuttonwidth_var = $ibuttonwidth_2
- Local $ioffset = $ibuttonwidth_2
- If IsFunc($huser_function) Then
- $iduser_func = GUICtrlCreateButton("Run User Func", $ibuttonwidth_3, $aiguisize[1] - 20, $ibuttonwidth_3, 20)
- $ibuttonwidth_var = $ibuttonwidth_3
- $ioffset = $ibuttonwidth_3 * 2
- EndIf
- $idexit_script = GUICtrlCreateButton("Exit Script", $ioffset, $aiguisize[1] - 20, $ibuttonwidth_var, 20)
- $iddata_label = GUICtrlCreateLabel($sdisplaydata, 0, $aiguisize[1] - 20, $ibuttonwidth_var, 18, BitOR($_arrayconstant_ss_center, $_arrayconstant_ss_centerimage))
- Select
- Case $btruncated OR $itranspose OR $brange_flag
- GUICtrlSetColor($iddata_label, 16711680)
- GUICtrlSetTip($iddata_label, $stipdata)
- EndSelect
- EndIf
- EndIf
- GUICtrlSetResizing($idlistview, $_arrayconstant_gui_dockborders)
- GUICtrlSetResizing($idcopy_id, $_arrayconstant_gui_dockleft + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
- GUICtrlSetResizing($idcopy_data, $_arrayconstant_gui_dockright + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
- GUICtrlSetResizing($iddata_label, $_arrayconstant_gui_dockleft + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
- GUICtrlSetResizing($iduser_func, $_arrayconstant_gui_dockhcenter + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
- GUICtrlSetResizing($idexit_script, $_arrayconstant_gui_dockright + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
- GUICtrlSendMsg($idlistview, $_arrayconstant_wm_setredraw, 0, 0)
- Local $iditem
- For $i = 0 To UBound($avarraytext) - 1
- $iditem = GUICtrlCreateListViewItem($avarraytext[$i], $idlistview)
- If $ialt_color Then
- GUICtrlSetBkColor($iditem, $ialt_color)
- EndIf
- Next
- If $icolalign Then
- Local Const $_arrayconstant_lvcf_fmt = 1
- Local Const $_arrayconstant_lvm_setcolumnw = (4096 + 96)
- 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")
- DllStructSetData($tcolumn, "Mask", $_arrayconstant_lvcf_fmt)
- DllStructSetData($tcolumn, "Fmt", $icolalign / 2)
- Local $pcolumn = DllStructGetPtr($tcolumn)
- For $i = 1 To $isubitem_end - $isubitem_start + 1
- GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnw, $i, $pcolumn)
- Next
- EndIf
- GUICtrlSendMsg($idlistview, $_arrayconstant_wm_setredraw, 1, 0)
- Local $iborder = 45
- If UBound($avarraytext) > 20 Then
- $iborder += 20
- EndIf
- Local $iwidth = $iborder, $icolwidth = 0, $aicolwidth[$isubitem_end - $isubitem_start + 2], $imin_colwidth = 55
- For $i = 0 To $isubitem_end - $isubitem_start + 1
- GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnwidth, $i, $_arrayconstant_lvscw_autosize)
- $icolwidth = GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getcolumnwidth, $i, 0)
- If $icolwidth < $imin_colwidth Then
- GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnwidth, $i, $imin_colwidth)
- $icolwidth = $imin_colwidth
- EndIf
- $iwidth += $icolwidth
- $aicolwidth[$i] = $icolwidth
- Next
- If $inorow Then $iwidth -= 55
- If $iwidth > @DesktopWidth - 100 Then
- $iwidth = $iborder
- For $i = 0 To $isubitem_end - $isubitem_start + 1
- If $aicolwidth[$i] > $imax_colwidth Then
- GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnwidth, $i, $imax_colwidth)
- $iwidth += $imax_colwidth
- Else
- $iwidth += $aicolwidth[$i]
- EndIf
- Next
- EndIf
- If $iwidth > @DesktopWidth - 100 Then
- $iwidth = @DesktopWidth - 100
- ElseIf $iwidth < $iminsize Then
- $iwidth = $iminsize
- EndIf
- Local $trect = DllStructCreate("struct; long Left;long Top;long Right;long Bottom; endstruct")
- DllCall("user32.dll", "struct*", "SendMessageW", "hwnd", GUICtrlGetHandle($idlistview), "uint", $_arrayconstant_lvm_getitemrect, "wparam", 0, "struct*", $trect)
- Local $aiwin_pos = WinGetPos($hgui)
- Local $ailv_pos = ControlGetPos($hgui, "", $idlistview)
- $iheight = ((UBound($avarraytext) + 2) * (DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top"))) + $aiwin_pos[3] - $ailv_pos[3]
- If $iheight > @DesktopHeight - 100 Then
- $iheight = @DesktopHeight - 100
- ElseIf $iheight < $iminsize Then
- $iheight = $iminsize
- EndIf
- If $iverbose Then SplashOff()
- GUISetState(@SW_HIDE, $hgui)
- WinMove($hgui, "", (@DesktopWidth - $iwidth) / 2, (@DesktopHeight - $iheight) / 2, $iwidth, $iheight)
- GUISetState(@SW_SHOW, $hgui)
- Local $ioneventmode = Opt("GUIOnEventMode", 0), $imsg
- While 1
- $imsg = GUIGetMsg()
- Switch $imsg
- Case $_arrayconstant_gui_event_close
- ExitLoop
- Case $idcopy_id, $idcopy_data
- Local $isel_count = GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getselectedcount, 0, 0)
- If $iverbose AND (NOT $isel_count) AND ($iitem_end - $iitem_start) * ($isubitem_end - $isubitem_start) > 10000 Then
- SplashTextOn("ArrayDisplay", "Copying data" & @CRLF & @CRLF & "Please be patient", 300, 100)
- EndIf
- Local $sclip = "", $sitem, $asplit
- For $i = 0 To $iitem_end - $iitem_start
- If $isel_count AND NOT (GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getitemstate, $i, $_arrayconstant_lvis_selected)) Then
- ContinueLoop
- EndIf
- $sitem = $avarraytext[$i]
- If $imsg = $idcopy_data Then
- $sitem = StringRegExpReplace($sitem, "^\[\d+\].(.*)$", "$1")
- EndIf
- If $icw_colwidth Then
- $asplit = StringSplit($sitem, $sad_separator)
- $sitem = ""
- For $j = 1 To $asplit[0]
- $sitem &= StringFormat("%-" & $icw_colwidth + 1 & "s", StringLeft($asplit[$j], $icw_colwidth))
- Next
- Else
- $sitem = StringReplace($sitem, $sad_separator, $vuser_separator)
- EndIf
- $sclip &= $sitem & @CRLF
- Next
- If $imsg = $idcopy_id Then
- If $icw_colwidth Then
- $asplit = StringSplit($sheader, $sad_separator)
- $sitem = ""
- For $j = 1 To $asplit[0]
- $sitem &= StringFormat("%-" & $icw_colwidth + 1 & "s", StringLeft($asplit[$j], $icw_colwidth))
- Next
- Else
- $sitem = StringReplace($sheader, $sad_separator, $vuser_separator)
- EndIf
- $sclip = $sitem & @CRLF & $sclip
- EndIf
- ClipPut($sclip)
- SplashOff()
- GUICtrlSetState($idlistview, $_arrayconstant_gui_focus)
- Case $iduser_func
- Local $aiselitems[$irowlimit] = [0]
- For $i = 0 To GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getitemcount, 0, 0)
- If GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getitemstate, $i, $_arrayconstant_lvis_selected) Then
- $aiselitems[0] += 1
- $aiselitems[$aiselitems[0]] = $i + $iitem_start
- EndIf
- Next
- ReDim $aiselitems[$aiselitems[0] + 1]
- $huser_function($aarray, $aiselitems)
- GUICtrlSetState($idlistview, $_arrayconstant_gui_focus)
- Case $idexit_script
- GUIDelete($hgui)
- Exit
- EndSwitch
- WEnd
- GUIDelete($hgui)
- Opt("GUICoordMode", $icoordmode)
- Opt("GUIOnEventMode", $ioneventmode)
- Opt("GUIDataSeparatorChar", $scurr_separator)
- Return 1
- EndFunc
- Func _arrayextract(Const ByRef $aarray, $istart_row = -1, $iend_row = -1, $istart_col = -1, $iend_col = -1)
- If $istart_row = Default Then $istart_row = -1
- If $iend_row = Default Then $iend_row = -1
- If $istart_col = Default Then $istart_col = -1
- If $iend_col = Default Then $iend_col = -1
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray, $ubound_rows) - 1
- If $iend_row = -1 Then $iend_row = $idim_1
- If $istart_row = -1 Then $istart_row = 0
- If $istart_row < -1 OR $iend_row < -1 Then Return SetError(3, 0, -1)
- If $istart_row > $idim_1 OR $iend_row > $idim_1 Then Return SetError(3, 0, -1)
- If $istart_row > $iend_row Then Return SetError(4, 0, -1)
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- Local $aretarray[$iend_row - $istart_row + 1]
- For $i = 0 To $iend_row - $istart_row
- $aretarray[$i] = $aarray[$i + $istart_row]
- Next
- Return $aretarray
- Case 2
- Local $idim_2 = UBound($aarray, $ubound_columns) - 1
- If $iend_col = -1 Then $iend_col = $idim_2
- If $istart_col = -1 Then $istart_col = 0
- If $istart_col < -1 OR $iend_col < -1 Then Return SetError(5, 0, -1)
- If $istart_col > $idim_2 OR $iend_col > $idim_2 Then Return SetError(5, 0, -1)
- If $istart_col > $iend_col Then Return SetError(6, 0, -1)
- If $istart_col = $iend_col Then
- Local $aretarray[$iend_row - $istart_row + 1]
- Else
- Local $aretarray[$iend_row - $istart_row + 1][$iend_col - $istart_col + 1]
- EndIf
- For $i = 0 To $iend_row - $istart_row
- For $j = 0 To $iend_col - $istart_col
- If $istart_col = $iend_col Then
- $aretarray[$i] = $aarray[$i + $istart_row][$j + $istart_col]
- Else
- $aretarray[$i][$j] = $aarray[$i + $istart_row][$j + $istart_col]
- EndIf
- Next
- Next
- Return $aretarray
- Case Else
- Return SetError(2, 0, -1)
- EndSwitch
- Return 1
- EndFunc
- Func _arrayfindall(Const ByRef $aarray, $vvalue, $istart = 0, $iend = 0, $icase = 0, $icompare = 0, $isubitem = 0, $brow = False)
- If $istart = Default Then $istart = 0
- If $iend = Default Then $iend = 0
- If $icase = Default Then $icase = 0
- If $icompare = Default Then $icompare = 0
- If $isubitem = Default Then $isubitem = 0
- If $brow = Default Then $brow = False
- $istart = _arraysearch($aarray, $vvalue, $istart, $iend, $icase, $icompare, 1, $isubitem, $brow)
- If @error Then Return SetError(@error, 0, -1)
- Local $iindex = 0, $avresult[UBound($aarray, ($brow ? $ubound_columns : $ubound_rows))]
- Do
- $avresult[$iindex] = $istart
- $iindex += 1
- $istart = _arraysearch($aarray, $vvalue, $istart + 1, $iend, $icase, $icompare, 1, $isubitem, $brow)
- Until @error
- ReDim $avresult[$iindex]
- Return $avresult
- EndFunc
- Func _arrayinsert(ByRef $aarray, $vrange, $vvalue = "", $istart = 0, $sdelim_item = "|", $sdelim_row = @CRLF, $iforce = $arrayfill_force_default)
- If $vvalue = Default Then $vvalue = ""
- If $istart = Default Then $istart = 0
- If $sdelim_item = Default Then $sdelim_item = "|"
- If $sdelim_row = Default Then $sdelim_row = @CRLF
- If $iforce = Default Then $iforce = $arrayfill_force_default
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray, $ubound_rows) - 1
- Local $hdatatype = 0
- Switch $iforce
- Case $arrayfill_force_int
- $hdatatype = Int
- Case $arrayfill_force_number
- $hdatatype = Number
- Case $arrayfill_force_ptr
- $hdatatype = Ptr
- Case $arrayfill_force_hwnd
- $hdatatype = HWnd
- Case $arrayfill_force_string
- $hdatatype = String
- EndSwitch
- Local $asplit_1, $asplit_2
- If IsArray($vrange) Then
- If UBound($vrange, $ubound_dimensions) <> 1 OR UBound($vrange, $ubound_rows) < 2 Then Return SetError(4, 0, -1)
- Else
- Local $inumber
- $vrange = StringStripWS($vrange, 8)
- $asplit_1 = StringSplit($vrange, ";")
- $vrange = ""
- For $i = 1 To $asplit_1[0]
- If NOT StringRegExp($asplit_1[$i], "^\d+(-\d+)?$") Then Return SetError(3, 0, -1)
- $asplit_2 = StringSplit($asplit_1[$i], "-")
- Switch $asplit_2[0]
- Case 1
- $vrange &= $asplit_2[1] & ";"
- Case 2
- If Number($asplit_2[2]) >= Number($asplit_2[1]) Then
- $inumber = $asplit_2[1] - 1
- Do
- $inumber += 1
- $vrange &= $inumber & ";"
- Until $inumber = $asplit_2[2]
- EndIf
- EndSwitch
- Next
- $vrange = StringSplit(StringTrimRight($vrange, 1), ";")
- EndIf
- If $vrange[1] < 0 OR $vrange[$vrange[0]] > $idim_1 Then Return SetError(5, 0, -1)
- For $i = 2 To $vrange[0]
- If $vrange[$i] < $vrange[$i - 1] Then Return SetError(3, 0, -1)
- Next
- Local $icopyto_index = $idim_1 + $vrange[0]
- Local $iinsertpoint_index = $vrange[0]
- Local $iinsert_index = $vrange[$iinsertpoint_index]
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- If $iforce = $arrayfill_force_singleitem Then
- ReDim $aarray[$idim_1 + $vrange[0] + 1]
- For $ireadfromindex = $idim_1 To 0 Step -1
- $aarray[$icopyto_index] = $aarray[$ireadfromindex]
- $icopyto_index -= 1
- $iinsert_index = $vrange[$iinsertpoint_index]
- While $ireadfromindex = $iinsert_index
- $aarray[$icopyto_index] = $vvalue
- $icopyto_index -= 1
- $iinsertpoint_index -= 1
- If $iinsertpoint_index < 1 Then ExitLoop 2
- $iinsert_index = $vrange[$iinsertpoint_index]
- WEnd
- Next
- Return $idim_1 + $vrange[0] + 1
- EndIf
- ReDim $aarray[$idim_1 + $vrange[0] + 1]
- If IsArray($vvalue) Then
- If UBound($vvalue, $ubound_dimensions) <> 1 Then Return SetError(5, 0, -1)
- $hdatatype = 0
- Else
- Local $atmp = StringSplit($vvalue, $sdelim_item, $str_nocount + $str_entiresplit)
- If UBound($atmp, $ubound_rows) = 1 Then
- $atmp[0] = $vvalue
- $hdatatype = 0
- EndIf
- $vvalue = $atmp
- EndIf
- For $ireadfromindex = $idim_1 To 0 Step -1
- $aarray[$icopyto_index] = $aarray[$ireadfromindex]
- $icopyto_index -= 1
- $iinsert_index = $vrange[$iinsertpoint_index]
- While $ireadfromindex = $iinsert_index
- If $iinsertpoint_index <= UBound($vvalue, $ubound_rows) Then
- If IsFunc($hdatatype) Then
- $aarray[$icopyto_index] = $hdatatype($vvalue[$iinsertpoint_index - 1])
- Else
- $aarray[$icopyto_index] = $vvalue[$iinsertpoint_index - 1]
- EndIf
- Else
- $aarray[$icopyto_index] = ""
- EndIf
- $icopyto_index -= 1
- $iinsertpoint_index -= 1
- If $iinsertpoint_index = 0 Then ExitLoop 2
- $iinsert_index = $vrange[$iinsertpoint_index]
- WEnd
- Next
- Case 2
- Local $idim_2 = UBound($aarray, $ubound_columns)
- If $istart < 0 OR $istart > $idim_2 - 1 Then Return SetError(6, 0, -1)
- Local $ivaldim_1, $ivaldim_2
- If IsArray($vvalue) Then
- If UBound($vvalue, $ubound_dimensions) <> 2 Then Return SetError(7, 0, -1)
- $ivaldim_1 = UBound($vvalue, $ubound_rows)
- $ivaldim_2 = UBound($vvalue, $ubound_columns)
- $hdatatype = 0
- Else
- $asplit_1 = StringSplit($vvalue, $sdelim_row, $str_nocount + $str_entiresplit)
- $ivaldim_1 = UBound($asplit_1, $ubound_rows)
- StringReplace($asplit_1[0], $sdelim_item, "")
- $ivaldim_2 = @extended + 1
- Local $atmp[$ivaldim_1][$ivaldim_2]
- For $i = 0 To $ivaldim_1 - 1
- $asplit_2 = StringSplit($asplit_1[$i], $sdelim_item, $str_nocount + $str_entiresplit)
- For $j = 0 To $ivaldim_2 - 1
- $atmp[$i][$j] = $asplit_2[$j]
- Next
- Next
- $vvalue = $atmp
- EndIf
- If UBound($vvalue, $ubound_columns) + $istart > UBound($aarray, $ubound_columns) Then Return SetError(8, 0, -1)
- ReDim $aarray[$idim_1 + $vrange[0] + 1][$idim_2]
- For $ireadfromindex = $idim_1 To 0 Step -1
- For $j = 0 To $idim_2 - 1
- $aarray[$icopyto_index][$j] = $aarray[$ireadfromindex][$j]
- Next
- $icopyto_index -= 1
- $iinsert_index = $vrange[$iinsertpoint_index]
- While $ireadfromindex = $iinsert_index
- For $j = 0 To $idim_2 - 1
- If $j < $istart Then
- $aarray[$icopyto_index][$j] = ""
- ElseIf $j - $istart > $ivaldim_2 - 1 Then
- $aarray[$icopyto_index][$j] = ""
- Else
- If $iinsertpoint_index - 1 < $ivaldim_1 Then
- If IsFunc($hdatatype) Then
- $aarray[$icopyto_index][$j] = $hdatatype($vvalue[$iinsertpoint_index - 1][$j - $istart])
- Else
- $aarray[$icopyto_index][$j] = $vvalue[$iinsertpoint_index - 1][$j - $istart]
- EndIf
- Else
- $aarray[$icopyto_index][$j] = ""
- EndIf
- EndIf
- Next
- $icopyto_index -= 1
- $iinsertpoint_index -= 1
- If $iinsertpoint_index = 0 Then ExitLoop 2
- $iinsert_index = $vrange[$iinsertpoint_index]
- WEnd
- Next
- Case Else
- Return SetError(2, 0, -1)
- EndSwitch
- Return UBound($aarray, $ubound_rows)
- EndFunc
- Func _arraymax(Const ByRef $aarray, $icompnumeric = 0, $istart = -1, $iend = -1, $isubitem = 0)
- Local $iresult = _arraymaxindex($aarray, $icompnumeric, $istart, $iend, $isubitem)
- If @error Then Return SetError(@error, 0, "")
- If UBound($aarray, $ubound_dimensions) = 1 Then
- Return $aarray[$iresult]
- Else
- Return $aarray[$iresult][$isubitem]
- EndIf
- EndFunc
- Func _arraymaxindex(Const ByRef $aarray, $icompnumeric = 0, $istart = -1, $iend = -1, $isubitem = 0)
- If $icompnumeric = Default Then $icompnumeric = 0
- If $istart = Default Then $istart = -1
- If $iend = Default Then $iend = -1
- If $isubitem = Default Then $isubitem = 0
- Local $iret = __array_minmaxindex($aarray, $icompnumeric, $istart, $iend, $isubitem, __array_greaterthan)
- Return SetError(@error, 0, $iret)
- EndFunc
- Func _arraymin(Const ByRef $aarray, $icompnumeric = 0, $istart = -1, $iend = -1, $isubitem = 0)
- Local $iresult = _arrayminindex($aarray, $icompnumeric, $istart, $iend, $isubitem)
- If @error Then Return SetError(@error, 0, "")
- If UBound($aarray, $ubound_dimensions) = 1 Then
- Return $aarray[$iresult]
- Else
- Return $aarray[$iresult][$isubitem]
- EndIf
- EndFunc
- Func _arrayminindex(Const ByRef $aarray, $icompnumeric = 0, $istart = -1, $iend = -1, $isubitem = 0)
- If $icompnumeric = Default Then $icompnumeric = 0
- If $istart = Default Then $istart = -1
- If $iend = Default Then $iend = -1
- If $isubitem = Default Then $isubitem = 0
- Local $iret = __array_minmaxindex($aarray, $icompnumeric, $istart, $iend, $isubitem, __array_lessthan)
- Return SetError(@error, 0, $iret)
- EndFunc
- Func _arraypermute(ByRef $aarray, $sdelimiter = "")
- If $sdelimiter = Default Then $sdelimiter = ""
- If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
- If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError(2, 0, 0)
- Local $isize = UBound($aarray), $ifactorial = 1, $aidx[$isize], $aresult[1], $icount = 1
- If UBound($aarray) Then
- For $i = 0 To $isize - 1
- $aidx[$i] = $i
- Next
- For $i = $isize To 1 Step -1
- $ifactorial *= $i
- Next
- ReDim $aresult[$ifactorial + 1]
- $aresult[0] = $ifactorial
- __array_exeterinternal($aarray, 0, $isize, $sdelimiter, $aidx, $aresult, $icount)
- Else
- $aresult[0] = 0
- EndIf
- Return $aresult
- EndFunc
- Func _arraypop(ByRef $aarray)
- If (NOT IsArray($aarray)) Then Return SetError(1, 0, "")
- If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError(2, 0, "")
- Local $iubound = UBound($aarray) - 1
- If $iubound = -1 Then Return SetError(3, 0, "")
- Local $slastval = $aarray[$iubound]
- If $iubound > -1 Then
- ReDim $aarray[$iubound]
- EndIf
- Return $slastval
- EndFunc
- Func _arraypush(ByRef $aarray, $vvalue, $idirection = 0)
- If $idirection = Default Then $idirection = 0
- If (NOT IsArray($aarray)) Then Return SetError(1, 0, 0)
- If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError(3, 0, 0)
- Local $iubound = UBound($aarray) - 1
- If IsArray($vvalue) Then
- Local $iubounds = UBound($vvalue)
- If ($iubounds - 1) > $iubound Then Return SetError(2, 0, 0)
- If $idirection Then
- For $i = $iubound To $iubounds Step -1
- $aarray[$i] = $aarray[$i - $iubounds]
- Next
- For $i = 0 To $iubounds - 1
- $aarray[$i] = $vvalue[$i]
- Next
- Else
- For $i = 0 To $iubound - $iubounds
- $aarray[$i] = $aarray[$i + $iubounds]
- Next
- For $i = 0 To $iubounds - 1
- $aarray[$i + $iubound - $iubounds + 1] = $vvalue[$i]
- Next
- EndIf
- Else
- If $iubound > -1 Then
- If $idirection Then
- For $i = $iubound To 1 Step -1
- $aarray[$i] = $aarray[$i - 1]
- Next
- $aarray[0] = $vvalue
- Else
- For $i = 0 To $iubound - 1
- $aarray[$i] = $aarray[$i + 1]
- Next
- $aarray[$iubound] = $vvalue
- EndIf
- EndIf
- EndIf
- Return 1
- EndFunc
- Func _arrayreverse(ByRef $aarray, $istart = 0, $iend = 0)
- If $istart = Default Then $istart = 0
- If $iend = Default Then $iend = 0
- If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
- If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError(3, 0, 0)
- If NOT UBound($aarray) Then Return SetError(4, 0, 0)
- Local $vtmp, $iubound = UBound($aarray) - 1
- If $iend < 1 OR $iend > $iubound Then $iend = $iubound
- If $istart < 0 Then $istart = 0
- If $istart > $iend Then Return SetError(2, 0, 0)
- For $i = $istart To Int(($istart + $iend - 1) / 2)
- $vtmp = $aarray[$i]
- $aarray[$i] = $aarray[$iend]
- $aarray[$iend] = $vtmp
- $iend -= 1
- Next
- Return 1
- EndFunc
- Func _arraysearch(Const ByRef $aarray, $vvalue, $istart = 0, $iend = 0, $icase = 0, $icompare = 0, $iforward = 1, $isubitem = -1, $brow = False)
- If $istart = Default Then $istart = 0
- If $iend = Default Then $iend = 0
- If $icase = Default Then $icase = 0
- If $icompare = Default Then $icompare = 0
- If $iforward = Default Then $iforward = 1
- If $isubitem = Default Then $isubitem = -1
- If $brow = Default Then $brow = False
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray) - 1
- If $idim_1 = -1 Then Return SetError(3, 0, -1)
- Local $idim_2 = UBound($aarray, $ubound_columns) - 1
- Local $bcomptype = False
- If $icompare = 2 Then
- $icompare = 0
- $bcomptype = True
- EndIf
- If $brow Then
- If UBound($aarray, $ubound_dimensions) = 1 Then Return SetError(5, 0, -1)
- If $iend < 1 OR $iend > $idim_2 Then $iend = $idim_2
- If $istart < 0 Then $istart = 0
- If $istart > $iend Then Return SetError(4, 0, -1)
- Else
- If $iend < 1 OR $iend > $idim_1 Then $iend = $idim_1
- If $istart < 0 Then $istart = 0
- If $istart > $iend Then Return SetError(4, 0, -1)
- EndIf
- Local $istep = 1
- If NOT $iforward Then
- Local $itmp = $istart
- $istart = $iend
- $iend = $itmp
- $istep = -1
- EndIf
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- If NOT $icompare Then
- If NOT $icase Then
- For $i = $istart To $iend Step $istep
- If $bcomptype AND VarGetType($aarray[$i]) <> VarGetType($vvalue) Then ContinueLoop
- If $aarray[$i] = $vvalue Then Return $i
- Next
- Else
- For $i = $istart To $iend Step $istep
- If $bcomptype AND VarGetType($aarray[$i]) <> VarGetType($vvalue) Then ContinueLoop
- If $aarray[$i] == $vvalue Then Return $i
- Next
- EndIf
- Else
- For $i = $istart To $iend Step $istep
- If $icompare = 3 Then
- If StringRegExp($aarray[$i], $vvalue) Then Return $i
- Else
- If StringInStr($aarray[$i], $vvalue, $icase) > 0 Then Return $i
- EndIf
- Next
- EndIf
- Case 2
- Local $idim_sub
- If $brow Then
- $idim_sub = $idim_1
- If $isubitem > $idim_sub Then $isubitem = $idim_sub
- If $isubitem < 0 Then
- $isubitem = 0
- Else
- $idim_sub = $isubitem
- EndIf
- Else
- $idim_sub = $idim_2
- If $isubitem > $idim_sub Then $isubitem = $idim_sub
- If $isubitem < 0 Then
- $isubitem = 0
- Else
- $idim_sub = $isubitem
- EndIf
- EndIf
- For $j = $isubitem To $idim_sub
- If NOT $icompare Then
- If NOT $icase Then
- For $i = $istart To $iend Step $istep
- If $brow Then
- If $bcomptype AND VarGetType($aarray[$j][$j]) <> VarGetType($vvalue) Then ContinueLoop
- If $aarray[$j][$i] = $vvalue Then Return $i
- Else
- If $bcomptype AND VarGetType($aarray[$i][$j]) <> VarGetType($vvalue) Then ContinueLoop
- If $aarray[$i][$j] = $vvalue Then Return $i
- EndIf
- Next
- Else
- For $i = $istart To $iend Step $istep
- If $brow Then
- If $bcomptype AND VarGetType($aarray[$j][$i]) <> VarGetType($vvalue) Then ContinueLoop
- If $aarray[$j][$i] == $vvalue Then Return $i
- Else
- If $bcomptype AND VarGetType($aarray[$i][$j]) <> VarGetType($vvalue) Then ContinueLoop
- If $aarray[$i][$j] == $vvalue Then Return $i
- EndIf
- Next
- EndIf
- Else
- For $i = $istart To $iend Step $istep
- If $icompare = 3 Then
- If $brow Then
- If StringRegExp($aarray[$j][$i], $vvalue) Then Return $i
- Else
- If StringRegExp($aarray[$i][$j], $vvalue) Then Return $i
- EndIf
- Else
- If $brow Then
- If StringInStr($aarray[$j][$i], $vvalue, $icase) > 0 Then Return $i
- Else
- If StringInStr($aarray[$i][$j], $vvalue, $icase) > 0 Then Return $i
- EndIf
- EndIf
- Next
- EndIf
- Next
- Case Else
- Return SetError(2, 0, -1)
- EndSwitch
- Return SetError(6, 0, -1)
- EndFunc
- Func _arrayshuffle(ByRef $aarray, $istart_row = 0, $iend_row = 0, $icol = -1)
- If $istart_row = Default Then $istart_row = 0
- If $iend_row = Default Then $iend_row = 0
- If $icol = Default Then $icol = -1
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray, $ubound_rows)
- If $iend_row = 0 Then $iend_row = $idim_1 - 1
- If $istart_row < 0 OR $istart_row > $idim_1 - 1 Then Return SetError(3, 0, -1)
- If $iend_row < 1 OR $iend_row > $idim_1 - 1 Then Return SetError(3, 0, -1)
- If $istart_row > $iend_row Then Return SetError(4, 0, -1)
- Local $vtmp, $irand
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- For $i = $iend_row To $istart_row + 1 Step -1
- $irand = Random($istart_row, $i, 1)
- $vtmp = $aarray[$i]
- $aarray[$i] = $aarray[$irand]
- $aarray[$irand] = $vtmp
- Next
- Return 1
- Case 2
- Local $idim_2 = UBound($aarray, $ubound_columns)
- If $icol < -1 OR $icol > $idim_2 - 1 Then Return SetError(5, 0, -1)
- Local $icol_start, $icol_end
- If $icol = -1 Then
- $icol_start = 0
- $icol_end = $idim_2 - 1
- Else
- $icol_start = $icol
- $icol_end = $icol
- EndIf
- For $i = $iend_row To $istart_row + 1 Step -1
- $irand = Random($istart_row, $i, 1)
- For $j = $icol_start To $icol_end
- $vtmp = $aarray[$i][$j]
- $aarray[$i][$j] = $aarray[$irand][$j]
- $aarray[$irand][$j] = $vtmp
- Next
- Next
- Return 1
- Case Else
- Return SetError(2, 0, -1)
- EndSwitch
- EndFunc
- Func _arraysort(ByRef $aarray, $idescending = 0, $istart = 0, $iend = 0, $isubitem = 0, $ipivot = 0)
- If $idescending = Default Then $idescending = 0
- If $istart = Default Then $istart = 0
- If $iend = Default Then $iend = 0
- If $isubitem = Default Then $isubitem = 0
- If $ipivot = Default Then $ipivot = 0
- If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
- Local $iubound = UBound($aarray) - 1
- If $iubound = -1 Then Return SetError(5, 0, 0)
- If $iend = Default Then $iend = 0
- If $iend < 1 OR $iend > $iubound OR $iend = Default Then $iend = $iubound
- If $istart < 0 OR $istart = Default Then $istart = 0
- If $istart > $iend Then Return SetError(2, 0, 0)
- If $idescending = Default Then $idescending = 0
- If $ipivot = Default Then $ipivot = 0
- If $isubitem = Default Then $isubitem = 0
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- If $ipivot Then
- __arraydualpivotsort($aarray, $istart, $iend)
- Else
- __arrayquicksort1d($aarray, $istart, $iend)
- EndIf
- If $idescending Then _arrayreverse($aarray, $istart, $iend)
- Case 2
- If $ipivot Then Return SetError(6, 0, 0)
- Local $isubmax = UBound($aarray, $ubound_columns) - 1
- If $isubitem > $isubmax Then Return SetError(3, 0, 0)
- If $idescending Then
- $idescending = -1
- Else
- $idescending = 1
- EndIf
- __arrayquicksort2d($aarray, $idescending, $istart, $iend, $isubitem, $isubmax)
- Case Else
- Return SetError(4, 0, 0)
- EndSwitch
- Return 1
- EndFunc
- Func __arrayquicksort1d(ByRef $aarray, Const ByRef $istart, Const ByRef $iend)
- If $iend <= $istart Then Return
- Local $vtmp
- If ($iend - $istart) < 15 Then
- Local $vcur
- For $i = $istart + 1 To $iend
- $vtmp = $aarray[$i]
- If IsNumber($vtmp) Then
- For $j = $i - 1 To $istart Step -1
- $vcur = $aarray[$j]
- If ($vtmp >= $vcur AND IsNumber($vcur)) OR (NOT IsNumber($vcur) AND StringCompare($vtmp, $vcur) >= 0) Then ExitLoop
- $aarray[$j + 1] = $vcur
- Next
- Else
- For $j = $i - 1 To $istart Step -1
- If (StringCompare($vtmp, $aarray[$j]) >= 0) Then ExitLoop
- $aarray[$j + 1] = $aarray[$j]
- Next
- EndIf
- $aarray[$j + 1] = $vtmp
- Next
- Return
- EndIf
- Local $l = $istart, $r = $iend, $vpivot = $aarray[Int(($istart + $iend) / 2)], $bnum = IsNumber($vpivot)
- Do
- If $bnum Then
- While ($aarray[$l] < $vpivot AND IsNumber($aarray[$l])) OR (NOT IsNumber($aarray[$l]) AND StringCompare($aarray[$l], $vpivot) < 0)
- $l += 1
- WEnd
- While ($aarray[$r] > $vpivot AND IsNumber($aarray[$r])) OR (NOT IsNumber($aarray[$r]) AND StringCompare($aarray[$r], $vpivot) > 0)
- $r -= 1
- WEnd
- Else
- While (StringCompare($aarray[$l], $vpivot) < 0)
- $l += 1
- WEnd
- While (StringCompare($aarray[$r], $vpivot) > 0)
- $r -= 1
- WEnd
- EndIf
- If $l <= $r Then
- $vtmp = $aarray[$l]
- $aarray[$l] = $aarray[$r]
- $aarray[$r] = $vtmp
- $l += 1
- $r -= 1
- EndIf
- Until $l > $r
- __arrayquicksort1d($aarray, $istart, $r)
- __arrayquicksort1d($aarray, $l, $iend)
- EndFunc
- Func __arrayquicksort2d(ByRef $aarray, Const ByRef $istep, Const ByRef $istart, Const ByRef $iend, Const ByRef $isubitem, Const ByRef $isubmax)
- If $iend <= $istart Then Return
- Local $vtmp, $l = $istart, $r = $iend, $vpivot = $aarray[Int(($istart + $iend) / 2)][$isubitem], $bnum = IsNumber($vpivot)
- Do
- If $bnum Then
- 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)
- $l += 1
- WEnd
- 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)
- $r -= 1
- WEnd
- Else
- While ($istep * StringCompare($aarray[$l][$isubitem], $vpivot) < 0)
- $l += 1
- WEnd
- While ($istep * StringCompare($aarray[$r][$isubitem], $vpivot) > 0)
- $r -= 1
- WEnd
- EndIf
- If $l <= $r Then
- For $i = 0 To $isubmax
- $vtmp = $aarray[$l][$i]
- $aarray[$l][$i] = $aarray[$r][$i]
- $aarray[$r][$i] = $vtmp
- Next
- $l += 1
- $r -= 1
- EndIf
- Until $l > $r
- __arrayquicksort2d($aarray, $istep, $istart, $r, $isubitem, $isubmax)
- __arrayquicksort2d($aarray, $istep, $l, $iend, $isubitem, $isubmax)
- EndFunc
- Func __arraydualpivotsort(ByRef $aarray, $ipivot_left, $ipivot_right, $bleftmost = True)
- If $ipivot_left > $ipivot_right Then Return
- Local $ilength = $ipivot_right - $ipivot_left + 1
- Local $i, $j, $k, $iai, $iak, $ia1, $ia2, $ilast
- If $ilength < 45 Then
- If $bleftmost Then
- $i = $ipivot_left
- While $i < $ipivot_right
- $j = $i
- $iai = $aarray[$i + 1]
- While $iai < $aarray[$j]
- $aarray[$j + 1] = $aarray[$j]
- $j -= 1
- If $j + 1 = $ipivot_left Then ExitLoop
- WEnd
- $aarray[$j + 1] = $iai
- $i += 1
- WEnd
- Else
- While 1
- If $ipivot_left >= $ipivot_right Then Return 1
- $ipivot_left += 1
- If $aarray[$ipivot_left] < $aarray[$ipivot_left - 1] Then ExitLoop
- WEnd
- While 1
- $k = $ipivot_left
- $ipivot_left += 1
- If $ipivot_left > $ipivot_right Then ExitLoop
- $ia1 = $aarray[$k]
- $ia2 = $aarray[$ipivot_left]
- If $ia1 < $ia2 Then
- $ia2 = $ia1
- $ia1 = $aarray[$ipivot_left]
- EndIf
- $k -= 1
- While $ia1 < $aarray[$k]
- $aarray[$k + 2] = $aarray[$k]
- $k -= 1
- WEnd
- $aarray[$k + 2] = $ia1
- While $ia2 < $aarray[$k]
- $aarray[$k + 1] = $aarray[$k]
- $k -= 1
- WEnd
- $aarray[$k + 1] = $ia2
- $ipivot_left += 1
- WEnd
- $ilast = $aarray[$ipivot_right]
- $ipivot_right -= 1
- While $ilast < $aarray[$ipivot_right]
- $aarray[$ipivot_right + 1] = $aarray[$ipivot_right]
- $ipivot_right -= 1
- WEnd
- $aarray[$ipivot_right + 1] = $ilast
- EndIf
- Return 1
- EndIf
- Local $iseventh = BitShift($ilength, 3) + BitShift($ilength, 6) + 1
- Local $ie1, $ie2, $ie3, $ie4, $ie5, $t
- $ie3 = Ceiling(($ipivot_left + $ipivot_right) / 2)
- $ie2 = $ie3 - $iseventh
- $ie1 = $ie2 - $iseventh
- $ie4 = $ie3 + $iseventh
- $ie5 = $ie4 + $iseventh
- If $aarray[$ie2] < $aarray[$ie1] Then
- $t = $aarray[$ie2]
- $aarray[$ie2] = $aarray[$ie1]
- $aarray[$ie1] = $t
- EndIf
- If $aarray[$ie3] < $aarray[$ie2] Then
- $t = $aarray[$ie3]
- $aarray[$ie3] = $aarray[$ie2]
- $aarray[$ie2] = $t
- If $t < $aarray[$ie1] Then
- $aarray[$ie2] = $aarray[$ie1]
- $aarray[$ie1] = $t
- EndIf
- EndIf
- If $aarray[$ie4] < $aarray[$ie3] Then
- $t = $aarray[$ie4]
- $aarray[$ie4] = $aarray[$ie3]
- $aarray[$ie3] = $t
- If $t < $aarray[$ie2] Then
- $aarray[$ie3] = $aarray[$ie2]
- $aarray[$ie2] = $t
- If $t < $aarray[$ie1] Then
- $aarray[$ie2] = $aarray[$ie1]
- $aarray[$ie1] = $t
- EndIf
- EndIf
- EndIf
- If $aarray[$ie5] < $aarray[$ie4] Then
- $t = $aarray[$ie5]
- $aarray[$ie5] = $aarray[$ie4]
- $aarray[$ie4] = $t
- If $t < $aarray[$ie3] Then
- $aarray[$ie4] = $aarray[$ie3]
- $aarray[$ie3] = $t
- If $t < $aarray[$ie2] Then
- $aarray[$ie3] = $aarray[$ie2]
- $aarray[$ie2] = $t
- If $t < $aarray[$ie1] Then
- $aarray[$ie2] = $aarray[$ie1]
- $aarray[$ie1] = $t
- EndIf
- EndIf
- EndIf
- EndIf
- Local $iless = $ipivot_left
- Local $igreater = $ipivot_right
- If (($aarray[$ie1] <> $aarray[$ie2]) AND ($aarray[$ie2] <> $aarray[$ie3]) AND ($aarray[$ie3] <> $aarray[$ie4]) AND ($aarray[$ie4] <> $aarray[$ie5])) Then
- Local $ipivot_1 = $aarray[$ie2]
- Local $ipivot_2 = $aarray[$ie4]
- $aarray[$ie2] = $aarray[$ipivot_left]
- $aarray[$ie4] = $aarray[$ipivot_right]
- Do
- $iless += 1
- Until $aarray[$iless] >= $ipivot_1
- Do
- $igreater -= 1
- Until $aarray[$igreater] <= $ipivot_2
- $k = $iless
- While $k <= $igreater
- $iak = $aarray[$k]
- If $iak < $ipivot_1 Then
- $aarray[$k] = $aarray[$iless]
- $aarray[$iless] = $iak
- $iless += 1
- ElseIf $iak > $ipivot_2 Then
- While $aarray[$igreater] > $ipivot_2
- $igreater -= 1
- If $igreater + 1 = $k Then ExitLoop 2
- WEnd
- If $aarray[$igreater] < $ipivot_1 Then
- $aarray[$k] = $aarray[$iless]
- $aarray[$iless] = $aarray[$igreater]
- $iless += 1
- Else
- $aarray[$k] = $aarray[$igreater]
- EndIf
- $aarray[$igreater] = $iak
- $igreater -= 1
- EndIf
- $k += 1
- WEnd
- $aarray[$ipivot_left] = $aarray[$iless - 1]
- $aarray[$iless - 1] = $ipivot_1
- $aarray[$ipivot_right] = $aarray[$igreater + 1]
- $aarray[$igreater + 1] = $ipivot_2
- __arraydualpivotsort($aarray, $ipivot_left, $iless - 2, True)
- __arraydualpivotsort($aarray, $igreater + 2, $ipivot_right, False)
- If ($iless < $ie1) AND ($ie5 < $igreater) Then
- While $aarray[$iless] = $ipivot_1
- $iless += 1
- WEnd
- While $aarray[$igreater] = $ipivot_2
- $igreater -= 1
- WEnd
- $k = $iless
- While $k <= $igreater
- $iak = $aarray[$k]
- If $iak = $ipivot_1 Then
- $aarray[$k] = $aarray[$iless]
- $aarray[$iless] = $iak
- $iless += 1
- ElseIf $iak = $ipivot_2 Then
- While $aarray[$igreater] = $ipivot_2
- $igreater -= 1
- If $igreater + 1 = $k Then ExitLoop 2
- WEnd
- If $aarray[$igreater] = $ipivot_1 Then
- $aarray[$k] = $aarray[$iless]
- $aarray[$iless] = $ipivot_1
- $iless += 1
- Else
- $aarray[$k] = $aarray[$igreater]
- EndIf
- $aarray[$igreater] = $iak
- $igreater -= 1
- EndIf
- $k += 1
- WEnd
- EndIf
- __arraydualpivotsort($aarray, $iless, $igreater, False)
- Else
- Local $ipivot = $aarray[$ie3]
- $k = $iless
- While $k <= $igreater
- If $aarray[$k] = $ipivot Then
- $k += 1
- ContinueLoop
- EndIf
- $iak = $aarray[$k]
- If $iak < $ipivot Then
- $aarray[$k] = $aarray[$iless]
- $aarray[$iless] = $iak
- $iless += 1
- Else
- While $aarray[$igreater] > $ipivot
- $igreater -= 1
- WEnd
- If $aarray[$igreater] < $ipivot Then
- $aarray[$k] = $aarray[$iless]
- $aarray[$iless] = $aarray[$igreater]
- $iless += 1
- Else
- $aarray[$k] = $ipivot
- EndIf
- $aarray[$igreater] = $iak
- $igreater -= 1
- EndIf
- $k += 1
- WEnd
- __arraydualpivotsort($aarray, $ipivot_left, $iless - 1, True)
- __arraydualpivotsort($aarray, $igreater + 1, $ipivot_right, False)
- EndIf
- EndFunc
- Func _arrayswap(ByRef $aarray, $iindex_1, $iindex_2, $bcol = False, $istart = -1, $iend = -1)
- If $bcol = Default Then $bcol = False
- If $istart = Default Then $istart = -1
- If $iend = Default Then $iend = -1
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray, $ubound_rows) - 1
- Local $idim_2 = UBound($aarray, $ubound_columns) - 1
- If $idim_2 = -1 Then
- $bcol = False
- $istart = -1
- $iend = -1
- EndIf
- If $istart > $iend Then Return SetError(5, 0, -1)
- If $bcol Then
- If $iindex_1 < 0 OR $iindex_2 > $idim_2 Then Return SetError(3, 0, -1)
- If $istart = -1 Then $istart = 0
- If $iend = -1 Then $iend = $idim_1
- Else
- If $iindex_1 < 0 OR $iindex_2 > $idim_1 Then Return SetError(3, 0, -1)
- If $istart = -1 Then $istart = 0
- If $iend = -1 Then $iend = $idim_2
- EndIf
- Local $vtmp
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- $vtmp = $aarray[$iindex_1]
- $aarray[$iindex_1] = $aarray[$iindex_2]
- $aarray[$iindex_2] = $vtmp
- Case 2
- If $istart < -1 OR $iend < -1 Then Return SetError(4, 0, -1)
- If $bcol Then
- If $istart > $idim_1 OR $iend > $idim_1 Then Return SetError(4, 0, -1)
- For $j = $istart To $iend
- $vtmp = $aarray[$j][$iindex_1]
- $aarray[$j][$iindex_1] = $aarray[$j][$iindex_2]
- $aarray[$j][$iindex_2] = $vtmp
- Next
- Else
- If $istart > $idim_2 OR $iend > $idim_2 Then Return SetError(4, 0, -1)
- For $j = $istart To $iend
- $vtmp = $aarray[$iindex_1][$j]
- $aarray[$iindex_1][$j] = $aarray[$iindex_2][$j]
- $aarray[$iindex_2][$j] = $vtmp
- Next
- EndIf
- Case Else
- Return SetError(2, 0, -1)
- EndSwitch
- Return 1
- EndFunc
- Func _arraytoclip(Const ByRef $aarray, $sdelim_col = "|", $istart_row = -1, $iend_row = -1, $sdelim_row = @CRLF, $istart_col = -1, $iend_col = -1)
- Local $sresult = _arraytostring($aarray, $sdelim_col, $istart_row, $iend_row, $sdelim_row, $istart_col, $iend_col)
- If @error Then Return SetError(@error, 0, 0)
- If ClipPut($sresult) Then Return 1
- Return SetError(-1, 0, 0)
- EndFunc
- Func _arraytostring(Const ByRef $aarray, $sdelim_col = "|", $istart_row = -1, $iend_row = -1, $sdelim_row = @CRLF, $istart_col = -1, $iend_col = -1)
- If $sdelim_col = Default Then $sdelim_col = "|"
- If $sdelim_row = Default Then $sdelim_row = @CRLF
- If $istart_row = Default Then $istart_row = -1
- If $iend_row = Default Then $iend_row = -1
- If $istart_col = Default Then $istart_col = -1
- If $iend_col = Default Then $iend_col = -1
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray, $ubound_rows) - 1
- If $istart_row = -1 Then $istart_row = 0
- If $iend_row = -1 Then $iend_row = $idim_1
- If $istart_row < -1 OR $iend_row < -1 Then Return SetError(3, 0, -1)
- If $istart_row > $idim_1 OR $iend_row > $idim_1 Then Return SetError(3, 0, "")
- If $istart_row > $iend_row Then Return SetError(4, 0, -1)
- Local $sret = ""
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- For $i = $istart_row To $iend_row
- $sret &= $aarray[$i] & $sdelim_col
- Next
- Return StringTrimRight($sret, StringLen($sdelim_col))
- Case 2
- Local $idim_2 = UBound($aarray, $ubound_columns) - 1
- If $istart_col = -1 Then $istart_col = 0
- If $iend_col = -1 Then $iend_col = $idim_2
- If $istart_col < -1 OR $iend_col < -1 Then Return SetError(5, 0, -1)
- If $istart_col > $idim_2 OR $iend_col > $idim_2 Then Return SetError(5, 0, -1)
- If $istart_col > $iend_col Then Return SetError(6, 0, -1)
- For $i = $istart_row To $iend_row
- For $j = $istart_col To $iend_col
- $sret &= $aarray[$i][$j] & $sdelim_col
- Next
- $sret = StringTrimRight($sret, StringLen($sdelim_col)) & $sdelim_row
- Next
- Return StringTrimRight($sret, StringLen($sdelim_row))
- Case Else
- Return SetError(2, 0, -1)
- EndSwitch
- Return 1
- EndFunc
- Func _arraytranspose(ByRef $aarray)
- Switch UBound($aarray, 0)
- Case 0
- Return SetError(2, 0, 0)
- Case 1
- Local $atemp[1][UBound($aarray)]
- For $i = 0 To UBound($aarray) - 1
- $atemp[0][$i] = $aarray[$i]
- Next
- $aarray = $atemp
- Case 2
- Local $idim_1 = UBound($aarray, 1), $idim_2 = UBound($aarray, 2)
- If $idim_1 <> $idim_2 Then
- Local $atemp[$idim_2][$idim_1]
- For $i = 0 To $idim_1 - 1
- For $j = 0 To $idim_2 - 1
- $atemp[$j][$i] = $aarray[$i][$j]
- Next
- Next
- $aarray = $atemp
- Else
- Local $velement
- For $i = 0 To $idim_1 - 1
- For $j = $i + 1 To $idim_2 - 1
- $velement = $aarray[$i][$j]
- $aarray[$i][$j] = $aarray[$j][$i]
- $aarray[$j][$i] = $velement
- Next
- Next
- EndIf
- Case Else
- Return SetError(1, 0, 0)
- EndSwitch
- Return 1
- EndFunc
- Func _arraytrim(ByRef $aarray, $itrimnum, $idirection = 0, $istart = 0, $iend = 0, $isubitem = 0)
- If $idirection = Default Then $idirection = 0
- If $istart = Default Then $istart = 0
- If $iend = Default Then $iend = 0
- If $isubitem = Default Then $isubitem = 0
- If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
- Local $idim_1 = UBound($aarray, $ubound_rows) - 1
- If $iend = 0 Then $iend = $idim_1
- If $istart > $iend Then Return SetError(3, 0, -1)
- If $istart < 0 OR $iend < 0 Then Return SetError(3, 0, -1)
- If $istart > $idim_1 OR $iend > $idim_1 Then Return SetError(3, 0, -1)
- If $istart > $iend Then Return SetError(4, 0, -1)
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- If $idirection Then
- For $i = $istart To $iend
- $aarray[$i] = StringTrimRight($aarray[$i], $itrimnum)
- Next
- Else
- For $i = $istart To $iend
- $aarray[$i] = StringTrimLeft($aarray[$i], $itrimnum)
- Next
- EndIf
- Case 2
- Local $idim_2 = UBound($aarray, $ubound_columns) - 1
- If $isubitem < 0 OR $isubitem > $idim_2 Then Return SetError(5, 0, -1)
- If $idirection Then
- For $i = $istart To $iend
- $aarray[$i][$isubitem] = StringTrimRight($aarray[$i][$isubitem], $itrimnum)
- Next
- Else
- For $i = $istart To $iend
- $aarray[$i][$isubitem] = StringTrimLeft($aarray[$i][$isubitem], $itrimnum)
- Next
- EndIf
- Case Else
- Return SetError(2, 0, 0)
- EndSwitch
- Return 1
- EndFunc
- Func _arrayunique(Const ByRef $aarray, $icolumn = 0, $ibase = 0, $icase = 0, $icount = $arrayunique_count, $iinttype = $arrayunique_auto)
- If $icolumn = Default Then $icolumn = 0
- If $ibase = Default Then $ibase = 0
- If $icase = Default Then $icase = 0
- If $icount = Default Then $icount = $arrayunique_count
- If UBound($aarray, $ubound_rows) = 0 Then Return SetError(1, 0, 0)
- Local $idims = UBound($aarray, $ubound_dimensions), $inumcolumns = UBound($aarray, $ubound_columns)
- If $idims > 2 Then Return SetError(2, 0, 0)
- If $ibase < 0 OR $ibase > 1 OR (NOT IsInt($ibase)) Then Return SetError(3, 0, 0)
- If $icase < 0 OR $icase > 1 OR (NOT IsInt($icase)) Then Return SetError(3, 0, 0)
- If $icount < 0 OR $icount > 1 OR (NOT IsInt($icount)) Then Return SetError(4, 0, 0)
- If $iinttype < 0 OR $iinttype > 4 OR (NOT IsInt($iinttype)) Then Return SetError(5, 0, 0)
- If $icolumn < 0 OR ($inumcolumns = 0 AND $icolumn > 0) OR ($inumcolumns > 0 AND $icolumn >= $inumcolumns) Then Return SetError(6, 0, 0)
- If $iinttype = $arrayunique_auto Then
- Local $vfirstelem = (($idims = 1) ? ($aarray[$ibase]) : ($aarray[$icolumn][$ibase]))
- If IsInt($vfirstelem) Then
- Switch VarGetType($vfirstelem)
- Case "Int32"
- $iinttype = $arrayunique_force32
- Case "Int64"
- $iinttype = $arrayunique_force64
- EndSwitch
- Else
- $iinttype = $arrayunique_force32
- EndIf
- EndIf
- ObjEvent("AutoIt.Error", "__ArrayUnique_AutoErrFunc")
- Local $odictionary = ObjCreate("Scripting.Dictionary")
- $odictionary.comparemode = Number(NOT $icase)
- Local $velem, $stype, $vkey, $bcomerror = False
- For $i = $ibase To UBound($aarray) - 1
- If $idims = 1 Then
- $velem = $aarray[$i]
- Else
- $velem = $aarray[$i][$icolumn]
- EndIf
- Switch $iinttype
- Case $arrayunique_force32
- $odictionary.item($velem)
- If @error Then
- $bcomerror = True
- ExitLoop
- EndIf
- Case $arrayunique_force64
- $stype = VarGetType($velem)
- If $stype = "Int32" Then
- $bcomerror = True
- ExitLoop
- EndIf
- $vkey = "#" & $stype & "#" & String($velem)
- If NOT $odictionary.item($vkey) Then
- $odictionary($vkey) = $velem
- EndIf
- Case $arrayunique_match
- $stype = VarGetType($velem)
- If StringLeft($stype, 3) = "Int" Then
- $vkey = "#Int#" & String($velem)
- Else
- $vkey = "#" & $stype & "#" & String($velem)
- EndIf
- If NOT $odictionary.item($vkey) Then
- $odictionary($vkey) = $velem
- EndIf
- Case $arrayunique_distinct
- $vkey = "#" & VarGetType($velem) & "#" & String($velem)
- If NOT $odictionary.item($vkey) Then
- $odictionary($vkey) = $velem
- EndIf
- EndSwitch
- Next
- Local $avalues, $j = 0
- If $bcomerror Then
- Return SetError(7, 0, 0)
- ElseIf $iinttype <> $arrayunique_force32 Then
- Local $avalues[$odictionary.count]
- For $vkey In $odictionary.keys()
- $avalues[$j] = $odictionary($vkey)
- If StringLeft($vkey, 5) = "#Ptr#" Then
- $avalues[$j] = Ptr($avalues[$j])
- EndIf
- $j += 1
- Next
- Else
- $avalues = $odictionary.keys()
- EndIf
- If $icount Then
- _arrayinsert($avalues, 0, $odictionary.count)
- EndIf
- Return $avalues
- EndFunc
- Func _array1dtohistogram($aarray, $isizing = 100)
- If UBound($aarray, 0) > 1 Then Return SetError(1, 0, "")
- $isizing = $isizing * 8
- Local $t, $n, $imin = 0, $imax = 0, $ioffset = 0
- For $i = 0 To UBound($aarray) - 1
- $t = $aarray[$i]
- $t = IsNumber($t) ? Round($t) : 0
- If $t < $imin Then $imin = $t
- If $t > $imax Then $imax = $t
- Next
- Local $irange = Int(Round(($imax - $imin) / 8)) * 8
- Local $ispaceratio = 4
- For $i = 0 To UBound($aarray) - 1
- $t = $aarray[$i]
- If $t Then
- $n = Abs(Round(($isizing * $t) / $irange) / 8)
- $aarray[$i] = ""
- If $t > 0 Then
- If $imin Then
- $ioffset = Int(Abs(Round(($isizing * $imin) / $irange) / 8) / 8 * $ispaceratio)
- $aarray[$i] = __array_stringrepeat(ChrW(32), $ioffset)
- EndIf
- Else
- If $imin <> $t Then
- $ioffset = Int(Abs(Round(($isizing * ($t - $imin)) / $irange) / 8) / 8 * $ispaceratio)
- $aarray[$i] = __array_stringrepeat(ChrW(32), $ioffset)
- EndIf
- EndIf
- $aarray[$i] &= __array_stringrepeat(ChrW(9608), Int($n / 8))
- $n = Mod($n, 8)
- If $n > 0 Then $aarray[$i] &= ChrW(9608 + 8 - $n)
- $aarray[$i] &= " " & $t
- Else
- $aarray[$i] = ""
- EndIf
- Next
- Return $aarray
- EndFunc
- Func __array_stringrepeat($sstring, $irepeatcount)
- $irepeatcount = Int($irepeatcount)
- If StringLen($sstring) < 1 OR $irepeatcount <= 0 Then Return SetError(1, 0, "")
- Local $sresult = ""
- While $irepeatcount > 1
- If BitAND($irepeatcount, 1) Then $sresult &= $sstring
- $sstring &= $sstring
- $irepeatcount = BitShift($irepeatcount, 1)
- WEnd
- Return $sstring & $sresult
- EndFunc
- Func __array_exeterinternal(ByRef $aarray, $istart, $isize, $sdelimiter, ByRef $aidx, ByRef $aresult, ByRef $icount)
- If $istart == $isize - 1 Then
- For $i = 0 To $isize - 1
- $aresult[$icount] &= $aarray[$aidx[$i]] & $sdelimiter
- Next
- If $sdelimiter <> "" Then $aresult[$icount] = StringTrimRight($aresult[$icount], StringLen($sdelimiter))
- $icount += 1
- Else
- Local $itemp
- For $i = $istart To $isize - 1
- $itemp = $aidx[$i]
- $aidx[$i] = $aidx[$istart]
- $aidx[$istart] = $itemp
- __array_exeterinternal($aarray, $istart + 1, $isize, $sdelimiter, $aidx, $aresult, $icount)
- $aidx[$istart] = $aidx[$i]
- $aidx[$i] = $itemp
- Next
- EndIf
- EndFunc
- Func __array_combinations($in, $ir)
- Local $i_total = 1
- For $i = $ir To 1 Step -1
- $i_total *= ($in / $i)
- $in -= 1
- Next
- Return Round($i_total)
- EndFunc
- Func __array_getnext($in, $ir, ByRef $ileft, $itotal, ByRef $aidx)
- If $ileft == $itotal Then
- $ileft -= 1
- Return
- EndIf
- Local $i = $ir - 1
- While $aidx[$i] == $in - $ir + $i
- $i -= 1
- WEnd
- $aidx[$i] += 1
- For $j = $i + 1 To $ir - 1
- $aidx[$j] = $aidx[$i] + $j - $i
- Next
- $ileft -= 1
- EndFunc
- Func __array_minmaxindex(Const ByRef $aarray, $icompnumeric, $istart, $iend, $isubitem, $fucomparison)
- If $icompnumeric = Default Then $icompnumeric = 0
- If $icompnumeric <> 1 Then $icompnumeric = 0
- If $istart = Default Then $istart = 0
- If $iend = Default Then $iend = 0
- If $isubitem = Default Then $isubitem = 0
- If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
- Local $idim_1 = UBound($aarray, $ubound_rows) - 1
- If $idim_1 < 0 Then Return SetError(1, 0, -1)
- If $iend = -1 Then $iend = $idim_1
- If $istart = -1 Then $istart = 0
- If $istart < -1 OR $iend < -1 Then Return SetError(3, 0, -1)
- If $istart > $idim_1 OR $iend > $idim_1 Then Return SetError(3, 0, -1)
- If $istart > $iend Then Return SetError(4, 0, -1)
- If $idim_1 < 0 Then Return SetError(5, 0, -1)
- Local $imaxminindex = $istart
- Switch UBound($aarray, $ubound_dimensions)
- Case 1
- If $icompnumeric Then
- For $i = $istart To $iend
- If $fucomparison(Number($aarray[$i]), Number($aarray[$imaxminindex])) Then $imaxminindex = $i
- Next
- Else
- For $i = $istart To $iend
- If $fucomparison($aarray[$i], $aarray[$imaxminindex]) Then $imaxminindex = $i
- Next
- EndIf
- Case 2
- If $isubitem < 0 OR $isubitem > UBound($aarray, $ubound_columns) - 1 Then Return SetError(6, 0, -1)
- If $icompnumeric Then
- For $i = $istart To $iend
- If $fucomparison(Number($aarray[$i][$isubitem]), Number($aarray[$imaxminindex][$isubitem])) Then $imaxminindex = $i
- Next
- Else
- For $i = $istart To $iend
- If $fucomparison($aarray[$i][$isubitem], $aarray[$imaxminindex][$isubitem]) Then $imaxminindex = $i
- Next
- EndIf
- Case Else
- Return SetError(2, 0, -1)
- EndSwitch
- Return $imaxminindex
- EndFunc
- Func __array_greaterthan($vvalue1, $vvalue2)
- Return $vvalue1 > $vvalue2
- EndFunc
- Func __array_lessthan($vvalue1, $vvalue2)
- Return $vvalue1 < $vvalue2
- EndFunc
- Func __arrayunique_autoerrfunc()
- EndFunc
- Global Const $gmem_fixed = 0
- Global Const $gmem_moveable = 2
- Global Const $gmem_nocompact = 16
- Global Const $gmem_nodiscard = 32
- Global Const $gmem_zeroinit = 64
- Global Const $gmem_modify = 128
- Global Const $gmem_discardable = 256
- Global Const $gmem_not_banked = 4096
- Global Const $gmem_share = 8192
- Global Const $gmem_ddeshare = 8192
- Global Const $gmem_notify = 16384
- Global Const $gmem_lower = 4096
- Global Const $gmem_valid_flags = 32626
- Global Const $gmem_invalid_handle = 32768
- Global Const $gptr = BitOR($gmem_fixed, $gmem_zeroinit)
- Global Const $ghnd = BitOR($gmem_moveable, $gmem_zeroinit)
- Global Const $mem_commit = 4096
- Global Const $mem_reserve = 8192
- Global Const $mem_top_down = 1048576
- Global Const $mem_shared = 134217728
- Global Const $page_noaccess = 1
- Global Const $page_readonly = 2
- Global Const $page_readwrite = 4
- Global Const $page_execute = 16
- Global Const $page_execute_read = 32
- Global Const $page_execute_readwrite = 64
- Global Const $page_execute_writecopy = 128
- Global Const $page_guard = 256
- Global Const $page_nocache = 512
- Global Const $page_writecombine = 1024
- Global Const $page_writecopy = 8
- Global Const $mem_decommit = 16384
- Global Const $mem_release = 32768
- Global Const $tagpoint = "struct;long X;long Y;endstruct"
- Global Const $tagrect = "struct;long Left;long Top;long Right;long Bottom;endstruct"
- Global Const $tagsize = "struct;long X;long Y;endstruct"
- Global Const $tagmargins = "int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight"
- Global Const $tagfiletime = "struct;dword Lo;dword Hi;endstruct"
- Global Const $tagsystemtime = "struct;word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds;endstruct"
- 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"
- Global Const $tagnmhdr = "struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct"
- Global Const $tagcomboboxexitem = "uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;int SelectedImage;int OverlayImage;" & "int Indent;lparam Param"
- Global Const $tagnmcbedragbegin = $tagnmhdr & ";int ItemID;wchar szText[260]"
- Global Const $tagnmcbeendedit = $tagnmhdr & ";bool fChanged;int NewSelection;wchar szText[260];int Why"
- Global Const $tagnmcomboboxex = $tagnmhdr & ";uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;" & "int SelectedImage;int OverlayImage;int Indent;lparam Param"
- 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"
- Global Const $tagnmdatetimechange = $tagnmhdr & ";dword Flag;" & $tagsystemtime
- Global Const $tagnmdatetimeformat = $tagnmhdr & ";ptr Format;" & $tagsystemtime & ";ptr pDisplay;wchar Display[64]"
- Global Const $tagnmdatetimeformatquery = $tagnmhdr & ";ptr Format;struct;long SizeX;long SizeY;endstruct"
- Global Const $tagnmdatetimekeydown = $tagnmhdr & ";int VirtKey;ptr Format;" & $tagsystemtime
- Global Const $tagnmdatetimestring = $tagnmhdr & ";ptr UserString;" & $tagsystemtime & ";dword Flags"
- 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"
- Global Const $taggdip_effectparams_blur = "float Radius; bool ExpandEdge"
- Global Const $taggdip_effectparams_brightnesscontrast = "int BrightnessLevel; int ContrastLevel"
- Global Const $taggdip_effectparams_colorbalance = "int CyanRed; int MagentaGreen; int YellowBlue"
- Global Const $taggdip_effectparams_colorcurve = "int Adjustment; int Channel; int AdjustValue"
- Global Const $taggdip_effectparams_colorlut = "byte LutB[256]; byte LutG[256]; byte LutR[256]; byte LutA[256]"
- Global Const $taggdip_effectparams_huesaturationlightness = "int HueLevel; int SaturationLevel; int LightnessLevel"
- Global Const $taggdip_effectparams_levels = "int Highlight; int Midtone; int Shadow"
- Global Const $taggdip_effectparams_redeyecorrection = "uint NumberOfAreas; ptr Areas"
- Global Const $taggdip_effectparams_sharpen = "float Radius; float Amount"
- Global Const $taggdip_effectparams_tint = "int Hue; int Amount"
- Global Const $taggdipbitmapdata = "uint Width;uint Height;int Stride;int Format;ptr Scan0;uint_ptr Reserved"
- Global Const $taggdipcolormatrix = "float m[25]"
- Global Const $taggdipencoderparam = "struct;byte GUID[16];ulong NumberOfValues;ulong Type;ptr Values;endstruct"
- Global Const $taggdipencoderparams = "uint Count;" & $taggdipencoderparam
- Global Const $taggdiprectf = "struct;float X;float Y;float Width;float Height;endstruct"
- Global Const $taggdipstartupinput = "uint Version;ptr Callback;bool NoThread;bool NoCodecs"
- Global Const $taggdipstartupoutput = "ptr HookProc;ptr UnhookProc"
- 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"
- Global Const $taggdippencoderparams = "uint Count;byte Params[1]"
- 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"
- Global Const $tagnmhddispinfo = $tagnmhdr & ";int Item;uint Mask;ptr Text;int TextMax;int Image;lparam lParam"
- Global Const $tagnmhdfilterbtnclick = $tagnmhdr & ";int Item;" & $tagrect
- Global Const $tagnmheader = $tagnmhdr & ";int Item;int Button;ptr pItem"
- Global Const $taggetipaddress = "byte Field4;byte Field3;byte Field2;byte Field1"
- Global Const $tagnmipaddress = $tagnmhdr & ";int Field;int Value"
- Global Const $taglvfindinfo = "struct;uint Flags;ptr Text;lparam Param;" & $tagpoint & ";uint Direction;endstruct"
- Global Const $taglvhittestinfo = $tagpoint & ";uint Flags;int Item;int SubItem;int iGroup"
- 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"
- Global Const $tagnmlistview = $tagnmhdr & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;" & "struct;long ActionX;long ActionY;endstruct;lparam Param"
- 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"
- Global Const $tagnmlvdispinfo = $tagnmhdr & ";" & $taglvitem
- Global Const $tagnmlvfinditem = $tagnmhdr & ";int Start;" & $taglvfindinfo
- Global Const $tagnmlvgetinfotip = $tagnmhdr & ";dword Flags;ptr Text;int TextMax;int Item;int SubItem;lparam lParam"
- Global Const $tagnmitemactivate = $tagnmhdr & ";int Index;int SubItem;uint NewState;uint OldState;uint Changed;" & $tagpoint & ";lparam lParam;uint KeyFlags"
- Global Const $tagnmlvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
- Global Const $tagnmlvscroll = $tagnmhdr & ";int DX;int DY"
- Global Const $tagmchittestinfo = "uint Size;" & $tagpoint & ";uint Hit;" & $tagsystemtime & ";" & $tagrect & ";int iOffset;int iRow;int iCol"
- 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"
- 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"
- 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"
- Global Const $tagnmdaystate = $tagnmhdr & ";" & $tagsystemtime & ";int DayState;ptr pDayState"
- 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"
- Global Const $tagnmobjectnotify = $tagnmhdr & ";int Item;ptr piid;ptr pObject;long Result;dword dwFlags"
- Global Const $tagnmtckeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
- 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"
- Global Const $tagtvitemex = "struct;" & $tagtvitem & ";int Integral;uint uStateEx;hwnd hwnd;int iExpandedImage;int iReserved;endstruct"
- 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"
- Global Const $tagnmtvcustomdraw = "struct;" & $tagnmhdr & ";dword DrawStage;handle HDC;" & $tagrect & ";dword_ptr ItemSpec;uint ItemState;lparam ItemParam;endstruct" & ";dword ClrText;dword ClrTextBk;int Level"
- Global Const $tagnmtvdispinfo = $tagnmhdr & ";" & $tagtvitem
- Global Const $tagnmtvgetinfotip = $tagnmhdr & ";ptr Text;int TextMax;handle hItem;lparam lParam"
- Global Const $tagnmtvitemchange = $tagnmhdr & ";uint Changed;handle hItem;uint StateNew;uint StateOld;lparam lParam;"
- Global Const $tagtvhittestinfo = $tagpoint & ";uint Flags;handle Item"
- Global Const $tagnmtvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
- Global Const $tagnmmouse = $tagnmhdr & ";dword_ptr ItemSpec;dword_ptr ItemData;" & $tagpoint & ";lparam HitInfo"
- Global Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
- Global Const $tagimageinfo = "handle hBitmap;handle hMask;int Unused1;int Unused2;" & $tagrect
- Global Const $tagmenuinfo = "dword Size;INT Mask;dword Style;uint YMax;handle hBack;dword ContextHelpID;ulong_ptr MenuData"
- 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"
- 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")
- Global Const $tagnmrebarautobreak = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;uint uMsg;uint fStyleCurrent;bool fAutoBreak"
- 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"
- Global Const $tagnmrebar = $tagnmhdr & ";dword dwMask;uint uBand;uint fStyle;uint wID;lparam lParam"
- Global Const $tagnmrebarchevron = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;" & $tagrect & ";lparam lParamNM"
- 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"
- Global Const $tagcolorscheme = "dword Size;dword BtnHighlight;dword BtnShadow"
- 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
- Global Const $tagnmtbhotitem = $tagnmhdr & ";int idOld;int idNew;dword dwFlags"
- Global Const $tagtbbutton = "int Bitmap;int Command;byte State;byte Style;dword_ptr Param;int_ptr String"
- Global Const $tagtbbuttoninfo = "uint Size;dword Mask;int Command;int Image;byte State;byte Style;word CX;dword_ptr Param;ptr Text;int TextMax"
- Global Const $tagnetresource = "dword Scope;dword Type;dword DisplayType;dword Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider"
- Global Const $tagoverlapped = "ulong_ptr Internal;ulong_ptr InternalHigh;struct;dword Offset;dword OffsetHigh;endstruct;handle hEvent"
- 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"
- 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"
- Global Const $tagbitmapinfo = $tagbitmapinfoheader & ";dword biRGBQuad[1]"
- Global Const $tagblendfunction = "byte Op;byte Flags;byte Alpha;byte Format"
- Global Const $tagguid = "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct"
- Global Const $tagwindowplacement = "uint length;uint flags;uint showCmd;long ptMinPosition[2];long ptMaxPosition[2];long rcNormalPosition[4]"
- Global Const $tagwindowpos = "hwnd hWnd;hwnd InsertAfter;int X;int Y;int CX;int CY;uint Flags"
- Global Const $tagscrollinfo = "uint cbSize;uint fMask;int nMin;int nMax;uint nPage;int nPos;int nTrackPos"
- Global Const $tagscrollbarinfo = "dword cbSize;" & $tagrect & ";int dxyLineButton;int xyThumbTop;" & "int xyThumbBottom;int reserved;dword rgstate[6]"
- 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"
- Global Const $tagkbdllhookstruct = "dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo"
- Global Const $tagprocess_information = "handle hProcess;handle hThread;dword ProcessID;dword ThreadID"
- 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"
- Global Const $tagsecurity_attributes = "dword Length;ptr Descriptor;bool InheritHandle"
- 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]"
- 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"
- Global Const $process_terminate = 1
- Global Const $process_create_thread = 2
- Global Const $process_set_sessionid = 4
- Global Const $process_vm_operation = 8
- Global Const $process_vm_read = 16
- Global Const $process_vm_write = 32
- Global Const $process_dup_handle = 64
- Global Const $process_create_process = 128
- Global Const $process_set_quota = 256
- Global Const $process_set_information = 512
- Global Const $process_query_information = 1024
- Global Const $process_query_limited_information = 4096
- Global Const $process_suspend_resume = 2048
- Global Const $process_all_access = 2035711
- Global Const $se_assignprimarytoken_name = "SeAssignPrimaryTokenPrivilege"
- Global Const $se_audit_name = "SeAuditPrivilege"
- Global Const $se_backup_name = "SeBackupPrivilege"
- Global Const $se_change_notify_name = "SeChangeNotifyPrivilege"
- Global Const $se_create_global_name = "SeCreateGlobalPrivilege"
- Global Const $se_create_pagefile_name = "SeCreatePagefilePrivilege"
- Global Const $se_create_permanent_name = "SeCreatePermanentPrivilege"
- Global Const $se_create_symbolic_link_name = "SeCreateSymbolicLinkPrivilege"
- Global Const $se_create_token_name = "SeCreateTokenPrivilege"
- Global Const $se_debug_name = "SeDebugPrivilege"
- Global Const $se_enable_delegation_name = "SeEnableDelegationPrivilege"
- Global Const $se_impersonate_name = "SeImpersonatePrivilege"
- Global Const $se_inc_base_priority_name = "SeIncreaseBasePriorityPrivilege"
- Global Const $se_inc_working_set_name = "SeIncreaseWorkingSetPrivilege"
- Global Const $se_increase_quota_name = "SeIncreaseQuotaPrivilege"
- Global Const $se_load_driver_name = "SeLoadDriverPrivilege"
- Global Const $se_lock_memory_name = "SeLockMemoryPrivilege"
- Global Const $se_machine_account_name = "SeMachineAccountPrivilege"
- Global Const $se_manage_volume_name = "SeManageVolumePrivilege"
- Global Const $se_prof_single_process_name = "SeProfileSingleProcessPrivilege"
- Global Const $se_relabel_name = "SeRelabelPrivilege"
- Global Const $se_remote_shutdown_name = "SeRemoteShutdownPrivilege"
- Global Const $se_restore_name = "SeRestorePrivilege"
- Global Const $se_security_name = "SeSecurityPrivilege"
- Global Const $se_shutdown_name = "SeShutdownPrivilege"
- Global Const $se_sync_agent_name = "SeSyncAgentPrivilege"
- Global Const $se_system_environment_name = "SeSystemEnvironmentPrivilege"
- Global Const $se_system_profile_name = "SeSystemProfilePrivilege"
- Global Const $se_systemtime_name = "SeSystemtimePrivilege"
- Global Const $se_take_ownership_name = "SeTakeOwnershipPrivilege"
- Global Const $se_tcb_name = "SeTcbPrivilege"
- Global Const $se_time_zone_name = "SeTimeZonePrivilege"
- Global Const $se_trusted_credman_access_name = "SeTrustedCredManAccessPrivilege"
- Global Const $se_unsolicited_input_name = "SeUnsolicitedInputPrivilege"
- Global Const $se_undock_name = "SeUndockPrivilege"
- Global Const $se_privilege_enabled_by_default = 1
- Global Const $se_privilege_enabled = 2
- Global Const $se_privilege_removed = 4
- Global Const $se_privilege_used_for_access = -2147483648
- Global Const $se_group_mandatory = 1
- Global Const $se_group_enabled_by_default = 2
- Global Const $se_group_enabled = 4
- Global Const $se_group_owner = 8
- Global Const $se_group_use_for_deny_only = 16
- Global Const $se_group_integrity = 32
- Global Const $se_group_integrity_enabled = 64
- Global Const $se_group_resource = 536870912
- Global Const $se_group_logon_id = -1073741824
- Global Enum $tokenprimary = 1, $tokenimpersonation
- Global Enum $securityanonymous = 0, $securityidentification, $securityimpersonation, $securitydelegation
- 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
- Global Const $token_assign_primary = 1
- Global Const $token_duplicate = 2
- Global Const $token_impersonate = 4
- Global Const $token_query = 8
- Global Const $token_query_source = 16
- Global Const $token_adjust_privileges = 32
- Global Const $token_adjust_groups = 64
- Global Const $token_adjust_default = 128
- Global Const $token_adjust_sessionid = 256
- Global Const $token_all_access = 983551
- Global Const $token_read = 131080
- Global Const $token_write = 131296
- Global Const $token_execute = 131072
- Global Const $token_has_traverse_privilege = 1
- Global Const $token_has_backup_privilege = 2
- Global Const $token_has_restore_privilege = 4
- Global Const $token_has_admin_group = 8
- Global Const $token_is_restricted = 16
- Global Const $token_session_not_referenced = 32
- Global Const $token_sandbox_inert = 64
- Global Const $token_has_impersonate_privilege = 128
- Global Const $rights_delete = 65536
- Global Const $read_control = 131072
- Global Const $write_dac = 262144
- Global Const $write_owner = 524288
- Global Const $synchronize = 1048576
- Global Const $access_system_security = 16777216
- Global Const $standard_rights_required = 983040
- Global Const $standard_rights_read = $read_control
- Global Const $standard_rights_write = $read_control
- Global Const $standard_rights_execute = $read_control
- Global Const $standard_rights_all = 2031616
- Global Const $specific_rights_all = 65535
- Global Enum $not_used_access = 0, $grant_access, $set_access, $deny_access, $revoke_access, $set_audit_success, $set_audit_failure
- 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
- Global Const $logon_with_profile = 1
- Global Const $logon_netcredentials_only = 2
- Global Enum $sidtypeuser = 1, $sidtypegroup, $sidtypedomain, $sidtypealias, $sidtypewellknowngroup, $sidtypedeletedaccount, $sidtypeinvalid, $sidtypeunknown, $sidtypecomputer, $sidtypelabel
- Global Const $sid_administrators = "S-1-5-32-544"
- Global Const $sid_users = "S-1-5-32-545"
- Global Const $sid_guests = "S-1-5-32-546"
- Global Const $sid_account_operators = "S-1-5-32-548"
- Global Const $sid_server_operators = "S-1-5-32-549"
- Global Const $sid_print_operators = "S-1-5-32-550"
- Global Const $sid_backup_operators = "S-1-5-32-551"
- Global Const $sid_replicator = "S-1-5-32-552"
- Global Const $sid_owner = "S-1-3-0"
- Global Const $sid_everyone = "S-1-1-0"
- Global Const $sid_network = "S-1-5-2"
- Global Const $sid_interactive = "S-1-5-4"
- Global Const $sid_system = "S-1-5-18"
- Global Const $sid_authenticated_users = "S-1-5-11"
- Global Const $sid_schannel_authentication = "S-1-5-64-14"
- Global Const $sid_digest_authentication = "S-1-5-64-21"
- Global Const $sid_nt_service = "S-1-5-80"
- Global Const $sid_untrusted_mandatory_level = "S-1-16-0"
- Global Const $sid_low_mandatory_level = "S-1-16-4096"
- Global Const $sid_medium_mandatory_level = "S-1-16-8192"
- Global Const $sid_medium_plus_mandatory_level = "S-1-16-8448"
- Global Const $sid_high_mandatory_level = "S-1-16-12288"
- Global Const $sid_system_mandatory_level = "S-1-16-16384"
- Global Const $sid_protected_process_mandatory_level = "S-1-16-20480"
- Global Const $sid_secure_process_mandatory_level = "S-1-16-28672"
- Global Const $sid_all_services = "S-1-5-80-0"
- Func _winapi_getlasterror(Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
- Local $aresult = DllCall("kernel32.dll", "dword", "GetLastError")
- Return SetError($_icurrenterror, $_icurrentextended, $aresult[0])
- EndFunc
- Func _winapi_setlasterror($ierrorcode, Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
- DllCall("kernel32.dll", "none", "SetLastError", "dword", $ierrorcode)
- Return SetError($_icurrenterror, $_icurrentextended, NULL )
- EndFunc
- Func __comerrorformating($ocomerror, $sprefix = @TAB)
- Local Const $str_striptrailing = 2
- 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)
- Return $serror
- EndFunc
- Func _security__adjusttokenprivileges($htoken, $bdisableall, $tnewstate, $ibufferlen, $tprevstate = 0, $prequired = 0)
- Local $acall = DllCall("advapi32.dll", "bool", "AdjustTokenPrivileges", "handle", $htoken, "bool", $bdisableall, "struct*", $tnewstate, "dword", $ibufferlen, "struct*", $tprevstate, "struct*", $prequired)
- If @error Then Return SetError(@error, @extended, False)
- Return NOT ($acall[0] = 0)
- EndFunc
- Func _security__createprocesswithtoken($htoken, $ilogonflags, $scommandline, $icreationflags, $scurdir, $tstartupinfo, $tprocess_information)
- 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)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
- Return True
- EndFunc
- Func _security__duplicatetokenex($hexistingtoken, $idesiredaccess, $iimpersonationlevel, $itokentype)
- Local $acall = DllCall("advapi32.dll", "bool", "DuplicateTokenEx", "handle", $hexistingtoken, "dword", $idesiredaccess, "struct*", 0, "int", $iimpersonationlevel, "int", $itokentype, "handle*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Return $acall[6]
- EndFunc
- Func _security__getaccountsid($saccount, $ssystem = "")
- Local $aacct = _security__lookupaccountname($saccount, $ssystem)
- If @error Then Return SetError(@error, @extended, 0)
- If IsArray($aacct) Then Return _security__stringsidtosid($aacct[0])
- Return ""
- EndFunc
- Func _security__getlengthsid($psid)
- If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
- Local $acall = DllCall("advapi32.dll", "dword", "GetLengthSid", "struct*", $psid)
- If @error Then Return SetError(@error, @extended, 0)
- Return $acall[0]
- EndFunc
- Func _security__gettokeninformation($htoken, $iclass)
- Local $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", 0, "dword", 0, "dword*", 0)
- If @error OR NOT $acall[5] Then Return SetError(@error + 10, @extended, 0)
- Local $ilen = $acall[5]
- Local $tbuffer = DllStructCreate("byte[" & $ilen & "]")
- $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", $tbuffer, "dword", DllStructGetSize($tbuffer), "dword*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Return $tbuffer
- EndFunc
- Func _security__impersonateself($ilevel = $securityimpersonation)
- Local $acall = DllCall("advapi32.dll", "bool", "ImpersonateSelf", "int", $ilevel)
- If @error Then Return SetError(@error, @extended, False)
- Return NOT ($acall[0] = 0)
- EndFunc
- Func _security__isvalidsid($psid)
- Local $acall = DllCall("advapi32.dll", "bool", "IsValidSid", "struct*", $psid)
- If @error Then Return SetError(@error, @extended, False)
- Return NOT ($acall[0] = 0)
- EndFunc
- Func _security__lookupaccountname($saccount, $ssystem = "")
- Local $tdata = DllStructCreate("byte SID[256]")
- Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountNameW", "wstr", $ssystem, "wstr", $saccount, "struct*", $tdata, "dword*", DllStructGetSize($tdata), "wstr", "", "dword*", DllStructGetSize($tdata), "int*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Local $aacct[3]
- $aacct[0] = _security__sidtostringsid(DllStructGetPtr($tdata, "SID"))
- $aacct[1] = $acall[5]
- $aacct[2] = $acall[7]
- Return $aacct
- EndFunc
- Func _security__lookupaccountsid($vsid, $ssystem = "")
- Local $psid, $aacct[3]
- If IsString($vsid) Then
- $psid = _security__stringsidtosid($vsid)
- Else
- $psid = $vsid
- EndIf
- If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
- Local $stypesystem = "ptr"
- If $ssystem Then $stypesystem = "wstr"
- Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountSidW", $stypesystem, $ssystem, "struct*", $psid, "wstr", "", "dword*", 65536, "wstr", "", "dword*", 65536, "int*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Local $aacct[3]
- $aacct[0] = $acall[3]
- $aacct[1] = $acall[5]
- $aacct[2] = $acall[7]
- Return $aacct
- EndFunc
- Func _security__lookupprivilegevalue($ssystem, $sname)
- Local $acall = DllCall("advapi32.dll", "bool", "LookupPrivilegeValueW", "wstr", $ssystem, "wstr", $sname, "int64*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Return $acall[3]
- EndFunc
- Func _security__openprocesstoken($hprocess, $iaccess)
- Local $acall = DllCall("advapi32.dll", "bool", "OpenProcessToken", "handle", $hprocess, "dword", $iaccess, "handle*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Return $acall[3]
- EndFunc
- Func _security__openthreadtoken($iaccess, $hthread = 0, $bopenasself = False)
- If $hthread = 0 Then
- Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
- If @error Then Return SetError(@error + 10, @extended, 0)
- $hthread = $aresult[0]
- EndIf
- Local $acall = DllCall("advapi32.dll", "bool", "OpenThreadToken", "handle", $hthread, "dword", $iaccess, "bool", $bopenasself, "handle*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Return $acall[4]
- EndFunc
- Func _security__openthreadtokenex($iaccess, $hthread = 0, $bopenasself = False)
- Local $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
- If $htoken = 0 Then
- Local Const $error_no_token = 1008
- If _winapi_getlasterror() <> $error_no_token Then Return SetError(20, _winapi_getlasterror(), 0)
- If NOT _security__impersonateself() Then Return SetError(@error + 10, _winapi_getlasterror(), 0)
- $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
- If $htoken = 0 Then Return SetError(@error, _winapi_getlasterror(), 0)
- EndIf
- Return $htoken
- EndFunc
- Func _security__setprivilege($htoken, $sprivilege, $benable)
- Local $iluid = _security__lookupprivilegevalue("", $sprivilege)
- If $iluid = 0 Then Return SetError(@error + 10, @extended, False)
- Local Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
- Local $tcurrstate = DllStructCreate($tagtoken_privileges)
- Local $icurrstate = DllStructGetSize($tcurrstate)
- Local $tprevstate = DllStructCreate($tagtoken_privileges)
- Local $iprevstate = DllStructGetSize($tprevstate)
- Local $trequired = DllStructCreate("int Data")
- DllStructSetData($tcurrstate, "Count", 1)
- DllStructSetData($tcurrstate, "LUID", $iluid)
- If NOT _security__adjusttokenprivileges($htoken, False, $tcurrstate, $icurrstate, $tprevstate, $trequired) Then Return SetError(2, @error, False)
- DllStructSetData($tprevstate, "Count", 1)
- DllStructSetData($tprevstate, "LUID", $iluid)
- Local $iattributes = DllStructGetData($tprevstate, "Attributes")
- If $benable Then
- $iattributes = BitOR($iattributes, $se_privilege_enabled)
- Else
- $iattributes = BitAND($iattributes, BitNOT($se_privilege_enabled))
- EndIf
- DllStructSetData($tprevstate, "Attributes", $iattributes)
- If NOT _security__adjusttokenprivileges($htoken, False, $tprevstate, $iprevstate, $tcurrstate, $trequired) Then Return SetError(3, @error, False)
- Return True
- EndFunc
- Func _security__settokeninformation($htoken, $itokeninformation, $vtokeninformation, $itokeninformationlength)
- Local $acall = DllCall("advapi32.dll", "bool", "SetTokenInformation", "handle", $htoken, "int", $itokeninformation, "struct*", $vtokeninformation, "dword", $itokeninformationlength)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
- Return True
- EndFunc
- Func _security__sidtostringsid($psid)
- If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, 0, "")
- Local $acall = DllCall("advapi32.dll", "bool", "ConvertSidToStringSidW", "struct*", $psid, "ptr*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, "")
- Local $pstringsid = $acall[2]
- Local $alen = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $pstringsid)
- Local $ssid = DllStructGetData(DllStructCreate("wchar Text[" & $alen[0] + 1 & "]", $pstringsid), "Text")
- DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pstringsid)
- Return $ssid
- EndFunc
- Func _security__sidtypestr($itype)
- Switch $itype
- Case $sidtypeuser
- Return "User"
- Case $sidtypegroup
- Return "Group"
- Case $sidtypedomain
- Return "Domain"
- Case $sidtypealias
- Return "Alias"
- Case $sidtypewellknowngroup
- Return "Well Known Group"
- Case $sidtypedeletedaccount
- Return "Deleted Account"
- Case $sidtypeinvalid
- Return "Invalid"
- Case $sidtypeunknown
- Return "Unknown Type"
- Case $sidtypecomputer
- Return "Computer"
- Case $sidtypelabel
- Return "A mandatory integrity label SID"
- Case Else
- Return "Unknown SID Type"
- EndSwitch
- EndFunc
- Func _security__stringsidtosid($ssid)
- Local $acall = DllCall("advapi32.dll", "bool", "ConvertStringSidToSidW", "wstr", $ssid, "ptr*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Local $psid = $acall[2]
- Local $tbuffer = DllStructCreate("byte Data[" & _security__getlengthsid($psid) & "]", $psid)
- Local $tsid = DllStructCreate("byte Data[" & DllStructGetSize($tbuffer) & "]")
- DllStructSetData($tsid, "Data", DllStructGetData($tbuffer, "Data"))
- DllCall("kernel32.dll", "handle", "LocalFree", "handle", $psid)
- Return $tsid
- EndFunc
- Global Const $tagmemmap = "handle hProc;ulong_ptr Size;ptr Mem"
- Func _memfree(ByRef $tmemmap)
- Local $pmemory = DllStructGetData($tmemmap, "Mem")
- Local $hprocess = DllStructGetData($tmemmap, "hProc")
- Local $bresult = _memvirtualfreeex($hprocess, $pmemory, 0, $mem_release)
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hprocess)
- If @error Then Return SetError(@error, @extended, False)
- Return $bresult
- EndFunc
- Func _memglobalalloc($ibytes, $iflags = 0)
- Local $aresult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $iflags, "ulong_ptr", $ibytes)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _memglobalfree($hmem)
- Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hmem)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _memgloballock($hmem)
- Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hmem)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _memglobalsize($hmem)
- Local $aresult = DllCall("kernel32.dll", "ulong_ptr", "GlobalSize", "handle", $hmem)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _memglobalunlock($hmem)
- Local $aresult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hmem)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _meminit($hwnd, $isize, ByRef $tmemmap)
- Local $aresult = DllCall("User32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
- If @error Then Return SetError(@error, @extended, 0)
- Local $iprocessid = $aresult[2]
- If $iprocessid = 0 Then Return SetError(1, 0, 0)
- Local $iaccess = BitOR($process_vm_operation, $process_vm_read, $process_vm_write)
- Local $hprocess = __mem_openprocess($iaccess, False, $iprocessid, True)
- Local $ialloc = BitOR($mem_reserve, $mem_commit)
- Local $pmemory = _memvirtualallocex($hprocess, 0, $isize, $ialloc, $page_readwrite)
- If $pmemory = 0 Then Return SetError(2, 0, 0)
- $tmemmap = DllStructCreate($tagmemmap)
- DllStructSetData($tmemmap, "hProc", $hprocess)
- DllStructSetData($tmemmap, "Size", $isize)
- DllStructSetData($tmemmap, "Mem", $pmemory)
- Return $pmemory
- EndFunc
- Func _memmovememory($psource, $pdest, $ilength)
- DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pdest, "struct*", $psource, "ulong_ptr", $ilength)
- If @error Then Return SetError(@error, @extended)
- EndFunc
- Func _memread(ByRef $tmemmap, $psrce, $pdest, $isize)
- Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $psrce, "struct*", $pdest, "ulong_ptr", $isize, "ulong_ptr*", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _memwrite(ByRef $tmemmap, $psrce, $pdest = 0, $isize = 0, $ssrce = "struct*")
- If $pdest = 0 Then $pdest = DllStructGetData($tmemmap, "Mem")
- If $isize = 0 Then $isize = DllStructGetData($tmemmap, "Size")
- Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $pdest, $ssrce, $psrce, "ulong_ptr", $isize, "ulong_ptr*", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _memvirtualalloc($paddress, $isize, $iallocation, $iprotect)
- Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _memvirtualallocex($hprocess, $paddress, $isize, $iallocation, $iprotect)
- Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _memvirtualfree($paddress, $isize, $ifreetype)
- Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFree", "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _memvirtualfreeex($hprocess, $paddress, $isize, $ifreetype)
- Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func __mem_openprocess($iaccess, $finherit, $iprocessid, $fdebugpriv = False)
- Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
- If @error Then Return SetError(@error, @extended, 0)
- If $aresult[0] Then Return $aresult[0]
- If NOT $fdebugpriv Then Return 0
- Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
- If @error Then Return SetError(@error, @extended, 0)
- _security__setprivilege($htoken, "SeDebugPrivilege", True)
- Local $ierror = @error
- Local $ilasterror = @extended
- Local $iret = 0
- If NOT @error Then
- $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
- $ierror = @error
- $ilasterror = @extended
- If $aresult[0] Then $iret = $aresult[0]
- _security__setprivilege($htoken, "SeDebugPrivilege", False)
- If @error Then
- $ierror = @error
- $ilasterror = @extended
- EndIf
- EndIf
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $htoken)
- Return SetError($ierror, $ilasterror, $iret)
- EndFunc
- Func _sendmessage($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
- Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageW", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
- If @error Then Return SetError(@error, @extended, "")
- If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
- Return $aresult
- EndFunc
- Func _sendmessagea($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
- Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageA", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
- If @error Then Return SetError(@error, @extended, "")
- If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
- Return $aresult
- EndFunc
- Global Const $sbars_sizegrip = 256
- Global Const $sbt_tooltips = 2048
- Global Const $sbars_tooltips = 2048
- Global Const $sbt_sunken = 0
- Global Const $sbt_noborders = 256
- Global Const $sbt_popout = 512
- Global Const $sbt_rtlreading = 1024
- Global Const $sbt_notabparsing = 2048
- Global Const $sbt_ownerdraw = 4096
- Global Const $__statusbarconstant_wm_user = 1024
- Global Const $sb_getborders = ($__statusbarconstant_wm_user + 7)
- Global Const $sb_geticon = ($__statusbarconstant_wm_user + 20)
- Global Const $sb_getparts = ($__statusbarconstant_wm_user + 6)
- Global Const $sb_getrect = ($__statusbarconstant_wm_user + 10)
- Global Const $sb_gettexta = ($__statusbarconstant_wm_user + 2)
- Global Const $sb_gettextw = ($__statusbarconstant_wm_user + 13)
- Global Const $sb_gettext = $sb_gettexta
- Global Const $sb_gettextlengtha = ($__statusbarconstant_wm_user + 3)
- Global Const $sb_gettextlengthw = ($__statusbarconstant_wm_user + 12)
- Global Const $sb_gettextlength = $sb_gettextlengtha
- Global Const $sb_gettiptexta = ($__statusbarconstant_wm_user + 18)
- Global Const $sb_gettiptextw = ($__statusbarconstant_wm_user + 19)
- Global Const $sb_getunicodeformat = 8192 + 6
- Global Const $sb_issimple = ($__statusbarconstant_wm_user + 14)
- Global Const $sb_setbkcolor = 8192 + 1
- Global Const $sb_seticon = ($__statusbarconstant_wm_user + 15)
- Global Const $sb_setminheight = ($__statusbarconstant_wm_user + 8)
- Global Const $sb_setparts = ($__statusbarconstant_wm_user + 4)
- Global Const $sb_settexta = ($__statusbarconstant_wm_user + 1)
- Global Const $sb_settextw = ($__statusbarconstant_wm_user + 11)
- Global Const $sb_settext = $sb_settexta
- Global Const $sb_settiptexta = ($__statusbarconstant_wm_user + 16)
- Global Const $sb_settiptextw = ($__statusbarconstant_wm_user + 17)
- Global Const $sb_setunicodeformat = 8192 + 5
- Global Const $sb_simple = ($__statusbarconstant_wm_user + 9)
- Global Const $sb_simpleid = 255
- Global Const $sbn_first = -880
- Global Const $sbn_simplemodechange = $sbn_first + 0
- Global Const $fc_nooverwrite = 0
- Global Const $fc_overwrite = 1
- Global Const $fc_createpath = 8
- Global Const $ft_modified = 0
- Global Const $ft_created = 1
- Global Const $ft_accessed = 2
- Global Const $ft_array = 0
- Global Const $ft_string = 1
- Global Const $fsf_createbutton = 1
- Global Const $fsf_newdialog = 2
- Global Const $fsf_editcontrol = 4
- Global Const $ft_nonrecursive = 0
- Global Const $ft_recursive = 1
- Global Const $fo_read = 0
- Global Const $fo_append = 1
- Global Const $fo_overwrite = 2
- Global Const $fo_createpath = 8
- Global Const $fo_binary = 16
- Global Const $fo_unicode = 32
- Global Const $fo_utf16_le = 32
- Global Const $fo_utf16_be = 64
- Global Const $fo_utf8 = 128
- Global Const $fo_utf8_nobom = 256
- Global Const $fo_ansi = 512
- Global Const $fo_utf16_le_nobom = 1024
- Global Const $fo_utf16_be_nobom = 2048
- Global Const $fo_utf8_full = 16384
- Global Const $fo_fullfile_detect = 16384
- Global Const $eof = -1
- Global Const $fd_filemustexist = 1
- Global Const $fd_pathmustexist = 2
- Global Const $fd_multiselect = 4
- Global Const $fd_promptcreatenew = 8
- Global Const $fd_promptoverwrite = 16
- Global Const $create_new = 1
- Global Const $create_always = 2
- Global Const $open_existing = 3
- Global Const $open_always = 4
- Global Const $truncate_existing = 5
- Global Const $invalid_set_file_pointer = -1
- Global Const $file_begin = 0
- Global Const $file_current = 1
- Global Const $file_end = 2
- Global Const $file_attribute_readonly = 1
- Global Const $file_attribute_hidden = 2
- Global Const $file_attribute_system = 4
- Global Const $file_attribute_directory = 16
- Global Const $file_attribute_archive = 32
- Global Const $file_attribute_device = 64
- Global Const $file_attribute_normal = 128
- Global Const $file_attribute_temporary = 256
- Global Const $file_attribute_sparse_file = 512
- Global Const $file_attribute_reparse_point = 1024
- Global Const $file_attribute_compressed = 2048
- Global Const $file_attribute_offline = 4096
- Global Const $file_attribute_not_content_indexed = 8192
- Global Const $file_attribute_encrypted = 16384
- Global Const $file_share_read = 1
- Global Const $file_share_write = 2
- Global Const $file_share_delete = 4
- Global Const $file_share_readwrite = BitOR($file_share_read, $file_share_write)
- Global Const $file_share_any = BitOR($file_share_read, $file_share_write, $file_share_delete)
- Global Const $generic_all = 268435456
- Global Const $generic_execute = 536870912
- Global Const $generic_write = 1073741824
- Global Const $generic_read = -2147483648
- Global Const $generic_readwrite = BitOR($generic_read, $generic_write)
- Global Const $file_encoding_utf16le = 32
- Global Const $fe_entire_utf8 = 1
- Global Const $fe_partialfirst_utf8 = 2
- Global Const $fn_fullpath = 0
- Global Const $fn_relativepath = 1
- Global Const $fv_comments = "Comments"
- Global Const $fv_companyname = "CompanyName"
- Global Const $fv_filedescription = "FileDescription"
- Global Const $fv_fileversion = "FileVersion"
- Global Const $fv_internalname = "InternalName"
- Global Const $fv_legalcopyright = "LegalCopyright"
- Global Const $fv_legaltrademarks = "LegalTrademarks"
- Global Const $fv_originalfilename = "OriginalFilename"
- Global Const $fv_productname = "ProductName"
- Global Const $fv_productversion = "ProductVersion"
- Global Const $fv_privatebuild = "PrivateBuild"
- Global Const $fv_specialbuild = "SpecialBuild"
- Global Const $frta_nocount = 0
- Global Const $frta_count = 1
- Global Const $frta_intarrays = 2
- Global Const $frta_entiresplit = 4
- Global Const $flta_filesfolders = 0
- Global Const $flta_files = 1
- Global Const $flta_folders = 2
- Global Const $fltar_filesfolders = 0
- Global Const $fltar_files = 1
- Global Const $fltar_folders = 2
- Global Const $fltar_nohidden = 4
- Global Const $fltar_nosystem = 8
- Global Const $fltar_nolink = 16
- Global Const $fltar_norecur = 0
- Global Const $fltar_recur = 1
- Global Const $fltar_nosort = 0
- Global Const $fltar_sort = 1
- Global Const $fltar_fastsort = 2
- Global Const $fltar_nopath = 0
- Global Const $fltar_relpath = 1
- Global Const $fltar_fullpath = 2
- Global Const $hgdi_error = Ptr(-1)
- Global Const $invalid_handle_value = Ptr(-1)
- Global Const $clr_invalid = -1
- Global Const $null_brush = 5
- Global Const $null_pen = 8
- Global Const $black_brush = 4
- Global Const $dkgray_brush = 3
- Global Const $dc_brush = 18
- Global Const $gray_brush = 2
- Global Const $hollow_brush = $null_brush
- Global Const $ltgray_brush = 1
- Global Const $white_brush = 0
- Global Const $black_pen = 7
- Global Const $dc_pen = 19
- Global Const $white_pen = 6
- Global Const $ansi_fixed_font = 11
- Global Const $ansi_var_font = 12
- Global Const $device_default_font = 14
- Global Const $default_gui_font = 17
- Global Const $oem_fixed_font = 10
- Global Const $system_font = 13
- Global Const $system_fixed_font = 16
- Global Const $default_palette = 15
- Global Const $mb_precomposed = 1
- Global Const $mb_composite = 2
- Global Const $mb_useglyphchars = 4
- Global Const $ulw_alpha = 2
- Global Const $ulw_colorkey = 1
- Global Const $ulw_opaque = 4
- Global Const $ulw_ex_noresize = 8
- Global Const $wh_callwndproc = 4
- Global Const $wh_callwndprocret = 12
- Global Const $wh_cbt = 5
- Global Const $wh_debug = 9
- Global Const $wh_foregroundidle = 11
- Global Const $wh_getmessage = 3
- Global Const $wh_journalplayback = 1
- Global Const $wh_journalrecord = 0
- Global Const $wh_keyboard = 2
- Global Const $wh_keyboard_ll = 13
- Global Const $wh_mouse = 7
- Global Const $wh_mouse_ll = 14
- Global Const $wh_msgfilter = -1
- Global Const $wh_shell = 10
- Global Const $wh_sysmsgfilter = 6
- Global Const $wpf_asyncwindowplacement = 4
- Global Const $wpf_restoretomaximized = 2
- Global Const $wpf_setminposition = 1
- Global Const $kf_extended = 256
- Global Const $kf_altdown = 8192
- Global Const $kf_up = 32768
- Global Const $llkhf_extended = BitShift($kf_extended, 8)
- Global Const $llkhf_injected = 16
- Global Const $llkhf_altdown = BitShift($kf_altdown, 8)
- Global Const $llkhf_up = BitShift($kf_up, 8)
- Global Const $ofn_allowmultiselect = 512
- Global Const $ofn_createprompt = 8192
- Global Const $ofn_dontaddtorecent = 33554432
- Global Const $ofn_enablehook = 32
- Global Const $ofn_enableincludenotify = 4194304
- Global Const $ofn_enablesizing = 8388608
- Global Const $ofn_enabletemplate = 64
- Global Const $ofn_enabletemplatehandle = 128
- Global Const $ofn_explorer = 524288
- Global Const $ofn_extensiondifferent = 1024
- Global Const $ofn_filemustexist = 4096
- Global Const $ofn_forceshowhidden = 268435456
- Global Const $ofn_hidereadonly = 4
- Global Const $ofn_longnames = 2097152
- Global Const $ofn_nochangedir = 8
- Global Const $ofn_nodereferencelinks = 1048576
- Global Const $ofn_nolongnames = 262144
- Global Const $ofn_nonetworkbutton = 131072
- Global Const $ofn_noreadonlyreturn = 32768
- Global Const $ofn_notestfilecreate = 65536
- Global Const $ofn_novalidate = 256
- Global Const $ofn_overwriteprompt = 2
- Global Const $ofn_pathmustexist = 2048
- Global Const $ofn_readonly = 1
- Global Const $ofn_shareaware = 16384
- Global Const $ofn_showhelp = 16
- Global Const $ofn_ex_noplacesbar = 1
- Global Const $tmpf_fixed_pitch = 1
- Global Const $tmpf_vector = 2
- Global Const $tmpf_truetype = 4
- Global Const $tmpf_device = 8
- Global Const $duplicate_close_source = 1
- Global Const $duplicate_same_access = 2
- Global Const $di_mask = 1
- Global Const $di_image = 2
- Global Const $di_normal = 3
- Global Const $di_compat = 4
- Global Const $di_defaultsize = 8
- Global Const $di_nomirror = 16
- Global Const $display_device_attached_to_desktop = 1
- Global Const $display_device_multi_driver = 2
- Global Const $display_device_primary_device = 4
- Global Const $display_device_mirroring_driver = 8
- Global Const $display_device_vga_compatible = 16
- Global Const $display_device_removable = 32
- Global Const $display_device_disconnect = 33554432
- Global Const $display_device_remote = 67108864
- Global Const $display_device_modespruned = 134217728
- Global Const $flashw_caption = 1
- Global Const $flashw_tray = 2
- Global Const $flashw_timer = 4
- Global Const $flashw_timernofg = 12
- Global Const $format_message_allocate_buffer = 256
- Global Const $format_message_ignore_inserts = 512
- Global Const $format_message_from_string = 1024
- Global Const $format_message_from_hmodule = 2048
- Global Const $format_message_from_system = 4096
- Global Const $format_message_argument_array = 8192
- Global Const $gw_hwndfirst = 0
- Global Const $gw_hwndlast = 1
- Global Const $gw_hwndnext = 2
- Global Const $gw_hwndprev = 3
- Global Const $gw_owner = 4
- Global Const $gw_child = 5
- Global Const $gw_enabledpopup = 6
- Global Const $gwl_wndproc = -4
- Global Const $gwl_hinstance = -6
- Global Const $gwl_hwndparent = -8
- Global Const $gwl_id = -12
- Global Const $gwl_style = -16
- Global Const $gwl_exstyle = -20
- Global Const $gwl_userdata = -21
- Global Const $std_cut = 0
- Global Const $std_copy = 1
- Global Const $std_paste = 2
- Global Const $std_undo = 3
- Global Const $std_redow = 4
- Global Const $std_delete = 5
- Global Const $std_filenew = 6
- Global Const $std_fileopen = 7
- Global Const $std_filesave = 8
- Global Const $std_printpre = 9
- Global Const $std_properties = 10
- Global Const $std_help = 11
- Global Const $std_find = 12
- Global Const $std_replace = 13
- Global Const $std_print = 14
- Global Const $image_bitmap = 0
- Global Const $image_icon = 1
- Global Const $image_cursor = 2
- Global Const $image_enhmetafile = 3
- Global Const $kb_sendspecial = 0
- Global Const $kb_sendraw = 1
- Global Const $kb_capsoff = 0
- Global Const $kb_capson = 1
- Global Const $dont_resolve_dll_references = 1
- Global Const $load_library_as_datafile = 2
- Global Const $load_with_altered_search_path = 8
- Global Const $load_ignore_code_authz_level = 16
- Global Const $load_library_as_datafile_exclusive = 64
- Global Const $load_library_as_image_resource = 32
- Global Const $load_library_search_application_dir = 512
- Global Const $load_library_search_default_dirs = 4096
- Global Const $load_library_search_dll_load_dir = 256
- Global Const $load_library_search_system32 = 2048
- Global Const $load_library_search_user_dirs = 1024
- Global Const $s_ok = 0
- Global Const $e_abort = -2147467260
- Global Const $e_accessdenied = -2147024891
- Global Const $e_fail = -2147467259
- Global Const $e_handle = -2147024890
- Global Const $e_invalidarg = -2147024809
- Global Const $e_nointerface = -2147467262
- Global Const $e_notimpl = -2147467263
- Global Const $e_outofmemory = -2147024882
- Global Const $e_pointer = -2147467261
- Global Const $e_unexpected = -2147418113
- Global Const $lr_defaultcolor = 0
- Global Const $lr_monochrome = 1
- Global Const $lr_color = 2
- Global Const $lr_copyreturnorg = 4
- Global Const $lr_copydeleteorg = 8
- Global Const $lr_loadfromfile = 16
- Global Const $lr_loadtransparent = 32
- Global Const $lr_defaultsize = 64
- Global Const $lr_vgacolor = 128
- Global Const $lr_loadmap3dcolors = 4096
- Global Const $lr_createdibsection = 8192
- Global Const $lr_copyfromresource = 16384
- Global Const $lr_shared = 32768
- Global Const $obm_trtype = 32732
- Global Const $obm_lfarrowi = 32734
- Global Const $obm_rgarrowi = 32735
- Global Const $obm_dnarrowi = 32736
- Global Const $obm_uparrowi = 32737
- Global Const $obm_combo = 32738
- Global Const $obm_mnarrow = 32739
- Global Const $obm_lfarrowd = 32740
- Global Const $obm_rgarrowd = 32741
- Global Const $obm_dnarrowd = 32742
- Global Const $obm_uparrowd = 32743
- Global Const $obm_restored = 32744
- Global Const $obm_zoomd = 32745
- Global Const $obm_reduced = 32746
- Global Const $obm_restore = 32747
- Global Const $obm_zoom = 32748
- Global Const $obm_reduce = 32749
- Global Const $obm_lfarrow = 32750
- Global Const $obm_rgarrow = 32751
- Global Const $obm_dnarrow = 32752
- Global Const $obm_uparrow = 32753
- Global Const $obm_close = 32754
- Global Const $obm_old_restore = 32755
- Global Const $obm_old_zoom = 32756
- Global Const $obm_old_reduce = 32757
- Global Const $obm_btncorners = 32758
- Global Const $obm_checkboxes = 32759
- Global Const $obm_check = 32760
- Global Const $obm_btsize = 32761
- Global Const $obm_old_lfarrow = 32762
- Global Const $obm_old_rgarrow = 32763
- Global Const $obm_old_dnarrow = 32764
- Global Const $obm_old_uparrow = 32765
- Global Const $obm_size = 32766
- Global Const $obm_old_close = 32767
- Global Const $oic_sample = 32512
- Global Const $oic_hand = 32513
- Global Const $oic_ques = 32514
- Global Const $oic_bang = 32515
- Global Const $oic_note = 32516
- Global Const $oic_winlogo = 32517
- Global Const $oic_warning = $oic_bang
- Global Const $oic_error = $oic_hand
- Global Const $oic_information = $oic_note
- Global $__g_ainprocess_winapi[64][2] = [[0, 0]]
- Global $__g_awinlist_winapi[64][2] = [[0, 0]]
- Global Const $__winapiconstant_wm_setfont = 48
- Global Const $__winapiconstant_fw_normal = 400
- Global Const $__winapiconstant_default_charset = 1
- Global Const $__winapiconstant_out_default_precis = 0
- Global Const $__winapiconstant_clip_default_precis = 0
- Global Const $__winapiconstant_default_quality = 0
- Global Const $__winapiconstant_logpixelsx = 88
- Global Const $__winapiconstant_logpixelsy = 90
- Global Const $tagcursorinfo = "dword Size;dword Flags;handle hCursor;" & $tagpoint
- Global Const $tagdisplay_device = "dword Size;wchar Name[32];wchar String[128];dword Flags;wchar ID[128];wchar Key[128]"
- Global Const $tagflashwinfo = "uint Size;hwnd hWnd;dword Flags;uint Count;dword TimeOut"
- Global Const $tagiconinfo = "bool Icon;dword XHotSpot;dword YHotSpot;handle hMask;handle hColor"
- Global Const $tagmemorystatusex = "dword Length;dword MemoryLoad;" & "uint64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & "uint64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual"
- Func _winapi_attachconsole($ipid = -1)
- Local $aresult = DllCall("kernel32.dll", "bool", "AttachConsole", "dword", $ipid)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_attachthreadinput($iattach, $iattachto, $battach)
- Local $aresult = DllCall("user32.dll", "bool", "AttachThreadInput", "dword", $iattach, "dword", $iattachto, "bool", $battach)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_beep($ifreq = 500, $iduration = 1000)
- Local $aresult = DllCall("kernel32.dll", "bool", "Beep", "dword", $ifreq, "dword", $iduration)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_bitblt($hdestdc, $ixdest, $iydest, $iwidth, $iheight, $hsrcdc, $ixsrc, $iysrc, $irop)
- 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)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_callnexthookex($hhook, $icode, $wparam, $lparam)
- Local $aresult = DllCall("user32.dll", "lresult", "CallNextHookEx", "handle", $hhook, "int", $icode, "wparam", $wparam, "lparam", $lparam)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_callwindowproc($pprevwndfunc, $hwnd, $imsg, $wparam, $lparam)
- Local $aresult = DllCall("user32.dll", "lresult", "CallWindowProc", "ptr", $pprevwndfunc, "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_clienttoscreen($hwnd, ByRef $tpoint)
- Local $aret = DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hwnd, "struct*", $tpoint)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Return $tpoint
- EndFunc
- Func _winapi_closehandle($hobject)
- Local $aresult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hobject)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_combinergn($hrgndest, $hrgnsrc1, $hrgnsrc2, $icombinemode)
- Local $aresult = DllCall("gdi32.dll", "int", "CombineRgn", "handle", $hrgndest, "handle", $hrgnsrc1, "handle", $hrgnsrc2, "int", $icombinemode)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_commdlgextendederror()
- Local Const $cderr_dialogfailure = 65535
- Local Const $cderr_findresfailure = 6
- Local Const $cderr_initialization = 2
- Local Const $cderr_loadresfailure = 7
- Local Const $cderr_loadstrfailure = 5
- Local Const $cderr_lockresfailure = 8
- Local Const $cderr_memallocfailure = 9
- Local Const $cderr_memlockfailure = 10
- Local Const $cderr_nohinstance = 4
- Local Const $cderr_nohook = 11
- Local Const $cderr_notemplate = 3
- Local Const $cderr_registermsgfail = 12
- Local Const $cderr_structsize = 1
- Local Const $fnerr_buffertoosmall = 12291
- Local Const $fnerr_invalidfilename = 12290
- Local Const $fnerr_subclassfailure = 12289
- Local $aresult = DllCall("comdlg32.dll", "dword", "CommDlgExtendedError")
- If NOT @error Then
- Switch $aresult[0]
- Case $cderr_dialogfailure
- 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.")
- Case $cderr_findresfailure
- Return SetError($aresult[0], 0, "The common dialog box function failed to find a specified resource.")
- Case $cderr_initialization
- Return SetError($aresult[0], 0, "The common dialog box function failed during initialization." & @LF & "This error often occurs when sufficient memory is not available.")
- Case $cderr_loadresfailure
- Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified resource.")
- Case $cderr_loadstrfailure
- Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified string.")
- Case $cderr_lockresfailure
- Return SetError($aresult[0], 0, "The common dialog box function failed to lock a specified resource.")
- Case $cderr_memallocfailure
- Return SetError($aresult[0], 0, "The common dialog box function was unable to allocate memory for internal structures.")
- Case $cderr_memlockfailure
- Return SetError($aresult[0], 0, "The common dialog box function was unable to lock the memory associated with a handle.")
- Case $cderr_nohinstance
- 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.")
- Case $cderr_nohook
- 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.")
- Case $cderr_notemplate
- 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.")
- Case $cderr_registermsgfail
- Return SetError($aresult[0], 0, "The RegisterWindowMessage function returned an error code when it was called by the common dialog box function.")
- Case $cderr_structsize
- Return SetError($aresult[0], 0, "The lStructSize member of the initialization structure for the corresponding common dialog box is invalid")
- Case $fnerr_buffertoosmall
- 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.")
- Case $fnerr_invalidfilename
- Return SetError($aresult[0], 0, "A file name is invalid.")
- Case $fnerr_subclassfailure
- Return SetError($aresult[0], 0, "An attempt to subclass a list box failed because sufficient memory was not available.")
- EndSwitch
- EndIf
- Return SetError(@error, @extended, "0x" & Hex($aresult[0]))
- EndFunc
- Func _winapi_copyicon($hicon)
- Local $aresult = DllCall("user32.dll", "handle", "CopyIcon", "handle", $hicon)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_createbitmap($iwidth, $iheight, $iplanes = 1, $ibitsperpel = 1, $pbits = 0)
- Local $aresult = DllCall("gdi32.dll", "handle", "CreateBitmap", "int", $iwidth, "int", $iheight, "uint", $iplanes, "uint", $ibitsperpel, "struct*", $pbits)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
- Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleBitmap", "handle", $hdc, "int", $iwidth, "int", $iheight)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_createcompatibledc($hdc)
- Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleDC", "handle", $hdc)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_createevent($tattributes = 0, $bmanualreset = True, $binitialstate = True, $sname = "")
- Local $snametype = "wstr"
- If $sname = "" Then
- $sname = 0
- $snametype = "ptr"
- EndIf
- Local $aresult = DllCall("kernel32.dll", "handle", "CreateEventW", "struct*", $tattributes, "bool", $bmanualreset, "bool", $binitialstate, $snametype, $sname)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_createfile($sfilename, $icreation, $iaccess = 4, $ishare = 0, $iattributes = 0, $tsecurity = 0)
- Local $ida = 0, $ism = 0, $icd = 0, $ifa = 0
- If BitAND($iaccess, 1) <> 0 Then $ida = BitOR($ida, $generic_execute)
- If BitAND($iaccess, 2) <> 0 Then $ida = BitOR($ida, $generic_read)
- If BitAND($iaccess, 4) <> 0 Then $ida = BitOR($ida, $generic_write)
- If BitAND($ishare, 1) <> 0 Then $ism = BitOR($ism, $file_share_delete)
- If BitAND($ishare, 2) <> 0 Then $ism = BitOR($ism, $file_share_read)
- If BitAND($ishare, 4) <> 0 Then $ism = BitOR($ism, $file_share_write)
- Switch $icreation
- Case 0
- $icd = $create_new
- Case 1
- $icd = $create_always
- Case 2
- $icd = $open_existing
- Case 3
- $icd = $open_always
- Case 4
- $icd = $truncate_existing
- EndSwitch
- If BitAND($iattributes, 1) <> 0 Then $ifa = BitOR($ifa, $file_attribute_archive)
- If BitAND($iattributes, 2) <> 0 Then $ifa = BitOR($ifa, $file_attribute_hidden)
- If BitAND($iattributes, 4) <> 0 Then $ifa = BitOR($ifa, $file_attribute_readonly)
- If BitAND($iattributes, 8) <> 0 Then $ifa = BitOR($ifa, $file_attribute_system)
- Local $aresult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sfilename, "dword", $ida, "dword", $ism, "struct*", $tsecurity, "dword", $icd, "dword", $ifa, "ptr", 0)
- If @error OR ($aresult[0] = $invalid_handle_value) Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- 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")
- 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)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_createfontindirect($tlogfont)
- Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontIndirectW", "struct*", $tlogfont)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_createpen($ipenstyle, $iwidth, $icolor)
- Local $aresult = DllCall("gdi32.dll", "handle", "CreatePen", "int", $ipenstyle, "int", $iwidth, "INT", $icolor)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_createprocess($sappname, $scommand, $tsecurity, $tthread, $binherit, $iflags, $penviron, $sdir, $tstartupinfo, $tprocess)
- Local $tcommand = 0
- Local $sappnametype = "wstr", $sdirtype = "wstr"
- If $sappname = "" Then
- $sappnametype = "ptr"
- $sappname = 0
- EndIf
- If $scommand <> "" Then
- $tcommand = DllStructCreate("wchar Text[" & 260 + 1 & "]")
- DllStructSetData($tcommand, "Text", $scommand)
- EndIf
- If $sdir = "" Then
- $sdirtype = "ptr"
- $sdir = 0
- EndIf
- 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)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_createrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect)
- Local $aresult = DllCall("gdi32.dll", "handle", "CreateRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_createroundrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect, $iwidthellipse, $iheightellipse)
- Local $aresult = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect, "int", $iwidthellipse, "int", $iheightellipse)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_createsolidbitmap($hwnd, $icolor, $iwidth, $iheight, $brgb = 1)
- Local $hdc = _winapi_getdc($hwnd)
- Local $hdestdc = _winapi_createcompatibledc($hdc)
- Local $hbitmap = _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
- Local $hold = _winapi_selectobject($hdestdc, $hbitmap)
- Local $trect = DllStructCreate($tagrect)
- DllStructSetData($trect, 1, 0)
- DllStructSetData($trect, 2, 0)
- DllStructSetData($trect, 3, $iwidth)
- DllStructSetData($trect, 4, $iheight)
- If $brgb Then
- $icolor = BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
- EndIf
- Local $hbrush = _winapi_createsolidbrush($icolor)
- If NOT _winapi_fillrect($hdestdc, $trect, $hbrush) Then
- _winapi_deleteobject($hbitmap)
- $hbitmap = 0
- EndIf
- _winapi_deleteobject($hbrush)
- _winapi_releasedc($hwnd, $hdc)
- _winapi_selectobject($hdestdc, $hold)
- _winapi_deletedc($hdestdc)
- If NOT $hbitmap Then Return SetError(1, 0, 0)
- Return $hbitmap
- EndFunc
- Func _winapi_createsolidbrush($icolor)
- Local $aresult = DllCall("gdi32.dll", "handle", "CreateSolidBrush", "INT", $icolor)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_createwindowex($iexstyle, $sclass, $sname, $istyle, $ix, $iy, $iwidth, $iheight, $hparent, $hmenu = 0, $hinstance = 0, $pparam = 0)
- If $hinstance = 0 Then $hinstance = _winapi_getmodulehandle("")
- 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)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_defwindowproc($hwnd, $imsg, $wparam, $lparam)
- Local $aresult = DllCall("user32.dll", "lresult", "DefWindowProc", "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_deletedc($hdc)
- Local $aresult = DllCall("gdi32.dll", "bool", "DeleteDC", "handle", $hdc)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_deleteobject($hobject)
- Local $aresult = DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hobject)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_destroyicon($hicon)
- Local $aresult = DllCall("user32.dll", "bool", "DestroyIcon", "handle", $hicon)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_destroywindow($hwnd)
- Local $aresult = DllCall("user32.dll", "bool", "DestroyWindow", "hwnd", $hwnd)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_drawedge($hdc, $trect, $iedgetype, $iflags)
- Local $aresult = DllCall("user32.dll", "bool", "DrawEdge", "handle", $hdc, "struct*", $trect, "uint", $iedgetype, "uint", $iflags)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_drawframecontrol($hdc, $trect, $itype, $istate)
- Local $aresult = DllCall("user32.dll", "bool", "DrawFrameControl", "handle", $hdc, "struct*", $trect, "uint", $itype, "uint", $istate)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_drawicon($hdc, $ix, $iy, $hicon)
- Local $aresult = DllCall("user32.dll", "bool", "DrawIcon", "handle", $hdc, "int", $ix, "int", $iy, "handle", $hicon)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_drawiconex($hdc, $ix, $iy, $hicon, $iwidth = 0, $iheight = 0, $istep = 0, $hbrush = 0, $iflags = 3)
- Local $ioptions
- Switch $iflags
- Case 1
- $ioptions = $di_mask
- Case 2
- $ioptions = $di_image
- Case 3
- $ioptions = $di_normal
- Case 4
- $ioptions = $di_compat
- Case 5
- $ioptions = $di_defaultsize
- Case Else
- $ioptions = $di_nomirror
- EndSwitch
- 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)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_drawline($hdc, $ix1, $iy1, $ix2, $iy2)
- _winapi_moveto($hdc, $ix1, $iy1)
- If @error Then Return SetError(@error, @extended, False)
- _winapi_lineto($hdc, $ix2, $iy2)
- If @error Then Return SetError(@error + 10, @extended, False)
- Return True
- EndFunc
- Func _winapi_drawtext($hdc, $stext, ByRef $trect, $iflags)
- Local $aresult = DllCall("user32.dll", "int", "DrawTextW", "handle", $hdc, "wstr", $stext, "int", -1, "struct*", $trect, "uint", $iflags)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_duplicatehandle($hsourceprocesshandle, $hsourcehandle, $htargetprocesshandle, $idesiredaccess, $iinherithandle, $ioptions)
- Local $aresult = DllCall("kernel32.dll", "bool", "DuplicateHandle", "handle", $hsourceprocesshandle, "handle", $hsourcehandle, "handle", $htargetprocesshandle, "handle*", 0, "dword", $idesiredaccess, "bool", $iinherithandle, "dword", $ioptions)
- If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
- Return $aresult[4]
- EndFunc
- Func _winapi_enablewindow($hwnd, $benable = True)
- Local $aresult = DllCall("user32.dll", "bool", "EnableWindow", "hwnd", $hwnd, "bool", $benable)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_enumdisplaydevices($sdevice, $idevnum)
- Local $tname = 0, $iflags = 0, $adevice[5]
- If $sdevice <> "" Then
- $tname = DllStructCreate("wchar Text[" & StringLen($sdevice) + 1 & "]")
- DllStructSetData($tname, "Text", $sdevice)
- EndIf
- Local $tdevice = DllStructCreate($tagdisplay_device)
- Local $idevice = DllStructGetSize($tdevice)
- DllStructSetData($tdevice, "Size", $idevice)
- Local $aret = DllCall("user32.dll", "bool", "EnumDisplayDevicesW", "struct*", $tname, "dword", $idevnum, "struct*", $tdevice, "dword", 1)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Local $in = DllStructGetData($tdevice, "Flags")
- If BitAND($in, $display_device_attached_to_desktop) <> 0 Then $iflags = BitOR($iflags, 1)
- If BitAND($in, $display_device_primary_device) <> 0 Then $iflags = BitOR($iflags, 2)
- If BitAND($in, $display_device_mirroring_driver) <> 0 Then $iflags = BitOR($iflags, 4)
- If BitAND($in, $display_device_vga_compatible) <> 0 Then $iflags = BitOR($iflags, 8)
- If BitAND($in, $display_device_removable) <> 0 Then $iflags = BitOR($iflags, 16)
- If BitAND($in, $display_device_modespruned) <> 0 Then $iflags = BitOR($iflags, 32)
- $adevice[0] = True
- $adevice[1] = DllStructGetData($tdevice, "Name")
- $adevice[2] = DllStructGetData($tdevice, "String")
- $adevice[3] = $iflags
- $adevice[4] = DllStructGetData($tdevice, "ID")
- Return $adevice
- EndFunc
- Func _winapi_enumwindows($bvisible = True, $hwnd = Default)
- __winapi_enumwindowsinit()
- If $hwnd = Default Then $hwnd = _winapi_getdesktopwindow()
- __winapi_enumwindowschild($hwnd, $bvisible)
- Return $__g_awinlist_winapi
- EndFunc
- Func __winapi_enumwindowsadd($hwnd, $sclass = "")
- If $sclass = "" Then $sclass = _winapi_getclassname($hwnd)
- $__g_awinlist_winapi[0][0] += 1
- Local $icount = $__g_awinlist_winapi[0][0]
- If $icount >= $__g_awinlist_winapi[0][1] Then
- ReDim $__g_awinlist_winapi[$icount + 64][2]
- $__g_awinlist_winapi[0][1] += 64
- EndIf
- $__g_awinlist_winapi[$icount][0] = $hwnd
- $__g_awinlist_winapi[$icount][1] = $sclass
- EndFunc
- Func __winapi_enumwindowschild($hwnd, $bvisible = True)
- $hwnd = _winapi_getwindow($hwnd, $gw_child)
- While $hwnd <> 0
- If (NOT $bvisible) OR _winapi_iswindowvisible($hwnd) Then
- __winapi_enumwindowsadd($hwnd)
- __winapi_enumwindowschild($hwnd, $bvisible)
- EndIf
- $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
- WEnd
- EndFunc
- Func __winapi_enumwindowsinit()
- ReDim $__g_awinlist_winapi[64][2]
- $__g_awinlist_winapi[0][0] = 0
- $__g_awinlist_winapi[0][1] = 64
- EndFunc
- Func _winapi_enumwindowspopup()
- __winapi_enumwindowsinit()
- Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_child)
- Local $sclass
- While $hwnd <> 0
- If _winapi_iswindowvisible($hwnd) Then
- $sclass = _winapi_getclassname($hwnd)
- If $sclass = "#32768" Then
- __winapi_enumwindowsadd($hwnd)
- ElseIf $sclass = "ToolbarWindow32" Then
- __winapi_enumwindowsadd($hwnd)
- ElseIf $sclass = "ToolTips_Class32" Then
- __winapi_enumwindowsadd($hwnd)
- ElseIf $sclass = "BaseBar" Then
- __winapi_enumwindowschild($hwnd)
- EndIf
- EndIf
- $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
- WEnd
- Return $__g_awinlist_winapi
- EndFunc
- Func _winapi_enumwindowstop()
- __winapi_enumwindowsinit()
- Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_child)
- While $hwnd <> 0
- If _winapi_iswindowvisible($hwnd) Then __winapi_enumwindowsadd($hwnd)
- $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
- WEnd
- Return $__g_awinlist_winapi
- EndFunc
- Func _winapi_expandenvironmentstrings($sstring)
- Local $aresult = DllCall("kernel32.dll", "dword", "ExpandEnvironmentStringsW", "wstr", $sstring, "wstr", "", "dword", 4096)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
- Return $aresult[2]
- EndFunc
- Func _winapi_extracticonex($sfilepath, $iindex, $palarge, $pasmall, $iicons)
- Local $aresult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sfilepath, "int", $iindex, "struct*", $palarge, "struct*", $pasmall, "uint", $iicons)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_fatalappexit($smessage)
- DllCall("kernel32.dll", "none", "FatalAppExitW", "uint", 0, "wstr", $smessage)
- If @error Then Return SetError(@error, @extended)
- EndFunc
- Func _winapi_fillrect($hdc, $trect, $hbrush)
- Local $aresult
- If IsPtr($hbrush) Then
- $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "struct*", $trect, "handle", $hbrush)
- Else
- $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "struct*", $trect, "dword_ptr", $hbrush)
- EndIf
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_findexecutable($sfilename, $sdirectory = "")
- Local $aresult = DllCall("shell32.dll", "INT", "FindExecutableW", "wstr", $sfilename, "wstr", $sdirectory, "wstr", "")
- If @error Then Return SetError(@error, @extended, "")
- If $aresult[0] <= 32 Then Return SetError(10, $aresult[0], "")
- Return SetExtended($aresult[0], $aresult[3])
- EndFunc
- Func _winapi_findwindow($sclassname, $swindowname)
- Local $aresult = DllCall("user32.dll", "hwnd", "FindWindowW", "wstr", $sclassname, "wstr", $swindowname)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_flashwindow($hwnd, $binvert = True)
- Local $aresult = DllCall("user32.dll", "bool", "FlashWindow", "hwnd", $hwnd, "bool", $binvert)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_flashwindowex($hwnd, $iflags = 3, $icount = 3, $itimeout = 0)
- Local $tflash = DllStructCreate($tagflashwinfo)
- Local $iflash = DllStructGetSize($tflash)
- Local $imode = 0
- If BitAND($iflags, 1) <> 0 Then $imode = BitOR($imode, $flashw_caption)
- If BitAND($iflags, 2) <> 0 Then $imode = BitOR($imode, $flashw_tray)
- If BitAND($iflags, 4) <> 0 Then $imode = BitOR($imode, $flashw_timer)
- If BitAND($iflags, 8) <> 0 Then $imode = BitOR($imode, $flashw_timernofg)
- DllStructSetData($tflash, "Size", $iflash)
- DllStructSetData($tflash, "hWnd", $hwnd)
- DllStructSetData($tflash, "Flags", $imode)
- DllStructSetData($tflash, "Count", $icount)
- DllStructSetData($tflash, "Timeout", $itimeout)
- Local $aresult = DllCall("user32.dll", "bool", "FlashWindowEx", "struct*", $tflash)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_floattoint($nfloat)
- Local $tfloat = DllStructCreate("float")
- Local $tint = DllStructCreate("int", DllStructGetPtr($tfloat))
- DllStructSetData($tfloat, 1, $nfloat)
- Return DllStructGetData($tint, 1)
- EndFunc
- Func _winapi_flushfilebuffers($hfile)
- Local $aresult = DllCall("kernel32.dll", "bool", "FlushFileBuffers", "handle", $hfile)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_formatmessage($iflags, $psource, $imessageid, $ilanguageid, ByRef $pbuffer, $isize, $varguments)
- Local $sbuffertype = "struct*"
- If IsString($pbuffer) Then $sbuffertype = "wstr"
- Local $aresult = DllCall("kernel32.dll", "dword", "FormatMessageW", "dword", $iflags, "struct*", $psource, "dword", $imessageid, "dword", $ilanguageid, $sbuffertype, $pbuffer, "dword", $isize, "ptr", $varguments)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
- If $sbuffertype = "wstr" Then $pbuffer = $aresult[5]
- Return $aresult[0]
- EndFunc
- Func _winapi_framerect($hdc, $trect, $hbrush)
- Local $aresult = DllCall("user32.dll", "int", "FrameRect", "handle", $hdc, "struct*", $trect, "handle", $hbrush)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_freelibrary($hmodule)
- Local $aresult = DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hmodule)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_getancestor($hwnd, $iflags = 1)
- Local $aresult = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hwnd, "uint", $iflags)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getasynckeystate($ikey)
- Local $aresult = DllCall("user32.dll", "short", "GetAsyncKeyState", "int", $ikey)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getbkmode($hdc)
- Local $aresult = DllCall("gdi32.dll", "int", "GetBkMode", "handle", $hdc)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getclassname($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
- If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
- Return SetExtended($aresult[0], $aresult[2])
- EndFunc
- Func _winapi_getclientheight($hwnd)
- Local $trect = _winapi_getclientrect($hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
- EndFunc
- Func _winapi_getclientwidth($hwnd)
- Local $trect = _winapi_getclientrect($hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
- EndFunc
- Func _winapi_getclientrect($hwnd)
- Local $trect = DllStructCreate($tagrect)
- Local $aret = DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "struct*", $trect)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Return $trect
- EndFunc
- Func _winapi_getcurrentprocess()
- Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentProcess")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getcurrentprocessid()
- Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentProcessId")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getcurrentthread()
- Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getcurrentthreadid()
- Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getcursorinfo()
- Local $tcursor = DllStructCreate($tagcursorinfo)
- Local $icursor = DllStructGetSize($tcursor)
- DllStructSetData($tcursor, "Size", $icursor)
- Local $aret = DllCall("user32.dll", "bool", "GetCursorInfo", "struct*", $tcursor)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Local $acursor[5]
- $acursor[0] = True
- $acursor[1] = DllStructGetData($tcursor, "Flags") <> 0
- $acursor[2] = DllStructGetData($tcursor, "hCursor")
- $acursor[3] = DllStructGetData($tcursor, "X")
- $acursor[4] = DllStructGetData($tcursor, "Y")
- Return $acursor
- EndFunc
- Func _winapi_getdc($hwnd)
- Local $aresult = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getdesktopwindow()
- Local $aresult = DllCall("user32.dll", "hwnd", "GetDesktopWindow")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getdevicecaps($hdc, $iindex)
- Local $aresult = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hdc, "int", $iindex)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getdibits($hdc, $hbitmap, $istartscan, $iscanlines, $pbits, $tbi, $iusage)
- Local $aresult = DllCall("gdi32.dll", "int", "GetDIBits", "handle", $hdc, "handle", $hbitmap, "uint", $istartscan, "uint", $iscanlines, "struct*", $pbits, "struct*", $tbi, "uint", $iusage)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_getdlgctrlid($hwnd)
- Local $aresult = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getdlgitem($hwnd, $iitemid)
- Local $aresult = DllCall("user32.dll", "hwnd", "GetDlgItem", "hwnd", $hwnd, "int", $iitemid)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getfilesizeex($hfile)
- Local $aresult = DllCall("kernel32.dll", "bool", "GetFileSizeEx", "handle", $hfile, "int64*", 0)
- If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, -1)
- Return $aresult[2]
- EndFunc
- Func _winapi_getfocus()
- Local $aresult = DllCall("user32.dll", "hwnd", "GetFocus")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getforegroundwindow()
- Local $aresult = DllCall("user32.dll", "hwnd", "GetForegroundWindow")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getguiresources($iflag = 0, $hprocess = -1)
- If $hprocess = -1 Then $hprocess = _winapi_getcurrentprocess()
- Local $aresult = DllCall("user32.dll", "dword", "GetGuiResources", "handle", $hprocess, "dword", $iflag)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_geticoninfo($hicon)
- Local $tinfo = DllStructCreate($tagiconinfo)
- Local $aret = DllCall("user32.dll", "bool", "GetIconInfo", "handle", $hicon, "struct*", $tinfo)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Local $aicon[6]
- $aicon[0] = True
- $aicon[1] = DllStructGetData($tinfo, "Icon") <> 0
- $aicon[2] = DllStructGetData($tinfo, "XHotSpot")
- $aicon[3] = DllStructGetData($tinfo, "YHotSpot")
- $aicon[4] = DllStructGetData($tinfo, "hMask")
- $aicon[5] = DllStructGetData($tinfo, "hColor")
- Return $aicon
- EndFunc
- Func _winapi_getlasterrormessage()
- Local $ilasterror = _winapi_getlasterror()
- Local $tbufferptr = DllStructCreate("ptr")
- Local $ncount = _winapi_formatmessage(BitOR($format_message_allocate_buffer, $format_message_from_system), 0, $ilasterror, 0, $tbufferptr, 0, 0)
- If @error Then Return SetError(@error, 0, "")
- Local $stext = ""
- Local $pbuffer = DllStructGetData($tbufferptr, 1)
- If $pbuffer Then
- If $ncount > 0 Then
- Local $tbuffer = DllStructCreate("wchar[" & ($ncount + 1) & "]", $pbuffer)
- $stext = DllStructGetData($tbuffer, 1)
- If StringRight($stext, 2) = @CRLF Then $stext = StringTrimRight($stext, 2)
- EndIf
- _winapi_localfree($pbuffer)
- EndIf
- Return $stext
- EndFunc
- Func _winapi_getlayeredwindowattributes($hwnd, ByRef $itranscolor, ByRef $itransgui, $bcolorref = False)
- $itranscolor = -1
- $itransgui = -1
- Local $aresult = DllCall("user32.dll", "bool", "GetLayeredWindowAttributes", "hwnd", $hwnd, "INT*", $itranscolor, "byte*", $itransgui, "dword*", 0)
- If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
- If NOT $bcolorref Then
- $aresult[2] = Int(BinaryMid($aresult[2], 3, 1) & BinaryMid($aresult[2], 2, 1) & BinaryMid($aresult[2], 1, 1))
- EndIf
- $itranscolor = $aresult[2]
- $itransgui = $aresult[3]
- Return $aresult[4]
- EndFunc
- Func _winapi_getmodulehandle($smodulename)
- Local $smodulenametype = "wstr"
- If $smodulename = "" Then
- $smodulename = 0
- $smodulenametype = "ptr"
- EndIf
- Local $aresult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $smodulenametype, $smodulename)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getmousepos($btoclient = False, $hwnd = 0)
- Local $imode = Opt("MouseCoordMode", 1)
- Local $apos = MouseGetPos()
- Opt("MouseCoordMode", $imode)
- Local $tpoint = DllStructCreate($tagpoint)
- DllStructSetData($tpoint, "X", $apos[0])
- DllStructSetData($tpoint, "Y", $apos[1])
- If $btoclient AND NOT _winapi_screentoclient($hwnd, $tpoint) Then Return SetError(@error + 20, @extended, 0)
- Return $tpoint
- EndFunc
- Func _winapi_getmouseposx($btoclient = False, $hwnd = 0)
- Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return DllStructGetData($tpoint, "X")
- EndFunc
- Func _winapi_getmouseposy($btoclient = False, $hwnd = 0)
- Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return DllStructGetData($tpoint, "Y")
- EndFunc
- Func _winapi_getobject($hobject, $isize, $pobject)
- Local $aresult = DllCall("gdi32.dll", "int", "GetObjectW", "handle", $hobject, "int", $isize, "struct*", $pobject)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getopenfilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
- Local $ipathlen = 4096
- Local $inulls = 0
- Local $tofn = DllStructCreate($tagopenfilename)
- Local $afiles[1] = [0]
- Local $iflag = $iflags
- Local $asflines = StringSplit($sfilter, "|")
- Local $asfilter[$asflines[0] * 2 + 1]
- Local $istart, $ifinal, $tagfilter
- $asfilter[0] = $asflines[0] * 2
- For $i = 1 To $asflines[0]
- $istart = StringInStr($asflines[$i], "(", 0, 1)
- $ifinal = StringInStr($asflines[$i], ")", 0, -1)
- $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), $str_stripleading + $str_striptrailing)
- $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), $str_stripleading + $str_striptrailing)
- $tagfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
- Next
- Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
- Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
- Local $tfilter = DllStructCreate($tagfilter & "wchar")
- Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
- Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
- For $i = 1 To $asfilter[0]
- DllStructSetData($tfilter, $i, $asfilter[$i])
- Next
- DllStructSetData($ttitle, "Title", $stitle)
- DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
- DllStructSetData($tpath, "Path", $sdefaultfile)
- DllStructSetData($textn, "Extension", $sdefaultext)
- DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
- DllStructSetData($tofn, "hwndOwner", $hwndowner)
- DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
- DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
- DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
- DllStructSetData($tofn, "nMaxFile", $ipathlen)
- DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
- DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
- DllStructSetData($tofn, "Flags", $iflag)
- DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
- DllStructSetData($tofn, "FlagsEx", $iflagsex)
- Local $ares = DllCall("comdlg32.dll", "bool", "GetOpenFileNameW", "struct*", $tofn)
- If @error OR NOT $ares[0] Then Return SetError(@error + 10, @extended, $afiles)
- If BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect AND BitAND($iflags, $ofn_explorer) = $ofn_explorer Then
- For $x = 1 To $ipathlen
- If DllStructGetData($tpath, "Path", $x) = Chr(0) Then
- DllStructSetData($tpath, "Path", "|", $x)
- $inulls += 1
- Else
- $inulls = 0
- EndIf
- If $inulls = 2 Then ExitLoop
- Next
- DllStructSetData($tpath, "Path", Chr(0), $x - 1)
- $afiles = StringSplit(DllStructGetData($tpath, "Path"), "|")
- If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
- Return StringSplit(DllStructGetData($tpath, "Path"), "|")
- ElseIf BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect Then
- $afiles = StringSplit(DllStructGetData($tpath, "Path"), " ")
- If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
- Return StringSplit(StringReplace(DllStructGetData($tpath, "Path"), " ", "|"), "|")
- Else
- Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
- EndIf
- EndFunc
- Func _winapi_getoverlappedresult($hfile, $toverlapped, ByRef $ibytes, $bwait = False)
- Local $aresult = DllCall("kernel32.dll", "bool", "GetOverlappedResult", "handle", $hfile, "struct*", $toverlapped, "dword*", 0, "bool", $bwait)
- If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, False)
- $ibytes = $aresult[3]
- Return $aresult[0]
- EndFunc
- Func _winapi_getparent($hwnd)
- Local $aresult = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getprocaddress($hmodule, $vname)
- Local $stype = "str"
- If IsNumber($vname) Then $stype = "word"
- Local $aresult = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", $hmodule, $stype, $vname)
- If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getprocessaffinitymask($hprocess)
- Local $aresult = DllCall("kernel32.dll", "bool", "GetProcessAffinityMask", "handle", $hprocess, "dword_ptr*", 0, "dword_ptr*", 0)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
- Local $amask[3]
- $amask[0] = True
- $amask[1] = $aresult[2]
- $amask[2] = $aresult[3]
- Return $amask
- EndFunc
- Func _winapi_getsavefilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
- Local $ipathlen = 4096
- Local $tofn = DllStructCreate($tagopenfilename)
- Local $afiles[1] = [0]
- Local $iflag = $iflags
- Local $asflines = StringSplit($sfilter, "|")
- Local $asfilter[$asflines[0] * 2 + 1]
- Local $istart, $ifinal, $tagfilter
- $asfilter[0] = $asflines[0] * 2
- For $i = 1 To $asflines[0]
- $istart = StringInStr($asflines[$i], "(", 0, 1)
- $ifinal = StringInStr($asflines[$i], ")", 0, -1)
- $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), $str_stripleading + $str_striptrailing)
- $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), $str_stripleading + $str_striptrailing)
- $tagfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
- Next
- Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
- Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
- Local $tfilter = DllStructCreate($tagfilter & "wchar")
- Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
- Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
- For $i = 1 To $asfilter[0]
- DllStructSetData($tfilter, $i, $asfilter[$i])
- Next
- DllStructSetData($ttitle, "Title", $stitle)
- DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
- DllStructSetData($tpath, "Path", $sdefaultfile)
- DllStructSetData($textn, "Extension", $sdefaultext)
- DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
- DllStructSetData($tofn, "hwndOwner", $hwndowner)
- DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
- DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
- DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
- DllStructSetData($tofn, "nMaxFile", $ipathlen)
- DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
- DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
- DllStructSetData($tofn, "Flags", $iflag)
- DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
- DllStructSetData($tofn, "FlagsEx", $iflagsex)
- Local $ares = DllCall("comdlg32.dll", "bool", "GetSaveFileNameW", "struct*", $tofn)
- If @error OR NOT $ares[0] Then Return SetError(@error + 10, @extended, $afiles)
- Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
- EndFunc
- Func _winapi_getstockobject($iobject)
- Local $aresult = DllCall("gdi32.dll", "handle", "GetStockObject", "int", $iobject)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getstdhandle($istdhandle)
- If $istdhandle < 0 OR $istdhandle > 2 Then Return SetError(2, 0, -1)
- Local Const $ahandle[3] = [-10, -11, -12]
- Local $aresult = DllCall("kernel32.dll", "handle", "GetStdHandle", "dword", $ahandle[$istdhandle])
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_getsyscolor($iindex)
- Local $aresult = DllCall("user32.dll", "INT", "GetSysColor", "int", $iindex)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getsyscolorbrush($iindex)
- Local $aresult = DllCall("user32.dll", "handle", "GetSysColorBrush", "int", $iindex)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getsystemmetrics($iindex)
- Local $aresult = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $iindex)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_gettextextentpoint32($hdc, $stext)
- Local $tsize = DllStructCreate($tagsize)
- Local $isize = StringLen($stext)
- Local $aret = DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hdc, "wstr", $stext, "int", $isize, "struct*", $tsize)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Return $tsize
- EndFunc
- Func _winapi_gettextmetrics($hdc)
- Local $ttextmetric = DllStructCreate($tagtextmetric)
- Local $aret = DllCall("gdi32.dll", "bool", "GetTextMetricsW", "handle", $hdc, "struct*", $ttextmetric)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Return $ttextmetric
- EndFunc
- Func _winapi_getwindow($hwnd, $icmd)
- Local $aresult = DllCall("user32.dll", "hwnd", "GetWindow", "hwnd", $hwnd, "uint", $icmd)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getwindowdc($hwnd)
- Local $aresult = DllCall("user32.dll", "handle", "GetWindowDC", "hwnd", $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getwindowheight($hwnd)
- Local $trect = _winapi_getwindowrect($hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
- EndFunc
- Func _winapi_getwindowlong($hwnd, $iindex)
- Local $sfuncname = "GetWindowLongW"
- If @AutoItX64 Then $sfuncname = "GetWindowLongPtrW"
- Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getwindowplacement($hwnd)
- Local $twindowplacement = DllStructCreate($tagwindowplacement)
- DllStructSetData($twindowplacement, "length", DllStructGetSize($twindowplacement))
- Local $aret = DllCall("user32.dll", "bool", "GetWindowPlacement", "hwnd", $hwnd, "struct*", $twindowplacement)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Return $twindowplacement
- EndFunc
- Func _winapi_getwindowrect($hwnd)
- Local $trect = DllStructCreate($tagrect)
- Local $aret = DllCall("user32.dll", "bool", "GetWindowRect", "hwnd", $hwnd, "struct*", $trect)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Return $trect
- EndFunc
- Func _winapi_getwindowrgn($hwnd, $hrgn)
- Local $aresult = DllCall("user32.dll", "int", "GetWindowRgn", "hwnd", $hwnd, "handle", $hrgn)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getwindowtext($hwnd)
- Local $aresult = DllCall("user32.dll", "int", "GetWindowTextW", "hwnd", $hwnd, "wstr", "", "int", 4096)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
- Return SetExtended($aresult[0], $aresult[2])
- EndFunc
- Func _winapi_getwindowthreadprocessid($hwnd, ByRef $ipid)
- Local $aresult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
- If @error Then Return SetError(@error, @extended, 0)
- $ipid = $aresult[2]
- Return $aresult[0]
- EndFunc
- Func _winapi_getwindowwidth($hwnd)
- Local $trect = _winapi_getwindowrect($hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
- EndFunc
- Func _winapi_getxyfrompoint(ByRef $tpoint, ByRef $ix, ByRef $iy)
- $ix = DllStructGetData($tpoint, "X")
- $iy = DllStructGetData($tpoint, "Y")
- EndFunc
- Func _winapi_globalmemorystatus()
- Local $tmem = DllStructCreate($tagmemorystatusex)
- DllStructSetData($tmem, 1, DllStructGetSize($tmem))
- Local $aret = DllCall("kernel32.dll", "bool", "GlobalMemoryStatusEx", "struct*", $tmem)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Local $amem[7]
- $amem[0] = DllStructGetData($tmem, 2)
- $amem[1] = DllStructGetData($tmem, 3)
- $amem[2] = DllStructGetData($tmem, 4)
- $amem[3] = DllStructGetData($tmem, 5)
- $amem[4] = DllStructGetData($tmem, 6)
- $amem[5] = DllStructGetData($tmem, 7)
- $amem[6] = DllStructGetData($tmem, 8)
- Return $amem
- EndFunc
- Func _winapi_guidfromstring($sguid)
- Local $tguid = DllStructCreate($tagguid)
- _winapi_guidfromstringex($sguid, $tguid)
- If @error Then Return SetError(@error + 10, @extended, 0)
- Return $tguid
- EndFunc
- Func _winapi_guidfromstringex($sguid, $tguid)
- Local $aresult = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sguid, "struct*", $tguid)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_hiword($ilong)
- Return BitShift($ilong, 16)
- EndFunc
- Func _winapi_inprocess($hwnd, ByRef $hlastwnd)
- If $hwnd = $hlastwnd Then Return True
- For $ii = $__g_ainprocess_winapi[0][0] To 1 Step -1
- If $hwnd = $__g_ainprocess_winapi[$ii][0] Then
- If $__g_ainprocess_winapi[$ii][1] Then
- $hlastwnd = $hwnd
- Return True
- Else
- Return False
- EndIf
- EndIf
- Next
- Local $ipid
- _winapi_getwindowthreadprocessid($hwnd, $ipid)
- Local $icount = $__g_ainprocess_winapi[0][0] + 1
- If $icount >= 64 Then $icount = 1
- $__g_ainprocess_winapi[0][0] = $icount
- $__g_ainprocess_winapi[$icount][0] = $hwnd
- $__g_ainprocess_winapi[$icount][1] = ($ipid = @AutoItPID)
- Return $__g_ainprocess_winapi[$icount][1]
- EndFunc
- Func _winapi_inttofloat($iint)
- Local $tint = DllStructCreate("int")
- Local $tfloat = DllStructCreate("float", DllStructGetPtr($tint))
- DllStructSetData($tint, 1, $iint)
- Return DllStructGetData($tfloat, 1)
- EndFunc
- Func _winapi_isclassname($hwnd, $sclassname)
- Local $sseparator = Opt("GUIDataSeparatorChar")
- Local $aclassname = StringSplit($sclassname, $sseparator)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $sclasscheck = _winapi_getclassname($hwnd)
- For $x = 1 To UBound($aclassname) - 1
- If StringUpper(StringMid($sclasscheck, 1, StringLen($aclassname[$x]))) = StringUpper($aclassname[$x]) Then Return True
- Next
- Return False
- EndFunc
- Func _winapi_iswindow($hwnd)
- Local $aresult = DllCall("user32.dll", "bool", "IsWindow", "hwnd", $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_iswindowvisible($hwnd)
- Local $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_invalidaterect($hwnd, $trect = 0, $berase = True)
- Local $aresult = DllCall("user32.dll", "bool", "InvalidateRect", "hwnd", $hwnd, "struct*", $trect, "bool", $berase)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_lineto($hdc, $ix, $iy)
- Local $aresult = DllCall("gdi32.dll", "bool", "LineTo", "handle", $hdc, "int", $ix, "int", $iy)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_loadbitmap($hinstance, $sbitmap)
- Local $sbitmaptype = "int"
- If IsString($sbitmap) Then $sbitmaptype = "wstr"
- Local $aresult = DllCall("user32.dll", "handle", "LoadBitmapW", "handle", $hinstance, $sbitmaptype, $sbitmap)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_loadimage($hinstance, $simage, $itype, $ixdesired, $iydesired, $iload)
- Local $aresult, $simagetype = "int"
- If IsString($simage) Then $simagetype = "wstr"
- $aresult = DllCall("user32.dll", "handle", "LoadImageW", "handle", $hinstance, $simagetype, $simage, "uint", $itype, "int", $ixdesired, "int", $iydesired, "uint", $iload)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_loadlibrary($sfilename)
- Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sfilename)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_loadlibraryex($sfilename, $iflags = 0)
- Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryExW", "wstr", $sfilename, "ptr", 0, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_loadshell32icon($iiconid)
- Local $ticons = DllStructCreate("ptr Data")
- Local $iicons = _winapi_extracticonex("shell32.dll", $iiconid, 0, $ticons, 1)
- If @error Then Return SetError(@error, @extended, 0)
- If $iicons <= 0 Then Return SetError(10, 0, 0)
- Return DllStructGetData($ticons, "Data")
- EndFunc
- Func _winapi_loadstring($hinstance, $istringid)
- Local $aresult = DllCall("user32.dll", "int", "LoadStringW", "handle", $hinstance, "uint", $istringid, "wstr", "", "int", 4096)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
- Return SetExtended($aresult[0], $aresult[3])
- EndFunc
- Func _winapi_localfree($hmemory)
- Local $aresult = DllCall("kernel32.dll", "handle", "LocalFree", "handle", $hmemory)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_loword($ilong)
- Return BitAND($ilong, 65535)
- EndFunc
- Func _winapi_makelangid($ilngidprimary, $ilngidsub)
- Return BitOR(BitShift($ilngidsub, -10), $ilngidprimary)
- EndFunc
- Func _winapi_makelcid($ilngid, $isortid)
- Return BitOR(BitShift($isortid, -16), $ilngid)
- EndFunc
- Func _winapi_makelong($ilo, $ihi)
- Return BitOR(BitShift($ihi, -16), BitAND($ilo, 65535))
- EndFunc
- Func _winapi_makeqword($ilodword, $ihidword)
- Local $tint64 = DllStructCreate("uint64")
- Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
- DllStructSetData($tdwords, 1, $ilodword)
- DllStructSetData($tdwords, 2, $ihidword)
- Return DllStructGetData($tint64, 1)
- EndFunc
- Func _winapi_messagebeep($itype = 1)
- Local $isound
- Switch $itype
- Case 1
- $isound = 0
- Case 2
- $isound = 16
- Case 3
- $isound = 32
- Case 4
- $isound = 48
- Case 5
- $isound = 64
- Case Else
- $isound = -1
- EndSwitch
- Local $aresult = DllCall("user32.dll", "bool", "MessageBeep", "uint", $isound)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_msgbox($iflags, $stitle, $stext)
- BlockInput(0)
- MsgBox($iflags, $stitle, $stext & " ")
- EndFunc
- Func _winapi_mouse_event($iflags, $ix = 0, $iy = 0, $idata = 0, $iextrainfo = 0)
- DllCall("user32.dll", "none", "mouse_event", "dword", $iflags, "dword", $ix, "dword", $iy, "dword", $idata, "ulong_ptr", $iextrainfo)
- If @error Then Return SetError(@error, @extended)
- EndFunc
- Func _winapi_moveto($hdc, $ix, $iy)
- Local $aresult = DllCall("gdi32.dll", "bool", "MoveToEx", "handle", $hdc, "int", $ix, "int", $iy, "ptr", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_movewindow($hwnd, $ix, $iy, $iwidth, $iheight, $brepaint = True)
- Local $aresult = DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hwnd, "int", $ix, "int", $iy, "int", $iwidth, "int", $iheight, "bool", $brepaint)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_muldiv($inumber, $inumerator, $idenominator)
- Local $aresult = DllCall("kernel32.dll", "int", "MulDiv", "int", $inumber, "int", $inumerator, "int", $idenominator)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_multibytetowidechar($vtext, $icodepage = 0, $iflags = 0, $bretstring = False)
- Local $stexttype = "str"
- If NOT IsString($vtext) Then $stexttype = "struct*"
- Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "ptr", 0, "int", 0)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
- Local $iout = $aresult[0]
- Local $tout = DllStructCreate("wchar[" & $iout & "]")
- $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "struct*", $tout, "int", $iout)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, 0)
- If $bretstring Then Return DllStructGetData($tout, 1)
- Return $tout
- EndFunc
- Func _winapi_multibytetowidecharex($stext, $ptext, $icodepage = 0, $iflags = 0)
- Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, "STR", $stext, "int", -1, "struct*", $ptext, "int", (StringLen($stext) + 1) * 2)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_openprocess($iaccess, $binherit, $ipid, $bdebugpriv = False)
- Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
- If @error Then Return SetError(@error, @extended, 0)
- If $aresult[0] Then Return $aresult[0]
- If NOT $bdebugpriv Then Return SetError(100, 0, 0)
- Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
- If @error Then Return SetError(@error + 10, @extended, 0)
- _security__setprivilege($htoken, "SeDebugPrivilege", True)
- Local $ierror = @error
- Local $iextended = @extended
- Local $iret = 0
- If NOT @error Then
- $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
- $ierror = @error
- $iextended = @extended
- If $aresult[0] Then $iret = $aresult[0]
- _security__setprivilege($htoken, "SeDebugPrivilege", False)
- If @error Then
- $ierror = @error + 20
- $iextended = @extended
- EndIf
- Else
- $ierror = @error + 30
- EndIf
- _winapi_closehandle($htoken)
- Return SetError($ierror, $iextended, $iret)
- EndFunc
- Func __winapi_parsefiledialogpath($spath)
- Local $afiles[3]
- $afiles[0] = 2
- Local $stemp = StringMid($spath, 1, StringInStr($spath, "\", 0, -1) - 1)
- $afiles[1] = $stemp
- $afiles[2] = StringMid($spath, StringInStr($spath, "\", 0, -1) + 1)
- Return $afiles
- EndFunc
- Func _winapi_pathfindonpath(Const $sfilepath, $aextrapaths = "", Const $spathdelimiter = @LF)
- Local $iextracount = 0
- If IsString($aextrapaths) Then
- If StringLen($aextrapaths) Then
- $aextrapaths = StringSplit($aextrapaths, $spathdelimiter, $str_entiresplit + $str_nocount)
- $iextracount = UBound($aextrapaths, $ubound_rows)
- EndIf
- ElseIf IsArray($aextrapaths) Then
- $iextracount = UBound($aextrapaths)
- EndIf
- Local $tpaths, $tpathptrs
- If $iextracount Then
- Local $tagstruct = ""
- For $path In $aextrapaths
- $tagstruct &= "wchar[" & StringLen($path) + 1 & "];"
- Next
- $tpaths = DllStructCreate($tagstruct)
- $tpathptrs = DllStructCreate("ptr[" & $iextracount + 1 & "]")
- For $i = 1 To $iextracount
- DllStructSetData($tpaths, $i, $aextrapaths[$i - 1])
- DllStructSetData($tpathptrs, 1, DllStructGetPtr($tpaths, $i), $i)
- Next
- DllStructSetData($tpathptrs, 1, Ptr(0), $iextracount + 1)
- EndIf
- Local $aresult = DllCall("shlwapi.dll", "bool", "PathFindOnPathW", "wstr", $sfilepath, "struct*", $tpathptrs)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, $sfilepath)
- Return $aresult[1]
- EndFunc
- Func _winapi_pointfromrect(ByRef $trect, $bcenter = True)
- Local $ix1 = DllStructGetData($trect, "Left")
- Local $iy1 = DllStructGetData($trect, "Top")
- Local $ix2 = DllStructGetData($trect, "Right")
- Local $iy2 = DllStructGetData($trect, "Bottom")
- If $bcenter Then
- $ix1 = $ix1 + (($ix2 - $ix1) / 2)
- $iy1 = $iy1 + (($iy2 - $iy1) / 2)
- EndIf
- Local $tpoint = DllStructCreate($tagpoint)
- DllStructSetData($tpoint, "X", $ix1)
- DllStructSetData($tpoint, "Y", $iy1)
- Return $tpoint
- EndFunc
- Func _winapi_postmessage($hwnd, $imsg, $wparam, $lparam)
- Local $aresult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_primarylangid($ilngid)
- Return BitAND($ilngid, 1023)
- EndFunc
- Func _winapi_ptinrect(ByRef $trect, ByRef $tpoint)
- Local $aresult = DllCall("user32.dll", "bool", "PtInRect", "struct*", $trect, "struct", $tpoint)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_readfile($hfile, $pbuffer, $itoread, ByRef $iread, $toverlapped = 0)
- Local $aresult = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $pbuffer, "dword", $itoread, "dword*", 0, "struct*", $toverlapped)
- If @error Then Return SetError(@error, @extended, False)
- $iread = $aresult[4]
- Return $aresult[0]
- EndFunc
- Func _winapi_readprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iread)
- Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, "struct*", $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
- If @error Then Return SetError(@error, @extended, False)
- $iread = $aresult[5]
- Return $aresult[0]
- EndFunc
- Func _winapi_rectisempty(ByRef $trect)
- Return (DllStructGetData($trect, "Left") = 0) AND (DllStructGetData($trect, "Top") = 0) AND (DllStructGetData($trect, "Right") = 0) AND (DllStructGetData($trect, "Bottom") = 0)
- EndFunc
- Func _winapi_redrawwindow($hwnd, $trect = 0, $hregion = 0, $iflags = 5)
- Local $aresult = DllCall("user32.dll", "bool", "RedrawWindow", "hwnd", $hwnd, "struct*", $trect, "handle", $hregion, "uint", $iflags)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_registerwindowmessage($smessage)
- Local $aresult = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $smessage)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_releasecapture()
- Local $aresult = DllCall("user32.dll", "bool", "ReleaseCapture")
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_releasedc($hwnd, $hdc)
- Local $aresult = DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_screentoclient($hwnd, ByRef $tpoint)
- Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient", "hwnd", $hwnd, "struct*", $tpoint)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_selectobject($hdc, $hgdiobj)
- Local $aresult = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hgdiobj)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setbkcolor($hdc, $icolor)
- Local $aresult = DllCall("gdi32.dll", "INT", "SetBkColor", "handle", $hdc, "INT", $icolor)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_setbkmode($hdc, $ibkmode)
- Local $aresult = DllCall("gdi32.dll", "int", "SetBkMode", "handle", $hdc, "int", $ibkmode)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_setcapture($hwnd)
- Local $aresult = DllCall("user32.dll", "hwnd", "SetCapture", "hwnd", $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_setcursor($hcursor)
- Local $aresult = DllCall("user32.dll", "handle", "SetCursor", "handle", $hcursor)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_setdefaultprinter($sprinter)
- Local $aresult = DllCall("winspool.drv", "bool", "SetDefaultPrinterW", "wstr", $sprinter)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setdibits($hdc, $hbitmap, $istartscan, $iscanlines, $pbits, $tbmi, $icoloruse = 0)
- Local $aresult = DllCall("gdi32.dll", "int", "SetDIBits", "handle", $hdc, "handle", $hbitmap, "uint", $istartscan, "uint", $iscanlines, "struct*", $pbits, "struct*", $tbmi, "INT", $icoloruse)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setendoffile($hfile)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetEndOfFile", "handle", $hfile)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setevent($hevent)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetEvent", "handle", $hevent)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setfilepointer($hfile, $ipos, $imethod = 0)
- Local $aresult = DllCall("kernel32.dll", "INT", "SetFilePointer", "handle", $hfile, "long", $ipos, "ptr", 0, "long", $imethod)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_setfocus($hwnd)
- Local $aresult = DllCall("user32.dll", "hwnd", "SetFocus", "hwnd", $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_setfont($hwnd, $hfont, $bredraw = True)
- _sendmessage($hwnd, $__winapiconstant_wm_setfont, $hfont, $bredraw, 0, "hwnd")
- EndFunc
- Func _winapi_sethandleinformation($hobject, $imask, $iflags)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetHandleInformation", "handle", $hobject, "dword", $imask, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setlayeredwindowattributes($hwnd, $itranscolor, $itransgui = 255, $iflags = 3, $bcolorref = False)
- If $iflags = Default OR $iflags = "" OR $iflags < 0 Then $iflags = 3
- If NOT $bcolorref Then
- $itranscolor = Int(BinaryMid($itranscolor, 3, 1) & BinaryMid($itranscolor, 2, 1) & BinaryMid($itranscolor, 1, 1))
- EndIf
- Local $aresult = DllCall("user32.dll", "bool", "SetLayeredWindowAttributes", "hwnd", $hwnd, "INT", $itranscolor, "byte", $itransgui, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setparent($hwndchild, $hwndparent)
- Local $aresult = DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hwndchild, "hwnd", $hwndparent)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_setprocessaffinitymask($hprocess, $imask)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetProcessAffinityMask", "handle", $hprocess, "ulong_ptr", $imask)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setsyscolors($velements, $vcolors)
- Local $bisearray = IsArray($velements), $biscarray = IsArray($vcolors)
- Local $ielementnum
- If NOT $biscarray AND NOT $bisearray Then
- $ielementnum = 1
- ElseIf $biscarray OR $bisearray Then
- If NOT $biscarray OR NOT $bisearray Then Return SetError(-1, -1, False)
- If UBound($velements) <> UBound($vcolors) Then Return SetError(-1, -1, False)
- $ielementnum = UBound($velements)
- EndIf
- Local $telements = DllStructCreate("int Element[" & $ielementnum & "]")
- Local $tcolors = DllStructCreate("INT NewColor[" & $ielementnum & "]")
- If NOT $bisearray Then
- DllStructSetData($telements, "Element", $velements, 1)
- Else
- For $x = 0 To $ielementnum - 1
- DllStructSetData($telements, "Element", $velements[$x], $x + 1)
- Next
- EndIf
- If NOT $biscarray Then
- DllStructSetData($tcolors, "NewColor", $vcolors, 1)
- Else
- For $x = 0 To $ielementnum - 1
- DllStructSetData($tcolors, "NewColor", $vcolors[$x], $x + 1)
- Next
- EndIf
- Local $aresult = DllCall("user32.dll", "bool", "SetSysColors", "int", $ielementnum, "struct*", $telements, "struct*", $tcolors)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_settextcolor($hdc, $icolor)
- Local $aresult = DllCall("gdi32.dll", "INT", "SetTextColor", "handle", $hdc, "INT", $icolor)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_setwindowlong($hwnd, $iindex, $ivalue)
- _winapi_setlasterror(0)
- Local $sfuncname = "SetWindowLongW"
- If @AutoItX64 Then $sfuncname = "SetWindowLongPtrW"
- Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex, "long_ptr", $ivalue)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_setwindowplacement($hwnd, $twindowplacement)
- Local $aresult = DllCall("user32.dll", "bool", "SetWindowPlacement", "hwnd", $hwnd, "struct*", $twindowplacement)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setwindowpos($hwnd, $hafter, $ix, $iy, $icx, $icy, $iflags)
- Local $aresult = DllCall("user32.dll", "bool", "SetWindowPos", "hwnd", $hwnd, "hwnd", $hafter, "int", $ix, "int", $iy, "int", $icx, "int", $icy, "uint", $iflags)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setwindowrgn($hwnd, $hrgn, $bredraw = True)
- Local $aresult = DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hwnd, "handle", $hrgn, "bool", $bredraw)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setwindowshookex($ihook, $pproc, $hdll, $ithreadid = 0)
- Local $aresult = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", $ihook, "ptr", $pproc, "handle", $hdll, "dword", $ithreadid)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_setwindowtext($hwnd, $stext)
- Local $aresult = DllCall("user32.dll", "bool", "SetWindowTextW", "hwnd", $hwnd, "wstr", $stext)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_showcursor($bshow)
- Local $aresult = DllCall("user32.dll", "int", "ShowCursor", "bool", $bshow)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_showerror($stext, $bexit = True)
- _winapi_msgbox($mb_systemmodal, "Error", $stext)
- If $bexit Then Exit
- EndFunc
- Func _winapi_showmsg($stext)
- _winapi_msgbox($mb_systemmodal, "Information", $stext)
- EndFunc
- Func _winapi_showwindow($hwnd, $icmdshow = 5)
- Local $aresult = DllCall("user32.dll", "bool", "ShowWindow", "hwnd", $hwnd, "int", $icmdshow)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_stringfromguid($tguid)
- Local $aresult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $tguid, "wstr", "", "int", 40)
- If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
- Return SetExtended($aresult[0], $aresult[2])
- EndFunc
- Func _winapi_stringlena(Const ByRef $tstring)
- Local $aresult = DllCall("kernel32.dll", "int", "lstrlenA", "struct*", $tstring)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_stringlenw(Const ByRef $tstring)
- Local $aresult = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $tstring)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_sublangid($ilngid)
- Return BitShift($ilngid, 10)
- EndFunc
- Func _winapi_systemparametersinfo($iaction, $iparam = 0, $vparam = 0, $iwinini = 0)
- Local $aresult = DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", $iaction, "uint", $iparam, "struct*", $vparam, "uint", $iwinini)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_twipsperpixelx()
- Local $hdc, $itwipsperpixelx
- $hdc = _winapi_getdc(0)
- $itwipsperpixelx = 1440 / _winapi_getdevicecaps($hdc, $__winapiconstant_logpixelsx)
- _winapi_releasedc(0, $hdc)
- Return $itwipsperpixelx
- EndFunc
- Func _winapi_twipsperpixely()
- Local $hdc, $itwipsperpixely
- $hdc = _winapi_getdc(0)
- $itwipsperpixely = 1440 / _winapi_getdevicecaps($hdc, $__winapiconstant_logpixelsy)
- _winapi_releasedc(0, $hdc)
- Return $itwipsperpixely
- EndFunc
- Func _winapi_unhookwindowshookex($hhook)
- Local $aresult = DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $hhook)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_updatelayeredwindow($hwnd, $hdestdc, $tptdest, $tsize, $hsrcdc, $tptsrce, $irgb, $tblend, $iflags)
- 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)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_updatewindow($hwnd)
- Local $aresult = DllCall("user32.dll", "bool", "UpdateWindow", "hwnd", $hwnd)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_waitforinputidle($hprocess, $itimeout = -1)
- Local $aresult = DllCall("user32.dll", "dword", "WaitForInputIdle", "handle", $hprocess, "dword", $itimeout)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_waitformultipleobjects($icount, $pahandles, $bwaitall = False, $itimeout = -1)
- Local $aresult = DllCall("kernel32.dll", "INT", "WaitForMultipleObjects", "dword", $icount, "struct*", $pahandles, "bool", $bwaitall, "dword", $itimeout)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_waitforsingleobject($hhandle, $itimeout = -1)
- Local $aresult = DllCall("kernel32.dll", "INT", "WaitForSingleObject", "handle", $hhandle, "dword", $itimeout)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_widechartomultibyte($vunicode, $icodepage = 0, $bretstring = True)
- Local $sunicodetype = "wstr"
- If NOT IsString($vunicode) Then $sunicodetype = "struct*"
- Local $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "ptr", 0, "int", 0, "ptr", 0, "ptr", 0)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, "")
- Local $tmultibyte = DllStructCreate("char[" & $aresult[0] & "]")
- $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "struct*", $tmultibyte, "int", $aresult[0], "ptr", 0, "ptr", 0)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
- If $bretstring Then Return DllStructGetData($tmultibyte, 1)
- Return $tmultibyte
- EndFunc
- Func _winapi_windowfrompoint(ByRef $tpoint)
- Local $aresult = DllCall("user32.dll", "hwnd", "WindowFromPoint", "struct", $tpoint)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_writeconsole($hconsole, $stext)
- Local $aresult = DllCall("kernel32.dll", "bool", "WriteConsoleW", "handle", $hconsole, "wstr", $stext, "dword", StringLen($stext), "dword*", 0, "ptr", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_writefile($hfile, $pbuffer, $itowrite, ByRef $iwritten, $toverlapped = 0)
- Local $aresult = DllCall("kernel32.dll", "bool", "WriteFile", "handle", $hfile, "struct*", $pbuffer, "dword", $itowrite, "dword*", 0, "struct*", $toverlapped)
- If @error Then Return SetError(@error, @extended, False)
- $iwritten = $aresult[4]
- Return $aresult[0]
- EndFunc
- Func _winapi_writeprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iwritten, $sbuffer = "ptr")
- Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, $sbuffer, $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
- If @error Then Return SetError(@error, @extended, False)
- $iwritten = $aresult[5]
- Return $aresult[0]
- EndFunc
- Global Const $_udf_globalids_offset = 2
- Global Const $_udf_globalid_max_win = 16
- Global Const $_udf_startid = 10000
- Global Const $_udf_globalid_max_ids = 55535
- Global Const $__udfguiconstant_ws_tabstop = 65536
- Global Const $__udfguiconstant_ws_visible = 268435456
- Global Const $__udfguiconstant_ws_child = 1073741824
- Global $__g_audf_globalids_used[$_udf_globalid_max_win][$_udf_globalid_max_ids + $_udf_globalids_offset + 1]
- Func __udf_getnextglobalid($hwnd)
- Local $nctrlid, $iusedindex = -1, $ballused = True
- If NOT WinExists($hwnd) Then Return SetError(-1, -1, 0)
- For $iindex = 0 To $_udf_globalid_max_win - 1
- If $__g_audf_globalids_used[$iindex][0] <> 0 Then
- If NOT WinExists($__g_audf_globalids_used[$iindex][0]) Then
- For $x = 0 To UBound($__g_audf_globalids_used, $ubound_columns) - 1
- $__g_audf_globalids_used[$iindex][$x] = 0
- Next
- $__g_audf_globalids_used[$iindex][1] = $_udf_startid
- $ballused = False
- EndIf
- EndIf
- Next
- For $iindex = 0 To $_udf_globalid_max_win - 1
- If $__g_audf_globalids_used[$iindex][0] = $hwnd Then
- $iusedindex = $iindex
- ExitLoop
- EndIf
- Next
- If $iusedindex = -1 Then
- For $iindex = 0 To $_udf_globalid_max_win - 1
- If $__g_audf_globalids_used[$iindex][0] = 0 Then
- $__g_audf_globalids_used[$iindex][0] = $hwnd
- $__g_audf_globalids_used[$iindex][1] = $_udf_startid
- $ballused = False
- $iusedindex = $iindex
- ExitLoop
- EndIf
- Next
- EndIf
- If $iusedindex = -1 AND $ballused Then Return SetError(16, 0, 0)
- If $__g_audf_globalids_used[$iusedindex][1] = $_udf_startid + $_udf_globalid_max_ids Then
- For $iidindex = $_udf_globalids_offset To UBound($__g_audf_globalids_used, $ubound_columns) - 1
- If $__g_audf_globalids_used[$iusedindex][$iidindex] = 0 Then
- $nctrlid = ($iidindex - $_udf_globalids_offset) + 10000
- $__g_audf_globalids_used[$iusedindex][$iidindex] = $nctrlid
- Return $nctrlid
- EndIf
- Next
- Return SetError(-1, $_udf_globalid_max_ids, 0)
- EndIf
- $nctrlid = $__g_audf_globalids_used[$iusedindex][1]
- $__g_audf_globalids_used[$iusedindex][1] += 1
- $__g_audf_globalids_used[$iusedindex][($nctrlid - 10000) + $_udf_globalids_offset] = $nctrlid
- Return $nctrlid
- EndFunc
- Func __udf_freeglobalid($hwnd, $iglobalid)
- If $iglobalid - $_udf_startid < 0 OR $iglobalid - $_udf_startid > $_udf_globalid_max_ids Then Return SetError(-1, 0, False)
- For $iindex = 0 To $_udf_globalid_max_win - 1
- If $__g_audf_globalids_used[$iindex][0] = $hwnd Then
- For $x = $_udf_globalids_offset To UBound($__g_audf_globalids_used, $ubound_columns) - 1
- If $__g_audf_globalids_used[$iindex][$x] = $iglobalid Then
- $__g_audf_globalids_used[$iindex][$x] = 0
- Return True
- EndIf
- Next
- Return SetError(-3, 0, False)
- EndIf
- Next
- Return SetError(-2, 0, False)
- EndFunc
- Global $__g_hsblastwnd
- Global Const $__statusbarconstant_classname = "msctls_statusbar32"
- Global Const $__statusbarconstant_wm_size = 5
- Global Const $__statusbarconstant_clr_default = -16777216
- Global Const $tagborders = "int BX;int BY;int RX"
- Func _guictrlstatusbar_create($hwnd, $vpartedge = -1, $vparttext = "", $istyles = -1, $iexstyles = 0)
- If NOT IsHWnd($hwnd) Then Return SetError(1, 0, 0)
- Local $istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconstant_ws_visible)
- If $istyles = -1 Then $istyles = 0
- If $iexstyles = -1 Then $iexstyles = 0
- Local $apartwidth[1], $aparttext[1]
- If @NumParams > 1 Then
- If IsArray($vpartedge) Then
- $apartwidth = $vpartedge
- Else
- $apartwidth[0] = $vpartedge
- EndIf
- If @NumParams = 2 Then
- ReDim $aparttext[UBound($apartwidth)]
- Else
- If IsArray($vparttext) Then
- $aparttext = $vparttext
- Else
- $aparttext[0] = $vparttext
- EndIf
- If UBound($apartwidth) <> UBound($aparttext) Then
- Local $ilast
- If UBound($apartwidth) > UBound($aparttext) Then
- $ilast = UBound($aparttext)
- ReDim $aparttext[UBound($apartwidth)]
- Else
- $ilast = UBound($apartwidth)
- ReDim $apartwidth[UBound($aparttext)]
- For $x = $ilast To UBound($apartwidth) - 1
- $apartwidth[$x] = $apartwidth[$x - 1] + 75
- Next
- $apartwidth[UBound($aparttext) - 1] = -1
- EndIf
- EndIf
- EndIf
- If NOT IsHWnd($hwnd) Then $hwnd = HWnd($hwnd)
- If @NumParams > 3 Then $istyle = BitOR($istyle, $istyles)
- EndIf
- Local $nctrlid = __udf_getnextglobalid($hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Local $hwndsbar = _winapi_createwindowex($iexstyles, $__statusbarconstant_classname, "", $istyle, 0, 0, 0, 0, $hwnd, $nctrlid)
- If @error Then Return SetError(@error, @extended, 0)
- If @NumParams > 1 Then
- _guictrlstatusbar_setparts($hwndsbar, UBound($apartwidth), $apartwidth)
- For $x = 0 To UBound($aparttext) - 1
- _guictrlstatusbar_settext($hwndsbar, $aparttext[$x], $x)
- Next
- EndIf
- Return $hwndsbar
- EndFunc
- Func _guictrlstatusbar_destroy(ByRef $hwnd)
- If NOT _winapi_isclassname($hwnd, $__statusbarconstant_classname) Then Return SetError(2, 2, False)
- Local $idestroyed = 0
- If IsHWnd($hwnd) Then
- If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
- Local $nctrlid = _winapi_getdlgctrlid($hwnd)
- Local $hparent = _winapi_getparent($hwnd)
- $idestroyed = _winapi_destroywindow($hwnd)
- Local $iret = __udf_freeglobalid($hparent, $nctrlid)
- If NOT $iret Then
- EndIf
- Else
- Return SetError(1, 1, False)
- EndIf
- EndIf
- If $idestroyed Then $hwnd = 0
- Return $idestroyed <> 0
- EndFunc
- Func _guictrlstatusbar_embedcontrol($hwnd, $ipart, $hcontrol, $ifit = 4)
- Local $arect = _guictrlstatusbar_getrect($hwnd, $ipart)
- Local $ibarx = $arect[0]
- Local $ibary = $arect[1]
- Local $ibarw = $arect[2] - $ibarx
- Local $ibarh = $arect[3] - $ibary
- Local $iconx = $ibarx
- Local $icony = $ibary
- Local $iconw = _winapi_getwindowwidth($hcontrol)
- Local $iconh = _winapi_getwindowheight($hcontrol)
- If $iconw > $ibarw Then $iconw = $ibarw
- If $iconh > $ibarh Then $iconh = $ibarh
- Local $ipadx = ($ibarw - $iconw) / 2
- Local $ipady = ($ibarh - $iconh) / 2
- If $ipadx < 0 Then $ipadx = 0
- If $ipady < 0 Then $ipady = 0
- If BitAND($ifit, 1) = 1 Then $iconx = $ibarx + $ipadx
- If BitAND($ifit, 2) = 2 Then $icony = $ibary + $ipady
- If BitAND($ifit, 4) = 4 Then
- $ipadx = _guictrlstatusbar_getbordersrect($hwnd)
- $ipady = _guictrlstatusbar_getbordersvert($hwnd)
- $iconx = $ibarx
- If _guictrlstatusbar_issimple($hwnd) Then $iconx += $ipadx
- $icony = $ibary + $ipady
- $iconw = $ibarw - ($ipadx * 2)
- $iconh = $ibarh - ($ipady * 2)
- EndIf
- _winapi_setparent($hcontrol, $hwnd)
- _winapi_movewindow($hcontrol, $iconx, $icony, $iconw, $iconh)
- EndFunc
- Func _guictrlstatusbar_getborders($hwnd)
- Local $tborders = DllStructCreate($tagborders)
- Local $iret
- If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
- $iret = _sendmessage($hwnd, $sb_getborders, 0, $tborders, 0, "wparam", "struct*")
- Else
- Local $isize = DllStructGetSize($tborders)
- Local $tmemmap
- Local $pmemory = _meminit($hwnd, $isize, $tmemmap)
- $iret = _sendmessage($hwnd, $sb_getborders, 0, $pmemory, 0, "wparam", "ptr")
- _memread($tmemmap, $pmemory, $tborders, $isize)
- _memfree($tmemmap)
- EndIf
- Local $aborders[3]
- If $iret = 0 Then Return SetError(-1, -1, $aborders)
- $aborders[0] = DllStructGetData($tborders, "BX")
- $aborders[1] = DllStructGetData($tborders, "BY")
- $aborders[2] = DllStructGetData($tborders, "RX")
- Return $aborders
- EndFunc
- Func _guictrlstatusbar_getbordershorz($hwnd)
- Local $aborders = _guictrlstatusbar_getborders($hwnd)
- Return SetError(@error, @extended, $aborders[0])
- EndFunc
- Func _guictrlstatusbar_getbordersrect($hwnd)
- Local $aborders = _guictrlstatusbar_getborders($hwnd)
- Return SetError(@error, @extended, $aborders[2])
- EndFunc
- Func _guictrlstatusbar_getbordersvert($hwnd)
- Local $aborders = _guictrlstatusbar_getborders($hwnd)
- Return SetError(@error, @extended, $aborders[1])
- EndFunc
- Func _guictrlstatusbar_getcount($hwnd)
- Return _sendmessage($hwnd, $sb_getparts)
- EndFunc
- Func _guictrlstatusbar_getheight($hwnd)
- Local $trect = _guictrlstatusbar_getrectex($hwnd, 0)
- Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top") - (_guictrlstatusbar_getbordersvert($hwnd) * 2)
- EndFunc
- Func _guictrlstatusbar_geticon($hwnd, $iindex = 0)
- Return _sendmessage($hwnd, $sb_geticon, $iindex, 0, 0, "wparam", "lparam", "handle")
- EndFunc
- Func _guictrlstatusbar_getparts($hwnd)
- Local $icount = _guictrlstatusbar_getcount($hwnd)
- Local $tparts = DllStructCreate("int[" & $icount & "]")
- Local $aparts[$icount + 1]
- If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
- $aparts[0] = _sendmessage($hwnd, $sb_getparts, $icount, $tparts, 0, "wparam", "struct*")
- Else
- Local $iparts = DllStructGetSize($tparts)
- Local $tmemmap
- Local $pmemory = _meminit($hwnd, $iparts, $tmemmap)
- $aparts[0] = _sendmessage($hwnd, $sb_getparts, $icount, $pmemory, 0, "wparam", "ptr")
- _memread($tmemmap, $pmemory, $tparts, $iparts)
- _memfree($tmemmap)
- EndIf
- For $ii = 1 To $icount
- $aparts[$ii] = DllStructGetData($tparts, 1, $ii)
- Next
- Return $aparts
- EndFunc
- Func _guictrlstatusbar_getrect($hwnd, $ipart)
- Local $trect = _guictrlstatusbar_getrectex($hwnd, $ipart)
- If @error Then Return SetError(@error, 0, 0)
- Local $arect[4]
- $arect[0] = DllStructGetData($trect, "Left")
- $arect[1] = DllStructGetData($trect, "Top")
- $arect[2] = DllStructGetData($trect, "Right")
- $arect[3] = DllStructGetData($trect, "Bottom")
- Return $arect
- EndFunc
- Func _guictrlstatusbar_getrectex($hwnd, $ipart)
- Local $trect = DllStructCreate($tagrect)
- Local $iret
- If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
- $iret = _sendmessage($hwnd, $sb_getrect, $ipart, $trect, 0, "wparam", "struct*")
- Else
- Local $irect = DllStructGetSize($trect)
- Local $tmemmap
- Local $pmemory = _meminit($hwnd, $irect, $tmemmap)
- $iret = _sendmessage($hwnd, $sb_getrect, $ipart, $pmemory, 0, "wparam", "ptr")
- _memread($tmemmap, $pmemory, $trect, $irect)
- _memfree($tmemmap)
- EndIf
- Return SetError($iret = 0, 0, $trect)
- EndFunc
- Func _guictrlstatusbar_gettext($hwnd, $ipart)
- Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)
- Local $ibuffer = _guictrlstatusbar_gettextlength($hwnd, $ipart) + 1
- If $ibuffer = 1 Then Return SetError(1, 0, "")
- Local $tbuffer
- If $bunicode Then
- $tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]")
- $ibuffer *= 2
- Else
- $tbuffer = DllStructCreate("char Text[" & $ibuffer & "]")
- EndIf
- If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
- _sendmessage($hwnd, $sb_gettextw, $ipart, $tbuffer, 0, "wparam", "struct*")
- Else
- Local $tmemmap
- Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
- If $bunicode Then
- _sendmessage($hwnd, $sb_gettextw, $ipart, $pmemory, 0, "wparam", "ptr")
- Else
- _sendmessage($hwnd, $sb_gettext, $ipart, $pmemory, 0, "wparam", "ptr")
- EndIf
- _memread($tmemmap, $pmemory, $tbuffer, $ibuffer)
- _memfree($tmemmap)
- EndIf
- Return DllStructGetData($tbuffer, "Text")
- EndFunc
- Func _guictrlstatusbar_gettextflags($hwnd, $ipart)
- If _guictrlstatusbar_getunicodeformat($hwnd) Then
- Return _sendmessage($hwnd, $sb_gettextlengthw, $ipart)
- Else
- Return _sendmessage($hwnd, $sb_gettextlength, $ipart)
- EndIf
- EndFunc
- Func _guictrlstatusbar_gettextlength($hwnd, $ipart)
- Return _winapi_loword(_guictrlstatusbar_gettextflags($hwnd, $ipart))
- EndFunc
- Func _guictrlstatusbar_gettextlengthex($hwnd, $ipart)
- Return _winapi_hiword(_guictrlstatusbar_gettextflags($hwnd, $ipart))
- EndFunc
- Func _guictrlstatusbar_gettiptext($hwnd, $ipart)
- Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)
- Local $tbuffer
- If $bunicode Then
- $tbuffer = DllStructCreate("wchar Text[4096]")
- Else
- $tbuffer = DllStructCreate("char Text[4096]")
- EndIf
- If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
- _sendmessage($hwnd, $sb_gettiptextw, _winapi_makelong($ipart, 4096), $tbuffer, 0, "wparam", "struct*")
- Else
- Local $tmemmap
- Local $pmemory = _meminit($hwnd, 4096, $tmemmap)
- If $bunicode Then
- _sendmessage($hwnd, $sb_gettiptextw, _winapi_makelong($ipart, 4096), $pmemory, 0, "wparam", "ptr")
- Else
- _sendmessage($hwnd, $sb_gettiptexta, _winapi_makelong($ipart, 4096), $pmemory, 0, "wparam", "ptr")
- EndIf
- _memread($tmemmap, $pmemory, $tbuffer, 4096)
- _memfree($tmemmap)
- EndIf
- Return DllStructGetData($tbuffer, "Text")
- EndFunc
- Func _guictrlstatusbar_getunicodeformat($hwnd)
- Return _sendmessage($hwnd, $sb_getunicodeformat) <> 0
- EndFunc
- Func _guictrlstatusbar_getwidth($hwnd, $ipart)
- Local $trect = _guictrlstatusbar_getrectex($hwnd, $ipart)
- Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left") - (_guictrlstatusbar_getbordershorz($hwnd) * 2)
- EndFunc
- Func _guictrlstatusbar_issimple($hwnd)
- Return _sendmessage($hwnd, $sb_issimple) <> 0
- EndFunc
- Func _guictrlstatusbar_resize($hwnd)
- _sendmessage($hwnd, $__statusbarconstant_wm_size)
- EndFunc
- Func _guictrlstatusbar_setbkcolor($hwnd, $icolor)
- $icolor = _sendmessage($hwnd, $sb_setbkcolor, 0, $icolor)
- If $icolor = $__statusbarconstant_clr_default Then Return "0x" & Hex($__statusbarconstant_clr_default)
- Return $icolor
- EndFunc
- Func _guictrlstatusbar_seticon($hwnd, $ipart, $hicon = -1, $siconfile = "")
- If $hicon = -1 Then Return _sendmessage($hwnd, $sb_seticon, $ipart, $hicon, 0, "wparam", "handle") <> 0
- If StringLen($siconfile) <= 0 Then Return _sendmessage($hwnd, $sb_seticon, $ipart, $hicon) <> 0
- Local $ticon = DllStructCreate("handle")
- Local $vresult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $siconfile, "int", $hicon, "ptr", 0, "struct*", $ticon, "uint", 1)
- If @error Then Return SetError(@error, @extended, False)
- $vresult = $vresult[0]
- If $vresult > 0 Then $vresult = _sendmessage($hwnd, $sb_seticon, $ipart, DllStructGetData($ticon, 1), 0, "wparam", "handle")
- DllCall("user32.dll", "bool", "DestroyIcon", "handle", DllStructGetData($ticon, 1))
- Return $vresult
- EndFunc
- Func _guictrlstatusbar_setminheight($hwnd, $iminheight)
- _sendmessage($hwnd, $sb_setminheight, $iminheight)
- _guictrlstatusbar_resize($hwnd)
- EndFunc
- Func _guictrlstatusbar_setparts($hwnd, $aparts = -1, $apartwidth = 25)
- Local $tparts, $iparts = 1
- If IsArray($aparts) <> 0 Then
- $aparts[UBound($aparts) - 1] = -1
- $iparts = UBound($aparts)
- $tparts = DllStructCreate("int[" & $iparts & "]")
- For $x = 0 To $iparts - 2
- DllStructSetData($tparts, 1, $aparts[$x], $x + 1)
- Next
- DllStructSetData($tparts, 1, -1, $iparts)
- ElseIf IsArray($apartwidth) <> 0 Then
- $iparts = UBound($apartwidth)
- $tparts = DllStructCreate("int[" & $iparts & "]")
- For $x = 0 To $iparts - 2
- DllStructSetData($tparts, 1, $apartwidth[$x], $x + 1)
- Next
- DllStructSetData($tparts, 1, -1, $iparts)
- ElseIf $aparts > 1 Then
- $iparts = $aparts
- $tparts = DllStructCreate("int[" & $iparts & "]")
- For $x = 1 To $iparts - 1
- DllStructSetData($tparts, 1, $apartwidth * $x, $x)
- Next
- DllStructSetData($tparts, 1, -1, $iparts)
- Else
- $tparts = DllStructCreate("int")
- DllStructSetData($tparts, $iparts, -1)
- EndIf
- If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
- _sendmessage($hwnd, $sb_setparts, $iparts, $tparts, 0, "wparam", "struct*")
- Else
- Local $isize = DllStructGetSize($tparts)
- Local $tmemmap
- Local $pmemory = _meminit($hwnd, $isize, $tmemmap)
- _memwrite($tmemmap, $tparts)
- _sendmessage($hwnd, $sb_setparts, $iparts, $pmemory, 0, "wparam", "ptr")
- _memfree($tmemmap)
- EndIf
- _guictrlstatusbar_resize($hwnd)
- Return True
- EndFunc
- Func _guictrlstatusbar_setsimple($hwnd, $bsimple = True)
- _sendmessage($hwnd, $sb_simple, $bsimple)
- EndFunc
- Func _guictrlstatusbar_settext($hwnd, $stext = "", $ipart = 0, $iuflag = 0)
- Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)
- Local $ibuffer = StringLen($stext) + 1
- Local $ttext
- If $bunicode Then
- $ttext = DllStructCreate("wchar Text[" & $ibuffer & "]")
- $ibuffer *= 2
- Else
- $ttext = DllStructCreate("char Text[" & $ibuffer & "]")
- EndIf
- DllStructSetData($ttext, "Text", $stext)
- If _guictrlstatusbar_issimple($hwnd) Then $ipart = $sb_simpleid
- Local $iret
- If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
- $iret = _sendmessage($hwnd, $sb_settextw, BitOR($ipart, $iuflag), $ttext, 0, "wparam", "struct*")
- Else
- Local $tmemmap
- Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
- _memwrite($tmemmap, $ttext)
- If $bunicode Then
- $iret = _sendmessage($hwnd, $sb_settextw, BitOR($ipart, $iuflag), $pmemory, 0, "wparam", "ptr")
- Else
- $iret = _sendmessage($hwnd, $sb_settext, BitOR($ipart, $iuflag), $pmemory, 0, "wparam", "ptr")
- EndIf
- _memfree($tmemmap)
- EndIf
- Return $iret <> 0
- EndFunc
- Func _guictrlstatusbar_settiptext($hwnd, $ipart, $stext)
- Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)
- Local $ibuffer = StringLen($stext) + 1
- Local $ttext
- If $bunicode Then
- $ttext = DllStructCreate("wchar TipText[" & $ibuffer & "]")
- $ibuffer *= 2
- Else
- $ttext = DllStructCreate("char TipText[" & $ibuffer & "]")
- EndIf
- DllStructSetData($ttext, "TipText", $stext)
- If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
- _sendmessage($hwnd, $sb_settiptextw, $ipart, $ttext, 0, "wparam", "struct*")
- Else
- Local $tmemmap
- Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
- _memwrite($tmemmap, $ttext, $pmemory, $ibuffer)
- If $bunicode Then
- _sendmessage($hwnd, $sb_settiptextw, $ipart, $pmemory, 0, "wparam", "ptr")
- Else
- _sendmessage($hwnd, $sb_settiptexta, $ipart, $pmemory, 0, "wparam", "ptr")
- EndIf
- _memfree($tmemmap)
- EndIf
- EndFunc
- Func _guictrlstatusbar_setunicodeformat($hwnd, $bunicode = True)
- Return _sendmessage($hwnd, $sb_setunicodeformat, $bunicode)
- EndFunc
- Func _guictrlstatusbar_showhide($hwnd, $istate)
- If $istate <> @SW_HIDE AND $istate <> @SW_SHOW Then Return SetError(1, 1, False)
- Return _winapi_showwindow($hwnd, $istate)
- EndFunc
- Global Const $ttf_idishwnd = 1
- Global Const $ttf_centertip = 2
- Global Const $ttf_rtlreading = 4
- Global Const $ttf_subclass = 16
- Global Const $ttf_track = 32
- Global Const $ttf_absolute = 128
- Global Const $ttf_transparent = 256
- Global Const $ttf_parselinks = 4096
- Global Const $ttf_di_setitem = 32768
- Global Const $__tooltipconstants_wm_user = 1024
- Global Const $ttm_activate = $__tooltipconstants_wm_user + 1
- Global Const $ttm_setdelaytime = $__tooltipconstants_wm_user + 3
- Global Const $ttm_addtool = $__tooltipconstants_wm_user + 4
- Global Const $ttm_deltool = $__tooltipconstants_wm_user + 5
- Global Const $ttm_newtoolrect = $__tooltipconstants_wm_user + 6
- Global Const $ttm_gettoolinfo = $__tooltipconstants_wm_user + 8
- Global Const $ttm_settoolinfo = $__tooltipconstants_wm_user + 9
- Global Const $ttm_hittest = $__tooltipconstants_wm_user + 10
- Global Const $ttm_gettext = $__tooltipconstants_wm_user + 11
- Global Const $ttm_updatetiptext = $__tooltipconstants_wm_user + 12
- Global Const $ttm_gettoolcount = $__tooltipconstants_wm_user + 13
- Global Const $ttm_enumtools = $__tooltipconstants_wm_user + 14
- Global Const $ttm_getcurrenttool = $__tooltipconstants_wm_user + 15
- Global Const $ttm_windowfrompoint = $__tooltipconstants_wm_user + 16
- Global Const $ttm_trackactivate = $__tooltipconstants_wm_user + 17
- Global Const $ttm_trackposition = $__tooltipconstants_wm_user + 18
- Global Const $ttm_settipbkcolor = $__tooltipconstants_wm_user + 19
- Global Const $ttm_settiptextcolor = $__tooltipconstants_wm_user + 20
- Global Const $ttm_getdelaytime = $__tooltipconstants_wm_user + 21
- Global Const $ttm_gettipbkcolor = $__tooltipconstants_wm_user + 22
- Global Const $ttm_gettiptextcolor = $__tooltipconstants_wm_user + 23
- Global Const $ttm_setmaxtipwidth = $__tooltipconstants_wm_user + 24
- Global Const $ttm_getmaxtipwidth = $__tooltipconstants_wm_user + 25
- Global Const $ttm_setmargin = $__tooltipconstants_wm_user + 26
- Global Const $ttm_getmargin = $__tooltipconstants_wm_user + 27
- Global Const $ttm_pop = $__tooltipconstants_wm_user + 28
- Global Const $ttm_update = $__tooltipconstants_wm_user + 29
- Global Const $ttm_getbubblesize = $__tooltipconstants_wm_user + 30
- Global Const $ttm_adjustrect = $__tooltipconstants_wm_user + 31
- Global Const $ttm_settitle = $__tooltipconstants_wm_user + 32
- Global Const $ttm_settitlew = $__tooltipconstants_wm_user + 33
- Global Const $ttm_popup = $__tooltipconstants_wm_user + 34
- Global Const $ttm_gettitle = $__tooltipconstants_wm_user + 35
- Global Const $ttm_addtoolw = $__tooltipconstants_wm_user + 50
- Global Const $ttm_deltoolw = $__tooltipconstants_wm_user + 51
- Global Const $ttm_newtoolrectw = $__tooltipconstants_wm_user + 52
- Global Const $ttm_gettoolinfow = $__tooltipconstants_wm_user + 53
- Global Const $ttm_settoolinfow = $__tooltipconstants_wm_user + 54
- Global Const $ttm_hittestw = $__tooltipconstants_wm_user + 55
- Global Const $ttm_gettextw = $__tooltipconstants_wm_user + 56
- Global Const $ttm_updatetiptextw = $__tooltipconstants_wm_user + 57
- Global Const $ttm_enumtoolsw = $__tooltipconstants_wm_user + 58
- Global Const $ttm_getcurrenttoolw = $__tooltipconstants_wm_user + 59
- Global Const $ttm_setwindowtheme = 8192 + 11
- Global Const $ttn_first = -520
- Global Const $ttn_getdispinfo = $ttn_first + 0
- Global Const $ttn_show = $ttn_first - 1
- Global Const $ttn_pop = $ttn_first - 2
- Global Const $ttn_linkclick = $ttn_first - 3
- Global Const $ttn_getdispinfow = $ttn_first - 10
- Global Const $tts_alwaystip = 1
- Global Const $tts_noprefix = 2
- Global Const $tts_noanimate = 16
- Global Const $tts_nofade = 32
- Global Const $tts_balloon = 64
- Global Const $tts_close = 128
- Global Const $tts_usevisualstyle = 256
- Global Const $ttdt_automatic = 0
- Global Const $ttdt_reshow = 1
- Global Const $ttdt_autopop = 2
- Global Const $ttdt_initial = 3
- Global Enum $tti_none, $tti_info, $tti_warning, $tti_error, $tti_info_large, $tti_warning_large, $tti_error_large
- Global $__g_heditlastwnd
- Global Const $__editconstant_classname = "Edit"
- Global Const $__editconstant_gui_checked = 1
- Global Const $__editconstant_gui_hide = 32
- Global Const $__editconstant_gui_event_close = -3
- Global Const $__editconstant_gui_enable = 64
- Global Const $__editconstant_gui_disable = 128
- Global Const $__editconstant_ss_center = 1
- Global Const $__editconstant_wm_setredraw = 11
- Global Const $__editconstant_ws_caption = 12582912
- Global Const $__editconstant_ws_popup = -2147483648
- Global Const $__editconstant_ws_sysmenu = 524288
- Global Const $__editconstant_ws_minimizebox = 131072
- Global Const $__editconstant_default_gui_font = 17
- Global Const $__editconstant_wm_setfont = 48
- Global Const $__editconstant_wm_gettextlength = 14
- Global Const $__editconstant_wm_gettext = 13
- Global Const $__editconstant_wm_settext = 12
- Global Const $__editconstant_sb_lineup = 0
- Global Const $__editconstant_sb_linedown = 1
- Global Const $__editconstant_sb_pagedown = 3
- Global Const $__editconstant_sb_pageup = 2
- Global Const $__editconstant_sb_scrollcaret = 4
- Global Const $__tageditballoontip = "dword Size;ptr Title;ptr Text;int Icon"
- Func _guictrledit_appendtext($hwnd, $stext)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $ilength = _guictrledit_gettextlen($hwnd)
- _guictrledit_setsel($hwnd, $ilength, $ilength)
- _sendmessage($hwnd, $em_replacesel, True, $stext, 0, "wparam", "wstr")
- EndFunc
- Func _guictrledit_beginupdate($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $__editconstant_wm_setredraw, False) = 0
- EndFunc
- Func _guictrledit_canundo($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_canundo) <> 0
- EndFunc
- Func _guictrledit_charfrompos($hwnd, $ix, $iy)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $areturn[2]
- Local $iret = _sendmessage($hwnd, $em_charfrompos, 0, _winapi_makelong($ix, $iy))
- $areturn[0] = _winapi_loword($iret)
- $areturn[1] = _winapi_hiword($iret)
- Return $areturn
- EndFunc
- Func _guictrledit_create($hwnd, $stext, $ix, $iy, $iwidth = 150, $iheight = 150, $istyle = 3150020, $iexstyle = 512)
- If NOT IsHWnd($hwnd) Then Return SetError(1, 0, 0)
- If NOT IsString($stext) Then Return SetError(2, 0, 0)
- If $iwidth = -1 Then $iwidth = 150
- If $iheight = -1 Then $iheight = 150
- If $istyle = -1 Then $istyle = 3150020
- If $iexstyle = -1 Then $iexstyle = 512
- If BitAND($istyle, $es_readonly) = $es_readonly Then
- $istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconstant_ws_visible, $istyle)
- Else
- $istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconstant_ws_visible, $__udfguiconstant_ws_tabstop, $istyle)
- EndIf
- Local $nctrlid = __udf_getnextglobalid($hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Local $hedit = _winapi_createwindowex($iexstyle, $__editconstant_classname, "", $istyle, $ix, $iy, $iwidth, $iheight, $hwnd, $nctrlid)
- _sendmessage($hedit, $__editconstant_wm_setfont, _winapi_getstockobject($__editconstant_default_gui_font), True)
- _guictrledit_settext($hedit, $stext)
- _guictrledit_setlimittext($hedit, 0)
- Return $hedit
- EndFunc
- Func _guictrledit_destroy(ByRef $hwnd)
- If NOT _winapi_isclassname($hwnd, $__editconstant_classname) Then Return SetError(2, 2, False)
- Local $idestroyed = 0
- If IsHWnd($hwnd) Then
- If _winapi_inprocess($hwnd, $__g_heditlastwnd) Then
- Local $nctrlid = _winapi_getdlgctrlid($hwnd)
- Local $hparent = _winapi_getparent($hwnd)
- $idestroyed = _winapi_destroywindow($hwnd)
- Local $iret = __udf_freeglobalid($hparent, $nctrlid)
- If NOT $iret Then
- EndIf
- Else
- Return SetError(1, 1, False)
- EndIf
- Else
- $idestroyed = GUICtrlDelete($hwnd)
- EndIf
- If $idestroyed Then $hwnd = 0
- Return $idestroyed <> 0
- EndFunc
- Func _guictrledit_emptyundobuffer($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- _sendmessage($hwnd, $em_emptyundobuffer)
- EndFunc
- Func _guictrledit_endupdate($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $__editconstant_wm_setredraw, True) = 0
- EndFunc
- Func _guictrledit_fmtlines($hwnd, $bsoftbreak = False)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_fmtlines, $bsoftbreak)
- EndFunc
- Func _guictrledit_find($hwnd, $breplace = False)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $ipos = 0, $icase, $ioccurance = 0, $ireplacements = 0
- Local $apartsrightedge[3] = [125, 225, -1]
- Local $ioldmode = Opt("GUIOnEventMode", 0)
- Local $asel = _guictrledit_getsel($hwnd)
- Local $stext = _guictrledit_gettext($hwnd)
- Local $hguisearch = GUICreate("Find", 349, 177, -1, -1, BitOR($__udfguiconstant_ws_child, $__editconstant_ws_minimizebox, $__editconstant_ws_caption, $__editconstant_ws_popup, $__editconstant_ws_sysmenu))
- Local $idstatusbar1 = _guictrlstatusbar_create($hguisearch, $apartsrightedge)
- _guictrlstatusbar_settext($idstatusbar1, "Find: ")
- GUISetIcon(@SystemDir & "\shell32.dll", 22, $hguisearch)
- GUICtrlCreateLabel("Find what:", 9, 10, 53, 16, $__editconstant_ss_center)
- Local $idinputsearch = GUICtrlCreateInput("", 80, 8, 257, 21)
- Local $idlblreplace = GUICtrlCreateLabel("Replace with:", 9, 42, 69, 17, $__editconstant_ss_center)
- Local $idinputreplace = GUICtrlCreateInput("", 80, 40, 257, 21)
- Local $idchkwholeonly = GUICtrlCreateCheckbox("Match whole word only", 9, 72, 145, 17)
- Local $idchkmatchcase = GUICtrlCreateCheckbox("Match case", 9, 96, 145, 17)
- Local $idbtnfindnext = GUICtrlCreateButton("Find Next", 168, 72, 161, 21, 0)
- Local $idbtnreplace = GUICtrlCreateButton("Replace", 168, 96, 161, 21, 0)
- Local $idbtnclose = GUICtrlCreateButton("Close", 104, 130, 161, 21, 0)
- If (IsArray($asel) AND $asel <> $ec_err) Then
- GUICtrlSetData($idinputsearch, StringMid($stext, $asel[0] + 1, $asel[1] - $asel[0]))
- If $asel[0] <> $asel[1] Then
- $ipos = $asel[0]
- If BitAND(GUICtrlRead($idchkmatchcase), $__editconstant_gui_checked) = $__editconstant_gui_checked Then $icase = 1
- $ioccurance = 1
- Local $itpose
- While 1
- $itpose = StringInStr($stext, GUICtrlRead($idinputsearch), $icase, $ioccurance)
- If NOT $itpose Then
- $ioccurance = 0
- ExitLoop
- ElseIf $itpose = $ipos + 1 Then
- ExitLoop
- EndIf
- $ioccurance += 1
- WEnd
- EndIf
- _guictrlstatusbar_settext($idstatusbar1, "Find: " & GUICtrlRead($idinputsearch))
- EndIf
- If $breplace = False Then
- GUICtrlSetState($idlblreplace, $__editconstant_gui_hide)
- GUICtrlSetState($idinputreplace, $__editconstant_gui_hide)
- GUICtrlSetState($idbtnreplace, $__editconstant_gui_hide)
- Else
- _guictrlstatusbar_settext($idstatusbar1, "Replacements: " & $ireplacements, 1)
- _guictrlstatusbar_settext($idstatusbar1, "With: ", 2)
- EndIf
- GUISetState(@SW_SHOW)
- Local $imsgfind
- While 1
- $imsgfind = GUIGetMsg()
- Select
- Case $imsgfind = $__editconstant_gui_event_close OR $imsgfind = $idbtnclose
- ExitLoop
- Case $imsgfind = $idbtnfindnext
- GUICtrlSetState($idbtnfindnext, $__editconstant_gui_disable)
- GUICtrlSetCursor($idbtnfindnext, 15)
- Sleep(100)
- _guictrlstatusbar_settext($idstatusbar1, "Find: " & GUICtrlRead($idinputsearch))
- If $breplace = True Then
- _guictrlstatusbar_settext($idstatusbar1, "Find: " & GUICtrlRead($idinputsearch))
- _guictrlstatusbar_settext($idstatusbar1, "With: " & GUICtrlRead($idinputreplace), 2)
- EndIf
- __guictrledit_findtext($hwnd, $idinputsearch, $idchkmatchcase, $idchkwholeonly, $ipos, $ioccurance, $ireplacements)
- Sleep(100)
- GUICtrlSetState($idbtnfindnext, $__editconstant_gui_enable)
- GUICtrlSetCursor($idbtnfindnext, 2)
- Case $imsgfind = $idbtnreplace
- GUICtrlSetState($idbtnreplace, $__editconstant_gui_disable)
- GUICtrlSetCursor($idbtnreplace, 15)
- Sleep(100)
- _guictrlstatusbar_settext($idstatusbar1, "Find: " & GUICtrlRead($idinputsearch))
- _guictrlstatusbar_settext($idstatusbar1, "With: " & GUICtrlRead($idinputreplace), 2)
- If $ipos Then
- _guictrledit_replacesel($hwnd, GUICtrlRead($idinputreplace))
- $ireplacements += 1
- $ioccurance -= 1
- _guictrlstatusbar_settext($idstatusbar1, "Replacements: " & $ireplacements, 1)
- EndIf
- __guictrledit_findtext($hwnd, $idinputsearch, $idchkmatchcase, $idchkwholeonly, $ipos, $ioccurance, $ireplacements)
- Sleep(100)
- GUICtrlSetState($idbtnreplace, $__editconstant_gui_enable)
- GUICtrlSetCursor($idbtnreplace, 2)
- EndSelect
- WEnd
- GUIDelete($hguisearch)
- Opt("GUIOnEventMode", $ioldmode)
- EndFunc
- Func _guictrledit_getcuebanner($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $ttext = DllStructCreate("wchar[4096]")
- If _sendmessage($hwnd, $em_getcuebanner, $ttext, 4096, 0, "struct*") <> 1 Then Return SetError(-1, 0, "")
- Return _winapi_widechartomultibyte($ttext)
- EndFunc
- Func __guictrledit_findtext($hwnd, $idinputsearch, $idchkmatchcase, $idchkwholeonly, ByRef $ipos, ByRef $ioccurance, ByRef $ireplacements)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $icase = 0, $iwhole = 0
- Local $bexact = False
- Local $sfind = GUICtrlRead($idinputsearch)
- Local $stext = _guictrledit_gettext($hwnd)
- If BitAND(GUICtrlRead($idchkmatchcase), $__editconstant_gui_checked) = $__editconstant_gui_checked Then $icase = 1
- If BitAND(GUICtrlRead($idchkwholeonly), $__editconstant_gui_checked) = $__editconstant_gui_checked Then $iwhole = 1
- If $sfind <> "" Then
- $ioccurance += 1
- $ipos = StringInStr($stext, $sfind, $icase, $ioccurance)
- If $iwhole AND $ipos Then
- Local $s_compare2 = StringMid($stext, $ipos + StringLen($sfind), 1)
- If $ipos = 1 Then
- 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
- Else
- Local $s_compare1 = StringMid($stext, $ipos - 1, 1)
- If ($ipos + StringLen($sfind)) - 1 = StringLen($stext) Then
- If ($s_compare1 = " " OR $s_compare1 = @LF OR $s_compare1 = @CR OR $s_compare1 = @CRLF OR $s_compare1 = @TAB) Then $bexact = True
- Else
- 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
- EndIf
- EndIf
- If $bexact = False Then
- __guictrledit_findtext($hwnd, $idinputsearch, $idchkmatchcase, $idchkwholeonly, $ipos, $ioccurance, $ireplacements)
- Else
- _guictrledit_setsel($hwnd, $ipos - 1, ($ipos + StringLen($sfind)) - 1)
- _guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
- EndIf
- ElseIf $iwhole AND NOT $ipos Then
- $ioccurance = 0
- MsgBox($mb_systemmodal, "Find", "Reached End of document, Can not find the string '" & $sfind & "'")
- ElseIf NOT $iwhole Then
- If NOT $ipos Then
- $ioccurance = 1
- _guictrledit_setsel($hwnd, -1, 0)
- _guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
- $ipos = StringInStr($stext, $sfind, $icase, $ioccurance)
- If NOT $ipos Then
- $ioccurance = 0
- MsgBox($mb_systemmodal, "Find", "Reached End of document, Can not find the string '" & $sfind & "'")
- Else
- _guictrledit_setsel($hwnd, $ipos - 1, ($ipos + StringLen($sfind)) - 1)
- _guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
- EndIf
- Else
- _guictrledit_setsel($hwnd, $ipos - 1, ($ipos + StringLen($sfind)) - 1)
- _guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
- EndIf
- EndIf
- EndIf
- EndFunc
- Func _guictrledit_getfirstvisibleline($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_getfirstvisibleline)
- EndFunc
- Func _guictrledit_gethandle($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return Ptr(_sendmessage($hwnd, $em_gethandle))
- EndFunc
- Func _guictrledit_getimestatus($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_getimestatus, $emsis_compositionstring)
- EndFunc
- Func _guictrledit_getlimittext($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_getlimittext)
- EndFunc
- Func _guictrledit_getline($hwnd, $iline)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $ilength = _guictrledit_linelength($hwnd, $iline)
- If $ilength = 0 Then Return ""
- Local $tbuffer = DllStructCreate("short Len;wchar Text[" & $ilength & "]")
- DllStructSetData($tbuffer, "Len", $ilength + 1)
- Local $iret = _sendmessage($hwnd, $em_getline, $iline, $tbuffer, 0, "wparam", "struct*")
- If $iret = 0 Then Return SetError($ec_err, $ec_err, "")
- Local $ttext = DllStructCreate("wchar Text[" & $ilength & "]", DllStructGetPtr($tbuffer))
- Return DllStructGetData($ttext, "Text")
- EndFunc
- Func _guictrledit_getlinecount($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_getlinecount)
- EndFunc
- Func _guictrledit_getmargins($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $amargins[2]
- Local $imargins = _sendmessage($hwnd, $em_getmargins)
- $amargins[0] = _winapi_loword($imargins)
- $amargins[1] = _winapi_hiword($imargins)
- Return $amargins
- EndFunc
- Func _guictrledit_getmodify($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_getmodify) <> 0
- EndFunc
- Func _guictrledit_getpasswordchar($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_getpasswordchar)
- EndFunc
- Func _guictrledit_getrect($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $arect[4]
- Local $trect = _guictrledit_getrectex($hwnd)
- $arect[0] = DllStructGetData($trect, "Left")
- $arect[1] = DllStructGetData($trect, "Top")
- $arect[2] = DllStructGetData($trect, "Right")
- $arect[3] = DllStructGetData($trect, "Bottom")
- Return $arect
- EndFunc
- Func _guictrledit_getrectex($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $trect = DllStructCreate($tagrect)
- _sendmessage($hwnd, $em_getrect, 0, $trect, 0, "wparam", "struct*")
- Return $trect
- EndFunc
- Func _guictrledit_getsel($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $asel[2]
- Local $tstart = DllStructCreate("uint Start")
- Local $tend = DllStructCreate("uint End")
- _sendmessage($hwnd, $em_getsel, $tstart, $tend, 0, "struct*", "struct*")
- $asel[0] = DllStructGetData($tstart, "Start")
- $asel[1] = DllStructGetData($tend, "End")
- Return $asel
- EndFunc
- Func _guictrledit_gettext($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $itextlen = _guictrledit_gettextlen($hwnd) + 1
- Local $ttext = DllStructCreate("wchar Text[" & $itextlen & "]")
- _sendmessage($hwnd, $__editconstant_wm_gettext, $itextlen, $ttext, 0, "wparam", "struct*")
- Return DllStructGetData($ttext, "Text")
- EndFunc
- Func _guictrledit_gettextlen($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $__editconstant_wm_gettextlength)
- EndFunc
- Func _guictrledit_getthumb($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_getthumb)
- EndFunc
- Func _guictrledit_getwordbreakproc($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_getwordbreakproc)
- EndFunc
- Func _guictrledit_hideballoontip($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_hideballoontip) <> 0
- EndFunc
- Func _guictrledit_inserttext($hwnd, $stext, $iindex = -1)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- If $iindex = -1 Then
- _guictrledit_appendtext($hwnd, $stext)
- Else
- _guictrledit_setsel($hwnd, $iindex, $iindex)
- _sendmessage($hwnd, $em_replacesel, True, $stext, 0, "wparam", "wstr")
- EndIf
- EndFunc
- Func _guictrledit_linefromchar($hwnd, $iindex = -1)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_linefromchar, $iindex)
- EndFunc
- Func _guictrledit_lineindex($hwnd, $iindex = -1)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_lineindex, $iindex)
- EndFunc
- Func _guictrledit_linelength($hwnd, $iindex = -1)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $icharindex = _guictrledit_lineindex($hwnd, $iindex)
- Return _sendmessage($hwnd, $em_linelength, $icharindex)
- EndFunc
- Func _guictrledit_linescroll($hwnd, $ihoriz, $ivert)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_linescroll, $ihoriz, $ivert) <> 0
- EndFunc
- Func _guictrledit_posfromchar($hwnd, $iindex)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $acoord[2]
- Local $iret = _sendmessage($hwnd, $em_posfromchar, $iindex)
- $acoord[0] = _winapi_loword($iret)
- $acoord[1] = _winapi_hiword($iret)
- Return $acoord
- EndFunc
- Func _guictrledit_replacesel($hwnd, $stext, $bundo = True)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- _sendmessage($hwnd, $em_replacesel, $bundo, $stext, 0, "wparam", "wstr")
- EndFunc
- Func _guictrledit_scroll($hwnd, $idirection)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- 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
- If $idirection == $__editconstant_sb_scrollcaret Then
- Return _sendmessage($hwnd, $em_scrollcaret)
- Else
- Return _sendmessage($hwnd, $em_scroll, $idirection)
- EndIf
- EndFunc
- Func _guictrledit_setcuebanner($hwnd, $stext, $bonfocus = False)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $ttext = _winapi_multibytetowidechar($stext)
- Return _sendmessage($hwnd, $em_setcuebanner, $bonfocus, $ttext, 0, "wparam", "struct*") = 1
- EndFunc
- Func _guictrledit_sethandle($hwnd, $hmemory)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- _sendmessage($hwnd, $em_sethandle, $hmemory, 0, 0, "handle")
- EndFunc
- Func _guictrledit_setimestatus($hwnd, $icomposition)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_setimestatus, $emsis_compositionstring, $icomposition)
- EndFunc
- Func _guictrledit_setlimittext($hwnd, $ilimit)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- _sendmessage($hwnd, $em_setlimittext, $ilimit)
- EndFunc
- Func _guictrledit_setmargins($hwnd, $imargin = 1, $ileft = 65535, $iright = 65535)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- _sendmessage($hwnd, $em_setmargins, $imargin, _winapi_makelong($ileft, $iright))
- EndFunc
- Func _guictrledit_setmodify($hwnd, $bmodified)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- _sendmessage($hwnd, $em_setmodify, $bmodified)
- EndFunc
- Func _guictrledit_setpasswordchar($hwnd, $sdisplaychar = "0")
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- $sdisplaychar = StringLeft($sdisplaychar, 1)
- If Asc($sdisplaychar) = 48 Then
- _sendmessage($hwnd, $em_setpasswordchar)
- Else
- _sendmessage($hwnd, $em_setpasswordchar, Asc($sdisplaychar))
- EndIf
- EndFunc
- Func _guictrledit_setreadonly($hwnd, $breadonly)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_setreadonly, $breadonly) <> 0
- EndFunc
- Func _guictrledit_setrect($hwnd, $arect)
- Local $trect = DllStructCreate($tagrect)
- DllStructSetData($trect, "Left", $arect[0])
- DllStructSetData($trect, "Top", $arect[1])
- DllStructSetData($trect, "Right", $arect[2])
- DllStructSetData($trect, "Bottom", $arect[3])
- _guictrledit_setrectex($hwnd, $trect)
- EndFunc
- Func _guictrledit_setrectex($hwnd, $trect)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- _sendmessage($hwnd, $em_setrect, 0, $trect, 0, "wparam", "struct*")
- EndFunc
- Func _guictrledit_setrectnp($hwnd, $arect)
- Local $trect = DllStructCreate($tagrect)
- DllStructSetData($trect, "Left", $arect[0])
- DllStructSetData($trect, "Top", $arect[1])
- DllStructSetData($trect, "Right", $arect[2])
- DllStructSetData($trect, "Bottom", $arect[3])
- _guictrledit_setrectnpex($hwnd, $trect)
- EndFunc
- Func _guictrledit_setrectnpex($hwnd, $trect)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- _sendmessage($hwnd, $em_setrectnp, 0, $trect, 0, "wparam", "struct*")
- EndFunc
- Func _guictrledit_setsel($hwnd, $istart, $iend)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- _sendmessage($hwnd, $em_setsel, $istart, $iend)
- EndFunc
- Func _guictrledit_settabstops($hwnd, $atabstops)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- If NOT IsArray($atabstops) Then Return SetError(-1, -1, False)
- Local $stabstops = ""
- Local $inumtabstops = UBound($atabstops)
- For $x = 0 To $inumtabstops - 1
- $stabstops &= "int;"
- Next
- $stabstops = StringTrimRight($stabstops, 1)
- Local $ttabstops = DllStructCreate($stabstops)
- For $x = 0 To $inumtabstops - 1
- DllStructSetData($ttabstops, $x + 1, $atabstops[$x])
- Next
- Local $iret = _sendmessage($hwnd, $em_settabstops, $inumtabstops, $ttabstops, 0, "wparam", "struct*") <> 0
- _winapi_invalidaterect($hwnd)
- Return $iret
- EndFunc
- Func _guictrledit_settext($hwnd, $stext)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- _sendmessage($hwnd, $__editconstant_wm_settext, 0, $stext, 0, "wparam", "wstr")
- EndFunc
- Func _guictrledit_setwordbreakproc($hwnd, $iaddressfunc)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- _sendmessage($hwnd, $em_setwordbreakproc, 0, $iaddressfunc)
- EndFunc
- Func _guictrledit_showballoontip($hwnd, $stitle, $stext, $iicon)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Local $ttitle = _winapi_multibytetowidechar($stitle)
- Local $ttext = _winapi_multibytetowidechar($stext)
- Local $ttt = DllStructCreate($__tageditballoontip)
- DllStructSetData($ttt, "Size", DllStructGetSize($ttt))
- DllStructSetData($ttt, "Title", DllStructGetPtr($ttitle))
- DllStructSetData($ttt, "Text", DllStructGetPtr($ttext))
- DllStructSetData($ttt, "Icon", $iicon)
- Return _sendmessage($hwnd, $em_showballoontip, 0, $ttt, 0, "wparam", "struct*") <> 0
- EndFunc
- Func _guictrledit_undo($hwnd)
- If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
- Return _sendmessage($hwnd, $em_undo) <> 0
- EndFunc
- Func _filecountlines($sfilepath)
- Local $hfileopen = FileOpen($sfilepath, $fo_read)
- If $hfileopen = -1 Then Return SetError(1, 0, 0)
- Local $sfileread = StringStripWS(FileRead($hfileopen), $str_striptrailing)
- FileClose($hfileopen)
- Return UBound(StringRegExp($sfileread, "\R", $str_regexparrayglobalmatch)) + 1 - Int($sfileread = "")
- EndFunc
- Func _filecreate($sfilepath)
- Local $hfileopen = FileOpen($sfilepath, BitOR($fo_overwrite, $fo_createpath))
- If $hfileopen = -1 Then Return SetError(1, 0, 0)
- Local $ifilewrite = FileWrite($hfileopen, "")
- FileClose($hfileopen)
- If NOT $ifilewrite Then Return SetError(2, 0, 0)
- Return 1
- EndFunc
- Func _filelisttoarray($sfilepath, $sfilter = "*", $iflag = $flta_filesfolders, $breturnpath = False)
- Local $sdelimiter = "|", $sfilelist = "", $sfilename = "", $sfullpath = ""
- $sfilepath = StringRegExpReplace($sfilepath, "[\\/]+$", "") & "\"
- If $iflag = Default Then $iflag = $flta_filesfolders
- If $breturnpath Then $sfullpath = $sfilepath
- If $sfilter = Default Then $sfilter = "*"
- If NOT FileExists($sfilepath) Then Return SetError(1, 0, 0)
- If StringRegExp($sfilter, "[\\/:><\|]|(?s)^\s*$") Then Return SetError(2, 0, 0)
- If NOT ($iflag = 0 OR $iflag = 1 OR $iflag = 2) Then Return SetError(3, 0, 0)
- Local $hsearch = FileFindFirstFile($sfilepath & $sfilter)
- If @error Then Return SetError(4, 0, 0)
- While 1
- $sfilename = FileFindNextFile($hsearch)
- If @error Then ExitLoop
- If ($iflag + @extended = 2) Then ContinueLoop
- $sfilelist &= $sdelimiter & $sfullpath & $sfilename
- WEnd
- FileClose($hsearch)
- If $sfilelist = "" Then Return SetError(4, 0, 0)
- Return StringSplit(StringTrimLeft($sfilelist, 1), $sdelimiter)
- EndFunc
- Func _filelisttoarrayrec($sfilepath, $smask = "*", $ireturn = $fltar_filesfolders, $irecur = $fltar_norecur, $isort = $fltar_nosort, $ireturnpath = $fltar_relpath)
- If NOT FileExists($sfilepath) Then Return SetError(1, 1, "")
- If $smask = Default Then $smask = "*"
- If $ireturn = Default Then $ireturn = $fltar_filesfolders
- If $irecur = Default Then $irecur = $fltar_norecur
- If $isort = Default Then $isort = $fltar_nosort
- If $ireturnpath = Default Then $ireturnpath = $fltar_relpath
- If $irecur > 1 OR NOT IsInt($irecur) Then Return SetError(1, 6, "")
- Local $blongpath = False
- If StringLeft($sfilepath, 4) == "\\?\" Then
- $blongpath = True
- EndIf
- Local $sfolderslash = ""
- If StringRight($sfilepath, 1) = "\" Then
- $sfolderslash = "\"
- Else
- $sfilepath = $sfilepath & "\"
- EndIf
- Local $asfoldersearchlist[100] = [1]
- $asfoldersearchlist[1] = $sfilepath
- Local $ihide_hs = 0, $shide_hs = ""
- If BitAND($ireturn, 4) Then
- $ihide_hs += 2
- $shide_hs &= "H"
- $ireturn -= 4
- EndIf
- If BitAND($ireturn, 8) Then
- $ihide_hs += 4
- $shide_hs &= "S"
- $ireturn -= 8
- EndIf
- Local $ihide_link = 0
- If BitAND($ireturn, 16) Then
- $ihide_link = 1024
- $ireturn -= 16
- EndIf
- Local $imaxlevel = 0
- If $irecur < 0 Then
- StringReplace($sfilepath, "\", "", 0, $str_nocasesensebasic)
- $imaxlevel = @extended - $irecur
- EndIf
- Local $sexclude_list = "", $sexclude_list_folder = "", $sinclude_list = "*"
- Local $amasksplit = StringSplit($smask, "|")
- Switch $amasksplit[0]
- Case 3
- $sexclude_list_folder = $amasksplit[3]
- ContinueCase
- Case 2
- $sexclude_list = $amasksplit[2]
- ContinueCase
- Case 1
- $sinclude_list = $amasksplit[1]
- EndSwitch
- Local $sinclude_file_mask = ".+"
- If $sinclude_list <> "*" Then
- If NOT __fltar_listtomask($sinclude_file_mask, $sinclude_list) Then Return SetError(1, 2, "")
- EndIf
- Local $sinclude_folder_mask = ".+"
- Switch $ireturn
- Case 0
- Switch $irecur
- Case 0
- $sinclude_folder_mask = $sinclude_file_mask
- EndSwitch
- Case 2
- $sinclude_folder_mask = $sinclude_file_mask
- EndSwitch
- Local $sexclude_file_mask = ":"
- If $sexclude_list <> "" Then
- If NOT __fltar_listtomask($sexclude_file_mask, $sexclude_list) Then Return SetError(1, 3, "")
- EndIf
- Local $sexclude_folder_mask = ":"
- If $irecur Then
- If $sexclude_list_folder Then
- If NOT __fltar_listtomask($sexclude_folder_mask, $sexclude_list_folder) Then Return SetError(1, 4, "")
- EndIf
- If $ireturn = 2 Then
- $sexclude_folder_mask = $sexclude_file_mask
- EndIf
- Else
- $sexclude_folder_mask = $sexclude_file_mask
- EndIf
- If NOT ($ireturn = 0 OR $ireturn = 1 OR $ireturn = 2) Then Return SetError(1, 5, "")
- If NOT ($isort = 0 OR $isort = 1 OR $isort = 2) Then Return SetError(1, 7, "")
- If NOT ($ireturnpath = 0 OR $ireturnpath = 1 OR $ireturnpath = 2) Then Return SetError(1, 8, "")
- If $ihide_link Then
- 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")
- Local $hdll = DllOpen("kernel32.dll"), $adll_ret
- EndIf
- Local $asreturnlist[100] = [0]
- Local $asfilematchlist = $asreturnlist, $asrootfilematchlist = $asreturnlist, $asfoldermatchlist = $asreturnlist
- Local $bfolder = False, $hsearch = 0, $scurrentpath = "", $sname = "", $sretpath = ""
- Local $iattribs = 0, $sattribs = ""
- Local $asfolderfilesectionlist[100][2] = [[0, 0]]
- While $asfoldersearchlist[0] > 0
- $scurrentpath = $asfoldersearchlist[$asfoldersearchlist[0]]
- $asfoldersearchlist[0] -= 1
- Switch $ireturnpath
- Case 1
- $sretpath = StringReplace($scurrentpath, $sfilepath, "")
- Case 2
- If $blongpath Then
- $sretpath = StringTrimLeft($scurrentpath, 4)
- Else
- $sretpath = $scurrentpath
- EndIf
- EndSwitch
- If $ihide_link Then
- $adll_ret = DllCall($hdll, "handle", "FindFirstFileW", "wstr", $scurrentpath & "*", "struct*", $tfile_data)
- If @error OR NOT $adll_ret[0] Then
- ContinueLoop
- EndIf
- $hsearch = $adll_ret[0]
- Else
- $hsearch = FileFindFirstFile($scurrentpath & "*")
- If $hsearch = -1 Then
- ContinueLoop
- EndIf
- EndIf
- If $ireturn = 0 AND $isort AND $ireturnpath Then
- __fltar_addtolist($asfolderfilesectionlist, $sretpath, $asfilematchlist[0] + 1)
- EndIf
- $sattribs = ""
- While 1
- If $ihide_link Then
- $adll_ret = DllCall($hdll, "int", "FindNextFileW", "handle", $hsearch, "struct*", $tfile_data)
- If @error OR NOT $adll_ret[0] Then
- ExitLoop
- EndIf
- $sname = DllStructGetData($tfile_data, "FileName")
- If $sname = ".." Then
- ContinueLoop
- EndIf
- $iattribs = DllStructGetData($tfile_data, "FileAttributes")
- If $ihide_hs AND BitAND($iattribs, $ihide_hs) Then
- ContinueLoop
- EndIf
- If BitAND($iattribs, $ihide_link) Then
- ContinueLoop
- EndIf
- $bfolder = False
- If BitAND($iattribs, 16) Then
- $bfolder = True
- EndIf
- Else
- $bfolder = False
- $sname = FileFindNextFile($hsearch, 1)
- If @error Then
- ExitLoop
- EndIf
- $sattribs = @extended
- If StringInStr($sattribs, "D") Then
- $bfolder = True
- EndIf
- If StringRegExp($sattribs, "[" & $shide_hs & "]") Then
- ContinueLoop
- EndIf
- EndIf
- If $bfolder Then
- Select
- Case $irecur < 0
- StringReplace($scurrentpath, "\", "", 0, $str_nocasesensebasic)
- If @extended < $imaxlevel Then
- ContinueCase
- EndIf
- Case $irecur = 1
- If NOT StringRegExp($sname, $sexclude_folder_mask) Then
- __fltar_addtolist($asfoldersearchlist, $scurrentpath & $sname & "\")
- EndIf
- EndSelect
- EndIf
- If $isort Then
- If $bfolder Then
- If StringRegExp($sname, $sinclude_folder_mask) AND NOT StringRegExp($sname, $sexclude_folder_mask) Then
- __fltar_addtolist($asfoldermatchlist, $sretpath & $sname & $sfolderslash)
- EndIf
- Else
- If StringRegExp($sname, $sinclude_file_mask) AND NOT StringRegExp($sname, $sexclude_file_mask) Then
- If $scurrentpath = $sfilepath Then
- __fltar_addtolist($asrootfilematchlist, $sretpath & $sname)
- Else
- __fltar_addtolist($asfilematchlist, $sretpath & $sname)
- EndIf
- EndIf
- EndIf
- Else
- If $bfolder Then
- If $ireturn <> 1 AND StringRegExp($sname, $sinclude_folder_mask) AND NOT StringRegExp($sname, $sexclude_folder_mask) Then
- __fltar_addtolist($asreturnlist, $sretpath & $sname & $sfolderslash)
- EndIf
- Else
- If $ireturn <> 2 AND StringRegExp($sname, $sinclude_file_mask) AND NOT StringRegExp($sname, $sexclude_file_mask) Then
- __fltar_addtolist($asreturnlist, $sretpath & $sname)
- EndIf
- EndIf
- EndIf
- WEnd
- If $ihide_link Then
- DllCall($hdll, "int", "FindClose", "ptr", $hsearch)
- Else
- FileClose($hsearch)
- EndIf
- WEnd
- If $ihide_link Then
- DllClose($hdll)
- EndIf
- If $isort Then
- Switch $ireturn
- Case 2
- If $asfoldermatchlist[0] = 0 Then Return SetError(1, 9, "")
- ReDim $asfoldermatchlist[$asfoldermatchlist[0] + 1]
- $asreturnlist = $asfoldermatchlist
- __arraydualpivotsort($asreturnlist, 1, $asreturnlist[0])
- Case 1
- If $asrootfilematchlist[0] = 0 AND $asfilematchlist[0] = 0 Then Return SetError(1, 9, "")
- If $ireturnpath = 0 Then
- __fltar_addfilelists($asreturnlist, $asrootfilematchlist, $asfilematchlist)
- __arraydualpivotsort($asreturnlist, 1, $asreturnlist[0])
- Else
- __fltar_addfilelists($asreturnlist, $asrootfilematchlist, $asfilematchlist, 1)
- EndIf
- Case 0
- If $asrootfilematchlist[0] = 0 AND $asfoldermatchlist[0] = 0 Then Return SetError(1, 9, "")
- If $ireturnpath = 0 Then
- __fltar_addfilelists($asreturnlist, $asrootfilematchlist, $asfilematchlist)
- $asreturnlist[0] += $asfoldermatchlist[0]
- ReDim $asfoldermatchlist[$asfoldermatchlist[0] + 1]
- _arrayconcatenate($asreturnlist, $asfoldermatchlist, 1)
- __arraydualpivotsort($asreturnlist, 1, $asreturnlist[0])
- Else
- Local $asreturnlist[$asfilematchlist[0] + $asrootfilematchlist[0] + $asfoldermatchlist[0] + 1]
- $asreturnlist[0] = $asfilematchlist[0] + $asrootfilematchlist[0] + $asfoldermatchlist[0]
- __arraydualpivotsort($asrootfilematchlist, 1, $asrootfilematchlist[0])
- For $i = 1 To $asrootfilematchlist[0]
- $asreturnlist[$i] = $asrootfilematchlist[$i]
- Next
- Local $inextinsertionindex = $asrootfilematchlist[0] + 1
- __arraydualpivotsort($asfoldermatchlist, 1, $asfoldermatchlist[0])
- Local $sfoldertofind = ""
- For $i = 1 To $asfoldermatchlist[0]
- $asreturnlist[$inextinsertionindex] = $asfoldermatchlist[$i]
- $inextinsertionindex += 1
- If $sfolderslash Then
- $sfoldertofind = $asfoldermatchlist[$i]
- Else
- $sfoldertofind = $asfoldermatchlist[$i] & "\"
- EndIf
- Local $ifilesectionendindex = 0, $ifilesectionstartindex = 0
- For $j = 1 To $asfolderfilesectionlist[0][0]
- If $sfoldertofind = $asfolderfilesectionlist[$j][0] Then
- $ifilesectionstartindex = $asfolderfilesectionlist[$j][1]
- If $j = $asfolderfilesectionlist[0][0] Then
- $ifilesectionendindex = $asfilematchlist[0]
- Else
- $ifilesectionendindex = $asfolderfilesectionlist[$j + 1][1] - 1
- EndIf
- If $isort = 1 Then
- __arraydualpivotsort($asfilematchlist, $ifilesectionstartindex, $ifilesectionendindex)
- EndIf
- For $k = $ifilesectionstartindex To $ifilesectionendindex
- $asreturnlist[$inextinsertionindex] = $asfilematchlist[$k]
- $inextinsertionindex += 1
- Next
- ExitLoop
- EndIf
- Next
- Next
- EndIf
- EndSwitch
- Else
- If $asreturnlist[0] = 0 Then Return SetError(1, 9, "")
- ReDim $asreturnlist[$asreturnlist[0] + 1]
- EndIf
- Return $asreturnlist
- EndFunc
- Func __fltar_addfilelists(ByRef $astarget, $assource_1, $assource_2, $isort = 0)
- ReDim $assource_1[$assource_1[0] + 1]
- If $isort = 1 Then __arraydualpivotsort($assource_1, 1, $assource_1[0])
- $astarget = $assource_1
- $astarget[0] += $assource_2[0]
- ReDim $assource_2[$assource_2[0] + 1]
- If $isort = 1 Then __arraydualpivotsort($assource_2, 1, $assource_2[0])
- _arrayconcatenate($astarget, $assource_2, 1)
- EndFunc
- Func __fltar_addtolist(ByRef $alist, $vvalue_0, $vvalue_1 = -1)
- If $vvalue_1 = -1 Then
- $alist[0] += 1
- If UBound($alist) <= $alist[0] Then ReDim $alist[UBound($alist) * 2]
- $alist[$alist[0]] = $vvalue_0
- Else
- $alist[0][0] += 1
- If UBound($alist) <= $alist[0][0] Then ReDim $alist[UBound($alist) * 2][2]
- $alist[$alist[0][0]][0] = $vvalue_0
- $alist[$alist[0][0]][1] = $vvalue_1
- EndIf
- EndFunc
- Func __fltar_listtomask(ByRef $smask, $slist)
- If StringRegExp($slist, "\\|/|:|\<|\>|\|") Then Return 0
- $slist = StringReplace(StringStripWS(StringRegExpReplace($slist, "\s*;\s*", ";"), $str_stripleading + $str_striptrailing), ";", "|")
- $slist = StringReplace(StringReplace(StringRegExpReplace($slist, "[][$^.{}()+\-]", "\\$0"), "?", "."), "*", ".*?")
- $smask = "(?i)^(" & $slist & ")\z"
- Return 1
- EndFunc
- Func _fileprint($sfilepath, $ishow = @SW_HIDE)
- If $ishow = Default Then $ishow = @SW_HIDE
- Return ShellExecute($sfilepath, "", @WorkingDir, "print", $ishow)
- EndFunc
- Func _filereadtoarray($sfilepath, ByRef $vreturn, $iflags = $frta_count, $sdelimiter = "")
- $vreturn = 0
- If $iflags = Default Then $iflags = $frta_count
- If $sdelimiter = Default Then $sdelimiter = ""
- Local $bexpand = True
- If BitAND($iflags, $frta_intarrays) Then
- $bexpand = False
- $iflags -= $frta_intarrays
- EndIf
- Local $ientire = $str_chrsplit
- If BitAND($iflags, $frta_entiresplit) Then
- $ientire = $str_entiresplit
- $iflags -= $frta_entiresplit
- EndIf
- Local $inocount = 0
- If $iflags <> $frta_count Then
- $iflags = $frta_nocount
- $inocount = $str_nocount
- EndIf
- If $sdelimiter Then
- Local $alines = FILEREADTOARRAY($sfilepath)
- If @error Then Return SetError(@error, 0, 0)
- Local $idim_1 = UBound($alines) + $iflags
- If $bexpand Then
- Local $idim_2 = UBound(StringSplit($alines[0], $sdelimiter, $ientire + $str_nocount))
- Local $atemp_array[$idim_1][$idim_2]
- Local $ifields, $asplit
- For $i = 0 To $idim_1 - $iflags - 1
- $asplit = StringSplit($alines[$i], $sdelimiter, $ientire + $str_nocount)
- $ifields = UBound($asplit)
- If $ifields <> $idim_2 Then
- Return SetError(3, 0, 0)
- EndIf
- For $j = 0 To $ifields - 1
- $atemp_array[$i + $iflags][$j] = $asplit[$j]
- Next
- Next
- If $idim_2 < 2 Then Return SetError(4, 0, 0)
- If $iflags Then
- $atemp_array[0][0] = $idim_1 - $iflags
- $atemp_array[0][1] = $idim_2
- EndIf
- Else
- Local $atemp_array[$idim_1]
- For $i = 0 To $idim_1 - $iflags - 1
- $atemp_array[$i + $iflags] = StringSplit($alines[$i], $sdelimiter, $ientire + $inocount)
- Next
- If $iflags Then
- $atemp_array[0] = $idim_1 - $iflags
- EndIf
- EndIf
- $vreturn = $atemp_array
- Else
- If $iflags Then
- Local $hfileopen = FileOpen($sfilepath, $fo_read)
- If $hfileopen = -1 Then Return SetError(1, 0, 0)
- Local $sfileread = FileRead($hfileopen)
- FileClose($hfileopen)
- If StringLen($sfileread) Then
- $vreturn = StringRegExp(@LF & $sfileread, "(?|(\N+)\z|(\N*)(?:\R))", 3)
- $vreturn[0] = UBound($vreturn) - 1
- Else
- Return SetError(2, 0, 0)
- EndIf
- Else
- $vreturn = FILEREADTOARRAY($sfilepath)
- If @error Then
- $vreturn = 0
- Return SetError(@error, 0, 0)
- EndIf
- EndIf
- EndIf
- Return 1
- EndFunc
- Func _filewritefromarray($sfilepath, Const ByRef $aarray, $ibase = Default, $iubound = Default, $sdelimiter = "|")
- Local $ireturn = 0
- If NOT IsArray($aarray) Then Return SetError(2, 0, $ireturn)
- Local $idims = UBound($aarray, $ubound_dimensions)
- If $idims > 2 Then Return SetError(4, 0, 0)
- Local $ilast = UBound($aarray) - 1
- If $iubound = Default OR $iubound > $ilast Then $iubound = $ilast
- If $ibase < 0 OR $ibase = Default Then $ibase = 0
- If $ibase > $iubound Then Return SetError(5, 0, $ireturn)
- If $sdelimiter = Default Then $sdelimiter = "|"
- Local $hfileopen = $sfilepath
- If IsString($sfilepath) Then
- $hfileopen = FileOpen($sfilepath, $fo_overwrite)
- If $hfileopen = -1 Then Return SetError(1, 0, $ireturn)
- EndIf
- Local $ierror = 0
- $ireturn = 1
- Switch $idims
- Case 1
- For $i = $ibase To $iubound
- If NOT FileWrite($hfileopen, $aarray[$i] & @CRLF) Then
- $ierror = 3
- $ireturn = 0
- ExitLoop
- EndIf
- Next
- Case 2
- Local $stemp = ""
- For $i = $ibase To $iubound
- $stemp = $aarray[$i][0]
- For $j = 1 To UBound($aarray, $ubound_columns) - 1
- $stemp &= $sdelimiter & $aarray[$i][$j]
- Next
- If NOT FileWrite($hfileopen, $stemp & @CRLF) Then
- $ierror = 3
- $ireturn = 0
- ExitLoop
- EndIf
- Next
- EndSwitch
- If IsString($sfilepath) Then FileClose($hfileopen)
- Return SetError($ierror, 0, $ireturn)
- EndFunc
- Func _filewritelog($slogpath, $slogmsg, $iflag = -1)
- Local $iopenmode = $fo_append
- Local $sdatenow = @YEAR & "-" & @MON & "-" & @MDAY
- Local $stimenow = @HOUR & ":" & @MIN & ":" & @SEC
- Local $smsg = $sdatenow & " " & $stimenow & " : " & $slogmsg
- If $iflag = Default Then $iflag = -1
- If $iflag <> -1 Then
- $iopenmode = $fo_overwrite
- $smsg &= @CRLF & FileRead($slogpath)
- EndIf
- Local $hfileopen = $slogpath
- If IsString($slogpath) Then
- $hfileopen = FileOpen($slogpath, $iopenmode)
- EndIf
- If $hfileopen = -1 Then Return SetError(1, 0, 0)
- Local $ireturn = FileWriteLine($hfileopen, $smsg)
- If IsString($slogpath) Then $ireturn = FileClose($hfileopen)
- If $ireturn <= 0 Then Return SetError(2, $ireturn, 0)
- Return $ireturn
- EndFunc
- Func _filewritetoline($sfilepath, $iline, $stext, $boverwrite = False)
- If $iline <= 0 Then Return SetError(4, 0, 0)
- If NOT IsString($stext) Then
- $stext = String($stext)
- If $stext = "" Then Return SetError(6, 0, 0)
- EndIf
- If $boverwrite = Default Then $boverwrite = False
- If NOT (IsBool($boverwrite) OR $boverwrite = 0 OR $boverwrite = 1) Then Return SetError(5, 0, 0)
- If NOT FileExists($sfilepath) Then Return SetError(2, 0, 0)
- Local $aarray = FILEREADTOARRAY($sfilepath)
- Local $iubound = UBound($aarray) - 1
- If ($iubound + 1) < $iline Then Return SetError(1, 0, 0)
- Local $hfileopen = FileOpen($sfilepath, FileGetEncoding($sfilepath) + $fo_overwrite)
- If $hfileopen = -1 Then Return SetError(3, 0, 0)
- Local $sdata = ""
- $iline -= 1
- For $i = 0 To $iubound
- If $i = $iline Then
- If $boverwrite Then
- If $stext Then $sdata &= $stext & @CRLF
- Else
- $sdata &= $stext & @CRLF & $aarray[$i] & @CRLF
- EndIf
- ElseIf $i < $iubound Then
- $sdata &= $aarray[$i] & @CRLF
- ElseIf $i = $iubound Then
- $sdata &= $aarray[$i]
- EndIf
- Next
- FileWrite($hfileopen, $sdata)
- FileClose($hfileopen)
- Return 1
- EndFunc
- Func _pathfull($srelativepath, $sbasepath = @WorkingDir)
- If NOT $srelativepath OR $srelativepath = "." Then Return $sbasepath
- Local $sfullpath = StringReplace($srelativepath, "/", "\")
- Local Const $sfullpathconst = $sfullpath
- Local $spath
- Local $brootonly = StringLeft($sfullpath, 1) = "\" AND StringMid($sfullpath, 2, 1) <> "\"
- If $sbasepath = Default Then $sbasepath = @WorkingDir
- For $i = 1 To 2
- $spath = StringLeft($sfullpath, 2)
- If $spath = "\\" Then
- $sfullpath = StringTrimLeft($sfullpath, 2)
- Local $nserverlen = StringInStr($sfullpath, "\") - 1
- $spath = "\\" & StringLeft($sfullpath, $nserverlen)
- $sfullpath = StringTrimLeft($sfullpath, $nserverlen)
- ExitLoop
- ElseIf StringRight($spath, 1) = ":" Then
- $sfullpath = StringTrimLeft($sfullpath, 2)
- ExitLoop
- Else
- $sfullpath = $sbasepath & "\" & $sfullpath
- EndIf
- Next
- If StringLeft($sfullpath, 1) <> "\" Then
- If StringLeft($sfullpathconst, 2) = StringLeft($sbasepath, 2) Then
- $sfullpath = $sbasepath & "\" & $sfullpath
- Else
- $sfullpath = "\" & $sfullpath
- EndIf
- EndIf
- Local $atemp = StringSplit($sfullpath, "\")
- Local $apathparts[$atemp[0]], $j = 0
- For $i = 2 To $atemp[0]
- If $atemp[$i] = ".." Then
- If $j Then $j -= 1
- ElseIf NOT ($atemp[$i] = "" AND $i <> $atemp[0]) AND $atemp[$i] <> "." Then
- $apathparts[$j] = $atemp[$i]
- $j += 1
- EndIf
- Next
- $sfullpath = $spath
- If NOT $brootonly Then
- For $i = 0 To $j - 1
- $sfullpath &= "\" & $apathparts[$i]
- Next
- Else
- $sfullpath &= $sfullpathconst
- If StringInStr($sfullpath, "..") Then $sfullpath = _pathfull($sfullpath)
- EndIf
- Do
- $sfullpath = StringReplace($sfullpath, ".\", "\")
- Until @extended = 0
- Return $sfullpath
- EndFunc
- Func _pathgetrelative($sfrom, $sto)
- If StringRight($sfrom, 1) <> "\" Then $sfrom &= "\"
- If StringRight($sto, 1) <> "\" Then $sto &= "\"
- If $sfrom = $sto Then Return SetError(1, 0, StringTrimRight($sto, 1))
- Local $asfrom = StringSplit($sfrom, "\")
- Local $asto = StringSplit($sto, "\")
- If $asfrom[1] <> $asto[1] Then Return SetError(2, 0, StringTrimRight($sto, 1))
- Local $i = 2
- Local $idiff = 1
- While 1
- If $asfrom[$i] <> $asto[$i] Then
- $idiff = $i
- ExitLoop
- EndIf
- $i += 1
- WEnd
- $i = 1
- Local $srelpath = ""
- For $j = 1 To $asto[0]
- If $i >= $idiff Then
- $srelpath &= "\" & $asto[$i]
- EndIf
- $i += 1
- Next
- $srelpath = StringTrimLeft($srelpath, 1)
- $i = 1
- For $j = 1 To $asfrom[0]
- If $i > $idiff Then
- $srelpath = "..\" & $srelpath
- EndIf
- $i += 1
- Next
- If StringRight($srelpath, 1) == "\" Then $srelpath = StringTrimRight($srelpath, 1)
- Return $srelpath
- EndFunc
- Func _pathmake($sdrive, $sdir, $sfilename, $sextension)
- If StringLen($sdrive) Then
- If NOT (StringLeft($sdrive, 2) = "\\") Then $sdrive = StringLeft($sdrive, 1) & ":"
- EndIf
- If StringLen($sdir) Then
- If NOT (StringRight($sdir, 1) = "\") AND NOT (StringRight($sdir, 1) = "/") Then $sdir = $sdir & "\"
- Else
- $sdir = "\"
- EndIf
- If StringLen($sdir) Then
- If NOT (StringLeft($sdir, 1) = "\") AND NOT (StringLeft($sdir, 1) = "/") Then $sdir = "\" & $sdir
- EndIf
- If StringLen($sextension) Then
- If NOT (StringLeft($sextension, 1) = ".") Then $sextension = "." & $sextension
- EndIf
- Return $sdrive & $sdir & $sfilename & $sextension
- EndFunc
- Func _pathsplit($sfilepath, ByRef $sdrive, ByRef $sdir, ByRef $sfilename, ByRef $sextension)
- Local $aarray = StringRegExp($sfilepath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $str_regexparraymatch)
- If @error Then
- ReDim $aarray[5]
- $aarray[0] = $sfilepath
- EndIf
- $sdrive = $aarray[1]
- If StringLeft($aarray[2], 1) == "/" Then
- $sdir = StringRegExpReplace($aarray[2], "\h*[\/\\]+\h*", "\/")
- Else
- $sdir = StringRegExpReplace($aarray[2], "\h*[\/\\]+\h*", "\\")
- EndIf
- $aarray[2] = $sdir
- $sfilename = $aarray[3]
- $sextension = $aarray[4]
- Return $aarray
- EndFunc
- Func _replacestringinfile($sfilepath, $ssearchstring, $sreplacestring, $icasesensitive = 0, $ioccurance = 1)
- If StringInStr(FileGetAttrib($sfilepath), "R") Then Return SetError(1, 0, -1)
- Local $hfileopen = FileOpen($sfilepath, $fo_read)
- If $hfileopen = -1 Then Return SetError(2, 0, -1)
- Local $sfileread = FileRead($hfileopen)
- FileClose($hfileopen)
- If $icasesensitive = Default Then $icasesensitive = 0
- If $ioccurance = Default Then $ioccurance = 1
- $sfileread = StringReplace($sfileread, $ssearchstring, $sreplacestring, 1 - $ioccurance, $icasesensitive)
- Local $ireturn = @extended
- If $ireturn Then
- Local $ifileencoding = FileGetEncoding($sfilepath)
- $hfileopen = FileOpen($sfilepath, $ifileencoding + $fo_overwrite)
- If $hfileopen = -1 Then Return SetError(3, 0, -1)
- FileWrite($hfileopen, $sfileread)
- FileClose($hfileopen)
- EndIf
- Return $ireturn
- EndFunc
- Func _tempfile($sdirectoryname = @TempDir, $sfileprefix = "~", $sfileextension = ".tmp", $irandomlength = 7)
- If $irandomlength = Default OR $irandomlength <= 0 Then $irandomlength = 7
- If $sdirectoryname = Default OR (NOT FileExists($sdirectoryname)) Then $sdirectoryname = @TempDir
- If $sfileextension = Default Then $sfileextension = ".tmp"
- If $sfileprefix = Default Then $sfileprefix = "~"
- If NOT FileExists($sdirectoryname) Then $sdirectoryname = @ScriptDir
- $sdirectoryname = StringRegExpReplace($sdirectoryname, "[\\/]+$", "")
- $sfileextension = StringRegExpReplace($sfileextension, "^\.+", "")
- $sfileprefix = StringRegExpReplace($sfileprefix, '[\\/:*?"<>|]', "")
- Local $stempname = ""
- Do
- $stempname = ""
- While StringLen($stempname) < $irandomlength
- $stempname &= Chr(Random(97, 122, 1))
- WEnd
- $stempname = $sdirectoryname & "\" & $sfileprefix & $stempname & "." & $sfileextension
- Until NOT FileExists($stempname)
- Return $stempname
- EndFunc
- Global Const $dts_shortdateformat = 0
- Global Const $dts_updown = 1
- Global Const $dts_shownone = 2
- Global Const $dts_longdateformat = 4
- Global Const $dts_timeformat = 9
- Global Const $dts_rightalign = 32
- Global Const $dts_shortdatecenturyformat = 12
- Global Const $dts_appcanparse = 16
- Global Const $dmw_longname = 0
- Global Const $dmw_shortname = 1
- Global Const $dmw_locale_longname = 2
- Global Const $dmw_locale_shortname = 3
- Global Const $gdt_error = -1
- Global Const $gdt_valid = 0
- Global Const $gdt_none = 1
- Global Const $gdtr_min = 1
- Global Const $gdtr_max = 2
- Global Const $mcht_nowhere = 0
- Global Const $mcht_title = 65536
- Global Const $mcht_calendar = 131072
- Global Const $mcht_todaylink = 196608
- Global Const $mcht_next = 16777216
- Global Const $mcht_prev = 33554432
- Global Const $mcht_titlebk = 65536
- Global Const $mcht_titlemonth = 65537
- Global Const $mcht_titleyear = 65538
- Global Const $mcht_titlebtnnext = 16842755
- Global Const $mcht_titlebtnprev = 33619971
- Global Const $mcht_calendarbk = 131072
- Global Const $mcht_calendardate = 131073
- Global Const $mcht_calendarday = 131074
- Global Const $mcht_calendarweeknum = 131075
- Global Const $mcht_calendardatenext = 16908288
- Global Const $mcht_calendardateprev = 33685504
- Global Const $mcs_daystate = 1
- Global Const $mcs_multiselect = 2
- Global Const $mcs_weeknumbers = 4
- Global Const $mcs_notodaycircle = 8
- Global Const $mcs_notoday = 16
- Global Const $mcs_notrailingdates = 64
- Global Const $mcs_shortdaysofweek = 128
- Global Const $mcs_noselchangeonnav = 256
- Global Const $mcm_first = 4096
- Global Const $mcm_getcalendarborder = ($mcm_first + 31)
- Global Const $mcm_getcalendarcount = ($mcm_first + 23)
- Global Const $mcm_getcalendargridinfo = ($mcm_first + 24)
- Global Const $mcm_getcalid = ($mcm_first + 27)
- Global Const $mcm_getcolor = ($mcm_first + 11)
- Global Const $mcm_getcurrentview = ($mcm_first + 22)
- Global Const $mcm_getcursel = ($mcm_first + 1)
- Global Const $mcm_getfirstdayofweek = ($mcm_first + 16)
- Global Const $mcm_getmaxselcount = ($mcm_first + 3)
- Global Const $mcm_getmaxtodaywidth = ($mcm_first + 21)
- Global Const $mcm_getminreqrect = ($mcm_first + 9)
- Global Const $mcm_getmonthdelta = ($mcm_first + 19)
- Global Const $mcm_getmonthrange = ($mcm_first + 7)
- Global Const $mcm_getrange = ($mcm_first + 17)
- Global Const $mcm_getselrange = ($mcm_first + 5)
- Global Const $mcm_gettoday = ($mcm_first + 13)
- Global Const $mcm_getunicodeformat = 8192 + 6
- Global Const $mcm_hittest = ($mcm_first + 14)
- Global Const $mcm_setcalendarborder = ($mcm_first + 30)
- Global Const $mcm_setcalid = ($mcm_first + 28)
- Global Const $mcm_setcolor = ($mcm_first + 10)
- Global Const $mcm_setcurrentview = ($mcm_first + 32)
- Global Const $mcm_setcursel = ($mcm_first + 2)
- Global Const $mcm_setdaystate = ($mcm_first + 8)
- Global Const $mcm_setfirstdayofweek = ($mcm_first + 15)
- Global Const $mcm_setmaxselcount = ($mcm_first + 4)
- Global Const $mcm_setmonthdelta = ($mcm_first + 20)
- Global Const $mcm_setrange = ($mcm_first + 18)
- Global Const $mcm_setselrange = ($mcm_first + 6)
- Global Const $mcm_settoday = ($mcm_first + 12)
- Global Const $mcm_setunicodeformat = 8192 + 5
- Global Const $mcm_sizerecttomin = ($mcm_first + 29)
- Global Const $mcn_first = -746
- Global Const $mcn_selchange = ($mcn_first - 3)
- Global Const $mcn_getdaystate = ($mcn_first - 1)
- Global Const $mcn_select = ($mcn_first)
- Global Const $mcn_viewchange = ($mcn_first - 4)
- Global Const $mcsc_background = 0
- Global Const $mcsc_monthbk = 4
- Global Const $mcsc_text = 1
- Global Const $mcsc_titlebk = 2
- Global Const $mcsc_titletext = 3
- Global Const $mcsc_trailingtext = 5
- Global Const $dtm_first = 4096
- Global Const $dtm_getsystemtime = $dtm_first + 1
- Global Const $dtm_setsystemtime = $dtm_first + 2
- Global Const $dtm_getrange = $dtm_first + 3
- Global Const $dtm_setrange = $dtm_first + 4
- Global Const $dtm_setformat = $dtm_first + 5
- Global Const $dtm_setmccolor = $dtm_first + 6
- Global Const $dtm_getmccolor = $dtm_first + 7
- Global Const $dtm_getmonthcal = $dtm_first + 8
- Global Const $dtm_setmcfont = $dtm_first + 9
- Global Const $dtm_getmcfont = $dtm_first + 10
- Global Const $dtm_setformatw = $dtm_first + 50
- Global Const $dtn_first = -740
- Global Const $dtn_first2 = -753
- Global Const $dtn_datetimechange = $dtn_first2 - 6
- Global Const $dtn_userstring = $dtn_first2 - 5
- Global Const $dtn_wmkeydown = $dtn_first2 - 4
- Global Const $dtn_format = $dtn_first2 - 3
- Global Const $dtn_formatquery = $dtn_first2 - 2
- Global Const $dtn_dropdown = $dtn_first2 - 1
- Global Const $dtn_closeup = $dtn_first2 + 0
- Global Const $dtn_userstringw = $dtn_first - 5
- Global Const $dtn_wmkeydownw = $dtn_first - 4
- Global Const $dtn_formatw = $dtn_first - 3
- Global Const $dtn_formatqueryw = $dtn_first - 2
- Global Const $gui_ss_default_date = $dts_longdateformat
- Global Const $gui_ss_default_monthcal = 0
- Global Const $linguistic_ignorecase = 16
- Global Const $linguistic_ignorediacritic = 32
- Global Const $norm_ignorecase = 1
- Global Const $norm_ignorekanatype = 65536
- Global Const $norm_ignorenonspace = 2
- Global Const $norm_ignoresymbols = 4
- Global Const $norm_ignorewidth = 131072
- Global Const $norm_linguistic_casing = 134217728
- Global Const $sort_digitsasnumbers = 8
- Global Const $sort_stringsort = 4096
- Global Const $cstr_less_than = 1
- Global Const $cstr_equal = 2
- Global Const $cstr_greater_than = 3
- Global Const $mui_language_id = 4
- Global Const $mui_language_name = 8
- Global Const $date_autolayout = 64
- Global Const $date_longdate = 2
- Global Const $date_ltrreading = 16
- Global Const $date_shortdate = 1
- Global Const $date_rtlreading = 32
- Global Const $date_use_alt_calendar = 4
- Global Const $date_yearmonth = 8
- Global Const $geo_nation = 1
- Global Const $geo_latitude = 2
- Global Const $geo_longitude = 3
- Global Const $geo_iso2 = 4
- Global Const $geo_iso3 = 5
- Global Const $geo_rfc1766 = 6
- Global Const $geo_lcid = 7
- Global Const $geo_friendlyname = 8
- Global Const $geo_officialname = 9
- Global Const $geo_timezones = 10
- Global Const $geo_officiallanguages = 11
- Global Const $geo_iso_un_number = 12
- Global Const $geo_parent = 13
- Global Const $locale_ilanguage = 1
- Global Const $locale_slanguage = 2
- Global Const $locale_senglanguage = 4097
- Global Const $locale_sabbrevlangname = 3
- Global Const $locale_snativelangname = 4
- Global Const $locale_icountry = 5
- Global Const $locale_scountry = 6
- Global Const $locale_sengcountry = 4098
- Global Const $locale_sabbrevctryname = 7
- Global Const $locale_snativectryname = 8
- Global Const $locale_idefaultlanguage = 9
- Global Const $locale_idefaultcountry = 10
- Global Const $locale_idefaultcodepage = 11
- Global Const $locale_idefaultansicodepage = 4100
- Global Const $locale_idefaultmaccodepage = 4113
- Global Const $locale_slist = 12
- Global Const $locale_imeasure = 13
- Global Const $locale_sdecimal = 14
- Global Const $locale_sthousand = 15
- Global Const $locale_sgrouping = 16
- Global Const $locale_idigits = 17
- Global Const $locale_ilzero = 18
- Global Const $locale_inegnumber = 4112
- Global Const $locale_snativedigits = 19
- Global Const $locale_scurrency = 20
- Global Const $locale_sintlsymbol = 21
- Global Const $locale_smondecimalsep = 22
- Global Const $locale_smonthousandsep = 23
- Global Const $locale_smongrouping = 24
- Global Const $locale_icurrdigits = 25
- Global Const $locale_iintlcurrdigits = 26
- Global Const $locale_icurrency = 27
- Global Const $locale_inegcurr = 28
- Global Const $locale_sdate = 29
- Global Const $locale_stime = 30
- Global Const $locale_sshortdate = 31
- Global Const $locale_slongdate = 32
- Global Const $locale_stimeformat = 4099
- Global Const $locale_idate = 33
- Global Const $locale_ildate = 34
- Global Const $locale_itime = 35
- Global Const $locale_itimemarkposn = 4101
- Global Const $locale_icentury = 36
- Global Const $locale_itlzero = 37
- Global Const $locale_idaylzero = 38
- Global Const $locale_imonlzero = 39
- Global Const $locale_s1159 = 40
- Global Const $locale_s2359 = 41
- Global Const $locale_icalendartype = 4105
- Global Const $locale_ioptionalcalendar = 4107
- Global Const $locale_ifirstdayofweek = 4108
- Global Const $locale_ifirstweekofyear = 4109
- Global Const $locale_sdayname1 = 42
- Global Const $locale_sdayname2 = 43
- Global Const $locale_sdayname3 = 44
- Global Const $locale_sdayname4 = 45
- Global Const $locale_sdayname5 = 46
- Global Const $locale_sdayname6 = 47
- Global Const $locale_sdayname7 = 48
- Global Const $locale_sabbrevdayname1 = 49
- Global Const $locale_sabbrevdayname2 = 50
- Global Const $locale_sabbrevdayname3 = 51
- Global Const $locale_sabbrevdayname4 = 52
- Global Const $locale_sabbrevdayname5 = 53
- Global Const $locale_sabbrevdayname6 = 54
- Global Const $locale_sabbrevdayname7 = 55
- Global Const $locale_smonthname1 = 56
- Global Const $locale_smonthname2 = 57
- Global Const $locale_smonthname3 = 58
- Global Const $locale_smonthname4 = 59
- Global Const $locale_smonthname5 = 60
- Global Const $locale_smonthname6 = 61
- Global Const $locale_smonthname7 = 62
- Global Const $locale_smonthname8 = 63
- Global Const $locale_smonthname9 = 64
- Global Const $locale_smonthname10 = 65
- Global Const $locale_smonthname11 = 66
- Global Const $locale_smonthname12 = 67
- Global Const $locale_smonthname13 = 4110
- Global Const $locale_sabbrevmonthname1 = 68
- Global Const $locale_sabbrevmonthname2 = 69
- Global Const $locale_sabbrevmonthname3 = 70
- Global Const $locale_sabbrevmonthname4 = 71
- Global Const $locale_sabbrevmonthname5 = 72
- Global Const $locale_sabbrevmonthname6 = 73
- Global Const $locale_sabbrevmonthname7 = 74
- Global Const $locale_sabbrevmonthname8 = 75
- Global Const $locale_sabbrevmonthname9 = 76
- Global Const $locale_sabbrevmonthname10 = 77
- Global Const $locale_sabbrevmonthname11 = 78
- Global Const $locale_sabbrevmonthname12 = 79
- Global Const $locale_sabbrevmonthname13 = 4111
- Global Const $locale_spositivesign = 80
- Global Const $locale_snegativesign = 81
- Global Const $locale_ipossignposn = 82
- Global Const $locale_inegsignposn = 83
- Global Const $locale_ipossymprecedes = 84
- Global Const $locale_ipossepbyspace = 85
- Global Const $locale_inegsymprecedes = 86
- Global Const $locale_inegsepbyspace = 87
- Global Const $locale_fontsignature = 88
- Global Const $locale_siso639langname = 89
- Global Const $locale_siso3166ctryname = 90
- Global Const $locale_idefaultebcdiccodepage = 4114
- Global Const $locale_ipapersize = 4106
- Global Const $locale_sengcurrname = 4103
- Global Const $locale_snativecurrname = 4104
- Global Const $locale_syearmonth = 4102
- Global Const $locale_ssortname = 4115
- Global Const $locale_idigitsubstitution = 4116
- Global Const $locale_custom_default = 3072
- Global Const $locale_custom_ui_default = 5120
- Global Const $locale_custom_unspecified = 4096
- Global Const $locale_invariant = 127
- Global Const $locale_system_default = 2048
- Global Const $locale_user_default = 1024
- Global Const $time_force24hourformat = 8
- Global Const $time_nominutesorseconds = 1
- Global Const $time_noseconds = 2
- Global Const $time_notimemarker = 4
- Global Const $lcid_installed = 1
- Global Const $lcid_supported = 2
- #Region Global Variables and Constants
- Global $__g_venum, $__g_vext = 0
- Global $__g_hheap = 0, $__g_irgbmode = 1
- Global Const $tagosversioninfo = "struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct"
- Global Const $__winver = __winver()
- #EndRegion Global Variables and Constants
- #Region Functions list
- #EndRegion Functions list
- #Region Public Functions
- Func _winapi_arraytostruct(Const ByRef $adata, $istart = 0, $iend = -1)
- If __checkerrorarraybounds($adata, $istart, $iend) Then Return SetError(@error + 10, @extended, 0)
- Local $tagstruct = ""
- For $i = $istart To $iend
- $tagstruct &= "wchar[" & (StringLen($adata[$i]) + 1) & "];"
- Next
- Local $tdata = DllStructCreate($tagstruct & "wchar[1]")
- Local $icount = 1
- For $i = $istart To $iend
- DllStructSetData($tdata, $icount, $adata[$i])
- $icount += 1
- Next
- DllStructSetData($tdata, $icount, ChrW(0))
- Return $tdata
- EndFunc
- Func _winapi_createmargins($ileftwidth, $irightwidth, $itopheight, $ibottomheight)
- Local $tmargins = DllStructCreate($tagmargins)
- DllStructSetData($tmargins, 1, $ileftwidth)
- DllStructSetData($tmargins, 2, $irightwidth)
- DllStructSetData($tmargins, 3, $itopheight)
- DllStructSetData($tmargins, 4, $ibottomheight)
- Return $tmargins
- EndFunc
- Func _winapi_createpoint($ix, $iy)
- Local $tpoint = DllStructCreate($tagpoint)
- DllStructSetData($tpoint, 1, $ix)
- DllStructSetData($tpoint, 2, $iy)
- Return $tpoint
- EndFunc
- Func _winapi_createrect($ileft, $itop, $iright, $ibottom)
- Local $trect = DllStructCreate($tagrect)
- DllStructSetData($trect, 1, $ileft)
- DllStructSetData($trect, 2, $itop)
- DllStructSetData($trect, 3, $iright)
- DllStructSetData($trect, 4, $ibottom)
- Return $trect
- EndFunc
- Func _winapi_createrectex($ix, $iy, $iwidth, $iheight)
- Local $trect = DllStructCreate($tagrect)
- DllStructSetData($trect, 1, $ix)
- DllStructSetData($trect, 2, $iy)
- DllStructSetData($trect, 3, $ix + $iwidth)
- DllStructSetData($trect, 4, $iy + $iheight)
- Return $trect
- EndFunc
- Func _winapi_createsize($iwidth, $iheight)
- Local $tsize = DllStructCreate($tagsize)
- DllStructSetData($tsize, 1, $iwidth)
- DllStructSetData($tsize, 2, $iheight)
- Return $tsize
- EndFunc
- Func _winapi_fatalexit($icode)
- DllCall("kernel32.dll", "none", "FatalExit", "int", $icode)
- If @error Then Return SetError(@error, @extended)
- EndFunc
- Func _winapi_getbitmapdimension($hbitmap)
- Local Const $tagbitmap = "struct;long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;endstruct"
- Local $tobj = DllStructCreate($tagbitmap)
- Local $aret = DllCall("gdi32.dll", "int", "GetObject", "handle", $hbitmap, "int", DllStructGetSize($tobj), "struct*", $tobj)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Return _winapi_createsize(DllStructGetData($tobj, "bmWidth"), DllStructGetData($tobj, "bmHeight"))
- EndFunc
- Func _winapi_getstring($pstring, $bunicode = True)
- Local $ilength = _winapi_strlen($pstring, $bunicode)
- If @error OR NOT $ilength Then Return SetError(@error + 10, @extended, "")
- Local $tstring = DllStructCreate(__iif($bunicode, "wchar", "char") & "[" & ($ilength + 1) & "]", $pstring)
- If @error Then Return SetError(@error, @extended, "")
- Return SetExtended($ilength, DllStructGetData($tstring, 1))
- EndFunc
- Func _winapi_isbadreadptr($paddress, $ilength)
- Local $aret = DllCall("kernel32.dll", "bool", "IsBadReadPtr", "struct*", $paddress, "uint_ptr", $ilength)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_isbadwriteptr($paddress, $ilength)
- Local $aret = DllCall("kernel32.dll", "bool", "IsBadWritePtr", "struct*", $paddress, "uint_ptr", $ilength)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_iswow64process($ipid = 0)
- If NOT $ipid Then $ipid = @AutoItPID
- Local $hprocess = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", __iif($__winver < 1536, 1024, 4096), "bool", 0, "dword", $ipid)
- If @error OR NOT $hprocess[0] Then Return SetError(@error + 20, @extended, False)
- Local $aret = DllCall("kernel32.dll", "bool", "IsWow64Process", "handle", $hprocess[0], "bool*", 0)
- If __checkerrorclosehandle($aret, $hprocess[0]) Then Return SetError(@error, @extended, False)
- Return $aret[2]
- EndFunc
- Func _winapi_movememory($pdestination, $psource, $ilength)
- If _winapi_isbadreadptr($psource, $ilength) Then Return SetError(10, @extended, 0)
- If _winapi_isbadwriteptr($pdestination, $ilength) Then Return SetError(11, @extended, 0)
- DllCall("ntdll.dll", "none", "RtlMoveMemory", "struct*", $pdestination, "struct*", $psource, "ulong_ptr", $ilength)
- If @error Then Return SetError(@error, @extended, 0)
- Return 1
- EndFunc
- Func _winapi_pathisdirectory($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsDirectoryW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_strlen($pstring, $bunicode = True)
- Local $w = ""
- If $bunicode Then $w = "W"
- Local $aret = DllCall("kernel32.dll", "int", "lstrlen" & $w, "struct*", $pstring)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_structtoarray(ByRef $tstruct, $iitems = 0)
- Local $isize = 2 * Floor(DllStructGetSize($tstruct) / 2)
- Local $pstruct = DllStructGetPtr($tstruct)
- If NOT $isize OR NOT $pstruct Then Return SetError(1, 0, 0)
- Local $tdata, $ilength, $ioffset = 0
- Local $aresult[101] = [0]
- While 1
- $ilength = _winapi_strlen($pstruct + $ioffset)
- If NOT $ilength Then
- ExitLoop
- EndIf
- If 2 * (1 + $ilength) + $ioffset > $isize Then Return SetError(3, 0, 0)
- $tdata = DllStructCreate("wchar[" & (1 + $ilength) & "]", $pstruct + $ioffset)
- If @error Then Return SetError(@error + 10, 0, 0)
- __inc($aresult)
- $aresult[$aresult[0]] = DllStructGetData($tdata, 1)
- If $aresult[0] = $iitems Then
- ExitLoop
- EndIf
- $ioffset += 2 * (1 + $ilength)
- If $ioffset >= $isize Then Return SetError(3, 0, 0)
- WEnd
- If NOT $aresult[0] Then Return SetError(2, 0, 0)
- __inc($aresult, -1)
- Return $aresult
- EndFunc
- Func _winapi_swapdword($ivalue)
- Local $tstruct1 = DllStructCreate("dword;dword")
- Local $tstruct2 = DllStructCreate("byte[4];byte[4]", DllStructGetPtr($tstruct1))
- DllStructSetData($tstruct1, 1, $ivalue)
- For $i = 1 To 4
- DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 5 - $i), $i)
- Next
- Return DllStructGetData($tstruct1, 2)
- EndFunc
- Func _winapi_swapqword($ivalue)
- Local $tstruct1 = DllStructCreate("int64;int64")
- Local $tstruct2 = DllStructCreate("byte[8];byte[8]", DllStructGetPtr($tstruct1))
- DllStructSetData($tstruct1, 1, $ivalue)
- For $i = 1 To 8
- DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 9 - $i), $i)
- Next
- Return DllStructGetData($tstruct1, 2)
- EndFunc
- Func _winapi_swapword($ivalue)
- Local $tstruct1 = DllStructCreate("word;word")
- Local $tstruct2 = DllStructCreate("byte[2];byte[2]", DllStructGetPtr($tstruct1))
- DllStructSetData($tstruct1, 1, $ivalue)
- For $i = 1 To 2
- DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 3 - $i), $i)
- Next
- Return DllStructGetData($tstruct1, 2)
- EndFunc
- Func _winapi_switchcolor($icolor)
- If $icolor = -1 Then Return $icolor
- Return BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
- EndFunc
- Func _winapi_zeromemory($pmemory, $ilength)
- If _winapi_isbadwriteptr($pmemory, $ilength) Then Return SetError(11, @extended, 0)
- DllCall("ntdll.dll", "none", "RtlZeroMemory", "struct*", $pmemory, "ulong_ptr", $ilength)
- If @error Then Return SetError(@error, @extended, 0)
- Return 1
- EndFunc
- #EndRegion Public Functions
- #Region Internal Functions
- Func __checkerrorarraybounds(Const ByRef $adata, ByRef $istart, ByRef $iend, $ndim = 1, $idim = $ubound_dimensions)
- If NOT IsArray($adata) Then Return SetError(1, 0, 1)
- If UBound($adata, $idim) <> $ndim Then Return SetError(2, 0, 1)
- If $istart < 0 Then $istart = 0
- Local $iubound = UBound($adata) - 1
- If $iend < 1 OR $iend > $iubound Then $iend = $iubound
- If $istart > $iend Then Return SetError(4, 0, 1)
- Return 0
- EndFunc
- Func __checkerrorclosehandle($aret, $hfile, $blasterror = 0, $icurerr = @error, $icurext = @extended)
- If NOT $icurerr AND NOT $aret[0] Then $icurerr = 10
- Local $ilasterror = _winapi_getlasterror()
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
- If $icurerr Then _winapi_setlasterror($ilasterror)
- If $blasterror Then $icurext = $ilasterror
- Return SetError($icurerr, $icurext, $icurerr)
- EndFunc
- Func __dll($spath, $bpin = False)
- Local $aret = DllCall("kernel32.dll", "bool", "GetModuleHandleExW", "dword", __iif($bpin, 1, 2), "wstr", $spath, "ptr*", 0)
- If NOT $aret[3] Then
- Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $spath)
- If NOT $aresult[0] Then Return 0
- EndIf
- Return 1
- EndFunc
- Func __enumwindowsproc($hwnd, $bvisible)
- Local $aresult
- If $bvisible Then
- $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
- If NOT $aresult[0] Then
- Return 1
- EndIf
- EndIf
- __inc($__g_venum)
- $__g_venum[$__g_venum[0][0]][0] = $hwnd
- $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
- $__g_venum[$__g_venum[0][0]][1] = $aresult[2]
- Return 1
- EndFunc
- Func __fatalexit($icode, $stext = "")
- If $stext Then MsgBox($mb_systemmodal, "AutoIt", $stext)
- _winapi_fatalexit($icode)
- EndFunc
- Func __heapalloc($isize, $babort = False)
- Local $aret
- If NOT $__g_hheap Then
- $aret = DllCall("kernel32.dll", "handle", "HeapCreate", "dword", 0, "ulong_ptr", 0, "ulong_ptr", 0)
- If @error OR NOT $aret[0] Then __fatalexit(1, "Error allocating memory.")
- $__g_hheap = $aret[0]
- EndIf
- $aret = DllCall("kernel32.dll", "ptr", "HeapAlloc", "handle", $__g_hheap, "dword", 8, "ulong_ptr", $isize)
- If @error OR NOT $aret[0] Then
- If $babort Then __fatalexit(1, "Error allocating memory.")
- Return SetError(@error + 30, @extended, 0)
- EndIf
- Return $aret[0]
- EndFunc
- Func __heapfree(ByRef $pmemory, $bcheck = False, $icurerr = @error, $icurext = @extended)
- If $bcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
- Local $aret = DllCall("kernel32.dll", "int", "HeapFree", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
- If @error OR NOT $aret[0] Then Return SetError(@error + 40, @extended, 0)
- $pmemory = 0
- Return SetError($icurerr, $icurext, 1)
- EndFunc
- Func __heaprealloc($pmemory, $isize, $bamount = False, $babort = False)
- Local $aret, $pret
- If __heapvalidate($pmemory) Then
- If $bamount AND (__heapsize($pmemory) >= $isize) Then Return SetExtended(1, Ptr($pmemory))
- $aret = DllCall("kernel32.dll", "ptr", "HeapReAlloc", "handle", $__g_hheap, "dword", 8, "ptr", $pmemory, "ulong_ptr", $isize)
- If @error OR NOT $aret[0] Then
- If $babort Then __fatalexit(1, "Error allocating memory.")
- Return SetError(@error + 20, @extended, Ptr($pmemory))
- EndIf
- $pret = $aret[0]
- Else
- $pret = __heapalloc($isize, $babort)
- If @error Then Return SetError(@error, @extended, 0)
- EndIf
- Return $pret
- EndFunc
- Func __heapsize($pmemory, $bcheck = False)
- If $bcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
- Local $aret = DllCall("kernel32.dll", "ulong_ptr", "HeapSize", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
- If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@error + 50, @extended, 0)
- Return $aret[0]
- EndFunc
- Func __heapvalidate($pmemory)
- If (NOT $__g_hheap) OR (NOT Ptr($pmemory)) Then Return SetError(9, 0, False)
- Local $aret = DllCall("kernel32.dll", "int", "HeapValidate", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func __inc(ByRef $adata, $iincrement = 100)
- Select
- Case UBound($adata, $ubound_columns)
- If $iincrement < 0 Then
- ReDim $adata[$adata[0][0] + 1][UBound($adata, $ubound_columns)]
- Else
- $adata[0][0] += 1
- If $adata[0][0] > UBound($adata) - 1 Then
- ReDim $adata[$adata[0][0] + $iincrement][UBound($adata, $ubound_columns)]
- EndIf
- EndIf
- Case UBound($adata, $ubound_rows)
- If $iincrement < 0 Then
- ReDim $adata[$adata[0] + 1]
- Else
- $adata[0] += 1
- If $adata[0] > UBound($adata) - 1 Then
- ReDim $adata[$adata[0] + $iincrement]
- EndIf
- EndIf
- Case Else
- Return 0
- EndSelect
- Return 1
- EndFunc
- Func __iif($btest, $vtrue, $vfalse)
- Return $btest ? $vtrue : $vfalse
- EndFunc
- Func __init($ddata)
- Local $ilength = BinaryLen($ddata)
- Local $aret = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", $ilength, "dword", 4096, "dword", 64)
- If @error OR NOT $aret[0] Then __fatalexit(1, "Error allocating memory.")
- Local $tdata = DllStructCreate("byte[" & $ilength & "]", $aret[0])
- DllStructSetData($tdata, 1, $ddata)
- Return $aret[0]
- EndFunc
- Func __rgb($icolor)
- If $__g_irgbmode Then
- $icolor = _winapi_switchcolor($icolor)
- EndIf
- Return $icolor
- EndFunc
- Func __winver()
- Local $tosvi = DllStructCreate($tagosversioninfo)
- DllStructSetData($tosvi, 1, DllStructGetSize($tosvi))
- Local $aret = DllCall("kernel32.dll", "bool", "GetVersionExW", "struct*", $tosvi)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
- Return BitOR(BitShift(DllStructGetData($tosvi, 2), -8), DllStructGetData($tosvi, 3))
- EndFunc
- #EndRegion Internal Functions
- #Region Global Variables and Constants
- Global Const $tagnumberfmt = "uint NumDigits;uint LeadingZero;uint Grouping;ptr DecimalSep;ptr ThousandSep;uint NegativeOrder"
- #EndRegion Global Variables and Constants
- #Region Functions list
- #EndRegion Functions list
- #Region Public Functions
- Func _winapi_comparestring($ilcid, $sstring1, $sstring2, $iflags = 0)
- Local $aret = DllCall("kernel32.dll", "int", "CompareStringW", "dword", $ilcid, "dword", $iflags, "wstr", $sstring1, "int", -1, "wstr", $sstring2, "int", -1)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_createnumberformatinfo($inumdigits, $ileadingzero, $igrouping, $sdecimalsep, $sthousandsep, $inegativeorder)
- Local $tfmt = DllStructCreate($tagnumberfmt & ";wchar[" & (StringLen($sdecimalsep) + 1) & "];wchar[" & (StringLen($sthousandsep) + 1) & "]")
- DllStructSetData($tfmt, 1, $inumdigits)
- DllStructSetData($tfmt, 2, $ileadingzero)
- DllStructSetData($tfmt, 3, $igrouping)
- DllStructSetData($tfmt, 4, DllStructGetPtr($tfmt, 7))
- DllStructSetData($tfmt, 5, DllStructGetPtr($tfmt, 8))
- DllStructSetData($tfmt, 6, $inegativeorder)
- DllStructSetData($tfmt, 7, $sdecimalsep)
- DllStructSetData($tfmt, 8, $sthousandsep)
- Return $tfmt
- EndFunc
- Func _winapi_enumsystemgeoid()
- Local $henumproc = DllCallbackRegister("__EnumGeoIDProc", "bool", "long")
- Dim $__g_venum[101] = [0]
- Local $aret = DllCall("kernel32.dll", "bool", "EnumSystemGeoID", "dword", 16, "long", 0, "ptr", DllCallbackGetPtr($henumproc))
- If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
- $__g_venum = @error + 10
- EndIf
- DllCallbackFree($henumproc)
- If $__g_venum Then Return SetError($__g_venum, 0, 0)
- __inc($__g_venum, -1)
- Return $__g_venum
- EndFunc
- Func _winapi_enumsystemlocales($iflag)
- Local $henumproc = DllCallbackRegister("__EnumLocalesProc", "bool", "ptr")
- Dim $__g_venum[101] = [0]
- Local $aret = DllCall("kernel32.dll", "bool", "EnumSystemLocalesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag)
- If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
- $__g_venum = @error + 10
- EndIf
- DllCallbackFree($henumproc)
- If $__g_venum Then Return SetError($__g_venum, 0, 0)
- __inc($__g_venum, -1)
- Return $__g_venum
- EndFunc
- Func _winapi_enumuilanguages($iflag = 0)
- Local $henumproc = DllCallbackRegister("__EnumUILanguagesProc", "bool", "ptr;long_ptr")
- Local $iid = 1
- If $__winver >= 1536 Then
- If BitAND($iflag, 8) Then
- $iid = 0
- EndIf
- Else
- $iflag = 0
- EndIf
- Dim $__g_venum[101] = [0]
- Local $aret = DllCall("kernel32.dll", "bool", "EnumUILanguagesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag, "long_ptr", $iid)
- If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
- $__g_venum = @error + 10
- EndIf
- DllCallbackFree($henumproc)
- If $__g_venum Then Return SetError($__g_venum, 0, 0)
- __inc($__g_venum, -1)
- Return $__g_venum
- EndFunc
- Func _winapi_getdateformat($ilcid = 0, $tsystemtime = 0, $iflags = 0, $sformat = "")
- If NOT $ilcid Then $ilcid = 1024
- Local $stypeofformat = "wstr"
- If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
- $stypeofformat = "ptr"
- $sformat = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "int", "GetDateFormatW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofformat, $sformat, "wstr", "", "int", 2048)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[5]
- EndFunc
- Func _winapi_getdurationformat($ilcid, $iduration, $sformat = "")
- If NOT $ilcid Then $ilcid = 1024
- Local $pst, $ival
- If IsDllStruct($iduration) Then
- $pst = DllStructGetPtr($iduration)
- $ival = 0
- Else
- $pst = 0
- $ival = $iduration
- EndIf
- Local $stypeofformat = "wstr"
- If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
- $stypeofformat = "ptr"
- $sformat = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "int", "GetDurationFormat", "dword", $ilcid, "dword", 0, "ptr", $pst, "uint64", $ival, $stypeofformat, $sformat, "wstr", "", "int", 2048)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[6]
- EndFunc
- Func _winapi_getgeoinfo($igeoid, $itype, $ilanguage = 0)
- Local $aret = DllCall("kernel32.dll", "int", "GetGeoInfoW", "long", $igeoid, "dword", $itype, "wstr", "", "int", 4096, "word", $ilanguage)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
- Return $aret[3]
- EndFunc
- Func _winapi_getlocaleinfo($ilcid, $itype)
- Local $aret = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", $ilcid, "dword", $itype, "wstr", "", "int", 2048)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[3]
- EndFunc
- Func _winapi_getnumberformat($ilcid, $snumber, $tnumberfmt = 0)
- If NOT $ilcid Then $ilcid = 1024
- Local $aret = DllCall("kernel32.dll", "int", "GetNumberFormatW", "dword", $ilcid, "dword", 0, "wstr", $snumber, "struct*", $tnumberfmt, "wstr", "", "int", 2048)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[5]
- EndFunc
- Func _winapi_getsystemdefaultlangid()
- Local $aret = DllCall("kernel32.dll", "word", "GetSystemDefaultLangID")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getsystemdefaultlcid()
- Local $aret = DllCall("kernel32.dll", "dword", "GetSystemDefaultLCID")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getsystemdefaultuilanguage()
- Local $aret = DllCall("kernel32.dll", "word", "GetSystemDefaultUILanguage")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getthreadlocale()
- Local $aret = DllCall("kernel32.dll", "dword", "GetThreadLocale")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getthreaduilanguage()
- Local $aret = DllCall("kernel32.dll", "word", "GetThreadUILanguage")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_gettimeformat($ilcid = 0, $tsystemtime = 0, $iflags = 0, $sformat = "")
- If NOT $ilcid Then $ilcid = 1024
- Local $stypeofformat = "wstr"
- If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
- $stypeofformat = "ptr"
- $sformat = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "int", "GetTimeFormatW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofformat, $sformat, "wstr", "", "int", 2048)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[5]
- EndFunc
- Func _winapi_getuserdefaultlangid()
- Local $aret = DllCall("kernel32.dll", "word", "GetUserDefaultLangID")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getuserdefaultlcid()
- Local $aret = DllCall("kernel32.dll", "dword", "GetUserDefaultLCID")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getuserdefaultuilanguage()
- Local $aret = DllCall("kernel32.dll", "word", "GetUserDefaultUILanguage")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getusergeoid()
- Local $aret = DllCall("kernel32.dll", "long", "GetUserGeoID", "uint", 16)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aret[0]
- EndFunc
- Func _winapi_isvalidlocale($ilcid, $iflag = 0)
- Local $aret = DllCall("kernel32.dll", "bool", "IsValidLocale", "dword", $ilcid, "dword", $iflag)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_setlocaleinfo($ilcid, $itype, $sdata)
- Local $aret = DllCall("kernel32.dll", "bool", "SetLocaleInfoW", "dword", $ilcid, "dword", $itype, "wstr", $sdata)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_setthreadlocale($ilcid)
- Local $aret = DllCall("kernel32.dll", "bool", "SetThreadLocale", "dword", $ilcid)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_setthreaduilanguage($ilanguage)
- Local $aret = DllCall("kernel32.dll", "word", "SetThreadUILanguage", "word", $ilanguage)
- If @error Then Return SetError(@error, @extended, False)
- Return ($aret[0] = $aret[1])
- EndFunc
- Func _winapi_setusergeoid($igeoid)
- Local $aret = DllCall("kernel32.dll", "bool", "SetUserGeoID", "long", $igeoid)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- #EndRegion Public Functions
- #Region Internal Functions
- Func __enumgeoidproc($iid)
- __inc($__g_venum)
- $__g_venum[$__g_venum[0]] = $iid
- Return 1
- EndFunc
- Func __enumlocalesproc($plocale)
- __inc($__g_venum)
- $__g_venum[$__g_venum[0]] = Dec(DllStructGetData(DllStructCreate("wchar[" & (_winapi_strlen($plocale) + 1) & "]", $plocale), 1))
- Return 1
- EndFunc
- Func __enumuilanguagesproc($planguage, $iid)
- __inc($__g_venum)
- $__g_venum[$__g_venum[0]] = DllStructGetData(DllStructCreate("wchar[" & (_winapi_strlen($planguage) + 1) & "]", $planguage), 1)
- If $iid Then
- $__g_venum[$__g_venum[0]] = Dec($__g_venum[$__g_venum[0]])
- EndIf
- Return 1
- EndFunc
- #EndRegion Internal Functions
- Func _dateadd($stype, $inumber, $sdate)
- Local $astimepart[4]
- Local $asdatepart[4]
- Local $ijuliandate
- $stype = StringLeft($stype, 1)
- If StringInStr("D,M,Y,w,h,n,s", $stype) = 0 OR $stype = "" Then
- Return SetError(1, 0, 0)
- EndIf
- If NOT StringIsInt($inumber) Then
- Return SetError(2, 0, 0)
- EndIf
- If NOT _dateisvalid($sdate) Then
- Return SetError(3, 0, 0)
- EndIf
- _datetimesplit($sdate, $asdatepart, $astimepart)
- If $stype = "d" OR $stype = "w" Then
- If $stype = "w" Then $inumber = $inumber * 7
- $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $inumber
- _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
- EndIf
- If $stype = "m" Then
- $asdatepart[2] = $asdatepart[2] + $inumber
- While $asdatepart[2] > 12
- $asdatepart[2] = $asdatepart[2] - 12
- $asdatepart[1] = $asdatepart[1] + 1
- WEnd
- While $asdatepart[2] < 1
- $asdatepart[2] = $asdatepart[2] + 12
- $asdatepart[1] = $asdatepart[1] - 1
- WEnd
- EndIf
- If $stype = "y" Then
- $asdatepart[1] = $asdatepart[1] + $inumber
- EndIf
- If $stype = "h" OR $stype = "n" OR $stype = "s" Then
- Local $itimeval = _timetoticks($astimepart[1], $astimepart[2], $astimepart[3]) / 1000
- If $stype = "h" Then $itimeval = $itimeval + $inumber * 3600
- If $stype = "n" Then $itimeval = $itimeval + $inumber * 60
- If $stype = "s" Then $itimeval = $itimeval + $inumber
- Local $iday2add = Int($itimeval / (24 * 60 * 60))
- $itimeval = $itimeval - $iday2add * 24 * 60 * 60
- If $itimeval < 0 Then
- $iday2add = $iday2add - 1
- $itimeval = $itimeval + 24 * 60 * 60
- EndIf
- $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $iday2add
- _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
- _tickstotime($itimeval * 1000, $astimepart[1], $astimepart[2], $astimepart[3])
- EndIf
- Local $inumdays = _daysinmonth($asdatepart[1])
- If $inumdays[$asdatepart[2]] < $asdatepart[3] Then $asdatepart[3] = $inumdays[$asdatepart[2]]
- $sdate = $asdatepart[1] & "/" & StringRight("0" & $asdatepart[2], 2) & "/" & StringRight("0" & $asdatepart[3], 2)
- If $astimepart[0] > 0 Then
- If $astimepart[0] > 2 Then
- $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2) & ":" & StringRight("0" & $astimepart[3], 2)
- Else
- $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2)
- EndIf
- EndIf
- Return $sdate
- EndFunc
- Func _datedayofweek($idaynum, $iformat = Default)
- Local Const $monday_is_no1 = 128
- If $iformat = Default Then $iformat = 0
- $idaynum = Int($idaynum)
- If $idaynum < 1 OR $idaynum > 7 Then Return SetError(1, 0, "")
- Local $tsystemtime = DllStructCreate($tagsystemtime)
- DllStructSetData($tsystemtime, "Year", BitAND($iformat, $monday_is_no1) ? 2007 : 2006)
- DllStructSetData($tsystemtime, "Month", 1)
- DllStructSetData($tsystemtime, "Day", $idaynum)
- Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longname) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat, $dmw_shortname) ? "ddd" : "dddd")
- EndFunc
- Func _datedaysinmonth($iyear, $imonthnum)
- $imonthnum = Int($imonthnum)
- $iyear = Int($iyear)
- Return __dateismonth($imonthnum) AND __dateisyear($iyear) ? _daysinmonth($iyear)[$imonthnum] : SetError(1, 0, 0)
- EndFunc
- Func _datediff($stype, $sstartdate, $senddate)
- $stype = StringLeft($stype, 1)
- If StringInStr("d,m,y,w,h,n,s", $stype) = 0 OR $stype = "" Then
- Return SetError(1, 0, 0)
- EndIf
- If NOT _dateisvalid($sstartdate) Then
- Return SetError(2, 0, 0)
- EndIf
- If NOT _dateisvalid($senddate) Then
- Return SetError(3, 0, 0)
- EndIf
- Local $asstartdatepart[4], $asstarttimepart[4], $asenddatepart[4], $asendtimepart[4]
- _datetimesplit($sstartdate, $asstartdatepart, $asstarttimepart)
- _datetimesplit($senddate, $asenddatepart, $asendtimepart)
- Local $adaysdiff = _datetodayvalue($asenddatepart[1], $asenddatepart[2], $asenddatepart[3]) - _datetodayvalue($asstartdatepart[1], $asstartdatepart[2], $asstartdatepart[3])
- Local $itimediff, $iyeardiff, $istarttimeinsecs, $iendtimeinsecs
- If $asstarttimepart[0] > 1 AND $asendtimepart[0] > 1 Then
- $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
- $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
- $itimediff = $iendtimeinsecs - $istarttimeinsecs
- If $itimediff < 0 Then
- $adaysdiff = $adaysdiff - 1
- $itimediff = $itimediff + 24 * 60 * 60
- EndIf
- Else
- $itimediff = 0
- EndIf
- Select
- Case $stype = "d"
- Return $adaysdiff
- Case $stype = "m"
- $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
- Local $imonthdiff = $asenddatepart[2] - $asstartdatepart[2] + $iyeardiff * 12
- If $asenddatepart[3] < $asstartdatepart[3] Then $imonthdiff = $imonthdiff - 1
- $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
- $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
- $itimediff = $iendtimeinsecs - $istarttimeinsecs
- If $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $imonthdiff = $imonthdiff - 1
- Return $imonthdiff
- Case $stype = "y"
- $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
- If $asenddatepart[2] < $asstartdatepart[2] Then $iyeardiff = $iyeardiff - 1
- If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] < $asstartdatepart[3] Then $iyeardiff = $iyeardiff - 1
- $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
- $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
- $itimediff = $iendtimeinsecs - $istarttimeinsecs
- If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $iyeardiff = $iyeardiff - 1
- Return $iyeardiff
- Case $stype = "w"
- Return Int($adaysdiff / 7)
- Case $stype = "h"
- Return $adaysdiff * 24 + Int($itimediff / 3600)
- Case $stype = "n"
- Return $adaysdiff * 24 * 60 + Int($itimediff / 60)
- Case $stype = "s"
- Return $adaysdiff * 24 * 60 * 60 + $itimediff
- EndSelect
- EndFunc
- Func _dateisleapyear($iyear)
- If StringIsInt($iyear) Then
- Select
- Case Mod($iyear, 4) = 0 AND Mod($iyear, 100) <> 0
- Return 1
- Case Mod($iyear, 400) = 0
- Return 1
- Case Else
- Return 0
- EndSelect
- EndIf
- Return SetError(1, 0, 0)
- EndFunc
- Func __dateismonth($inumber)
- $inumber = Int($inumber)
- Return $inumber >= 1 AND $inumber <= 12
- EndFunc
- Func _dateisvalid($sdate)
- Local $asdatepart[4], $astimepart[4]
- _datetimesplit($sdate, $asdatepart, $astimepart)
- If NOT StringIsInt($asdatepart[1]) Then Return 0
- If NOT StringIsInt($asdatepart[2]) Then Return 0
- If NOT StringIsInt($asdatepart[3]) Then Return 0
- $asdatepart[1] = Int($asdatepart[1])
- $asdatepart[2] = Int($asdatepart[2])
- $asdatepart[3] = Int($asdatepart[3])
- Local $inumdays = _daysinmonth($asdatepart[1])
- If $asdatepart[1] < 1000 OR $asdatepart[1] > 2999 Then Return 0
- If $asdatepart[2] < 1 OR $asdatepart[2] > 12 Then Return 0
- If $asdatepart[3] < 1 OR $asdatepart[3] > $inumdays[$asdatepart[2]] Then Return 0
- If $astimepart[0] < 1 Then Return 1
- If $astimepart[0] < 2 Then Return 0
- If $astimepart[0] = 2 Then $astimepart[3] = "00"
- If NOT StringIsInt($astimepart[1]) Then Return 0
- If NOT StringIsInt($astimepart[2]) Then Return 0
- If NOT StringIsInt($astimepart[3]) Then Return 0
- $astimepart[1] = Int($astimepart[1])
- $astimepart[2] = Int($astimepart[2])
- $astimepart[3] = Int($astimepart[3])
- If $astimepart[1] < 0 OR $astimepart[1] > 23 Then Return 0
- If $astimepart[2] < 0 OR $astimepart[2] > 59 Then Return 0
- If $astimepart[3] < 0 OR $astimepart[3] > 59 Then Return 0
- Return 1
- EndFunc
- Func __dateisyear($inumber)
- Return StringLen($inumber) = 4
- EndFunc
- Func _datelastweekdaynum($iweekdaynum)
- Select
- Case NOT StringIsInt($iweekdaynum)
- Return SetError(1, 0, 0)
- Case $iweekdaynum < 1 OR $iweekdaynum > 7
- Return SetError(2, 0, 0)
- Case Else
- Local $ilastweekdaynum
- If $iweekdaynum = 1 Then
- $ilastweekdaynum = 7
- Else
- $ilastweekdaynum = $iweekdaynum - 1
- EndIf
- Return $ilastweekdaynum
- EndSelect
- EndFunc
- Func _datelastmonthnum($imonthnum)
- Select
- Case NOT StringIsInt($imonthnum)
- Return SetError(1, 0, 0)
- Case NOT __dateismonth($imonthnum)
- Return SetError(2, 0, 0)
- Case Else
- Local $ilastmonthnum
- If $imonthnum = 1 Then
- $ilastmonthnum = 12
- Else
- $ilastmonthnum = $imonthnum - 1
- EndIf
- $ilastmonthnum = StringFormat("%02d", $ilastmonthnum)
- Return $ilastmonthnum
- EndSelect
- EndFunc
- Func _datelastmonthyear($imonthnum, $iyear)
- Select
- Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
- Return SetError(1, 0, 0)
- Case NOT __dateismonth($imonthnum)
- Return SetError(2, 0, 0)
- Case Else
- Local $ilastyear
- If $imonthnum = 1 Then
- $ilastyear = $iyear - 1
- Else
- $ilastyear = $iyear
- EndIf
- $ilastyear = StringFormat("%04d", $ilastyear)
- Return $ilastyear
- EndSelect
- EndFunc
- Func _datenextweekdaynum($iweekdaynum)
- Select
- Case NOT StringIsInt($iweekdaynum)
- Return SetError(1, 0, 0)
- Case $iweekdaynum < 1 OR $iweekdaynum > 7
- Return SetError(2, 0, 0)
- Case Else
- Local $inextweekdaynum
- If $iweekdaynum = 7 Then
- $inextweekdaynum = 1
- Else
- $inextweekdaynum = $iweekdaynum + 1
- EndIf
- Return $inextweekdaynum
- EndSelect
- EndFunc
- Func _datenextmonthnum($imonthnum)
- Select
- Case NOT StringIsInt($imonthnum)
- Return SetError(1, 0, 0)
- Case NOT __dateismonth($imonthnum)
- Return SetError(2, 0, 0)
- Case Else
- Local $inextmonthnum
- If $imonthnum = 12 Then
- $inextmonthnum = 1
- Else
- $inextmonthnum = $imonthnum + 1
- EndIf
- $inextmonthnum = StringFormat("%02d", $inextmonthnum)
- Return $inextmonthnum
- EndSelect
- EndFunc
- Func _datenextmonthyear($imonthnum, $iyear)
- Select
- Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
- Return SetError(1, 0, 0)
- Case NOT __dateismonth($imonthnum)
- Return SetError(2, 0, 0)
- Case Else
- Local $inextyear
- If $imonthnum = 12 Then
- $inextyear = $iyear + 1
- Else
- $inextyear = $iyear
- EndIf
- $inextyear = StringFormat("%04d", $inextyear)
- Return $inextyear
- EndSelect
- EndFunc
- Func _datetimeformat($sdate, $stype)
- Local $asdatepart[4], $astimepart[4]
- Local $stempdate = "", $stemptime = ""
- Local $sam, $spm, $stempstring = ""
- If NOT _dateisvalid($sdate) Then
- Return SetError(1, 0, "")
- EndIf
- If $stype < 0 OR $stype > 5 OR NOT IsInt($stype) Then
- Return SetError(2, 0, "")
- EndIf
- _datetimesplit($sdate, $asdatepart, $astimepart)
- Switch $stype
- Case 0
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sshortdate)
- If NOT @error AND NOT ($stempstring = "") Then
- $stempdate = $stempstring
- Else
- $stempdate = "M/d/yyyy"
- EndIf
- If $astimepart[0] > 1 Then
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stimeformat)
- If NOT @error AND NOT ($stempstring = "") Then
- $stemptime = $stempstring
- Else
- $stemptime = "h:mm:ss tt"
- EndIf
- EndIf
- Case 1
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_slongdate)
- If NOT @error AND NOT ($stempstring = "") Then
- $stempdate = $stempstring
- Else
- $stempdate = "dddd, MMMM dd, yyyy"
- EndIf
- Case 2
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sshortdate)
- If NOT @error AND NOT ($stempstring = "") Then
- $stempdate = $stempstring
- Else
- $stempdate = "M/d/yyyy"
- EndIf
- Case 3
- If $astimepart[0] > 1 Then
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stimeformat)
- If NOT @error AND NOT ($stempstring = "") Then
- $stemptime = $stempstring
- Else
- $stemptime = "h:mm:ss tt"
- EndIf
- EndIf
- Case 4
- If $astimepart[0] > 1 Then
- $stemptime = "hh:mm"
- EndIf
- Case 5
- If $astimepart[0] > 1 Then
- $stemptime = "hh:mm:ss"
- EndIf
- EndSwitch
- If $stempdate <> "" Then
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sdate)
- If NOT @error AND NOT ($stempstring = "") Then
- $stempdate = StringReplace($stempdate, "/", $stempstring)
- EndIf
- Local $iwday = _datetodayofweek($asdatepart[1], $asdatepart[2], $asdatepart[3])
- $asdatepart[3] = StringRight("0" & $asdatepart[3], 2)
- $asdatepart[2] = StringRight("0" & $asdatepart[2], 2)
- $stempdate = StringReplace($stempdate, "d", "@")
- $stempdate = StringReplace($stempdate, "m", "#")
- $stempdate = StringReplace($stempdate, "y", "&")
- $stempdate = StringReplace($stempdate, "@@@@", _datedayofweek($iwday, 0))
- $stempdate = StringReplace($stempdate, "@@@", _datedayofweek($iwday, 1))
- $stempdate = StringReplace($stempdate, "@@", $asdatepart[3])
- $stempdate = StringReplace($stempdate, "@", StringReplace(StringLeft($asdatepart[3], 1), "0", "") & StringRight($asdatepart[3], 1))
- $stempdate = StringReplace($stempdate, "####", _datetomonth($asdatepart[2], 0))
- $stempdate = StringReplace($stempdate, "###", _datetomonth($asdatepart[2], 1))
- $stempdate = StringReplace($stempdate, "##", $asdatepart[2])
- $stempdate = StringReplace($stempdate, "#", StringReplace(StringLeft($asdatepart[2], 1), "0", "") & StringRight($asdatepart[2], 1))
- $stempdate = StringReplace($stempdate, "&&&&", $asdatepart[1])
- $stempdate = StringReplace($stempdate, "&&", StringRight($asdatepart[1], 2))
- EndIf
- If $stemptime <> "" Then
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_s1159)
- If NOT @error AND NOT ($stempstring = "") Then
- $sam = $stempstring
- Else
- $sam = "AM"
- EndIf
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_s2359)
- If NOT @error AND NOT ($stempstring = "") Then
- $spm = $stempstring
- Else
- $spm = "PM"
- EndIf
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stime)
- If NOT @error AND NOT ($stempstring = "") Then
- $stemptime = StringReplace($stemptime, ":", $stempstring)
- EndIf
- If StringInStr($stemptime, "tt") Then
- If $astimepart[1] < 12 Then
- $stemptime = StringReplace($stemptime, "tt", $sam)
- If $astimepart[1] = 0 Then $astimepart[1] = 12
- Else
- $stemptime = StringReplace($stemptime, "tt", $spm)
- If $astimepart[1] > 12 Then $astimepart[1] = $astimepart[1] - 12
- EndIf
- EndIf
- $astimepart[1] = StringRight("0" & $astimepart[1], 2)
- $astimepart[2] = StringRight("0" & $astimepart[2], 2)
- $astimepart[3] = StringRight("0" & $astimepart[3], 2)
- $stemptime = StringReplace($stemptime, "hh", StringFormat("%02d", $astimepart[1]))
- $stemptime = StringReplace($stemptime, "h", StringReplace(StringLeft($astimepart[1], 1), "0", "") & StringRight($astimepart[1], 1))
- $stemptime = StringReplace($stemptime, "mm", StringFormat("%02d", $astimepart[2]))
- $stemptime = StringReplace($stemptime, "ss", StringFormat("%02d", $astimepart[3]))
- $stempdate = StringStripWS($stempdate & " " & $stemptime, $str_stripleading + $str_striptrailing)
- EndIf
- Return $stempdate
- EndFunc
- Func _datetimesplit($sdate, ByRef $adatepart, ByRef $itimepart)
- Local $sdatetime = StringSplit($sdate, " T")
- If $sdatetime[0] > 0 Then $adatepart = StringSplit($sdatetime[1], "/-.")
- If $sdatetime[0] > 1 Then
- $itimepart = StringSplit($sdatetime[2], ":")
- If UBound($itimepart) < 4 Then ReDim $itimepart[4]
- Else
- Dim $itimepart[4]
- EndIf
- If UBound($adatepart) < 4 Then ReDim $adatepart[4]
- For $x = 1 To 3
- If StringIsInt($adatepart[$x]) Then
- $adatepart[$x] = Int($adatepart[$x])
- Else
- $adatepart[$x] = -1
- EndIf
- If StringIsInt($itimepart[$x]) Then
- $itimepart[$x] = Int($itimepart[$x])
- Else
- $itimepart[$x] = 0
- EndIf
- Next
- Return 1
- EndFunc
- Func _datetodayofweek($iyear, $imonth, $iday)
- If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then
- Return SetError(1, 0, "")
- EndIf
- Local $i_factora = Int((14 - $imonth) / 12)
- Local $i_factory = $iyear - $i_factora
- Local $i_factorm = $imonth + (12 * $i_factora) - 2
- 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)
- Return $i_factord + 1
- EndFunc
- Func _datetodayofweekiso($iyear, $imonth, $iday)
- Local $idow = _datetodayofweek($iyear, $imonth, $iday)
- If @error Then
- Return SetError(1, 0, "")
- EndIf
- If $idow >= 2 Then Return $idow - 1
- Return 7
- EndFunc
- Func _datetodayvalue($iyear, $imonth, $iday)
- If NOT _dateisvalid(StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)) Then
- Return SetError(1, 0, "")
- EndIf
- If $imonth < 3 Then
- $imonth = $imonth + 12
- $iyear = $iyear - 1
- EndIf
- Local $i_factora = Int($iyear / 100)
- Local $i_factorb = Int($i_factora / 4)
- Local $i_factorc = 2 - $i_factora + $i_factorb
- Local $i_factore = Int(1461 * ($iyear + 4716) / 4)
- Local $i_factorf = Int(153 * ($imonth + 1) / 5)
- Local $ijuliandate = $i_factorc + $iday + $i_factore + $i_factorf - 1524.5
- Return $ijuliandate
- EndFunc
- Func _datetomonth($imonnum, $iformat = Default)
- If $iformat = Default Then $iformat = 0
- $imonnum = Int($imonnum)
- If NOT __dateismonth($imonnum) Then Return SetError(1, 0, "")
- Local $tsystemtime = DllStructCreate($tagsystemtime)
- DllStructSetData($tsystemtime, "Year", @YEAR)
- DllStructSetData($tsystemtime, "Month", $imonnum)
- DllStructSetData($tsystemtime, "Day", 1)
- Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longname) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat, $dmw_shortname) ? "MMM" : "MMMM")
- EndFunc
- Func _dayvaluetodate($ijuliandate, ByRef $iyear, ByRef $imonth, ByRef $iday)
- If $ijuliandate < 0 OR NOT IsNumber($ijuliandate) Then
- Return SetError(1, 0, 0)
- EndIf
- Local $i_factorz = Int($ijuliandate + 0.5)
- Local $i_factorw = Int(($i_factorz - 1867216.25) / 36524.25)
- Local $i_factorx = Int($i_factorw / 4)
- Local $i_factora = $i_factorz + 1 + $i_factorw - $i_factorx
- Local $i_factorb = $i_factora + 1524
- Local $i_factorc = Int(($i_factorb - 122.1) / 365.25)
- Local $i_factord = Int(365.25 * $i_factorc)
- Local $i_factore = Int(($i_factorb - $i_factord) / 30.6001)
- Local $i_factorf = Int(30.6001 * $i_factore)
- $iday = $i_factorb - $i_factord - $i_factorf
- If $i_factore - 1 < 13 Then
- $imonth = $i_factore - 1
- Else
- $imonth = $i_factore - 13
- EndIf
- If $imonth < 3 Then
- $iyear = $i_factorc - 4715
- Else
- $iyear = $i_factorc - 4716
- EndIf
- $iyear = StringFormat("%04d", $iyear)
- $imonth = StringFormat("%02d", $imonth)
- $iday = StringFormat("%02d", $iday)
- Return $iyear & "/" & $imonth & "/" & $iday
- EndFunc
- Func _date_juliandayno($iyear, $imonth, $iday)
- Local $sfulldate = StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)
- If NOT _dateisvalid($sfulldate) Then
- Return SetError(1, 0, "")
- EndIf
- Local $ijday = 0
- Local $aidaysinmonth = _daysinmonth($iyear)
- For $icntr = 1 To $imonth - 1
- $ijday = $ijday + $aidaysinmonth[$icntr]
- Next
- $ijday = ($iyear * 1000) + ($ijday + $iday)
- Return $ijday
- EndFunc
- Func _juliantodate($ijday, $ssep = "/")
- Local $iyear = Int($ijday / 1000)
- Local $idays = Mod($ijday, 1000)
- Local $imaxdays = 365
- If _dateisleapyear($iyear) Then $imaxdays = 366
- If $idays > $imaxdays Then
- Return SetError(1, 0, "")
- EndIf
- Local $aidaysinmonth = _daysinmonth($iyear)
- Local $imonth = 1
- While $idays > $aidaysinmonth[$imonth]
- $idays = $idays - $aidaysinmonth[$imonth]
- $imonth = $imonth + 1
- WEnd
- Return StringFormat("%04d%s%02d%s%02d", $iyear, $ssep, $imonth, $ssep, $idays)
- EndFunc
- Func _now()
- Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, 0)
- EndFunc
- Func _nowcalc()
- Return @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
- EndFunc
- Func _nowcalcdate()
- Return @YEAR & "/" & @MON & "/" & @MDAY
- EndFunc
- Func _nowdate()
- Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY, 0)
- EndFunc
- Func _nowtime($stype = 3)
- If $stype < 3 OR $stype > 5 Then $stype = 3
- Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $stype)
- EndFunc
- Func _setdate($iday, $imonth = 0, $iyear = 0)
- If $iyear = 0 Then $iyear = @YEAR
- If $imonth = 0 Then $imonth = @MON
- If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then Return 1
- Local $tsystemtime = DllStructCreate($tagsystemtime)
- DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
- If @error Then Return SetError(@error, @extended, 0)
- DllStructSetData($tsystemtime, "Day", $iday)
- If $imonth > 0 Then DllStructSetData($tsystemtime, "Month", $imonth)
- If $iyear > 0 Then DllStructSetData($tsystemtime, "Year", $iyear)
- Local $ireturn = _date_time_setlocaltime($tsystemtime)
- If @error Then Return SetError(@error + 10, @extended, 0)
- Return Int($ireturn)
- EndFunc
- Func _settime($ihour, $iminute, $isecond = 0, $imseconds = 0)
- If $ihour < 0 OR $ihour > 23 Then Return 1
- If $iminute < 0 OR $iminute > 59 Then Return 1
- If $isecond < 0 OR $isecond > 59 Then Return 1
- If $imseconds < 0 OR $imseconds > 999 Then Return 1
- Local $tsystemtime = DllStructCreate($tagsystemtime)
- DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
- If @error Then Return SetError(@error, @extended, 0)
- DllStructSetData($tsystemtime, "Hour", $ihour)
- DllStructSetData($tsystemtime, "Minute", $iminute)
- If $isecond > 0 Then DllStructSetData($tsystemtime, "Seconds", $isecond)
- If $imseconds > 0 Then DllStructSetData($tsystemtime, "MSeconds", $imseconds)
- Local $ireturn = _date_time_setlocaltime($tsystemtime)
- If @error Then Return SetError(@error + 10, @extended, 0)
- Return Int($ireturn)
- EndFunc
- Func _tickstotime($iticks, ByRef $ihours, ByRef $imins, ByRef $isecs)
- If Number($iticks) > 0 Then
- $iticks = Int($iticks / 1000)
- $ihours = Int($iticks / 3600)
- $iticks = Mod($iticks, 3600)
- $imins = Int($iticks / 60)
- $isecs = Mod($iticks, 60)
- Return 1
- ElseIf Number($iticks) = 0 Then
- $ihours = 0
- $iticks = 0
- $imins = 0
- $isecs = 0
- Return 1
- Else
- Return SetError(1, 0, 0)
- EndIf
- EndFunc
- Func _timetoticks($ihours = @HOUR, $imins = @MIN, $isecs = @SEC)
- If StringIsInt($ihours) AND StringIsInt($imins) AND StringIsInt($isecs) Then
- Local $iticks = 1000 * ((3600 * $ihours) + (60 * $imins) + $isecs)
- Return $iticks
- Else
- Return SetError(1, 0, 0)
- EndIf
- EndFunc
- Func _weeknumberiso($iyear = @YEAR, $imonth = @MON, $iday = @MDAY)
- If $iday > 31 OR $iday < 1 Then
- Return SetError(1, 0, -1)
- ElseIf NOT __dateismonth($imonth) Then
- Return SetError(2, 0, -1)
- ElseIf $iyear < 1 OR $iyear > 2999 Then
- Return SetError(3, 0, -1)
- EndIf
- Local $idow = _datetodayofweekiso($iyear, $imonth, $iday) - 1
- Local $idow0101 = _datetodayofweekiso($iyear, 1, 1) - 1
- If ($imonth = 1 AND 3 < $idow0101 AND $idow0101 < 7 - ($iday - 1)) Then
- $idow = $idow0101 - 1
- $idow0101 = _datetodayofweekiso($iyear - 1, 1, 1) - 1
- $imonth = 12
- $iday = 31
- $iyear = $iyear - 1
- ElseIf ($imonth = 12 AND 30 - ($iday - 1) < _datetodayofweekiso($iyear + 1, 1, 1) - 1 AND _datetodayofweekiso($iyear + 1, 1, 1) - 1 < 4) Then
- Return 1
- EndIf
- Return Int((_datetodayofweekiso($iyear, 1, 1) - 1 < 4) + 4 * ($imonth - 1) + (2 * ($imonth - 1) + ($iday - 1) + $idow0101 - $idow + 6) * 36 / 256)
- EndFunc
- Func _weeknumber($iyear = @YEAR, $imonth = @MON, $iday = @MDAY, $iweekstart = 1)
- If $iday > 31 OR $iday < 1 Then
- Return SetError(1, 0, -1)
- ElseIf NOT __dateismonth($imonth) Then
- Return SetError(3, 0, -1)
- ElseIf $iyear < 1 OR $iyear > 2999 Then
- Return SetError(4, 0, -1)
- ElseIf $iweekstart < 1 OR $iweekstart > 2 Then
- Return SetError(2, 0, -1)
- EndIf
- Local $istartweek1, $iendweek1
- Local $idow0101 = _datetodayofweekiso($iyear, 1, 1)
- Local $idate = $iyear & "/" & $imonth & "/" & $iday
- If $iweekstart = 1 Then
- If $idow0101 = 6 Then
- $istartweek1 = 0
- Else
- $istartweek1 = -1 * $idow0101 - 1
- EndIf
- $iendweek1 = $istartweek1 + 6
- Else
- $istartweek1 = $idow0101 * -1
- $iendweek1 = $istartweek1 + 6
- EndIf
- Local $istartweek1ny
- Local $iendweek1date = _dateadd("d", $iendweek1, $iyear & "/01/01")
- Local $idow0101ny = _datetodayofweekiso($iyear + 1, 1, 1)
- If $iweekstart = 1 Then
- If $idow0101ny = 6 Then
- $istartweek1ny = 0
- Else
- $istartweek1ny = -1 * $idow0101ny - 1
- EndIf
- Else
- $istartweek1ny = $idow0101ny * -1
- EndIf
- Local $istartweek1dateny = _dateadd("d", $istartweek1ny, $iyear + 1 & "/01/01")
- Local $icurrdatediff = _datediff("d", $iendweek1date, $idate) - 1
- Local $icurrdatediffny = _datediff("d", $istartweek1dateny, $idate)
- If $icurrdatediff >= 0 AND $icurrdatediffny < 0 Then Return 2 + Int($icurrdatediff / 7)
- If $icurrdatediff < 0 OR $icurrdatediffny >= 0 Then Return 1
- EndFunc
- Func _daysinmonth($iyear)
- Local $adays = [12, 31, (_dateisleapyear($iyear) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
- Return $adays
- EndFunc
- Func __date_time_clonesystemtime($psystemtime)
- Local $tsystemtime1 = DllStructCreate($tagsystemtime, $psystemtime)
- Local $tsystemtime2 = DllStructCreate($tagsystemtime)
- DllStructSetData($tsystemtime2, "Month", DllStructGetData($tsystemtime1, "Month"))
- DllStructSetData($tsystemtime2, "Day", DllStructGetData($tsystemtime1, "Day"))
- DllStructSetData($tsystemtime2, "Year", DllStructGetData($tsystemtime1, "Year"))
- DllStructSetData($tsystemtime2, "Hour", DllStructGetData($tsystemtime1, "Hour"))
- DllStructSetData($tsystemtime2, "Minute", DllStructGetData($tsystemtime1, "Minute"))
- DllStructSetData($tsystemtime2, "Second", DllStructGetData($tsystemtime1, "Second"))
- DllStructSetData($tsystemtime2, "MSeconds", DllStructGetData($tsystemtime1, "MSeconds"))
- DllStructSetData($tsystemtime2, "DOW", DllStructGetData($tsystemtime1, "DOW"))
- Return $tsystemtime2
- EndFunc
- Func _date_time_comparefiletime($tfiletime1, $tfiletime2)
- Local $aresult = DllCall("kernel32.dll", "long", "CompareFileTime", "struct*", $tfiletime1, "struct*", $tfiletime2)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _date_time_dosdatetimetofiletime($ifatdate, $ifattime)
- Local $ttime = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "DosDateTimeToFileTime", "word", $ifatdate, "word", $ifattime, "struct*", $ttime)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $ttime)
- EndFunc
- Func _date_time_dosdatetoarray($idosdate)
- Local $adate[3]
- $adate[0] = BitAND($idosdate, 31)
- $adate[1] = BitAND(BitShift($idosdate, 5), 15)
- $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
- Return $adate
- EndFunc
- Func _date_time_dosdatetimetoarray($idosdate, $idostime)
- Local $adate[6]
- $adate[0] = BitAND($idosdate, 31)
- $adate[1] = BitAND(BitShift($idosdate, 5), 15)
- $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
- $adate[5] = BitAND($idostime, 31) * 2
- $adate[4] = BitAND(BitShift($idostime, 5), 63)
- $adate[3] = BitAND(BitShift($idostime, 11), 31)
- Return $adate
- EndFunc
- Func _date_time_dosdatetimetostr($idosdate, $idostime)
- Local $adate = _date_time_dosdatetimetoarray($idosdate, $idostime)
- Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
- EndFunc
- Func _date_time_dosdatetostr($idosdate)
- Local $adate = _date_time_dosdatetoarray($idosdate)
- Return StringFormat("%02d/%02d/%04d", $adate[0], $adate[1], $adate[2])
- EndFunc
- Func _date_time_dostimetoarray($idostime)
- Local $atime[3]
- $atime[2] = BitAND($idostime, 31) * 2
- $atime[1] = BitAND(BitShift($idostime, 5), 63)
- $atime[0] = BitAND(BitShift($idostime, 11), 31)
- Return $atime
- EndFunc
- Func _date_time_dostimetostr($idostime)
- Local $atime = _date_time_dostimetoarray($idostime)
- Return StringFormat("%02d:%02d:%02d", $atime[0], $atime[1], $atime[2])
- EndFunc
- Func _date_time_encodefiletime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
- Local $tsystemtime = _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour, $iminute, $isecond, $imseconds)
- Return _date_time_systemtimetofiletime($tsystemtime)
- EndFunc
- Func _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
- Local $tsystemtime = DllStructCreate($tagsystemtime)
- DllStructSetData($tsystemtime, "Month", $imonth)
- DllStructSetData($tsystemtime, "Day", $iday)
- DllStructSetData($tsystemtime, "Year", $iyear)
- DllStructSetData($tsystemtime, "Hour", $ihour)
- DllStructSetData($tsystemtime, "Minute", $iminute)
- DllStructSetData($tsystemtime, "Second", $isecond)
- DllStructSetData($tsystemtime, "MSeconds", $imseconds)
- Return $tsystemtime
- EndFunc
- Func _date_time_filetimetoarray(ByRef $tfiletime)
- If ((DllStructGetData($tfiletime, 1) + DllStructGetData($tfiletime, 2)) = 0) Then Return SetError(10, 0, 0)
- Local $tsystemtime = _date_time_filetimetosystemtime($tfiletime)
- If @error Then Return SetError(@error, @extended, 0)
- Return _date_time_systemtimetoarray($tsystemtime)
- EndFunc
- Func _date_time_filetimetostr(ByRef $tfiletime, $ifmt = 0)
- Local $adate = _date_time_filetimetoarray($tfiletime)
- If @error Then Return SetError(@error, @extended, "")
- If $ifmt Then
- Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $adate[2], $adate[0], $adate[1], $adate[3], $adate[4], $adate[5])
- Else
- Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
- EndIf
- EndFunc
- Func _date_time_filetimetodosdatetime($tfiletime)
- Local $adate[2]
- Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToDosDateTime", "struct*", $tfiletime, "word*", 0, "word*", 0)
- If @error Then Return SetError(@error, @extended, $adate)
- $adate[0] = $aresult[2]
- $adate[1] = $aresult[3]
- Return SetExtended($aresult[0], $adate)
- EndFunc
- Func _date_time_filetimetolocalfiletime($tfiletime)
- Local $tlocal = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToLocalFileTime", "struct*", $tfiletime, "struct*", $tlocal)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tlocal)
- EndFunc
- Func _date_time_filetimetosystemtime($tfiletime)
- Local $tsysttime = DllStructCreate($tagsystemtime)
- Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToSystemTime", "struct*", $tfiletime, "struct*", $tsysttime)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tsysttime)
- EndFunc
- Func _date_time_getfiletime($hfile)
- Local $adate[3]
- $adate[0] = DllStructCreate($tagfiletime)
- $adate[1] = DllStructCreate($tagfiletime)
- $adate[2] = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "GetFileTime", "handle", $hfile, "struct*", $adate[0], "struct*", $adate[1], "struct*", $adate[2])
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $adate)
- EndFunc
- Func _date_time_getlocaltime()
- Local $tsysttime = DllStructCreate($tagsystemtime)
- DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsysttime)
- If @error Then Return SetError(@error, @extended, 0)
- Return $tsysttime
- EndFunc
- Func _date_time_getsystemtime()
- Local $tsysttime = DllStructCreate($tagsystemtime)
- DllCall("kernel32.dll", "none", "GetSystemTime", "struct*", $tsysttime)
- If @error Then Return SetError(@error, @extended, 0)
- Return $tsysttime
- EndFunc
- Func _date_time_getsystemtimeadjustment()
- Local $ainfo[3]
- Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimeAdjustment", "dword*", 0, "dword*", 0, "bool*", 0)
- If @error Then Return SetError(@error, @extended, 0)
- $ainfo[0] = $aresult[1]
- $ainfo[1] = $aresult[2]
- $ainfo[2] = $aresult[3] <> 0
- Return SetExtended($aresult[0], $ainfo)
- EndFunc
- Func _date_time_getsystemtimeasfiletime()
- Local $tfiletime = DllStructCreate($tagfiletime)
- DllCall("kernel32.dll", "none", "GetSystemTimeAsFileTime", "struct*", $tfiletime)
- If @error Then Return SetError(@error, @extended, 0)
- Return $tfiletime
- EndFunc
- Func _date_time_getsystemtimes()
- Local $ainfo[3]
- $ainfo[0] = DllStructCreate($tagfiletime)
- $ainfo[1] = DllStructCreate($tagfiletime)
- $ainfo[2] = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimes", "struct*", $ainfo[0], "struct*", $ainfo[1], "struct*", $ainfo[2])
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $ainfo)
- EndFunc
- Func _date_time_gettickcount()
- Local $aresult = DllCall("kernel32.dll", "dword", "GetTickCount")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _date_time_gettimezoneinformation()
- Local $ttimezone = DllStructCreate($tagtime_zone_information)
- Local $aresult = DllCall("kernel32.dll", "dword", "GetTimeZoneInformation", "struct*", $ttimezone)
- If @error OR $aresult[0] = -1 Then Return SetError(@error, @extended, 0)
- Local $ainfo[8]
- $ainfo[0] = $aresult[0]
- $ainfo[1] = DllStructGetData($ttimezone, "Bias")
- $ainfo[2] = _winapi_widechartomultibyte(DllStructGetPtr($ttimezone, "StdName"))
- $ainfo[3] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "StdDate"))
- $ainfo[4] = DllStructGetData($ttimezone, "StdBias")
- $ainfo[5] = _winapi_widechartomultibyte(DllStructGetPtr($ttimezone, "DayName"))
- $ainfo[6] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "DayDate"))
- $ainfo[7] = DllStructGetData($ttimezone, "DayBias")
- Return $ainfo
- EndFunc
- Func _date_time_localfiletimetofiletime($tlocaltime)
- Local $tfiletime = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "LocalFileTimeToFileTime", "struct*", $tlocaltime, "struct*", $tfiletime)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tfiletime)
- EndFunc
- Func _date_time_setfiletime($hfile, $tcreatetime, $tlastaccess, $tlastwrite)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetFileTime", "handle", $hfile, "struct*", $tcreatetime, "struct*", $tlastaccess, "struct*", $tlastwrite)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _date_time_setlocaltime($tsystemtime)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tsystemtime)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, False)
- $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tsystemtime)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _date_time_setsystemtime($tsystemtime)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTime", "struct*", $tsystemtime)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _date_time_setsystemtimeadjustment($iadjustment, $bdisabled)
- Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
- If @error Then Return SetError(@error + 10, @extended, False)
- _security__setprivilege($htoken, "SeSystemtimePrivilege", True)
- Local $ierror = @error
- Local $ilasterror = @extended
- Local $bret = False
- If NOT @error Then
- Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTimeAdjustment", "dword", $iadjustment, "bool", $bdisabled)
- If @error Then
- $ierror = @error
- $ilasterror = @extended
- ElseIf $aresult[0] Then
- $bret = True
- Else
- $ierror = 20
- $ilasterror = _winapi_getlasterror()
- EndIf
- _security__setprivilege($htoken, "SeSystemtimePrivilege", False)
- If NOT $ierror AND @error Then $ierror = 22
- EndIf
- _winapi_closehandle($htoken)
- Return SetError($ierror, $ilasterror, $bret)
- EndFunc
- Func _date_time_settimezoneinformation($ibias, $sstdname, $tstddate, $istdbias, $sdayname, $tdaydate, $idaybias)
- Local $tstdname = _winapi_multibytetowidechar($sstdname)
- Local $tdayname = _winapi_multibytetowidechar($sdayname)
- Local $tzoneinfo = DllStructCreate($tagtime_zone_information)
- DllStructSetData($tzoneinfo, "Bias", $ibias)
- DllStructSetData($tzoneinfo, "StdName", DllStructGetData($tstdname, 1))
- _memmovememory($tstddate, DllStructGetPtr($tzoneinfo, "StdDate"), DllStructGetSize($tstddate))
- DllStructSetData($tzoneinfo, "StdBias", $istdbias)
- DllStructSetData($tzoneinfo, "DayName", DllStructGetData($tdayname, 1))
- _memmovememory($tdaydate, DllStructGetPtr($tzoneinfo, "DayDate"), DllStructGetSize($tdaydate))
- DllStructSetData($tzoneinfo, "DayBias", $idaybias)
- Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
- If @error Then Return SetError(@error + 10, @extended, False)
- _security__setprivilege($htoken, "SeSystemtimePrivilege", True)
- Local $ierror = @error
- Local $ilasterror = @extended
- Local $bret = False
- If NOT @error Then
- Local $aresult = DllCall("kernel32.dll", "bool", "SetTimeZoneInformation", "struct*", $tzoneinfo)
- If @error Then
- $ierror = @error
- $ilasterror = @extended
- ElseIf $aresult[0] Then
- $ilasterror = 0
- $bret = True
- Else
- $ierror = 20
- $ilasterror = _winapi_getlasterror()
- EndIf
- _security__setprivilege($htoken, "SeSystemtimePrivilege", False)
- If NOT $ierror AND @error Then $ierror = 22
- EndIf
- _winapi_closehandle($htoken)
- Return SetError($ierror, $ilasterror, $bret)
- EndFunc
- Func _date_time_systemtimetoarray(ByRef $tsystemtime)
- Local $ainfo[8]
- $ainfo[0] = DllStructGetData($tsystemtime, "Month")
- $ainfo[1] = DllStructGetData($tsystemtime, "Day")
- $ainfo[2] = DllStructGetData($tsystemtime, "Year")
- $ainfo[3] = DllStructGetData($tsystemtime, "Hour")
- $ainfo[4] = DllStructGetData($tsystemtime, "Minute")
- $ainfo[5] = DllStructGetData($tsystemtime, "Second")
- $ainfo[6] = DllStructGetData($tsystemtime, "MSeconds")
- $ainfo[7] = DllStructGetData($tsystemtime, "DOW")
- Return $ainfo
- EndFunc
- Func _date_time_systemtimetodatestr(ByRef $tsystemtime, $ifmt = 0)
- Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
- If @error Then Return SetError(@error, @extended, "")
- If $ifmt Then
- Return StringFormat("%04d/%02d/%02d", $ainfo[2], $ainfo[0], $ainfo[1])
- Else
- Return StringFormat("%02d/%02d/%04d", $ainfo[0], $ainfo[1], $ainfo[2])
- EndIf
- EndFunc
- Func _date_time_systemtimetodatetimestr(ByRef $tsystemtime, $ifmt = 0)
- Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
- If @error Then Return SetError(@error, @extended, "")
- If $ifmt Then
- Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $ainfo[2], $ainfo[0], $ainfo[1], $ainfo[3], $ainfo[4], $ainfo[5])
- Else
- Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $ainfo[0], $ainfo[1], $ainfo[2], $ainfo[3], $ainfo[4], $ainfo[5])
- EndIf
- EndFunc
- Func _date_time_systemtimetofiletime($tsystemtime)
- Local $tfiletime = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToFileTime", "struct*", $tsystemtime, "struct*", $tfiletime)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tfiletime)
- EndFunc
- Func _date_time_systemtimetotimestr(ByRef $tsystemtime)
- Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
- Return StringFormat("%02d:%02d:%02d", $ainfo[3], $ainfo[4], $ainfo[5])
- EndFunc
- Func _date_time_systemtimetotzspecificlocaltime($tutc, $ttimezone = 0)
- Local $tlocaltime = DllStructCreate($tagsystemtime)
- Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToTzSpecificLocalTime", "struct*", $ttimezone, "struct*", $tutc, "struct*", $tlocaltime)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tlocaltime)
- EndFunc
- Func _date_time_tzspecificlocaltimetosystemtime($tlocaltime, $ttimezone = 0)
- Local $tutc = DllStructCreate($tagsystemtime)
- Local $aresult = DllCall("kernel32.dll", "bool", "TzSpecificLocalTimeToSystemTime", "struct*", $ttimezone, "struct*", $tlocaltime, "struct*", $tutc)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tutc)
- EndFunc
- Global Const $url_scheme_invalid = -1
- Global Const $url_scheme_unknown = 0
- Global Const $url_scheme_ftp = 1
- Global Const $url_scheme_http = 2
- Global Const $url_scheme_gopher = 3
- Global Const $url_scheme_mailto = 4
- Global Const $url_scheme_news = 5
- Global Const $url_scheme_nntp = 6
- Global Const $url_scheme_telnet = 7
- Global Const $url_scheme_wais = 8
- Global Const $url_scheme_file = 9
- Global Const $url_scheme_mk = 10
- Global Const $url_scheme_https = 11
- Global Const $url_scheme_shell = 12
- Global Const $url_scheme_snews = 13
- Global Const $url_scheme_local = 14
- Global Const $url_scheme_javascript = 15
- Global Const $url_scheme_vbscript = 16
- Global Const $url_scheme_about = 17
- Global Const $url_scheme_res = 18
- Global Const $url_scheme_msshellrooted = 19
- Global Const $url_scheme_msshellidlist = 20
- Global Const $url_scheme_mshelp = 21
- Global Const $url_scheme_msshelldevice = 22
- Global Const $url_scheme_wildcard = 23
- Global Const $url_scheme_search_ms = 24
- Global Const $url_scheme_search = 25
- Global Const $url_scheme_knownfolder = 26
- Global Const $gct_invalid = 0
- Global Const $gct_lfnchar = 1
- Global Const $gct_separator = 8
- Global Const $gct_shortchar = 2
- Global Const $gct_wild = 4
- Global Const $url_apply_default = 1
- Global Const $url_apply_guessscheme = 2
- Global Const $url_apply_guessfile = 4
- Global Const $url_apply_forceapply = 8
- Global Const $url_dont_simplify = 134217728
- Global Const $url_escape_as_utf8 = 262144
- Global Const $url_escape_percent = 4096
- Global Const $url_escape_spaces_only = 67108864
- Global Const $url_escape_unsafe = 536870912
- Global Const $url_no_meta = 134217728
- Global Const $url_pluggable_protocol = 1073741824
- Global Const $url_unescape = 268435456
- Global Const $url_part_hostname = 2
- Global Const $url_part_password = 4
- Global Const $url_part_port = 5
- Global Const $url_part_query = 6
- Global Const $url_part_scheme = 1
- Global Const $url_part_username = 3
- Global Const $urlis_appliable = 4
- Global Const $urlis_directory = 5
- Global Const $urlis_fileurl = 3
- Global Const $urlis_hasquery = 6
- Global Const $urlis_nohistory = 2
- Global Const $urlis_opaque = 1
- Global Const $urlis_url = 0
- #Region Functions list
- #EndRegion Functions list
- #Region Public Functions
- Func _winapi_commandlinetoargv($scmd)
- Local $aresult[1] = [0]
- $scmd = StringStripWS($scmd, $str_stripleading + $str_striptrailing)
- If NOT $scmd Then
- Return $aresult
- EndIf
- Local $aret = DllCall("shell32.dll", "ptr", "CommandLineToArgvW", "wstr", $scmd, "int*", 0)
- If @error OR NOT $aret[0] OR (NOT $aret[2]) Then Return SetError(@error + 10, @extended, 0)
- Local $tptr = DllStructCreate("ptr[" & $aret[2] & "]", $aret[0])
- Dim $aresult[$aret[2] + 1] = [$aret[2]]
- For $i = 1 To $aret[2]
- $aresult[$i] = _winapi_getstring(DllStructGetData($tptr, 1, $i))
- Next
- DllCall("kernel32.dll", "handle", "LocalFree", "handle", $aret[0])
- Return $aresult
- EndFunc
- Func _winapi_isnameinexpression($sstring, $spattern, $bcasesensitive = False)
- If NOT $bcasesensitive Then $spattern = StringUpper($spattern)
- Local $tus1 = __us($spattern)
- Local $tus2 = __us($sstring)
- Local $aret = DllCall("ntdll.dll", "boolean", "RtlIsNameInExpression", "struct*", $tus1, "struct*", $tus2, "boolean", NOT $bcasesensitive, "ptr", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_parseurl($surl)
- Local $tagparsedurl = "dword Size;ptr Protocol;uint cchProtocol;ptr Suffix;uint cchSuffix;uint Scheme"
- Local $tpurl = DllStructCreate($tagparsedurl)
- DllStructSetData($tpurl, 1, DllStructGetSize($tpurl))
- Local $turl = DllStructCreate("wchar[4096]")
- DllStructSetData($turl, 1, $surl)
- Local $aret = DllCall("shlwapi.dll", "long", "ParseURLW", "struct*", $turl, "struct*", $tpurl)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Local $aresult[3]
- $aresult[0] = DllStructGetData(DllStructCreate("wchar[" & DllStructGetData($tpurl, 3) & "]", DllStructGetData($tpurl, 2)), 1)
- $aresult[1] = DllStructGetData(DllStructCreate("wchar[" & DllStructGetData($tpurl, 5) & "]", DllStructGetData($tpurl, 4)), 1)
- $aresult[2] = DllStructGetData($tpurl, 6)
- Return $aresult
- EndFunc
- Func _winapi_parseusername($suser)
- If NOT __dll("credui.dll") Then Return SetError(103, 0, 0)
- Local $aret = DllCall("credui.dll", "dword", "CredUIParseUserNameW", "wstr", $suser, "wstr", "", "ulong", 4096, "wstr", "", "ulong", 4096)
- If @error Then Return SetError(@error, @extended, 0)
- Switch $aret[0]
- Case 0
- Case 1315
- If StringStripWS($suser, $str_stripleading + $str_striptrailing) Then
- $aret[2] = $suser
- $aret[4] = ""
- Else
- ContinueCase
- EndIf
- Case Else
- Return SetError(10, $aret[0], 0)
- EndSwitch
- Local $aresult[2]
- $aresult[0] = $aret[4]
- $aresult[1] = $aret[2]
- Return $aresult
- EndFunc
- Func _winapi_pathaddbackslash($sfilepath)
- Local $tpath = DllStructCreate("wchar[260]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathAddBackslashW", "struct*", $tpath)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return DllStructGetData($tpath, 1)
- EndFunc
- Func _winapi_pathaddextension($sfilepath, $sext = "")
- Local $tpath = DllStructCreate("wchar[260]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $stypeofext = "wstr"
- If NOT StringStripWS($sext, $str_stripleading + $str_striptrailing) Then
- $stypeofext = "ptr"
- $sext = 0
- EndIf
- Local $aret = DllCall("shlwapi.dll", "bool", "PathAddExtensionW", "struct*", $tpath, $stypeofext, $sext)
- If @error Then Return SetError(@error, @extended, "")
- Return SetExtended($aret[0], DllStructGetData($tpath, 1))
- EndFunc
- Func _winapi_pathappend($sfilepath, $smore)
- Local $tpath = DllStructCreate("wchar[260]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathAppendW", "struct*", $tpath, "wstr", $smore)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return DllStructGetData($tpath, 1)
- EndFunc
- Func _winapi_pathbuildroot($idrive)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathBuildRootW", "wstr", "", "int", $idrive)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathcanonicalize($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathCanonicalizeW", "wstr", "", "wstr", $sfilepath)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, $sfilepath)
- Return $aret[1]
- EndFunc
- Func _winapi_pathcommonprefix($spath1, $spath2)
- Local $aret = DllCall("shlwapi.dll", "int", "PathCommonPrefixW", "wstr", $spath1, "wstr", $spath2, "wstr", "")
- If @error Then Return SetError(@error, @extended, "")
- Return SetExtended($aret[0], $aret[3])
- EndFunc
- Func _winapi_pathcompactpath($hwnd, $sfilepath, $iwidth = 0)
- If $iwidth < 1 Then
- Local $trect = DllStructCreate($tagrect)
- DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "struct*", $trect)
- $iwidth += DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
- EndIf
- Local $aret = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
- If @error OR NOT $aret[0] Then Return SetError(@error + 20, @extended, $sfilepath)
- Local $hdc = $aret[0]
- Local Const $wm_getfont = 49
- $aret = DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hwnd, "uint", $wm_getfont, "wparam", 0, "lparam", 0)
- Local $hback = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $aret[0])
- Local $ierror = 0
- $aret = DllCall("shlwapi.dll", "bool", "PathCompactPathW", "handle", $hdc, "wstr", $sfilepath, "int", $iwidth)
- If @error OR NOT $aret[0] Then $ierror = @error + 10
- DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hback[0])
- DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
- If $ierror Then Return SetError($ierror, 0, $sfilepath)
- Return $aret[2]
- EndFunc
- Func _winapi_pathcompactpathex($sfilepath, $imax)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathCompactPathExW", "wstr", "", "wstr", $sfilepath, "uint", $imax + 1, "dword", 0)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, $sfilepath)
- Return $aret[1]
- EndFunc
- Func _winapi_pathcreatefromurl($surl)
- Local $aret = DllCall("shlwapi.dll", "long", "PathCreateFromUrlW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", 0)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[2]
- EndFunc
- Func _winapi_pathfindextension($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "wstr", "PathFindExtensionW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[0]
- EndFunc
- Func _winapi_pathfindfilename($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "wstr", "PathFindFileNameW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, $sfilepath)
- Return $aret[0]
- EndFunc
- Func _winapi_pathfindnextcomponent($sfilepath)
- Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathFindNextComponentW", "struct*", $tpath)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return _winapi_getstring($aret[0])
- EndFunc
- Func _winapi_pathgetargs($sfilepath)
- Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathGetArgsW", "struct*", $tpath)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return _winapi_getstring($aret[0])
- EndFunc
- Func _winapi_pathgetchartype($schar)
- Local $aret = DllCall("shlwapi.dll", "uint", "PathGetCharTypeW", "word", AscW($schar))
- If @error Then Return SetError(@error, @extended, -1)
- Return $aret[0]
- EndFunc
- Func _winapi_pathgetdrivenumber($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "int", "PathGetDriveNumberW", "wstr", $sfilepath)
- If @error OR ($aret[0] = -1) Then Return SetError(@error, @extended, "")
- Return Chr($aret[0] + 65) & ":"
- EndFunc
- Func _winapi_pathiscontenttype($sfilepath, $stype)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsContentTypeW", "wstr", $sfilepath, "wstr", $stype)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisexe($sfilepath)
- Local $aret = DllCall("shell32.dll", "bool", "PathIsExe", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisfilespec($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsFileSpecW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathislfnfilespec($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsLFNFileSpecW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisrelative($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsRelativeW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisroot($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsRootW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathissameroot($spath1, $spath2)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsSameRootW", "wstr", $spath1, "wstr", $spath2)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathissystemfolder($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsSystemFolderW", "wstr", $sfilepath, "dword", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisunc($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisuncserver($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCServerW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisuncservershare($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCServerShareW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathmakesystemfolder($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathMakeSystemFolderW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathmatchspec($sfilepath, $sspec)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathMatchSpecW", "wstr", $sfilepath, "wstr", $sspec)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathparseiconlocation($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "int", "PathParseIconLocationW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, 0)
- Local $aresult[2]
- $aresult[0] = $aret[1]
- $aresult[1] = $aret[0]
- Return $aresult
- EndFunc
- Func _winapi_pathrelativepathto($spathfrom, $bdirfrom, $spathto, $bdirto)
- If $bdirfrom Then
- $bdirfrom = 16
- EndIf
- If $bdirto Then
- $bdirto = 16
- EndIf
- Local $aret = DllCall("shlwapi.dll", "bool", "PathRelativePathToW", "wstr", "", "wstr", $spathfrom, "dword", $bdirfrom, "wstr", $spathto, "dword", $bdirto)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathremoveargs($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "none", "PathRemoveArgsW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathremovebackslash($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathRemoveBackslashW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathremoveextension($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "none", "PathRemoveExtensionW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathremovefilespec($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathRemoveFileSpecW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return SetExtended($aret[0], $aret[1])
- EndFunc
- Func _winapi_pathrenameextension($sfilepath, $sext)
- Local $tpath = DllStructCreate("wchar[260]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathRenameExtensionW", "struct*", $tpath, "wstr", $sext)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return DllStructGetData($tpath, 1)
- EndFunc
- Func _winapi_pathsearchandqualify($sfilepath, $bexists = False)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathSearchAndQualifyW", "wstr", $sfilepath, "wstr", "", "int", 4096)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- If $bexists AND NOT FileExists($aret[2]) Then Return SetError(20, 0, "")
- Return $aret[2]
- EndFunc
- Func _winapi_pathskiproot($sfilepath)
- Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathSkipRootW", "struct*", $tpath)
- If @error Then Return SetError(@error, @extended, "")
- If NOT $aret[0] Then Return $sfilepath
- Return _winapi_getstring($aret[0])
- EndFunc
- Func _winapi_pathstrippath($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "none", "PathStripPathW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathstriptoroot($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathStripToRootW", "wstr", $sfilepath)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathundecorate($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "none", "PathUndecorateW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathunexpandenvstrings($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathUnExpandEnvStringsW", "wstr", $sfilepath, "wstr", "", "uint", 4096)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[2]
- EndFunc
- Func _winapi_pathunmakesystemfolder($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathUnmakeSystemFolderW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathunquotespaces($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "none", "PathUnquoteSpacesW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathyetanothermakeuniquename($sfilepath)
- Local $aret = DllCall("shell32.dll", "int", "PathYetAnotherMakeUniqueName", "wstr", "", "wstr", $sfilepath, "ptr", 0, "ptr", 0)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_shellgetimagelist($bsmall = False)
- Local $plarge, $psmall, $tptr = DllStructCreate("ptr")
- If $bsmall Then
- $plarge = 0
- $psmall = DllStructGetPtr($tptr)
- Else
- $plarge = DllStructGetPtr($tptr)
- $psmall = 0
- EndIf
- Local $aret = DllCall("shell32.dll", "int", "Shell_GetImageLists", "ptr", $plarge, "ptr", $psmall)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
- Return DllStructGetData($tptr, 1)
- EndFunc
- Func _winapi_urlapplyscheme($surl, $iflags = 1)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlApplySchemeW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[2]
- EndFunc
- Func _winapi_urlcanonicalize($surl, $iflags)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlCanonicalizeW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[2]
- EndFunc
- Func _winapi_urlcombine($surl, $spart, $iflags = 0)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlCombineW", "wstr", $surl, "wstr", $spart, "wstr", "", "dword*", 4096, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[3]
- EndFunc
- Func _winapi_urlcompare($surl1, $surl2, $bignoreslash = False)
- Local $aret = DllCall("shlwapi.dll", "int", "UrlCompareW", "wstr", $surl1, "wstr", $surl2, "bool", $bignoreslash)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_urlcreatefrompath($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlCreateFromPathW", "wstr", $sfilepath, "wstr", "", "dword*", 4096, "dword", 0)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] < 0 OR $aret[0] > 1 Then
- Return SetError(10, $aret[0], "")
- EndIf
- Return $aret[2]
- EndFunc
- Func _winapi_urlfixup($surl)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlFixupW", "wstr", $surl, "wstr", "", "dword", 4096)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[2]
- EndFunc
- Func _winapi_urlgetpart($surl, $ipart)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlGetPartW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $ipart, "dword", 0)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[2]
- EndFunc
- Func _winapi_urlhash($surl, $ilength = 32)
- If $ilength <= 0 OR $ilength > 256 Then Return SetError(256, 0, 0)
- Local $tdata = DllStructCreate("byte[" & $ilength & "]")
- Local $aret = DllCall("shlwapi.dll", "long", "UrlHashW", "wstr", $surl, "struct*", $tdata, "dword", $ilength)
- If @error Then Return SetError(@error + 10, @extended, 0)
- If $aret[0] Then Return SetError(10, $aret[0], 0)
- Return DllStructGetData($tdata, 1)
- EndFunc
- Func _winapi_urlis($surl, $itype = 0)
- Local $aret = DllCall("shlwapi.dll", "bool", "UrlIsW", "wstr", $surl, "uint", $itype)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- #EndRegion Public Functions
- #Region Internal Functions
- Func __us($sstring, $ilength = 0)
- If $ilength Then
- $sstring = StringLeft($sstring, $ilength)
- Else
- $ilength = StringLen($sstring)
- EndIf
- Local $tus = DllStructCreate("ushort;ushort;ptr;wchar[" & ($ilength + 1) & "]")
- DllStructSetData($tus, 1, 2 * StringLen($sstring))
- DllStructSetData($tus, 2, 2 * $ilength)
- DllStructSetData($tus, 3, DllStructGetPtr($tus, 4))
- DllStructSetData($tus, 4, $sstring)
- Return $tus
- EndFunc
- #EndRegion Internal Functions
- Local $gui_window
- Local $gui_label_x, $gui_label_y, $gui_label_z, $gui_label_r, $gui_label_hp, $gui_label_exp, $gui_label_bg_game_status
- Local $gui_label_mp, $gui_prog_hp, $gui_prog_mp, $gui_prog_exp, $gui_label_level, $gui_label_current_casting
- Local $gui_label_target, $gui_label_debuff, $gui_label_zoneid, $gui_label_status, $gui_label_bot, $distance
- Local $gui_log, $tstring, $profile_array, $filename
- Local $sdrive = "", $sdir = "", $sfilename = "", $sextension = ""
- Dim $acmdline[1]
- Global $sensdistance = 8
- Global $walkrange = 4
- Global $next = False
- Global $togelx = 3
- Global $wow = 1
- Global $checkpremium = False
- Global $localversion = "1.0.0"
- Global $profileopen = True
- Global $data = "[" & _nowtime(3) & "] Welcome to Ferib's Waypoint Bot!" & @CRLF & "[" & _nowtime(3) & "] Please select a profile first!"
- Global $record = False, $loop = False
- Global $sstatus = "Online"
- Global $pstatus = "Wating for profile"
- ;~ $id = ProcessExists("wow.exe")
- $id = ProcessExists("WoWCircle - 32.exe")
- $openmem = _memoryopen($id)
- Global $baseaddr = _memorymodulegetbaseaddress($id, "wow.exe")
- $gui_window = GUICreate("Ferib's Waypoint Bot", 300, 230, 100, 100, -1, $ws_ex_toolwindow)
- GUICtrlSetState(-1, $gui_dropaccepted)
- GUISetBkColor(51)
- GUICtrlSetDefColor(16777215)
- $gui_label_x = GUICtrlCreateLabel("Attached to: Wow.exe - " & $id, 5, 5, 200, 15)
- $gui_label_y = GUICtrlCreateLabel("Premium user: " & $checkpremium, 5, 21, 200, 15)
- $gui_label_z = GUICtrlCreateLabel("Server Status: " & $sstatus, 5, 37, 200, 15)
- $gui_label_r = GUICtrlCreateLabel("Player Status: " & $pstatus, 5, 54, 180, 15)
- $gui_button_load = GUICtrlCreateButton("Load Profile", 195, 5, 100, 21)
- GUICtrlSetColor(-1, 0)
- $gui_button_save = GUICtrlCreateButton("Record", 195, 26, 100, 21)
- GUICtrlSetColor(-1, 0)
- $gui_button_start = GUICtrlCreateButton("Start", 195, 47, 100, 21)
- GUICtrlSetColor(-1, 0)
- $gui_log = GUICtrlCreateEdit($data, 5, 75, 290, 145, $es_readonly)
- GUICtrlSetState(-1, $gui_dropaccepted)
- GUICtrlSetBkColor(-1, 51)
- GUISetState(@SW_SHOW)
- WinSetOnTop($gui_window, "", 1)
- WinSetTrans($gui_window, "", 200)
- #Region database
- Local $urlbase = "http://www.ferib.nl/database/Ferib_databaseB.txt"
- Local $urlxxx1 = "http://www.ferib.nl/database/Ferib_databaseX1.txt"
- Local $urlxxx2 = "http://www.ferib.nl/database/Ferib_databaseX2.txt"
- Local $urlyyy1 = "http://www.ferib.nl/database/Ferib_databaseY1.txt"
- Local $urlyyy2 = "http://www.ferib.nl/database/Ferib_databaseY2.txt"
- Local $urlzzz1 = "http://www.ferib.nl/database/Ferib_databaseZ1.txt"
- Local $urlzzz2 = "http://www.ferib.nl/database/Ferib_databaseZ2.txt"
- Local $urlctm = "http://www.ferib.nl/database/Ferib_CTM.txt"
- Local $urlctmv = "http://www.ferib.nl/database/Ferib_CTMV.txt"
- Local $urlctmdl = "http://www.ferib.nl/database/Ferib_CTMDL.txt"
- Local $urlctmnn = "http://www.ferib.nl/database/Ferib_CTMNN.txt"
- $httpb = ObjCreate("winhttp.winhttprequest.5.1")
- $httpb.open("GET", $urlbase)
- Sleep(50)
- $httpb.send()
- $httpb.waitforresponse()
- $sourceb = $httpb.responsetext()
- Global $base8 = $sourceb
- $httpctm = ObjCreate("winhttp.winhttprequest.5.1")
- $httpctm.open("GET", $urlctm)
- Sleep(50)
- $httpctm.send()
- $httpctm.waitforresponse()
- $sourcectm = $httpctm.responsetext()
- Global $ctm = $sourcectm
- $httpctmdl = ObjCreate("winhttp.winhttprequest.5.1")
- $httpctmdl.open("GET", $urlctmdl)
- Sleep(50)
- $httpctmdl.send()
- $httpctmdl.waitforresponse()
- $sourcectmdl = $httpctmdl.responsetext()
- Global $download = $sourcectmdl
- $httpctmnn = ObjCreate("winhttp.winhttprequest.5.1")
- $httpctmnn.open("GET", $urlctmnn)
- Sleep(50)
- $httpctmnn.send()
- $httpctmnn.waitforresponse()
- $sourcectmnn = $httpctmnn.responsetext()
- Global $name = $sourcectmnn
- $httpctmv = ObjCreate("winhttp.winhttprequest.5.1")
- $httpctmv.open("GET", $urlctmv)
- Sleep(50)
- $httpctmv.send()
- $httpctmv.waitforresponse()
- $sourcectmv = $httpctmv.responsetext()
- Global $ctmv = $sourcectmv
- $httpxxx1 = ObjCreate("winhttp.winhttprequest.5.1")
- $httpxxx1.open("GET", $urlxxx1)
- Sleep(50)
- $httpxxx1.send()
- $httpxxx1.waitforresponse()
- $sourcexxx1 = $httpxxx1.responsetext()
- Global $xxx1 = $sourcexxx1
- $httpxxx2 = ObjCreate("winhttp.winhttprequest.5.1")
- $httpxxx2.open("GET", $urlxxx2)
- Sleep(50)
- $httpxxx2.send()
- $httpxxx2.waitforresponse()
- $sourcexxx2 = $httpxxx2.responsetext()
- Global $xxx2 = $sourcexxx2
- $httpyyy1 = ObjCreate("winhttp.winhttprequest.5.1")
- $httpyyy1.open("GET", $urlyyy1)
- Sleep(50)
- $httpyyy1.send()
- $httpyyy1.waitforresponse()
- $sourceyyy1 = $httpyyy1.responsetext()
- Global $yyy1 = $sourceyyy1
- $httpyyy2 = ObjCreate("winhttp.winhttprequest.5.1")
- $httpyyy2.open("GET", $urlyyy2)
- Sleep(50)
- $httpyyy2.send()
- $httpyyy2.waitforresponse()
- $sourceyyy2 = $httpyyy2.responsetext()
- Global $yyy2 = $sourceyyy2
- $httpzzz1 = ObjCreate("winhttp.winhttprequest.5.1")
- $httpzzz1.open("GET", $urlzzz1)
- Sleep(50)
- $httpzzz1.send()
- $httpzzz1.waitforresponse()
- $sourcezzz1 = $httpzzz1.responsetext()
- Global $zzz1 = $sourcezzz1
- $httpzzz2 = ObjCreate("winhttp.winhttprequest.5.1")
- $httpzzz2.open("GET", $urlzzz2)
- Sleep(50)
- $httpzzz2.send()
- $httpzzz2.waitforresponse()
- $sourcezzz2 = $httpzzz2.responsetext()
- Global $zzz2 = $sourcezzz2
- #EndRegion
- Global $mem_clicktomove_go = "0x" & Hex($baseaddr + $ctm)
- Global $mem_clicktomove_x = "0x" & Hex($baseaddr + $ctm + 40)
- Global $mem_clicktomove_y = "0x" & Hex($baseaddr + $ctm + 40 + 4)
- Global $mem_clicktomove_z = "0x" & Hex($baseaddr + $ctm + 40 + 4 + 4)
- Global $offsetx[3] = [0, Dec($xxx1), Dec($xxx2)]
- Global $offsety[3] = [0, Dec($yyy1), Dec($yyy2)]
- Global $offsetz[3] = [0, Dec($zzz1), Dec($zzz2)]
- Global $offsetf[3] = [0, Dec("124"), Dec("28")]
- Global $staticoffsetx = $base8
- Global $staticoffsety = $base8
- Global $staticoffsetz = $base8
- Global $staticoffsetf = $base8
- Global $finaladdrx = "0x" & Hex($baseaddr + $staticoffsetx)
- Global $finaladdry = "0x" & Hex($baseaddr + $staticoffsety)
- Global $finaladdrz = "0x" & Hex($baseaddr + $staticoffsetz)
- Global $finaladdrf = "0x" & Hex($baseaddr + $staticoffsetf)
- If $localversion = $ctmv Then
- Else
- $data = GUICtrlRead($gui_log)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] New version found! (" & $ctmv & ")")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- $data = GUICtrlRead($gui_log)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Downloading New Version...")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- If FileExists(@ScriptDir & "\" & $name & ".exe") Then
- FileDelete(@ScriptDir & "\" & $name & ".exe")
- EndIf
- $urldownloader = $download
- $directory = @ScriptDir & "\" & $name & ".exe"
- InetGet($urldownloader, $directory, 9)
- $data = GUICtrlRead($gui_log)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] New version download!")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- Run($directory)
- Sleep(3000)
- Exit
- EndIf
- checkpremium()
- Func checkpremium()
- Local $urlip = "http://www.ferib.nl/IP"
- $httpip = ObjCreate("winhttp.winhttprequest.5.1")
- $httpip.open("GET", $urlip)
- $httpip.send()
- $httpip.waitforresponse()
- $sourceip = $httpip.responsetext()
- Global $ip = $sourceip
- Local $urlo = "http://www.ferib.nl/database/Ferib_Check_License.txt"
- $httpo = ObjCreate("winhttp.winhttprequest.5.1")
- $httpo.open("GET", $urlo)
- $httpo.send()
- $httpo.waitforresponse()
- $sourceo = $httpo.responsetext()
- Global $ipmatch = $sourceo
- Local $iposition = StringInStr($ipmatch, $ip)
- If $iposition > 0 Then
- Global $premium = 1
- Global $checkpremium = True
- GUICtrlSetData($gui_label_y, "Premium user: " & $checkpremium)
- Else
- Global $premium = 0
- Global $checkpremium = False
- EndIf
- If $ipmatch = 0 Then
- Global $premium = 1
- Global $checkpremium = True
- GUICtrlSetData($gui_label_y, "Premium user: " & $checkpremium)
- EndIf
- If $ipmatch = "free" Then
- Global $premium = 1
- Global $checkpremium = True
- GUICtrlSetData($gui_label_y, "Premium user: " & $checkpremium)
- EndIf
- EndFunc
- $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- Local $acmdline = _winapi_commandlinetoargv($cmdlineraw)
- If UBound($acmdline) > 1 Then
- $filename = $acmdline[1]
- If FileExists($filename) Then
- Global $profileopen = False
- load()
- Global $profileopen = True
- EndIf
- EndIf
- While 1
- $nmsg = GUIGetMsg()
- Switch $nmsg
- Case $gui_event_close
- Exit
- Case $gui_button_load
- load()
- Case $gui_button_save
- If FileExists($filename) Then
- If $record = False Then
- $record = True
- Else
- $record = False
- EndIf
- GUICtrlSetData($gui_button_start, "Distance: " & $sensdistance)
- GUICtrlSetData($gui_button_save, "Stop Record")
- record($record)
- EndIf
- Case $gui_button_start
- If FileExists($filename) Then
- GUICtrlSetData($gui_button_start, "Stop")
- If $loop = False Then
- GUICtrlSetData($gui_button_save, "Loop: Off")
- Else
- GUICtrlSetData($gui_button_save, "Loop: On")
- EndIf
- If $premium = 0 Then
- GUICtrlSetState($gui_button_save, $gui_disable)
- EndIf
- EndIf
- startr()
- EndSwitch
- WEnd
- Func move()
- $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- $filehandle = FileOpen($filename)
- $wplist = FileRead($filename)
- $pointliste = _stringbetween($wplist, "|>", @CRLF)
- $imax = UBound($pointliste, 1) - 1
- $iii = 0
- If waypointnearby($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1]) < $imax Then
- $iii = waypointnearby($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1])
- EndIf
- For $i = $iii To $imax
- $point = $i
- $maxpoint = $imax
- If $next = True Then
- $i = waypointnext($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1], $i)
- EndIf
- $wx = _stringbetween($wplist, "<x>", "</x>")
- $wy = _stringbetween($wplist, "<y>", "</y>")
- $wz = _stringbetween($wplist, "<z>", "</z>")
- _waypoint_walk($wx[$i], $wy[$i], $wz[$i])
- $data = GUICtrlRead($gui_log)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Running to waypoint...")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- For $x = 0 To 1000000
- $nmsg = GUIGetMsg()
- Switch $nmsg
- Case $gui_event_close
- Exit
- Case $gui_button_save
- If $loop = False Then
- $loop = True
- GUICtrlSetData($gui_button_save, "Loop: On")
- Else
- $loop = False
- GUICtrlSetData($gui_button_save, "Loop: Off")
- EndIf
- Case $gui_button_start
- GUICtrlSetData($gui_button_start, "Start")
- GUICtrlSetData($gui_button_save, "Record")
- GUICtrlSetState($gui_button_save, $gui_enable)
- Global $loop = False
- $x = 1000000
- $i = $imax
- $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- _waypoint_walk($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1])
- ExitLoop
- EndSwitch
- $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Running...")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- $pstatus = "Running... (" & $point & "/" & $maxpoint & ")"
- GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
- Sleep(100)
- 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
- Sleep(50)
- $x = 1000000
- Else
- $unstuck = _memoryread($mem_clicktomove_go, $openmem, "dword")
- 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
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Unstucking player...")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- $pstatus = "Unstucking player.. (" & $point & "/" & $maxpoint & ")"
- GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
- $data = GUICtrlRead($gui_log)
- $nmsg = GUIGetMsg()
- Switch $nmsg
- Case $gui_button_start
- GUICtrlSetData($gui_button_start, "Start")
- GUICtrlSetData($gui_button_save, "Record")
- GUICtrlSetState($gui_button_save, $gui_enable)
- Global $loop = False
- $x = 1000000
- $i = $imax
- $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- _waypoint_walk($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1])
- ExitLoop
- EndSwitch
- backw()
- $xxx = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $yyy = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $zzz = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- Sleep(900)
- $xx = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $yy = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $zz = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- If getdistance($xx, $yy, $zz, $xxx, $yyy, $zzz) < 2 Then
- right()
- Sleep(500)
- $unstuckleft = getdistance($xx, $yy, $zz, $xxx, $yyy, $zzz)
- backw()
- Sleep(500)
- forw()
- Sleep(500)
- $unstuckright = getdistance($xx, $yy, $zz, $xxx, $yyy, $zzz)
- $nmsg = GUIGetMsg()
- Switch $nmsg
- Case $gui_button_start
- GUICtrlSetData($gui_button_start, "Start")
- GUICtrlSetData($gui_button_save, "Record")
- Global $loop = False
- $x = 1000000
- $i = $imax
- $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- _waypoint_walk($mem_player_current_x[1], $mem_player_current_y[1], $mem_player_current_z[1])
- ExitLoop
- EndSwitch
- If $unstuckright > $unstuckleft Then
- $togelx = 6
- forw()
- Sleep(800)
- left()
- Sleep(600)
- $togelx = 3
- ToolTip("", 0, 0)
- Else
- $togelx = 8
- backw()
- Sleep(1300)
- right()
- Sleep(600)
- $togelx = 3
- ToolTip("", 0, 0)
- EndIf
- EndIf
- _waypoint_walk($wx[$i], $wy[$i], $wz[$i])
- EndIf
- EndIf
- Next
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Running to next waypoint...")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- $pstatus = "Looking for next waypoint... (" & $point & "/" & $maxpoint & ")"
- GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
- Sleep(50)
- Next
- If $loop = True Then move()
- FileClose($filehandle)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Waypoints finished!")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- GUICtrlSetData($gui_button_start, "Start")
- GUICtrlSetData($gui_button_save, "Record")
- $pstatus = "Finished! (" & $point & "/" & $maxpoint & ")"
- GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
- EndFunc
- Func record($record)
- If FileExists($filename) Then
- If $record = True Then
- $data = GUICtrlRead($gui_log)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Recording Started!")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- _addwaypoint()
- $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- While 1
- If $record = True Then
- $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- 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
- _addwaypoint()
- $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- Else
- $nmsg = GUIGetMsg()
- Switch $nmsg
- Case $gui_event_close
- Exit
- Case $gui_button_save
- $record = False
- GUICtrlSetData($gui_button_save, "Record")
- GUICtrlSetData($gui_button_start, "Start")
- record($record)
- Case $gui_button_start
- If $sensdistance = 8 Then
- $sensdistance = 15
- GUICtrlSetData($gui_button_start, "Distance : " & $sensdistance)
- ElseIf $sensdistance = 15 Then
- $sensdistance = 27
- GUICtrlSetData($gui_button_start, "Distance : " & $sensdistance)
- ElseIf $sensdistance = 27 Then
- $sensdistance = 4
- GUICtrlSetData($gui_button_start, "Distance : " & $sensdistance)
- ElseIf $sensdistance = 4 Then
- $sensdistance = 6
- GUICtrlSetData($gui_button_start, "Distance : " & $sensdistance)
- ElseIf $sensdistance = 6 Then
- $sensdistance = 8
- GUICtrlSetData($gui_button_start, "Distance : " & $sensdistance)
- EndIf
- EndSwitch
- EndIf
- Else
- ExitLoop
- EndIf
- WEnd
- Else
- $data = GUICtrlRead($gui_log)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Recording ended!")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- EndIf
- EndIf
- EndFunc
- Func _waypoint_walk($wx, $wy, $wz)
- _memorywrite($mem_clicktomove_go, $openmem, 5, "dword")
- _memorywrite($mem_clicktomove_x, $openmem, $wx, "float")
- _memorywrite($mem_clicktomove_y, $openmem, $wy, "float")
- _memorywrite($mem_clicktomove_z, $openmem, $wz, "float")
- _memorywrite($mem_clicktomove_x, $openmem, $wx, "float")
- EndFunc
- Func load()
- If NOT FileExists($filename) OR $profileopen = True Then
- Global $filename = FileOpenDialog("Select a Waypoint Profile", @ScriptDir & "\", "WaypointProfile (*.ferib;*.txt)", $fd_filemustexist + $fd_multiselect)
- EndIf
- If FileExists($filename) Then
- $data = GUICtrlRead($gui_log)
- $filenameo = _pathsplit($filename, $sdrive, $sdir, $sfilename, $sextension)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Profile: " & $filenameo[3] & " loaded!")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- $pstatus = "Reading profile"
- GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
- $filehandle = FileOpen($filename)
- $filedata = FileRead($filehandle)
- $checkloop = _stringbetween($filedata, "<loop>", "</loop>")
- If UBound($checkloop) Then
- If $checkloop[0] = "true" Then
- Global $loop = True
- EndIf
- EndIf
- $checsensd = _stringbetween($filedata, "<distance>", "</distance>")
- If UBound($checsensd) Then
- $sensdistance = $checsensd[0]
- EndIf
- $checwalk = _stringbetween($filedata, "<walk>", "</walk>")
- If UBound($checwalk) Then
- $walkrange = $checwalk[0]
- EndIf
- $checnext = _stringbetween($filedata, "<next>", "</next>")
- If UBound($checnext) Then
- If $checnext[0] = "true" Then
- $next = True
- EndIf
- EndIf
- FileClose($filehandle)
- Else
- $data = GUICtrlRead($gui_log)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Profile does not exist!")
- $pstatus = "Unknown file"
- GUICtrlSetData($gui_label_r, "Player Status: " & $pstatus)
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- EndIf
- EndFunc
- Func startr()
- If FileExists($filename) Then
- $data = GUICtrlRead($gui_log)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] waypoint profile started!")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- move()
- Else
- $data = GUICtrlRead($gui_log)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Load Profile first")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- EndIf
- EndFunc
- Func stopr()
- EndFunc
- Func _addwaypoint()
- If FileExists($filename) Then
- $mem_player_current_x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- $mem_player_current_y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- $mem_player_current_z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- $data = GUICtrlRead($gui_log)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Waypoint added!")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- $filehandle = FileOpen($filename, 1)
- $filedata = FileRead($filehandle)
- 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)
- FileClose($filehandle)
- Else
- $data = GUICtrlRead($gui_log)
- GUICtrlSetData($gui_log, $data & @CRLF & "[" & _nowtime(5) & "] Load Profile first")
- _guictrledit_linescroll($gui_log, 0, _guictrledit_getlinecount($gui_log))
- EndIf
- EndFunc
- Func _die()
- Exit
- EndFunc
- Func getdistance($x1, $y1, $z1, $x2, $y2, $z2)
- $xf = ($x2 - $x1) * ($x2 - $x1)
- $yf = ($y2 - $y1) * ($y2 - $y1)
- $zf = ($z2 - $z1) * ($z2 - $z1)
- $ff = Sqrt($xf + $yf + $zf)
- Return $ff
- EndFunc
- Func waypointnearby($x, $y, $z)
- Local $distance[0]
- $filehandle = FileOpen($filename)
- $wplist = FileRead($filename)
- $pointliste = _stringbetween($wplist, "|>", @CRLF)
- $jmax = UBound($pointliste, 1) - 1
- For $j = 0 To $jmax
- $wx = _stringbetween($wplist, "<x>", "</x>")
- $wy = _stringbetween($wplist, "<y>", "</y>")
- $wz = _stringbetween($wplist, "<z>", "</z>")
- _arrayadd($distance, getdistance($x, $y, $z, $wx[$j], $wy[$j], $wz[$j]))
- Next
- _arraymin($distance)
- $mindistance = _arraymin($distance)
- $ai = _arraysearch($distance, $mindistance)
- FileClose($filehandle)
- Return $ai
- EndFunc
- Func waypointnext($x, $y, $z, $lastpoint)
- Local $distance[0]
- Local $distance2[0]
- $filehandle = FileOpen($filename)
- $wplist = FileRead($filename)
- $pointliste = _stringbetween($wplist, "|>", @CRLF)
- $jmax = UBound($pointliste, 1) - 1
- For $j = 0 To $jmax
- $wx = _stringbetween($wplist, "<x>", "</x>")
- $wy = _stringbetween($wplist, "<y>", "</y>")
- $wz = _stringbetween($wplist, "<z>", "</z>")
- _arrayadd($distance, getdistance($x, $y, $z, $wx[$j], $wy[$j], $wz[$j]))
- _arrayadd($distance2, getdistance($x, $y, $z, $wx[$j], $wy[$j], $wz[$j]))
- Next
- FileClose($filehandle)
- $ai = _arrayminindex($distance)
- $distance[$ai] = 999999999
- $distance[$lastpoint] = 999999999
- $ai = _arrayminindex($distance)
- ToolTip($ai, 0, 0)
- Return $ai
- EndFunc
- Func forw()
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- Sleep(5)
- If $f[1] >= "0" AND $f[1] <= "1.575" Then
- Global $f11t = "1.575"-$f[1]
- Global $ff11t = "1.575"-$f11t
- Global $ff11 = $ff11t * $togelx
- Global $f11 = $f11t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f11x = $x[1] + $f11
- Global $ff11y = $y[1] + $ff11
- _waypoint_walk($f11x, $ff11y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "1.575" AND $f[1] <= "3.15" Then
- Global $f2t = "3.15"-$f[1]
- Global $ff2t = "1.575"-$f2t
- Global $ff2 = $ff2t * $togelx
- Global $f2 = $f2t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f2x = $x[1] - $ff2
- Global $ff2y = $y[1] + $f2
- _waypoint_walk($f2x, $ff2y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "3.15" AND $f[1] <= "4.725" Then
- Global $f3t = "4.725"-$f[1]
- Global $ff3t = "1.575"-$f3t
- Global $ff3 = $ff3t * $togelx
- Global $f3 = $f3t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f3x = $x[1] - $f3
- Global $ff3y = $y[1] - $ff3
- _waypoint_walk($f3x, $ff3y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "4.725" AND $f[1] <= "6.3" Then
- Global $f4t = "6.3"-$f[1]
- Global $ff4t = "1.575"-$f4t
- Global $ff4 = $ff4t * $togelx
- Global $f4 = $f4t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f4x = $x[1] + $ff4
- Global $ff4y = $y[1] - $f4
- _waypoint_walk($f4x, $ff4y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- EndIf
- EndFunc
- Func backw()
- If $wow = 1 Then
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- Sleep(5)
- If $f[1] >= "0" AND $f[1] <= "1.575" Then
- Global $f11t = "1.575"-$f[1]
- Global $ff11t = "1.575"-$f11t
- Global $ff11 = $ff11t * $togelx
- Global $f11 = $f11t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f11x = $x[1] - $f11
- Global $ff11y = $y[1] - $ff11
- _waypoint_walk($f11x, $ff11y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "1.575" AND $f[1] <= "3.15" Then
- Global $f2t = "3.15"-$f[1]
- Global $ff2t = "1.575"-$f2t
- Global $ff2 = $ff2t * $togelx
- Global $f2 = $f2t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f2x = $x[1] + $ff2
- Global $ff2y = $y[1] - $f2
- _waypoint_walk($f2x, $ff2y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "3.15" AND $f[1] <= "4.725" Then
- Global $f3t = "4.725"-$f[1]
- Global $ff3t = "1.575"-$f3t
- Global $ff3 = $ff3t * $togelx
- Global $f3 = $f3t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f3x = $x[1] + $f3
- Global $ff3y = $y[1] + $ff3
- _waypoint_walk($f3x, $ff3y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "4.725" AND $f[1] <= "6.3" Then
- Global $f4t = "6.3"-$f[1]
- Global $ff4t = "1.575"-$f4t
- Global $ff4 = $ff4t * $togelx
- Global $f4 = $f4t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f4x = $x[1] - $ff4
- Global $ff4y = $y[1] + $f4
- _waypoint_walk($f4x, $ff4y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- EndIf
- EndIf
- EndFunc
- Func left()
- If $wow = 1 Then
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- Sleep(5)
- If $f[1] >= "0" AND $f[1] <= "1.575" Then
- Global $f11t = "1.575"-$f[1]
- Global $ff11t = "1.575"-$f11t
- Global $ff11 = $ff11t * $togelx
- Global $f11 = $f11t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f11x = $x[1] - $ff11
- Global $ff11y = $y[1] + $f11
- _waypoint_walk($f11x, $ff11y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "1.575" AND $f[1] <= "3.15" Then
- Global $f2t = "3.15"-$f[1]
- Global $ff2t = "1.575"-$f2t
- Global $ff2 = $ff2t * $togelx
- Global $f2 = $f2t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f2x = $x[1] - $f2
- Global $ff2y = $y[1] - $ff2
- _waypoint_walk($f2x, $ff2y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "3.15" AND $f[1] <= "4.725" Then
- Global $f3t = "4.725"-$f[1]
- Global $ff3t = "1.575"-$f3t
- Global $ff3 = $ff3t * $togelx
- Global $f3 = $f3t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f3x = $x[1] + $ff3
- Global $ff3y = $y[1] - $f3
- _waypoint_walk($f3x, $ff3y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "4.725" AND $f[1] <= "6.3" Then
- Global $f4t = "6.3"-$f[1]
- Global $ff4t = "1.575"-$f4t
- Global $ff4 = $ff4t * $togelx
- Global $f4 = $f4t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f4x = $x[1] + $f4
- Global $ff4y = $y[1] + $ff4
- _waypoint_walk($f4x, $ff4y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- EndIf
- EndIf
- EndFunc
- Func right()
- If $wow = 1 Then
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $z = _memorypointerread($finaladdrz, $openmem, $offsetz, "float")
- Sleep(5)
- If $f[1] >= "0" AND $f[1] <= "1.575" Then
- Global $f11t = "1.575"-$f[1]
- Global $ff11t = "1.575"-$f11t
- Global $ff11 = $ff11t * $togelx
- Global $f11 = $f11t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f11x = $x[1] + $ff11
- Global $ff11y = $y[1] - $f11
- _waypoint_walk($f11x, $ff11y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "1.575" AND $f[1] <= "3.15" Then
- Global $f2t = "3.15"-$f[1]
- Global $ff2t = "1.575"-$f2t
- Global $ff2 = $ff2t * $togelx
- Global $f2 = $f2t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f2x = $x[1] + $f2
- Global $ff2y = $y[1] + $ff2
- _waypoint_walk($f2x, $ff2y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "3.15" AND $f[1] <= "4.725" Then
- Global $f3t = "4.725"-$f[1]
- Global $ff3t = "1.575"-$f3t
- Global $ff3 = $ff3t * $togelx
- Global $f3 = $f3t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f3x = $x[1] - $ff3
- Global $ff3y = $y[1] + $f3
- _waypoint_walk($f3x, $ff3y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- ElseIf $f[1] >= "4.725" AND $f[1] <= "6.3" Then
- Global $f4t = "6.3"-$f[1]
- Global $ff4t = "1.575"-$f4t
- Global $ff4 = $ff4t * $togelx
- Global $f4 = $f4t * $togelx
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- Global $f4x = $x[1] - $f4
- Global $ff4y = $y[1] - $ff4
- _waypoint_walk($f4x, $ff4y, $z[1])
- Global $f = _memorypointerread($finaladdrf, $openmem, $offsetf, "float")
- Global $x = _memorypointerread($finaladdrx, $openmem, $offsetx, "float")
- Global $y = _memorypointerread($finaladdry, $openmem, $offsety, "float")
- EndIf
- EndIf
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement