Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 03/11/2025 in Posts

  1. I have been creating few controls with round corners for awhile for my own needs and I felt it was time to make an UDF and share it with the community. The idea behind this UDF is to use essentially simple basic AutoIt GUI functions. I did not want to embark in GDI+ to create the controls. I wanted to be easy to use with enough features that it would answer most requirements. The functions contained in the UDF : _RGUI_RoundLabel _RGUI_RoundButton _RGUI_RoundInput _RGUI_RoundEdit _RGUI_RoundGroup _RGUI_RoundScrollBar _RGUI_ScrollBarSet _RGUI_ScrollBarDestroy _RGUI_RoundRect _RGUI_DrawLine _RGUI_ButtonPress _RGUI_ButtonReset Version 2025-04-06 * Solved an issue where scroll bar and control are not in the same GUI child * Added 4th example on how to use scrollbar with ListView over a background generated by GDI+ Version 2025-03-28 * Added support to auto-size label and button controls (by passing -1 for width and/or height) * Removed the requirement to pass handle of the GUI to _RGUI_RoundGroup * Added 3rd example on how to use scrollbar with RichEdit Version 2025-03-21 * Added support of round corner scrollbar * Added a 2nd example on how to use scrollbar with ListBox Version 2025-03-15 * Basic framework for the UDF Here an example of what could be done with the UDF : If you feel there should be new controls, I will consider adding them to the UDF. RoundGUI.zip
    12 points
  2. To test as intended: see read me! file in zip This program is still under development, but feel free to make this code better with suggestions and better code There is an open ticket for a bug in _GUICtrlRichEdit_StreamToFile so the script uses a workaround: https://www.autoitscript.com/trac/autoit/ticket/4038#ticket Wanna take a look at the code? Here you go: #cs name: MiniMark function: a minimalistic editor for custom rtf files version: 4 made by: TheAutomator project: https://www.autoitscript.com/forum/topic/212763-minimark-a-minimalistic-rtf-editor todo: • make user level install possible (requested by argumentum) • allow dropping files to gui • add shortcut to incert and change checkmarks • consider sort lines, remove duplicate lines, remove whitespace button • add file changed indicator • add right click menu on edit • check if programfiles exist when opened • look into embedding images and sounds into compiled exe • make variable names better (autoit rules) bugs in AutoIT rich edit functions: https://www.autoitscript.com/trac/autoit/ticket/4038#ticket https://www.autoitscript.com/trac/autoit/ticket/4040#ticket should be fixed in next version! remarks: to test MiniMark without compilation: • copy "MiniMark.au3" in the "MiniMark" folder and run it (title font will be the default one if you don't install the font) to install and test MiniMark as intended: • compile minimark to exe (with options, the exe will apear in the "MiniMark" folder) • compile setup to exe (with options) • use the setup to install MiniMark • restart computer (if things don't update directly) • rightclick to create a new mnm file • double click it and tadaaaah! hystory: version 1 + added some changes inspired by Werty + code revised + added functionality like opening files with a window, noticed by Argumentum + added sounds version 2 + scrolling is now possible thanks to Pixelsearch + scroll code was revised by Nine + changed some code to prevent a sound to be played twice + added "return $gui_rundefmsg" to "func wm_command" version 3 + made an installer/uninstaller (needs install path choice) + removed unnecessary guictrlcreatedummy code + undo buffer is set to empty when file loaded + added search function with custom gui (work in progress) + added scroll bar (that is buggy AF) version 4 + code revised again + made find and replace work better + better custom scrollbar (based on cursor position in edit) + added "save as" shortcut + added option to silence sounds + added option to save zoom amount (bug -> see ticket) + new search gui + added settings gui + added ini file to save settings + added custom popups in same style as MiniMark + added about button with link to forum + added per-monitor v2 dpi awareness (requires windows 10 creators update or later) + added better way to create controls on the fly (not as many images needed) + added checkmarks + added upper and lower case hotkeys + added incert date and time hotkey #ce #Region au3 #autoit3wrapper_icon=setup\icon.ico #autoit3wrapper_outfile_x64=MiniMark\MiniMark.exe #autoit3wrapper_usex64=y #NoTrayIcon #include <guirichedit.au3> #include <guiconstants.au3> #include <winapisyswin.au3> #include <array.au3> #include <date.au3> #EndRegion au3 #Region MiniMark constants ; colors Const $color_text_white = 0x00ffffff Const $color_text_gray = 0x00c0c0c0 Const $color_element_gray = 0x606060 Const $color_control_gray = 0x404040 Const $color_border_gray = 0x202020 Const $color_text_red = 0x006600ff Const $color_text_green = 0x0000ff66 Const $color_text_blue = 0x00ff6600 Const $color_transparent_background = 0xff00ff ; font names Const $font_handel_gothic_bt = 'handelgothic bt' Const $font_lucida_console = 'lucida console' ; sound effects Const $sound_start = @ScriptDir & '\sounds\start.wav' Const $sound_click = @ScriptDir & '\sounds\click.wav' Const $sound_alert = @ScriptDir & '\sounds\alert.wav' Const $sound_stop = @ScriptDir & '\sounds\stop.wav' ; user interface images Const $image_alert = @ScriptDir & '\images\alert.bmp' Const $image_button = @ScriptDir & '\images\button.bmp' Const $image_MiniMark = @ScriptDir & '\images\MiniMark.bmp' Const $image_scroll = @ScriptDir & '\images\scroll.bmp' Const $image_scroll_down = @ScriptDir & '\images\scroll_down.bmp' Const $image_scroll_up = @ScriptDir & '\images\scroll_up.bmp' Const $image_search = @ScriptDir & '\images\search.bmp' Const $image_settings = @ScriptDir & '\images\settings.bmp' Const $image_size_down = @ScriptDir & '\images\size_down.bmp' Const $image_size_up = @ScriptDir & '\images\size_up.bmp' Const $image_tick_on = @ScriptDir & '\images\tick_on.bmp' Const $image_tick_off = @ScriptDir & '\images\tick_off.bmp' ; files Const $file_intro = @ScriptDir & '\data\MiniMark.mnm' Const $file_settings = @ScriptDir & '\data\settings.ini' #EndRegion MiniMark constants #Region custom gui create functions ; create titles. Func title_create($title, $w) Local $title_handle = GUICtrlCreateLabel($title, 5, 5, $w, 20, BitOR($ss_centerimage, $ss_center), $gui_ws_ex_parentdrag) ; use label to drag form GUICtrlSetFont(Default, 12, 400, 0, $font_handel_gothic_bt) GUICtrlSetColor(Default, $color_text_gray) GUICtrlSetBkColor(Default, $gui_bkcolor_transparent) Return $title_handle EndFunc ;==>title_create ; create buttons. Func button_create($text, $tip, $sub, $x, $y) Local $button_handle = GUICtrlCreatePic($image_button, $x, $y, 70, 20) GUICtrlSetTip(Default, $tip, $sub) Local $button_label = GUICtrlCreateLabel($text, $x, $y, 70, 20, BitOR($ss_centerimage, $ss_center)) GUICtrlSetFont(Default, 9, 400, 0, $font_handel_gothic_bt) GUICtrlSetColor(Default, $color_text_gray) GUICtrlSetBkColor(Default, $gui_bkcolor_transparent) Return $button_handle EndFunc ;==>button_create ; create checkboxes. Func checkbox_create($text, $tip, $sub, $x, $y, $state = 0) Local $checkbox_handle = GUICtrlCreatePic($state ? $image_tick_on : $image_tick_off, $x, $y, 70, 20) GUICtrlSetTip(Default, $tip, $sub) Local $checkbox_label = GUICtrlCreateLabel($text, $x, $y, 50, 20, BitOR($ss_centerimage, $ss_center)) GUICtrlSetFont(Default, 9, 400, 0, $font_handel_gothic_bt) GUICtrlSetColor(Default, $color_text_gray) GUICtrlSetBkColor(Default, $gui_bkcolor_transparent) Return $checkbox_handle EndFunc ;==>checkbox_create ; create inputs (+5 on the left, -5 on the right; so we don't overlap the corners). Func input_create($x, $y, $tip) Local $input_handle = GUICtrlCreateInput('', $x, $y, 210, 20, $es_autohscroll, 0) GUICtrlSetTip(Default, $tip) GUICtrlSetColor(Default, $color_text_gray) GUICtrlSetBkColor(Default, $color_control_gray) GUICtrlSetFont(Default, 12, 400, 0, $font_handel_gothic_bt) Return $input_handle EndFunc ;==>input_create #EndRegion custom gui create functions #Region checkbox messages Func checkbox_toggle($checkbox_handle, ByRef $checkbox_state) play_sound($sound_click) $checkbox_state = $checkbox_state ? 0 : 1 GUICtrlSetImage($checkbox_handle, $checkbox_state ? $image_tick_on : $image_tick_off) EndFunc ;==>checkbox_toggle #EndRegion checkbox messages #Region sound effects $checkbox_sound_state = Int(IniRead($file_settings, 'settings', 'sound', 1)) ; read from ini Func play_sound($name, $wait = 0) If $checkbox_sound_state Then SoundPlay($name, $wait) EndFunc ;==>play_sound #EndRegion sound effects #Region custom msgbox ; alert constants Const $alert_ok = 0 Const $alert_link_close = 1 Const $alert_yes_no_cancel = 2 ; a custom messagebox, used for warnings and notifications Func alert($title = 'Alert', $text = '', $type = $alert_ok) Local $alert_form = GUICreate('Alert', 230, 120, Default, Default, $ws_popup, BitOR($ws_ex_layered, $ws_ex_topmost)) GUISetBkColor($color_transparent_background) Local $alert_background = GUICtrlCreatePic($image_alert, 0, 0, 230, 120) GUICtrlSetState(Default, $gui_disable) Local $alert_title = title_create($title, 220) Local $alert_text = GUICtrlCreateLabel($text, 10, 35, 210, 50, $ss_center) ;, bitor($ss_centerimage, $ss_center, $bs_multiline)) GUICtrlSetFont(Default, 8, 400, 0, $font_handel_gothic_bt) GUICtrlSetColor(Default, $color_text_gray) GUICtrlSetBkColor(Default, $color_control_gray) Local $alert_button_1 = -14, $alert_button_2 = -14, $alert_button_3 = -14 Switch $type Case $alert_ok $alert_button_2 = button_create('Ok', '', Default, 80, 95) Case $alert_link_close $alert_button_1 = button_create('Link', 'Go to the AutoIt forum to check for MiniMark updates.', Default, 5, 95) $alert_button_3 = button_create('Close', '', Default, 155, 95) Case $alert_yes_no_cancel $alert_button_1 = button_create('Yes', '', Default, 5, 95) $alert_button_2 = button_create('No', '', Default, 80, 95) $alert_button_3 = button_create('Cancel', '', Default, 155, 95) EndSwitch _WinAPI_SetLayeredWindowAttributes($alert_form, $color_transparent_background) ; set the transparant gui color GUISetState(@SW_SHOW) play_sound($sound_alert) Local $choice ; to return what button was clicked While 1 Switch GUIGetMsg() Case $gui_event_close $choice = 0 ExitLoop Case $alert_button_1 $choice = 1 ExitLoop Case $alert_button_2 $choice = 2 ExitLoop Case $alert_button_3 $choice = 3 ExitLoop EndSwitch WEnd play_sound($sound_click) GUIDelete($alert_form) Return $choice EndFunc ;==>alert #EndRegion custom msgbox #Region dll calls ; set per-monitor v2 dpi awareness (requires windows 10 creators update or later) dllcall("user32.dll", "bool", "setprocessdpiawarenesscontext", "ptr", -4) #EndRegion dll calls #Region parameters Func get_filename() Local $path_split = StringSplit($cmdline[1], '\', 3) Return StringTrimRight($path_split[UBound($path_split) - 1], 4) EndFunc ;==>get_filename Func wrong_file_extension($path = $cmdline[1]) Return StringRight($path, 4) <> '.mnm' EndFunc ;==>wrong_file_extension Func set_default_file() Global $cmdline = [1, $file_intro] ; overwrite if empty to load default intro file EndFunc ;==>set_default_file If $cmdline[0] = 1 Then If wrong_file_extension() Then alert('Wrong file type!', 'You can only open *.mnm files with this program.', $alert_ok) set_default_file() EndIf Else set_default_file() EndIf #EndRegion parameters #Region MiniMark gui $MiniMark_form = GUICreate('MiniMark', 380, 380, Default, Default, $ws_popup, $ws_ex_layered) GUISetBkColor($color_transparent_background) $MiniMark_background = GUICtrlCreatePic($image_MiniMark, 0, 0, 380, 380) GUICtrlSetState(Default, $gui_disable) $MiniMark_title = title_create(get_filename(), 370) $MiniMark_edit = _GUICtrlRichEdit_Create($MiniMark_form, 'Loading...', 10, 35, 270, 335, BitOR($es_multiline, $es_autovscroll, $es_nohidesel), 0) ; $es_nohidesel for visible selection when using search function _GUICtrlRichEdit_SetBkColor($MiniMark_edit, $color_control_gray) $button_settings = button_create('Options', 'Open settings.', Default, 305, 30) $button_open = button_create('Open', 'Open a new *.mnm file.', 'ctrl + o', 305, 55) $button_bold = button_create('Bold', 'Make selection bold.', 'ctrl + b', 305, 80) $button_italic = button_create('Italic', 'Make selection italic.', 'ctrl + i', 305, 105) $button_struck = button_create('Struck', 'Make selection struck.', 'ctrl + t', 305, 130) $button_underline = button_create('Underline', 'Make selection underlined.', 'ctrl + u', 305, 155) $button_red = button_create('Red', 'Make selection red.', 'shift + ctrl + r', 305, 180) $button_green = button_create('Green', 'Make selection green.', 'shift + ctrl + g', 305, 205) $button_blue = button_create('Blue', 'Make selection blue.', 'shift + ctrl + b', 305, 230) $button_white = button_create('White', 'Make selection white.', 'shift + ctrl + w', 305, 255) $button_default = button_create('Default', 'Make selection default style and gray.', 'shift + ctrl + d', 305, 280) $button_search = button_create('Search', 'Find and replace text.', 'ctrl + f', 305, 305) $button_save = button_create('save', 'Save file / save file as.', 'ctrl + s / shift + ctrl + s', 305, 330) $save_as = GUICtrlCreateDummy() $button_now = GUICtrlCreateDummy() $button_tick = GUICtrlCreateDummy() $button_upper = GUICtrlCreateDummy() $button_lower = GUICtrlCreateDummy() $button_quit = button_create('Quit', 'Quit the program.', 'escape', 305, 355) $MiniMark_scroll_up = GUICtrlCreatePic($image_scroll_up, 290, 30, 10, 10) $MiniMark_scroll_thumb = GUICtrlCreatePic($image_scroll, 290, 45, 10, 20) ; scroll background: 290, 45, 10, 315 $MiniMark_scroll_down = GUICtrlCreatePic($image_scroll_down, 290, 365, 10, 10) _WinAPI_SetLayeredWindowAttributes($MiniMark_form, $color_transparent_background) ;set the transparant gui color GUISetState(@SW_SHOW, $MiniMark_form) play_sound($sound_start) ; play MiniMark startup sound. #EndRegion MiniMark gui #Region edit messages ; we need this becouse the rich edit keeps changing the text to the default style. GUIRegisterMsg($wm_command, wm_command) Func wm_command($hwnd, $imsg, $wparam, $lparam) If $MiniMark_edit <> $lparam Then Return $gui_rundefmsg If _GUICtrlRichEdit_IsTextSelected($MiniMark_edit) Then Return $gui_rundefmsg If _GUICtrlRichEdit_GetFont($MiniMark_edit)[1] <> $font_lucida_console Then _GUICtrlRichEdit_SetFont($MiniMark_edit, 9, $font_lucida_console) _GUICtrlRichEdit_SetCharColor($MiniMark_edit, $color_text_gray) EndIf Return $gui_rundefmsg EndFunc ;==>wm_command ; we need this to make the rich edit scrollable with no $ws_vscroll set (we use a custom scrollbar instead). _GUICtrlRichEdit_SetEventMask($MiniMark_edit, $enm_scrollevents) GUIRegisterMsg($wm_notify, wm_notify) Func wm_notify($hwnd, $imsg, $wparam, $lparam) Local $tfilter = DllStructCreate($tagmsgfilter, $lparam) If $tfilter.hwndfrom = $MiniMark_edit Then _GUICtrlRichEdit_ScrollLines($tfilter.hwndfrom, $tfilter.wparam ? 1 : -1) Return $gui_rundefmsg EndFunc ;==>wm_notify #EndRegion edit messages #Region markup functions ; function that handles text color actions. Func colorize($color) ; if already in selected color -> make default color again play_sound($sound_click) If _GUICtrlRichEdit_GetCharColor($MiniMark_edit) <> $color Then _GUICtrlRichEdit_SetCharColor($MiniMark_edit, $color) Else _GUICtrlRichEdit_SetCharColor($MiniMark_edit, $color_text_gray) EndIf If $color = $color_text_gray Then _GUICtrlRichEdit_SetCharAttributes($MiniMark_edit, '-bo-it-un-st') EndFunc ;==>colorize ; function that handles text style actions. Func stylize($style) ; if already in selected style -> undo style play_sound($sound_click) If StringInStr(_GUICtrlRichEdit_GetCharAttributes($MiniMark_edit), $style & '+') Then _GUICtrlRichEdit_SetCharAttributes($MiniMark_edit, '-' & $style) Else _GUICtrlRichEdit_SetCharAttributes($MiniMark_edit, '+' & $style) EndIf EndFunc ;==>stylize #EndRegion markup functions #Region tools Func change_case($upper) Local $selection = _GUICtrlRichEdit_GetSel($MiniMark_edit) If $selection[0] = $selection[1] Then Return Local $selection_text = _GUICtrlRichEdit_GetSelText($MiniMark_edit) If $upper Then $selection_text = StringUpper($selection_text) Else $selection_text = StringLower($selection_text) EndIf _GUICtrlRichEdit_ReplaceText($MiniMark_edit, $selection_text) _GUICtrlRichEdit_SetSel($MiniMark_edit, $selection[0], $selection[1]) EndFunc Func tickmark() Local $first_char = _GUICtrlRichEdit_GetFirstCharPosOnLine($MiniMark_edit) Local $line_from_char = _GUICtrlRichEdit_GetLineNumberFromCharPos($MiniMark_edit, $first_char) Local $tick_type = StringLeft(_GUICtrlRichEdit_GetTextInLine($MiniMark_edit, $line_from_char), 1) Local $tick_replace Switch $tick_type ; ■□○●• Case '☐' $tick_replace = '☑' Case '☑' $tick_replace = '☐' Case Else _GUICtrlRichEdit_SetSel($MiniMark_edit, $first_char, $first_char) _GUICtrlRichEdit_InsertText($MiniMark_edit, '☐ ') Return endSwitch _GUICtrlRichEdit_SetSel($MiniMark_edit, $first_char, $first_char + 1) _GUICtrlRichEdit_ReplaceText($MiniMark_edit, $tick_replace) EndFunc #EndRegion tools #Region scroller messages ; the scrollbar of hell! ; https://www.autoitscript.com/forum/topic/212778-goto-specific-line-in-rich-edit-control Const $scroll_x = 290 ; x of $scroll control at all times Const $scroll_t = 45, $scroll_m = 295 ; top and maximum Local $scroll_drag = False ; are we dragging the scroll button? Local $scroll_selection ; remember the current selection before we change it Func edit_clicked() Local $scroll_cursor = GUIGetCursorInfo($MiniMark_form) ; get x, y position of cursor If $scroll_cursor[0] >= 5 And $scroll_cursor[0] <= 285 And $scroll_cursor[1] >= 30 And $scroll_cursor[1] <= 375 Then Local $scroll_y Local $scroll_line = _GUICtrlRichEdit_GetLineNumberFromCharPos($MiniMark_edit, _GUICtrlRichEdit_GetSel($MiniMark_edit)[1]) - 1 Local $scroll_last = _GUICtrlRichEdit_GetLineCount($MiniMark_edit) - 1 If $scroll_last = 0 Then $scroll_y = $scroll_t Else $scroll_y = $scroll_t + (($scroll_line / $scroll_last) * $scroll_m) EndIf GUICtrlSetPos($MiniMark_scroll_thumb, $scroll_x, $scroll_y) ; drag scroll button within range of background bar EndIf EndFunc ;==>edit_clicked Func thumb_clicked() Local $scroll_cursor = GUIGetCursorInfo($MiniMark_form) If $scroll_cursor[0] >= 290 And $scroll_cursor[0] <= 300 And $scroll_cursor[1] >= 45 And $scroll_cursor[1] <= 360 Then $scroll_drag = True $scroll_selection = _GUICtrlRichEdit_GetSel($MiniMark_edit) EndIf EndFunc ;==>thumb_clicked Func thumb_motion() If Not $scroll_drag Then Return Local $scroll_x = 290 ; x of $scroll control at all times Local $scroll_min_y = 55, $scroll_max_y = 350 ; range of y movement for $scroll (top of frame till bottom - height) Local $scroll_cursor = GUIGetCursorInfo($MiniMark_form)[1] ; get y position of cursor If $scroll_cursor < $scroll_min_y Then $scroll_cursor = $scroll_min_y If $scroll_cursor > $scroll_max_y Then $scroll_cursor = $scroll_max_y GUICtrlSetPos($MiniMark_scroll_thumb, $scroll_x, $scroll_cursor - 10) ; drag scroll button within range of background bar Local $scroll_ratio = ($scroll_cursor - $scroll_min_y) / ($scroll_max_y - $scroll_min_y) ; calculate scroll position percentage between 0 and 1 Local $scroll_last = _GUICtrlRichEdit_GetLineCount($MiniMark_edit) Local $scroll_calculate = $scroll_ratio * $scroll_last ; calculate where to walk to Local $scroll_line = _GUICtrlRichEdit_GetFirstCharPosOnLine($MiniMark_edit, $scroll_calculate) _GUICtrlRichEdit_SetSel($MiniMark_edit, $scroll_line, $scroll_line) EndFunc ;==>thumb_motion Func thumb_released() If $scroll_drag Then Local $scroll_new_pos = _GUICtrlRichEdit_GetScrollPos($MiniMark_edit) _GUICtrlRichEdit_SetSel($MiniMark_edit, $scroll_selection[0], $scroll_selection[1]) _GUICtrlRichEdit_SetScrollPos($MiniMark_edit, $scroll_new_pos[0], $scroll_new_pos[1]) $scroll_drag = False EndIf EndFunc ;==>thumb_released #EndRegion scroller messages #Region shortcuts ; here we set all the shortcuts for the buttons. Dim $hotkeysaccel[18][2] = [ _ ['+^d', $button_default], _ ['^b', $button_bold], _ ['^i', $button_italic], _ ['^u', $button_underline], _ ['^t', $button_struck], _ ['+^r', $button_red], _ ['+^g', $button_green], _ ['+^b', $button_blue], _ ['+^w', $button_white], _ ['^o', $button_open], _ ['^s', $button_save], _ ['+^s', $save_as], _ ['{f5}', $button_now], _ ['!t', $button_tick], _ ['!u', $button_upper], _ ['!l', $button_lower], _ ['^f', $button_search], _ ['{esc}', $button_quit] _ ] GUISetAccelerators($hotkeysaccel, $MiniMark_form) #EndRegion shortcuts #Region search gui $search_form = GUICreate('Search', 305, 105, Default, Default, $ws_popup, BitOR($ws_ex_layered, $ws_ex_topmost)) GUISetBkColor($color_transparent_background) GUICtrlCreatePic($image_search, 0, 0, 305, 105) GUICtrlSetState(Default, $gui_disable) $search_title = title_create('Find and replace', 295) $input_find = input_create(10, 30, 'What to look for.') $input_replace = input_create(10, 55, 'Replace by what.') $checkbox_case_state = 0 $checkbox_case = checkbox_create('Case', 'Toggle casesence.', Default, 230, 30) $checkbox_word_state = 0 $checkbox_word = checkbox_create('Word', 'Toggle whole word only.', Default, 230, 55) $button_search_find = button_create('Find', 'find string.', Default, 5, 80) $button_search_replace = button_create('Replace', 'Replace current match.', Default, 80, 80) $button_search_replace_all = button_create('Replace all', 'Replace all matches.', Default, 155, 80) $button_search_close = button_create('Close', '', Default, 230, 80) _WinAPI_SetLayeredWindowAttributes($search_form, $color_transparent_background) ;set the transparant gui color #EndRegion search gui #Region search functions Func find() Local $find_text = GUICtrlRead($input_find) If $find_text = '' Then Return play_sound($sound_click) Local $selection = _GUICtrlRichEdit_GetSel($MiniMark_edit) $selection = _GUICtrlRichEdit_FindTextInRange($MiniMark_edit, $find_text, $selection[1], -1, $checkbox_case_state = 1, $checkbox_word_state = 1) If $selection[0] = -1 And $selection[1] = -1 Then alert('Search ended', 'No more matches found.' & @CRLF & 'Next time when you press the [Find] button, the search function will start looking from the beginning of the text.', $alert_ok) _GUICtrlRichEdit_SetSel($MiniMark_edit, 0, 0) Else _GUICtrlRichEdit_SetSel($MiniMark_edit, $selection[0], $selection[1]) EndIf EndFunc ;==>find Func replace() Local $find_text = GUICtrlRead($input_find) If $find_text = '' Then Return play_sound($sound_click) Local $replace_text = GUICtrlRead($input_replace) _GUICtrlRichEdit_ReplaceText($MiniMark_edit, $replace_text) find() EndFunc ;==>replace Func replace_all() Local $find_text = GUICtrlRead($input_find) If $find_text = '' Then Return play_sound($sound_click) Local $replace_text = GUICtrlRead($input_replace) Local $selection = _GUICtrlRichEdit_FindTextInRange($MiniMark_edit, $find_text, 0, -1, $checkbox_case_state = 1, $checkbox_word_state = 1) While $selection[0] > -1 And $selection[1] > -1 _GUICtrlRichEdit_SetSel($MiniMark_edit, $selection[0], $selection[1]) _GUICtrlRichEdit_ReplaceText($MiniMark_edit, $replace_text) $selection = _GUICtrlRichEdit_FindTextInRange($MiniMark_edit, $find_text, $selection[1], -1, $checkbox_case_state = 1, $checkbox_word_state = 1) WEnd alert('Search ended', 'No more matches found.' & @CRLF & 'All matches are replaced (if there were are any).', $alert_ok) EndFunc ;==>replace_all Func find_and_replace() play_sound($sound_click) local $selection_text = _GUICtrlRichEdit_GetSelText($MiniMark_edit) if @error <> -1 then GUICtrlSetData($input_find, $selection_text) GUISetState(@SW_SHOW, $search_form) While 1 Switch GUIGetMsg() Case $gui_event_close, $button_search_close play_sound($sound_click) GUISetState(@SW_HIDE, $search_form) ExitLoop Case $checkbox_case checkbox_toggle($checkbox_case, $checkbox_case_state) Case $checkbox_word checkbox_toggle($checkbox_word, $checkbox_word_state) Case $button_search_find find() Case $button_search_replace replace() Case $button_search_replace_all replace_all() EndSwitch WEnd EndFunc #EndRegion search functions #Region settings $font_size = Int(IniRead($file_settings, 'settings', 'fontsize', 100)) $settings_form = GUICreate('Settings', 230, 80, Default, Default, $ws_popup, BitOR($ws_ex_layered, $ws_ex_topmost)) GUISetBkColor($color_transparent_background) GUICtrlCreatePic($image_settings, 0, 0, 230, 80) GUICtrlSetState(Default, $gui_disable) $settings_title = title_create('Settings', 220) $checkbox_sound = checkbox_create('Sound', 'play sounds?', Default, 5, 30, $checkbox_sound_state) $button_settings_save = button_create('Save', 'Save settings.', Default, 5, 55) $button_settings_info = button_create('Info', 'About MiniMark.', Default, 155, 30) $button_settings_reset = button_create('Reset', 'Reset to default settings.', Default, 80, 55) $button_settings_close = button_create('Close', '', Default, 155, 55) $number_step = GUICtrlCreateInput($font_size, 85, 30, 45, 20, BitOR($es_center, $es_number, $es_autohscroll), 0) GUICtrlSetTip(Default, 'Custom font size (zoom).') GUICtrlSetColor(Default, $color_text_gray) GUICtrlSetBkColor(Default, $color_control_gray) GUICtrlSetFont(Default, 12, 400, 0, $font_handel_gothic_bt) GUICtrlSetLimit(Default, 8) $number_step_up = GUICtrlCreatePic($image_size_up, 130, 30, 20, 10) $number_step_down = GUICtrlCreatePic($image_size_down, 130, 40, 20, 10) _WinAPI_SetLayeredWindowAttributes($settings_form, $color_transparent_background) ;set the transparant gui color #EndRegion settings #Region settings function Func settings() play_sound($sound_click) GUICtrlSetData($number_step, Int(_GUICtrlRichEdit_GetZoom($MiniMark_edit))) GUISetState(@SW_SHOW, $settings_form) While 1 Switch GUIGetMsg() Case $gui_event_close, $button_settings_close play_sound($sound_click) GUISetState(@SW_HIDE, $settings_form) ExitLoop Case $checkbox_sound checkbox_toggle($checkbox_sound, $checkbox_sound_state) Case $number_step_up number_step(1) Case $number_step_down number_step(-1) Case $button_settings_info If alert('About', 'MiniMark version 4.' & @CRLF & 'Created by:' & @CRLF & 'Tom Schrauwen (TheAutomator).', $alert_link_close) = 1 Then ShellExecute('https://www.autoitscript.com/forum/topic/212763-MiniMark-a-minimalistic-rtf-editor') Case $button_settings_reset settings_reset() Case $button_settings_save settings_save() EndSwitch WEnd EndFunc #EndRegion settings function #Region settings messages ; write ini Func number_step($amount) Local $number = GUICtrlRead($number_step) $number += $amount GUICtrlSetData($number_step, $number) play_sound($sound_click) EndFunc ;==>number_step Func settings_reset() If Not $checkbox_sound_state Then checkbox_toggle($checkbox_sound, $checkbox_sound_state) GUICtrlSetData($number_step, 100) play_sound($sound_click) EndFunc ;==>settings_reset Func settings_save() IniWrite($file_settings, 'settings', 'sound', $checkbox_sound_state) IniWrite($file_settings, 'settings', 'fontsize', GUICtrlRead($number_step)) _GUICtrlRichEdit_SetZoom($MiniMark_edit, GUICtrlRead($number_step)) play_sound($sound_click) EndFunc ;==>settings_save #EndRegion settings messages #Region file functions ; if this is not the case, or when there are no arguments, we just open the intro file instead. ; also extract the filename from $cmdline to display as title. Func load_file() ; add fileexists check? GUICtrlSetData($MiniMark_title, get_filename()) GUICtrlSetTip($MiniMark_title, $cmdline[1]) ; display full path on mouse over title _GUICtrlRichEdit_Deselect($MiniMark_edit) _GUICtrlRichEdit_StreamFromFile($MiniMark_edit, $cmdline[1]) _GUICtrlRichEdit_SetZoom($MiniMark_edit, Int($font_size)) ; needed becouse it resets after loading (https://www.autoitscript.com/forum/topic/190695-_guictrlrichedit_setzoom-parameter-limitation) _GUICtrlRichEdit_SetModified($MiniMark_edit, False) _GUICtrlRichEdit_EmptyUndoBuffer($MiniMark_edit) GUICtrlSetPos($MiniMark_scroll_thumb, $scroll_x, 340) ; put scroll button at end EndFunc ;==>load_file load_file() ; load input file ; before opening another file or before quitting, we need to check if the current file is modified. Func save_changes_cancel() ; returns true if we wanna cancel follow up actions If Not _GUICtrlRichEdit_IsModified($MiniMark_edit) Then Return Switch alert('Save changes?', 'This file was modified.' & @CRLF & 'Do you wanna save your work first?', $alert_yes_no_cancel) Case 1 ; yes save_file() Case 2 ; no Return Case Else Return True ; abort next actions EndSwitch EndFunc ;==>save_changes_cancel ; the function that saves the current text to a *.mnm file. ; _guictrlrichedit_streamtofile($edit, $cmdline[1]) -> bug, adds new paragraph every time (see ticket). Func save_file($as = False) ; as triggers a save to dialog If $as Then play_sound($sound_click) Local $new_file = FileSaveDialog('Save MiniMark file...', @DesktopDir, 'MiniMark file (*.mnm)', 16, '', $MiniMark_form) If @error Or wrong_file_extension() Then Return $cmdline[1] = $new_file GUICtrlSetTip($MiniMark_title, $new_file) ; display full path on mouse over title GUICtrlSetData($MiniMark_title, get_filename()) Else If Not _GUICtrlRichEdit_IsModified($MiniMark_edit) Then Return play_sound($sound_click) EndIf _GUICtrlRichEdit_Deselect($MiniMark_edit) Local $var = _GUICtrlRichEdit_StreamToVar($MiniMark_edit) $var = StringTrimRight($var, 9) & "}" ; bug will be resolved in future versions Local $file = FileOpen($cmdline[1], $fo_overwrite) Local $written = FileWrite($file, $var) FileClose($file) If $written = 1 Then ; 0 = failed to write, 1 = succes _GUICtrlRichEdit_SetModified($MiniMark_edit, False) Else alert('File write error!', "Can't save the file..." & @CRLF & 'Check if the file is read only.', $alert_ok) EndIf EndFunc ;==>save_file ; open a file with the open dialog. Func open_file() If save_changes_cancel() Then Return play_sound($sound_click) Local $file = FileOpenDialog('Open new MiniMark file...', @DesktopDir, 'MiniMark file (*.mnm)', 3, '', $MiniMark_form) If @error Or wrong_file_extension() Then Return $cmdline[1] = $file load_file() EndFunc ;==>open_file #EndRegion file functions #Region quit function ; when the program unloads we need to destroy the rich edit control and play the stop sound Func quit() If save_changes_cancel() Then Return play_sound($sound_stop, 1) _GUICtrlRichEdit_Destroy($MiniMark_edit) GUIDelete() Exit EndFunc ;==>quit #EndRegion quit function #Region main loop While 1 Switch GUIGetMsg() Case $gui_event_close, $button_quit quit() Case $button_now _GUICtrlRichEdit_InsertText($MiniMark_edit, _now()) Case $button_tick tickmark() Case $button_upper change_case(True) Case $button_lower change_case(False) Case $MiniMark_scroll_up play_sound($sound_click) _GUICtrlRichEdit_ScrollLines($MiniMark_edit, -1) Case $MiniMark_scroll_down play_sound($sound_click) _GUICtrlRichEdit_ScrollLines($MiniMark_edit, 1) Case $button_open open_file() Case $button_save save_file() Case $save_as save_file(True) Case $button_bold stylize('bo') Case $button_italic stylize('it') Case $button_struck stylize('st') Case $button_underline stylize('un') Case $button_red colorize($color_text_red) Case $button_green colorize($color_text_green) Case $button_blue colorize($color_text_blue) Case $button_white colorize($color_text_white) Case $button_default colorize($color_text_gray) Case $gui_event_primarydown thumb_clicked() Case $gui_event_mousemove thumb_motion() Case $gui_event_primaryup edit_clicked() thumb_released() Case $button_search find_and_replace() Case $button_settings settings() EndSwitch WEnd #EndRegion main loop And here is the code for the installer: SETUP FOR VERSION 4 STILL IN THE MAKING! #cs function: installer for MiniMark version: 3 made by: TheAutomator project: https://www.autoitscript.com/forum/topic/212763-minimark-a-minimalistic-rtf-editor todo: • check if programfiles exist when opened • add choice for install path and user level install • installer does'nt use the "fileinstall" function (yet) #ce #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #autoit3wrapper_icon=setup\setup.ico #autoit3wrapper_outfile=Setup.EXE #autoit3wrapper_compression=4 #autoit3wrapper_useupx=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #NoTrayIcon #RequireAdmin #include <guiconstants.au3> #include <winapisyswin.au3> const $source_path = @ScriptDir & '\minimark' const $setup_path = @ScriptDir & '\setup' const $install_path = @ProgramFilesDir & '\MiniMark' const $install_font = @ScriptDir & '\setup\handelgo.ttf' const $font_lucida = 'lucida console' const $image_background = @scriptdir & '\setup\setup.bmp' const $image_install = @scriptdir & '\setup\install.bmp' const $image_remove = @scriptdir & '\setup\remove.bmp' const $image_exit = @scriptdir & '\minimark\exit.bmp' const $color_gui_transparant = 0xff00ff const $color_edit_background = 0x323232 const $color_edit_gray = 0xb4b4b4 const $color_edit_red = 0xff0066 const $color_edit_green = 0x66ff00 const $sound_start = @scriptdir & '\minimark\start.wav' const $sound_click = @scriptdir & '\minimark\click.wav' const $sound_alert = @scriptdir & '\minimark\alert.wav' const $sound_stop = @scriptdir & '\minimark\stop.wav' local $check_installed = FileExists($install_path) soundplay($sound_start) ; startup sound $form = guicreate('MiniMark Setup', 310, 240, default, default, $ws_popup, $ws_ex_layered) guisetbkcolor($color_gui_transparant) $title = guictrlcreatelabel('', 10, 10, 280, 20, $SS_GRAYRECT, $gui_ws_ex_parentdrag) ; use label to drag form (hidden behind gui image) guictrlcreatepic($image_background, 0, 0, 310, 240) guictrlsetstate(default, $gui_disable) $console = GUICtrlCreateEdit('MiniMark V3 setup' & @CRLF & 'made by: TheAutomator', 20, 50, 270, 140, bitor($es_multiline, $es_autovscroll, $es_readonly), 0) GUICtrlSetColor(Default, $color_edit_gray) GUICtrlSetBkColor(Default, $color_edit_background) GUICtrlSetFont(Default, 9, 0, 0, $font_lucida) $button_install = guictrlcreatepic($check_installed ? $image_remove : $image_install, 10, 210, 50, 20) $button_exit = guictrlcreatepic($image_exit, 250, 210, 50, 20) $escape = guictrlcreatedummy() dim $hotkeysaccel[1][2] = [["{esc}", $escape]] guisetaccelerators($hotkeysaccel) _winapi_setlayeredwindowattributes($form, $color_gui_transparant) ; 0xff00ff is set as the transparant gui color guisetstate() func console($text) GUICtrlSetData($console, @crlf & @crlf & $text, 1) EndFunc console($check_installed ? 'it looks like MiniMark is already installed, press [remove] to uninstall' : 'it looks like MiniMark is not installed yet, press [install] to install it') func install_remove() ; needs admin rights, compiling installer to exe is probably needed... GUICtrlSetColor($console, $color_edit_green) soundplay($sound_click) GUICtrlSetState($button_install, $gui_hide) if $check_installed then ; remove it console('removing MiniMark from:') console($install_path) DirRemove($install_path, 1) console('removing MiniMark menu') RegDelete('HKEY_CLASSES_ROOT\.mnm') RegDelete('HKEY_CLASSES_ROOT\MiniMark') console('removing "handelgothic bt" font') RegDelete('HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', 'HandelGothic BT (TrueType)') ; uninstall font in registery DllCall('gdi32.dll', 'int', 'RemoveFontResource', 'str', @WindowsDir & '\Fonts\handelgo.ttf') ; uninstall font in fonts folder DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', 0xFFFF, 'int', 0x1D, 'int', 0, 'int', 0) ; tell windows about font changes FileDelete(@WindowsDir & '\Fonts\handelgo.ttf') ; delete font in fonts folder $check_installed = FileExists($install_path) if $check_installed Then GUICtrlSetColor($console, $color_edit_red) soundplay($sound_alert) console('MiniMark was not removed correctly...') Else console('MiniMark was uninstalled succesfully!') EndIf Else ; install it console('installing MiniMark to:') console($install_path) DirCopy($source_path, $install_path, 1) ; $fc_overwrite console('installing MiniMark menu') RegWrite('HKEY_CLASSES_ROOT\.mnm', '', 'REG_SZ', 'MiniMark') ; add filetype RegWrite('HKEY_CLASSES_ROOT\.mnm', 'PerceivedType', 'REG_SZ', 'Document') ; tell windows it's a document RegWrite('HKEY_CLASSES_ROOT\.mnm\ShellNew', 'NullFile', 'REG_SZ', '') ; add it to the 'new' file menu RegWrite('HKEY_CLASSES_ROOT\MiniMark', '', 'REG_SZ', 'MiniMark File') ; add edit menu for *.mnm file RegWrite('HKEY_CLASSES_ROOT\MiniMark', 'BrowserFlags', 'REG_DWORD', '00000008') RegWrite('HKEY_CLASSES_ROOT\MiniMark', 'EditFlags', 'REG_DWORD', '00000000') RegWrite('HKEY_CLASSES_ROOT\MiniMark\DefaultIcon', '', 'REG_SZ', $install_path & '\MiniMark.exe,0') ; set icon for *.mnm file RegWrite('HKEY_CLASSES_ROOT\MiniMark\Shell\Open', 'Icon', 'REG_SZ', $install_path & '\MiniMark.exe,0') ; set icon for open menu RegWrite('HKEY_CLASSES_ROOT\MiniMark\Shell\Open\Command', '', 'REG_SZ', $install_path & '\MiniMark.exe "%1"') ; always open with MiniMark console('installing "handelgothic bt" font') FileCopy($install_font, @WindowsDir & '\Fonts\', 1) ; $FC_OVERWRITE (1) = overwrite existing files RegWrite('HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', 'HandelGothic BT (TrueType)', 'REG_SZ', 'handelgo.ttf') ; install font in registery DllCall('gdi32.dll', 'int', 'AddFontResource', 'str', @WindowsDir & '\Fonts\handelgo.ttf') ; install font in fonts folder DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', 0xFFFF, 'int', 0x1D, 'int', 0, 'int', 0) ; tell windows about font changes DllCall('shell32.dll', 'none', 'SHChangeNotify', 'long', 0x08000000, 'uint', 0, 'ptr', 0, 'ptr', 0) ; refresh the icon cache (ie4uinit.exe -show) $check_installed = FileExists($install_path) if $check_installed Then console('MiniMark was installed succesfully!') Else GUICtrlSetColor($console, $color_edit_red) soundplay($sound_alert) console('MiniMark was not installed correctly...') EndIf EndIf guictrlsetimage($button_install, $check_installed ? $image_remove : $image_install) GUICtrlSetState($button_install, $gui_show) EndFunc func quit() soundplay($sound_stop, 1) exit endfunc while 1 switch guigetmsg() case $gui_event_close, $button_exit, $escape quit() case $button_install install_remove() endswitch wend TheAutomator. MiniMark 4 BETA.zip
    7 points
  3. Nine

    Shell Application Bar

    I was wondering how to create an Application Bar that would be recognized by the system. Searching on the forum here revealed that there was a few attempts of doing so but none was successful. So here a working example of how to perform it. Notice how maximized windows are shrunk by the application bar. 😎 #NoTrayIcon ;#AutoIt3Wrapper_UseX64=y #include <GUIConstants.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> #include <TrayConstants.au3> ; #SHAppBarMessage# ============================================================================================================= ; Name ..........: SHAppBarMessage.AU3 ; Description ...: Create an Application Bar recognized by the system ; Author ........: Nine ; Created .......: 2025-04-04 ; Modified ......: ; Remarks .......: ; Example .......: Yes ; =============================================================================================================================== Opt("MustDeclareVars", True) Opt("GUICloseOnESC", False) Opt("TrayMenuMode", 1) Opt("TrayAutoPause", 0) Global Enum $ABM_NEW, $ABM_REMOVE, $ABM_QUERYPOS, $ABM_SETPOS, $ABM_GETSTATE, $ABM_GETTASKBARPOS, $ABM_ACTIVATE, $ABM_GETAUTOHIDEBAR, _ $ABM_SETAUTOHIDEBAR, $ABM_WINDOWPOSCHANGED, $ABM_SETSTATE Global Enum $ABS_ONTOP, $ABS_AUTOHIDE, $ABS_ALWAYSONTOP Global Enum $ABE_LEFT, $ABE_TOP, $ABE_RIGHT, $ABE_BOTTOM Global Enum $ABN_STATECHANGE, $ABN_POSCHANGED, $ABN_FULLSCREENAPP, $ABN_WINDOWARRANGE Global Const $CALLBACK = $WM_USER + 0x10 Global Const $tagAPPBARDATA = "dword cbSize;hwnd hWnd;uint uCallbackMessage;uint uEdge;" & $tagRECT & ";lparam lParam" Global $idDummy Example() Func Example() Local $tAppBarData = DllStructCreate($tagAPPBARDATA) $tAppBarData.cbSize = DllStructGetSize($tAppBarData) Local $hGUI = GUICreate("", 80, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0x202020) GUISetFont(11, 0, 0, "Comic Sans MS") Local $idHide = GUICtrlCreateButton(" Hide", 5, 5, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 200, 0) Local $idTask = GUICtrlCreateButton(" Task", 5, 40, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 16739, 0) Local $idDo = GUICtrlCreateButton(" Do", 5, 75, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 16802, 0) Local $idDont = GUICtrlCreateButton(" Don't", 5, 110, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 240, 0) Local $idExit = GUICtrlCreateButton(" Exit", 5, 300, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 290, 0) $tAppBarData.hWnd = $hGUI $tAppBarData.uCallbackMessage = $CALLBACK DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_NEW, "struct*", $tAppBarData) AppBarSetPos($tAppBarData) GUIRegisterMsg($CALLBACK, AppBarProc) GUISetState() $idDummy = GUICtrlCreateDummy() While True Switch GUIGetMsg() Case $idExit ExitLoop Case $idDummy AppBarSetPos($tAppBarData) Case $idHide GUISetState(@SW_HIDE) DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_REMOVE, "struct*", $tAppBarData) TraySetIcon("shell32.dll", 255) TraySetState($TRAY_ICONSTATE_SHOW) TraySetToolTip("Left click to restore" & @CRLF & "Right click to Exit") Case $idTask ToggleTaskBar() EndSwitch Switch TrayGetMsg() Case $TRAY_EVENT_PRIMARYDOWN GUISetState(@SW_SHOW) DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_NEW, "struct*", $tAppBarData) AppBarSetPos($tAppBarData) TraySetState($TRAY_ICONSTATE_HIDE) Case $TRAY_EVENT_SECONDARYUP Exit EndSwitch WEnd DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_REMOVE, "struct*", $tAppBarData) EndFunc ;==>Example Func AppBarSetPos(ByRef $tAppBar) $tAppBar.uEdge = $ABE_LEFT $tAppBar.left = 0 $tAppBar.top = 0 $tAppBar.Right = 80 $tAppBar.Bottom = @DesktopHeight DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_QUERYPOS, "struct*", $tAppBar) DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_SETPOS, "struct*", $tAppBar) WinMove($tAppBar.hWnd, "", $tAppBar.Left, $tAppBar.Top, $tAppBar.Right, $tAppBar.Bottom) EndFunc ;==>AppBarSetPos Func ToggleTaskBar() Local $tAppBar = DllStructCreate($tagAPPBARDATA) $tAppBar.cbSize = DllStructGetSize($tAppBar) Local $iState = DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_GETSTATE, "struct*", $tAppBar)[0] $tAppBar.lParam = $iState = $ABS_AUTOHIDE ? $ABS_ALWAYSONTOP : $ABS_AUTOHIDE DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_SETSTATE, "struct*", $tAppBar) EndFunc ;==>ToggleTaskBar Func AppBarProc($hWnd, $iMsg, $wParam, $lParam) If $wParam = $ABN_POSCHANGED Then GUICtrlSendToDummy($idDummy, $wParam) Return $GUI_RUNDEFMSG EndFunc ;==>AppBarProc
    7 points
  4. Just uploaded SciTEx86.zip & SciTEx64.zip which contain the Latest SciTE 5.5.6 versions released April 2, 2025, for those that like to use the latest version of SciTE Full. This will also be part of the final update of SciTE4AutoIt3.
    4 points
  5. My apologies for just now getting into the thread, but I thought I had notifications for mentions sent to email, since I only really hit the forums when doing research while developing something or updating the changes for the VSCode extension. @Sven-Seyfert sent me an email that let me know that I was missing stuff, so I'm going through the thread to see what I can add.
    4 points
  6. This is a UDF to use a Listview or Treeview as a File/Folder Explorer. You can also fine the TreeListExplorer UDF on Github. It allows to create a system, where a root folder can be set and that synchronizes all attached Tree or Listviews. So it is possible to attach multiple views to one system. Additionally, it is possible to add an Input Control as a View to show the current folder. When pressing {ENTER}, the system opens the path provided by the input. The following functions are available: ; #CURRENT# ===================================================================================================================== ; __TreeListExplorer_StartUp ; __TreeListExplorer_Shutdown ; __TreeListExplorer_CreateSystem ; __TreeListExplorer_DeleteSystem ; __TreeListExplorer_AddView ; __TreeListExplorer_RemoveView ; __TreeListExplorer_OpenPath ; __TreeListExplorer_Reload ; __TreeListExplorer_GetPath ; __TreeListExplorer_GetRoot ; __TreeListExplorer_GetSelected ; __TreeListExplorer_SetRoot ; =============================================================================================================================== When creating a System, a callback function can be provided to be called, when the root folder or the current folder changes. When adding a View, callback functions for single/double click at an item as well as a loading callback can be added. Example view: The Code for the Example to get a quick overview: If you like it, please leave me a comment, also if you have any suggestions to make it better or if you found bugs. I did a complete rework of this UDF (2025/03/02). Now it is easier to use and does not need external UDFs anymore. This also removes a lot of bugs, that were in the old version. It is also possible to freely select if folders and/or files should be visible in any view. Changelog: Version 1.0.0 (Old Version) Version 2.0.0 (New Version after rework) Version 2.1.0 - Rename $sCallbackOnSelect to $sCallbackOnClick - Add an additional callback $sCallbackOnSelectionChange, that is called whenever the Tree-/ListView item selection changes Version 2.2.0 - Improve loading speed for TreeView folders when expanding Version 2.3.0 - Fix some bugs where folders did not correctly expand/collapse when clicking them (when the root folder is not "" => shows all drives) - Fix some documentation - Add a method for reloading (__TreeListExplorer_Reload) the current folder (ListView/TreeView) or all folders (TreeView) - Remove the reload parameter from the __TreeListExplorer_OpenPath method (Replaced with __TreeListExplorer_Reload). - Other small internal changes Version 2.4.0 - Add the possibility to handle file/folder selections better - Files/Folders keep selected when reloading - The currently selected File/Folder can be checked with __TreeListExplorer_GetSelected - File selection is synchronized between all Tree-/Listviews, Folder selection only between ListViews (TreeView folder selection changes the current folder and expands it) - fixed minor issues Version 2.5.0 - Disabled TreeList expand with a single click and changed it to a double click - Selection is now synchronized for all files/folders between all views (Tree-/ListView) - The Selection callback is now moved from __TreeListExplorer_AddView to __TreeListExplorer_CreateSystem and only fires ones per change for the system and not for every view (as it was before) - All callbacks were changed to pass the selected folder and some additional information is now provided (clicked index/item, the loading path,...) - Small performance improvements - Some internal restructuring Version 2.5.1 - Fixed: selection not working for drives Version 2.6.0 - Added support for icons of all file extensions for TreeViews and ListViews. Version 2.7.0 - Input controls are now possible as a view. They show the current folder and when pressing {ENTER} inside, the system tries to open the path show in the input. - Changed the behavior of the treeview when clicking items. They now change the current folder, but are not expanded. This changes the folder in the ListView, when clicking a folder in the TreeView. Version 2.7.1 - Clicking on the Bitmap of a TreeView item is now registered as a click (not just the text like before) - Fixed a missing selection update when clicking on a TreeView item Version 2.7.2 - Add parameter for setting the (file-/folder-)icon size on startup Version 2.8.0 - TreeView selection is now triggering the select event and the $sSelect corresponds to the selected folder/file. NOTE: __TreeViewExplorer_GetSelected will be empty, if the selection is a folder in a treeview - Selection handling was improved, especially the synchronization between TreeView and ListView - Add keyboard navigation to the listview - Fixed a bug, where the icon index was sent as event (GuIGetMsg), when an item was clicked (happens without the udf message handling, so it needed a workaround: suppress the default autoit handler for mouseclicks) Version 2.8.1 - Fixed a bug, where the select callback was sometimes not send correctly Version 2.9.0 - Fixed bug for TreeViews, where folders were shown as expandable, when having only files but no folders, even if showing files was turned of - rework how treeviews are filled/updated/expanded (folders that are expanded will stay expanded on reload) - add the possibility to set a depth limit for the treeview (Example: Drive selection with $sRoot="" and $iMaxDepth=0) - Fixed bug for Arrow selection in the ListView to not trigger a click event anymore - When the open folder or the selection changed, the TreeView checks, if it still exists (=> treeview updates, if a folder was deleted) Version 2.9.1 - Workaround for a Bug in the GuiTreeView UDF (until it is fixed), causing random control deletions instead of TreeView item deletions Version 2.9.3 - Fixed custom icon size when extracting icons Version 2.9.4 - Improved display quality for some icons (Thanks WildByDesign for the work on that) - Fixed an issue, where cached file icons for individual files were shown as a folder Version 2.9.5 - Improved display quality for some icons (When resource files are defined in the registry, the one with the size greater or equal to the required icon size will be choosen) Version 2.10.0 - Added the possibility to filter ListViews/TreeViews with a callback function. This callbackfunction is called for every file/folder and only if it returns True, will they be added to the view. - Added the possibility to set $bNavigate for ListViews when adding them. This enables or disables the possibility to navigate through folders with doubleclicks in a ListView (and add/removes the ".." folder at the top, which enables the user to navigate to the parent folder) Special thanks to @WildByDesign for a lot of testing to help improving this UDF. TreeListExplorer.au3 TreeListExplorer-Example.au3
    4 points
  7. If you want the text scrolling to continue even when you drag the GUI or even when an MsgBox() is in action, you can use _WinAPI_SetTimer instead of AdlibRegister, as in this slightly modified version of your script. ... But if you don't care, then forget it ... #include <GUIConstants.au3> #include <WinAPISysWin.au3> $guiWidth = 300 $hGUI = GUICreate("Main GUI", $guiWidth, 70) $sString = "This is a long string that scrolls smoothly and infinitely in a short label control." ; Create a child GUI for scrolling label $iMargin = 10 $sGap = " " $iLabelWidth = $guiWidth - $iMargin * 2 $hChildGUI = GUICreate("", $iLabelWidth, 20, 10, 10, $WS_CHILD, -1, $hGUI) GUISetFont(12, 400, 0, "Arial") ; Create a label wide enough to hold a long string without truncation $idLabel = GUICtrlCreateLabel($sString, 0, 0, 2000, 20, BitOR($SS_NOPREFIX, $SS_LEFTNOWORDWRAP)) ; Get the string width $tmpLabel = GUICtrlCreateLabel($sString, 0, 0, -1, 20, BitOR($SS_NOPREFIX, $SS_LEFTNOWORDWRAP)) $iStringWidth = ControlGetPos($hChildGUI, "", $tmpLabel)[2] - 9 ; Label is wider than the string width by 9 pixels GUICtrlDelete($tmpLabel) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hChildGUI) ; Update the label data if the string width is larger than the label width If $iStringWidth > $iLabelWidth Then GUICtrlSetData($idLabel, $sString & $sGap & $sString) $iScrollPos = 0 $iMarquee = 0 $iScrollDelay = 40 ; AdlibRegister("_Marquee", $iScrollDelay) ; -- setup timer-- Local $hTimerProc = DllCallbackRegister('_Marquee', 'none', 'hwnd;uint;uint_ptr;dword') Local $iTimerID = _WinAPI_SetTimer(0, 0, $iScrollDelay, DllCallbackGetPtr($hTimerProc)) ; ---------------- EndIf MsgBox(64, "Info", "text scrolls") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; -- clean timer-- _WinAPI_KillTimer(0, $iTimerID) DllCallbackFree($hTimerProc) ; ---------------- Func _Marquee($hWnd, $iMsg, $iTimerID, $iTime) #forceref $hWnd, $iMsg, $iTimerID, $iTime $iMarquee += 1 If $iMarquee < 3000 / $iScrollDelay Then Return ; 3 seconds of halt when $sString comes to the initial position $iScrollPos -= 1 If - $iScrollPos = $iStringWidth + StringLen($sGap) * 4 Then ; Initialize the $idLabel's position $iMarquee = 0 $iScrollPos = 0 EndIf GUICtrlSetPos($idLabel, $iScrollPos, 0) EndFunc ;==>_Marquee
    4 points
  8. Hey CYCho I realize this doesn't really further our cause, but here's what I've managed to do with XAudio2 for what its worth. XAudio2.zip
    3 points
  9. You are confusing two situations: 1) a string in an UTF8 source file: it will be decoded and stored as UCS2 in memory at runtime, then processed as UTF16-LE by OS primitives. 2) an UTF8 string stored in memory, possibly sent by or to be fed to an external process: this is a string of bytes, not UCS2 encoding units. To be correctly decoded and processed by OS string primitives and rendered, it needs to be converted to UCS2 and then seen as UTF16-LE. Alternatively, if you need to send a native AutoIt string to an external process requiring UTF8 data, then the conversion is applicable. I'm the author of this text in help and I'm not a native english speaker; if you find that some wording needs rework/clarification, just propose.
    3 points
  10. Is there a reason not having shortcuts for Tidy / Au3Stripper? Ctrl+T would interfere with VSCode's object search and I couldn't think of a better one. I didn't see Au3Stripper in the Tools menu for SciTe and I never have used it so I honestly missed/forgot that one. $VARIABLES & @MACROs aren't shown with a different color. Any reason for that or did I miss something? This is based on the VSCode theme's choice of color for variables (variable.other) vs macros (constant.other) from the tmLanguage tags Is there any logic in the extension to fix some of the auto indent quirks, or is everybody just livening with it? (I know all about them having messed with the LUA code for that and still not have it perfect) Do you mean the way that code blocks like If...EndIf indent, or the way that VSCode indents default to 2 spaces vs AutoIt standard being a tab and how that messes with Tidy?
    3 points
  11. WildByDesign, ; System aware DPI awareness DllCall("User32.dll", "bool", "SetProcessDPIAware") ; Per-monitor V2 DPI awareness ;DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -4) I didn't even know that dll call existed before you showed me. Gonna add this to the code for sure, thanks for letting me know! BTW, about the design (spoiler alert), it's getting an update: and you're the first to get to see it :p updated code (and credits to you) coming soon!
    3 points
  12. Hey Nine, yeah, the shuffling stuff around was more me catching up to you - i.e. following and figuring out what was supposed to happen. but looking back at it - this bit seems to be problematic. $tGUID = __COM_CreateGUID($blah, DllStructGetPtr($tGUID)) I'd say we're releasing memory of the "old" struct when we reassign $tGUID. But we're never actually allocating memory for the "new" struct at the old position because we're specifying a ptr in DllStructCreate, also a small gremlin. this was being created as $MF_TOPOLOGY_SOURCESTREAM_NODE. $aCall = DllCall("Mf.dll", "long", "MFCreateTopologyNode", "dword", $MF_TOPOLOGY_OUTPUT_NODE, "ptr*", 0) $pOutputNode = $aCall[2] $oOutputNode = ObjCreateInterface($pOutputNode, $sIID_IMFTopologyNode, $tag_IMFTopologyNode) @argumentum - as my niece would say, "you get what you get and you don't get upset" . Sorry, I don't have an answer for you at this stage mate, but will let you know if we come across anything!
    2 points
  13. Another way : #include <Constants.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> Global Const $WM_NOTIFYICON = $WM_USER + 1 Global Const $sWinTitle = "TrayExample" AutoItWinSetTitle($sWinTitle) Opt("TrayMenuMode", 3) Example() Func Example() Local $idAbout = TrayCreateItem("About") TrayCreateItem("") Local $idExit = TrayCreateItem("Exit") HotKeySet("{F9}", ShowTrayMenu) While True Switch TrayGetMsg() Case $idExit ExitLoop Case $idAbout MsgBox($MB_SYSTEMMODAL, "About", "AutoIt tray menu example." & @CRLF & @CRLF & _ "Version: " & @AutoItVersion & @CRLF & _ "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) EndSwitch WEnd EndFunc ;==>Example Func ShowTrayMenu() _SendMessage(WinGetHandle($sWinTitle), $WM_NOTIFYICON, 0, $WM_LBUTTONDOWN) EndFunc ;==>ShowTrayMenu
    2 points
  14. Ok got the topology working I think... Edit: skipped the IMFMediaEventGenerator step and went straight to playback! #AutoIt3Wrapper_UseX64=N ;test both x86/x64 #include <APIErrorsConstants.au3> #include <StructureConstants.au3> #include <GUIConstants.au3> #include <Array.au3> Opt("MustDeclareVars", True) Local $sTestFile = "c:\users\matt\Desktop\test.mp4" #Region Constants Global Const $S_OK = 0 Global Const $S_FALSE = 1 Global Const $MF_VERSION = 0x00020070 ; 0x00010070 is needed for pre-Win7. Global Enum $MFSTARTUP_FULL, $MFSTARTUP_LITE, $MFSTARTUP_NOSOCKET = $MFSTARTUP_LITE Global Const $MF_RESOLUTION_MEDIASOURCE = 1 Global Enum $MF_OBJECT_MEDIASOURCE, $MF_OBJECT_BYTESTREAM, $MF_OBJECT_INVALID ; MF_TOPOLOGY_TYPE Global Enum $MF_TOPOLOGY_OUTPUT_NODE, _ $MF_TOPOLOGY_SOURCESTREAM_NODE, _ $MF_TOPOLOGY_TRANSFORM_NODE, _ $MF_TOPOLOGY_TEE_NODE, _ $MF_TOPOLOGY_MAX = 0xffffffff ; MFSESSION_SETTOPOLOGY_FLAGS Global Enum $MFSESSION_SETTOPOLOGY_IMMEDIATE = 0x1, _ $MFSESSION_SETTOPOLOGY_NORESOLUTION = 0x2, _ $MFSESSION_SETTOPOLOGY_CLEAR_CURRENT = 0x4 Global Enum $VT_EMPTY = 0, _ $VT_NULL = 1, _ $VT_I2 = 2, _ $VT_I4 = 3, _ $VT_R4 = 4, _ $VT_R8 = 5, _ $VT_CY = 6, _ $VT_DATE = 7, _ $VT_BSTR = 8, _ $VT_DISPATCH = 9, _ $VT_ERROR = 10, _ $VT_BOOL = 11, _ $VT_VARIANT = 12, _ $VT_UNKNOWN = 13, _ $VT_DECIMAL = 14, _ $VT_I1 = 16, _ $VT_UI1 = 17, _ $VT_UI2 = 18, _ $VT_UI4 = 19, _ $VT_I8 = 20, _ $VT_UI8 = 21, _ $VT_INT = 22, _ $VT_UINT = 23, _ $VT_VOID = 24, _ $VT_HRESULT = 25, _ $VT_PTR = 26, _ $VT_SAFEARRAY = 27, _ $VT_CARRAY = 28, _ $VT_USERDEFINED = 29, _ $VT_LPSTR = 30, _ $VT_LPWSTR = 31, _ $VT_RECORD = 36, _ $VT_INT_PTR = 37, _ $VT_UINT_PTR = 38, _ $VT_FILETIME = 64, _ $VT_BLOB = 65, _ $VT_STREAM = 66, _ $VT_STORAGE = 67, _ $VT_STREAMED_OBJECT = 68, _ $VT_STORED_OBJECT = 69, _ $VT_BLOB_OBJECT = 70, _ $VT_CF = 71, _ $VT_CLSID = 72, _ $VT_VERSIONED_STREAM = 73, _ $VT_BSTR_BLOB = 0xfff, _ $VT_VECTOR = 0x1000, _ $VT_ARRAY = 0x2000, _ $VT_BYREF = 0x4000, _ $VT_RESERVED = 0x8000, _ $VT_ILLEGAL = 0xffff, _ $VT_ILLEGALMASKED = 0xfff, _ $VT_TYPEMASK = 0xfff #EndRegion #Region Interface Defs Global Const $sIID_IMFAttributes = "(2cd2d921-c447-44a7-a13c-4adabfc247e3)" Global Const $tag_IMFAttributes = _ "GetItem hresult(struct*; struct*);" & _ "GetItemType hresult(struct*; long*);" & _ "CompareItem hresult(struct*; struct*; bool*);" & _ "Compare hresult(ptr; long; bool*);" & _ "GetUINT32 hresult(struct*; uint*);" & _ "GetUINT64 hresult(struct*; uint64*);" & _ "GetDouble hresult(struct*; double*);" & _ "GetGUID hresult(struct*; struct*);" & _ "GetStringLength hresult(struct*; uint*);" & _ "GetString hresult(struct*; wstr; uint; uint*);" & _ "GetAllocatedString hresult(struct*; wstr*; uint*);" & _ "GetBlobSize hresult(struct*; uint*);" & _ "GetBlob hresult(struct*; struct*; uint; uint*);" & _ "GetAllocatedBlob hresult(struct*; ptr*; uint*);" & _ "GetUnknown hresult(struct*; struct*; ptr*);" & _ "SetItem hresult(struct*; struct*);" & _ "DeleteItem hresult(struct*);" & _ "DeleteAllItems hresult();" & _ "SetUINT32 hresult(struct*; uint);" & _ "SetUINT64 hresult(struct*; uint64);" & _ "SetDouble hresult(struct*; double);" & _ "SetGUID hresult(struct*; struct*);" & _ "SetString hresult(struct*; wstr);" & _ "SetBlob hresult(struct*; struct*; uint);" & _ "SetUnknown hresult(struct*; ptr);" & _ "LockStore hresult();" & _ "UnlockStore hresult();" & _ "GetCount hresult(uint*);" & _ "GetItemByIndex hresult(uint; struct*; struct*);" & _ "CopyAllItems hresult(ptr);" Global Const $sIID_IMFMediaEventGenerator = "(2cd0bd52-bcd5-4b89-b62c-eadc0c031e7d)" Global Const $tag_IMFMediaEventGenerator = _ "GetEvent hresult(long; ptr*);" & _ "BeginGetEvent hresult(ptr; ptr);" & _ "EndGetEvent hresult(ptr; ptr*);" & _ "QueueEvent hresult(uint; struct*; hresult; struct*);" Global Const $sIID_IMFMediaSession = "{90377834-21D0-4dee-8214-BA2E3E6C1127}" Global Const $tag_IMFMediaSession = $tag_IMFMediaEventGenerator & _ "SetTopology hresult(uint; ptr);" & _ "ClearTopologies hresult();" & _ "Start hresult(struct*; struct*);" & _ "Pause hresult();" & _ "Stop hresult();" & _ "Close hresult();" & _ "Shutdown hresult();" & _ "GetClock hresult(ptr*);" & _ "GetSessionCapabilities hresult(uint*);" & _ "GetFullTopology hresult(uint; uint64; ptr*);" Global Const $sIID_IMFMediaSource = "{279a808d-aec7-40c8-9c6b-a6b492c78a66}" Global Const $tag_IMFMediaSource = $tag_IMFMediaEventGenerator & _ "GetCharacteristics hresult(uint*);" & _ "CreatePresentationDescriptor hresult(ptr*);" & _ "Start hresult(ptr; struct*; struct*);" & _ "Stop hresult();" & _ "Pause hresult();" & _ "Shutdown hresult();" Global Const $sIID_IMFSourceResolver = "{FBE5A32D-A497-4b61-BB85-97B1A848A6E3}" Global Const $tag_IMFSourceResolver = _ "CreateObjectFromURL hresult(wstr; uint; ptr; long*; ptr*);" & _ "CreateObjectFromByteStream hresult(ptr; wstr; uint; ptr; long*; ptr*);" & _ "BeginCreateObjectFromURL hresult(wstr; uint; ptr; ptr*; ptr; ptr);" & _ "EndCreateObjectFromURL hresult(ptr; long*; ptr*);" & _ "BeginCreateObjectFromByteStream hresult(ptr; wstr; uint; ptr; ptr*; ptr; ptr);" & _ "EndCreateObjectFromByteStream hresult(ptr; long*; ptr*);" & _ "CancelObjectCreation hresult(ptr);" Global Const $sIID_IMFPresentationDescriptor = "{03cb2711-24d7-4db6-a17f-f3a7a479a536}" Global Const $tag_IMFPresentationDescriptor = $tag_IMFAttributes & _ "GetStreamDescriptorCount hresult(uint*);" & _ "GetStreamDescriptorByIndex hresult(uint; bool*; ptr*);" & _ "SelectStream hresult(uint);" & _ "DeselectStream hresult(uint);" & _ "Clone hresult(ptr*);" Global Const $sIID_IMFTopologyNode = "{83cf873a-f6da-4bc8-823f-bacfd55dc430}" Global Const $tag_IMFTopologyNode = $tag_IMFAttributes & _ "SetObject hresult(ptr);" & _ "GetObject hresult(ptr*);" & _ "GetNodeType hresult(long*);" & _ "GetTopoNodeID hresult(uint64*);" & _ "SetTopoNodeID hresult(uint64);" & _ "GetInputCount hresult(uint*);" & _ "GetOutputCount hresult(uint*);" & _ "ConnectOutput hresult(uint; ptr; uint);" & _ "DisconnectOutput hresult(uint);" & _ "GetInput hresult(uint; ptr*; uint*);" & _ "GetOutput hresult(uint; ptr*; uint*);" & _ "SetOutputPrefType hresult(uint; ptr);" & _ "GetOutputPrefType hresult(uint; ptr*);" & _ "SetInputPrefType hresult(uint; ptr);" & _ "GetInputPrefType hresult(uint; ptr*);" & _ "CloneFrom hresult(ptr);" Global Const $sIID_IMFTopology = "{83cf873a-f6da-4bc8-823f-bacfd55dc433}" Global Const $tag_IMFTopology = $tag_IMFAttributes & _ "GetTopologyID hresult(uint64*);" & _ "AddNode hresult(ptr);" & _ "RemoveNode hresult(ptr);" & _ "GetNodeCount hresult(short*);" & _ "GetNode hresult(short; ptr*);" & _ "Clear hresult();" & _ "CloneFrom hresult(ptr);" & _ "GetNodeByID hresult(uint64; ptr*);" & _ "GetSourceNodeCollection hresult(ptr*);" & _ "GetOutputNodeCollection hresult(ptr*);" Global Const $sIID_IMFStreamDescriptor = "{56c03d9c-9dbb-45f5-ab4b-d80f47c05938}" Global Const $tag_IMFStreamDescriptor = $tag_IMFAttributes & _ "GetStreamIdentifier hresult(uint*);" & _ "GetMediaTypeHandler hresult(ptr*);" Global Const $sIID_IMFMediaTypeHandler = "{e93dcf6c-4b07-4e1e-8123-aa16ed6eadf5}" Global Const $tag_IMFMediaTypeHandler = _ "IsMediaTypeSupported hresult(ptr; ptr*);" & _ "GetMediaTypeCount hresult(uint*);" & _ "GetMediaTypeByIndex hresult(uint; ptr*);" & _ "SetCurrentMediaType hresult(ptr);" & _ "GetCurrentMediaType hresult(ptr*);" & _ "GetMajorType hresult(struct*);" #EndRegion #Region GUIDs Global Const $MF_TOPONODE_ERRORCODE = __COM_CreateGUID("{494bbcee-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_CONNECT_METHOD = __COM_CreateGUID("{494bbcf1-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_LOCKED = __COM_CreateGUID("{494bbcf7-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_WORKQUEUE_ID = __COM_CreateGUID("{494bbcf8-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_WORKQUEUE_MMCSS_CLASS = __COM_CreateGUID("{494bbcf9-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_DECRYPTOR = __COM_CreateGUID("{494bbcfa-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_DISCARDABLE = __COM_CreateGUID("{494bbcfb-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_ERROR_MAJORTYPE = __COM_CreateGUID("{494bbcfd-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_ERROR_SUBTYPE = __COM_CreateGUID("{494bbcfe-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_WORKQUEUE_MMCSS_TASKID = __COM_CreateGUID("{494bbcff-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_MARKIN_HERE = __COM_CreateGUID("{494bbd00-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_MARKOUT_HERE = __COM_CreateGUID("{494bbd01-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_DECODER = __COM_CreateGUID("{494bbd02-b031-4e38-97c4-d5422dd618dc}") Global Const $MF_TOPONODE_MEDIASTART = __COM_CreateGUID("{835c58ea-e075-4bc7-bcba-4de000df9ae6}") Global Const $MF_TOPONODE_MEDIASTOP = __COM_CreateGUID("{835c58eb-e075-4bc7-bcba-4de000df9ae6}") Global Const $MF_TOPONODE_SOURCE = __COM_CreateGUID("{835c58ec-e075-4bc7-bcba-4de000df9ae6}") Global Const $MF_TOPONODE_PRESENTATION_DESCRIPTOR = __COM_CreateGUID("{835c58ed-e075-4bc7-bcba-4de000df9ae6}") Global Const $MF_TOPONODE_STREAM_DESCRIPTOR = __COM_CreateGUID("{835c58ee-e075-4bc7-bcba-4de000df9ae6}") Global Const $MF_TOPONODE_SEQUENCE_ELEMENTID = __COM_CreateGUID("{835c58ef-e075-4bc7-bcba-4de000df9ae6}") Global Const $MF_TOPONODE_TRANSFORM_OBJECTID = __COM_CreateGUID("{88dcc0c9-293e-4e8b-9aeb-0ad64cc016b0}") Global Const $MF_TOPONODE_STREAMID = __COM_CreateGUID("{14932f9b-9087-4bb4-8412-5167145cbe04}") Global Const $MF_TOPONODE_NOSHUTDOWN_ON_REMOVE = __COM_CreateGUID("{14932f9c-9087-4bb4-8412-5167145cbe04}") Global Const $MF_TOPONODE_RATELESS = __COM_CreateGUID("{14932f9d-9087-4bb4-8412-5167145cbe04}") Global Const $MF_TOPONODE_DISABLE_PREROLL = __COM_CreateGUID("{14932f9e-9087-4bb4-8412-5167145cbe04}") Global Const $MF_TOPONODE_PRIMARYOUTPUT = __COM_CreateGUID("{6304ef99-16b2-4ebe-9d67-e4c539b3a259}") Global Const $MFMediaType_Audio = __COM_CreateGUID("{73647561-0000-0010-8000-00aa00389b71}") Global Const $MFMediaType_Binary = __COM_CreateGUID("{72178c25-e45b-11d5-bc2a-00b0d0f3f4ab}") Global Const $MFMediaType_Default = __COM_CreateGUID("{81a412e6-8103-4b06-857f-1862781024ac}") Global Const $MFMediaType_FileTransfer = __COM_CreateGUID("{72178c26-e45b-11d5-bc2a-00b0d0f3f4ab}") Global Const $MFMediaType_HTML = __COM_CreateGUID("{72178c24-e45b-11d5-bc2a-00b0d0f3f4ab}") Global Const $MFMediaType_Image = __COM_CreateGUID("{72178c23-e45b-11d5-bc2a-00b0d0f3f4ab}") Global Const $MFMediaType_MultiplexedFrames = __COM_CreateGUID("{6ea542b0-281f-4231-a464-fe2f5022501c}") Global Const $MFMediaType_Perception = __COM_CreateGUID("{597ff6f9-6ea2-4670-85b4-ea84073fe940}") Global Const $MFMediaType_Protected = __COM_CreateGUID("{7b4b6fe6-9d04-4494-be14-7e0bd076c8e4}") Global Const $MFMediaType_SAMI = __COM_CreateGUID("{e69669a0-3dcd-40cb-9e2e-3708387c0616}") Global Const $MFMediaType_Script = __COM_CreateGUID("{72178c22-e45b-11d5-bc2a-00b0d0f3f4ab}") Global Const $MFMediaType_Stream = __COM_CreateGUID("{e436eb83-524f-11ce-9f53-0020af0ba770}") Global Const $MFMediaType_Subtitle = __COM_CreateGUID("{a6d13581-ed50-4e65-ae08-26065576aacc}") Global Const $MFMediaType_Video = __COM_CreateGUID("{73646976-0000-0010-8000-00aa00389b71}") #Region Local $hResult Local $hWnd = GUICreate("Basic Playback", 800, 600, -1, -1, $WS_OVERLAPPEDWINDOW) _MF_Startup() ;Start Session ConsoleWrite(StringFormat("(%d,0) Start Session", @ScriptLineNumber) & @CRLF) Local $pIMFMediaSession = _MF_CreateMediaSession() Local $oIMFMediaSession = ObjCreateInterface($pIMFMediaSession, $sIID_IMFMediaSession, $tag_IMFMediaSession) ConsoleWrite(StringFormat("(%d,0) $oIMFMediaSession = %s\r\n", @ScriptLineNumber, IsObj($oIMFMediaSession)) & @CRLF) ;Create the media source (using source resolver). ConsoleWrite(StringFormat("(%d,0) Load Source", @ScriptLineNumber) & @CRLF) Local $pIMFSourceResolver = _MF_CreateSourceResolver() Local $oIMFSourceResolver = ObjCreateInterface($pIMFSourceResolver, $sIID_IMFSourceResolver, $tag_IMFSourceResolver) Local $iObjType, $pMediaSource ;OUT Params $hResult = $oIMFSourceResolver.CreateObjectFromURL($sTestFile, $MF_RESOLUTION_MEDIASOURCE, 0, $iObjType, $pMediaSource) Local $oIMFMediaSource = ObjCreateInterface($pMediaSource, $sIID_IMFMediaSource, $tag_IMFMediaSource) ;Get the media source's presentation descriptor. Local $pIMFPresentationDescriptor $hResult = $oIMFMediaSource.CreatePresentationDescriptor($pIMFPresentationDescriptor) Local $oIMFPresentationDescriptor = ObjCreateInterface($pIMFPresentationDescriptor, $sIID_IMFPresentationDescriptor, $tag_IMFPresentationDescriptor) ConsoleWrite(StringFormat("(%d,0) $oIMFPresentationDescriptor = %s\r\n", @ScriptLineNumber, IsObj($oIMFPresentationDescriptor)) & @CRLF) ; Create an empty topology. ConsoleWrite(StringFormat("(%d, 0) Create playback topology", @ScriptLineNumber) & @CRLF) Local $pIMFTopology = _MF_CreateTopology() Local $oIMFTopology = ObjCreateInterface($pIMFTopology, $sIID_IMFTopology, $tag_IMFTopology) ; Use the presentation descriptor to enumerate the stream descriptors. Local $iCount $hResult = $oIMFPresentationDescriptor.GetStreamDescriptorCount($iCount) ConsoleWrite(StringFormat("(%d,0) Steam Count in media: %d", @ScriptLineNumber, $iCount) & @CRLF) Local $pIMFStreamDescriptor, $oIMFStreamDescriptor, $bSelect Local $pSourceNode, $oSourceNode Local $pOutputNode, $oOutputNode Local $pIMFMediaTypeHandler, $oIMFMediaTypeHandler Local $tGUID = __COM_CreateGUID() Local $pIMFActivate ;For each stream descriptor: For $i = 0 To $iCount - 1 ConsoleWrite(StringFormat("\r\n(%d,0) Stream: %d", @ScriptLineNumber, $i) & @CRLF) $hResult = $oIMFPresentationDescriptor.GetStreamDescriptorByIndex($i, $bSelect, $pIMFStreamDescriptor) $oIMFStreamDescriptor = ObjCreateInterface($pIMFStreamDescriptor, $sIID_IMFStreamDescriptor, $tag_IMFStreamDescriptor) ;~ Get the stream's major media type, such as audio or video. ;~ Check if the stream is currently selected. (Optionally, you can select or deselect a stream, based on the media type.) ;~ If the stream is selected, create an activation object for the media sink, based on the stream's media type. ;~ Add a source node for the stream and an output node for the media sink. ;~ Connect the source node to the output node. If $bSelect Then $hResult = $oIMFStreamDescriptor.GetMediaTypeHandler($pIMFMediaTypeHandler) $oIMFMediaTypeHandler = ObjCreateInterface($pIMFMediaTypeHandler, $sIID_IMFMediaTypeHandler, $tag_IMFMediaTypeHandler) $oIMFMediaTypeHandler.GetMajorType($tGUID) Select Case __COM_CompareGUIDs($tGUID, $MFMediaType_Audio) ConsoleWrite(StringFormat("(%d,0) Stream type Audio", @ScriptLineNumber) & @CRLF) $pIMFActivate = _MF_CreateAudioRendererActivate() Case __COM_CompareGUIDs($tGUID, $MFMediaType_Video) ConsoleWrite(StringFormat("(%d,0) Steam Type Video", @ScriptLineNumber) & @CRLF) $pIMFActivate = _MF_CreateVideoRendererActivate($hWnd) Case Else ConsoleWrite(StringFormat("(%d,0) Steam Type: %s", @ScriptLineNumber, __COM_ReadGUIDAt(DllStructGetPtr($tGUID))) & @CRLF) ContinueLoop EndSelect ; Add a source node for this stream. - If Not $hResult Then ... is just for testing. if any thrown an error it will be written to the console. $pSourceNode = _MF_CreateTopologyNode($MF_TOPOLOGY_SOURCESTREAM_NODE) $oSourceNode = ObjCreateInterface($pSourceNode, $sIID_IMFTopologyNode, $tag_IMFTopologyNode) $hResult = $oSourceNode.SetUnknown($MF_TOPONODE_SOURCE, $pMediaSource) If Not $hResult Then $hResult = $oSourceNode.SetUnknown($MF_TOPONODE_PRESENTATION_DESCRIPTOR, $pIMFPresentationDescriptor) If Not $hResult Then $hResult = $oSourceNode.SetUnknown($MF_TOPONODE_STREAM_DESCRIPTOR, $pIMFStreamDescriptor) If Not $hResult Then $hResult = $oIMFTopology.AddNode($pSourceNode) ConsoleWrite(StringFormat("(%d,0) Add SrcNode for strm %d, hr = 0x%08x", @ScriptLineNumber, $i, $hResult) & @CRLF) ; Create the output node for the renderer. $pOutputNode = _MF_CreateTopologyNode($MF_TOPOLOGY_OUTPUT_NODE) $oOutputNode = ObjCreateInterface($pOutputNode, $sIID_IMFTopologyNode, $tag_IMFTopologyNode) $hResult = $oOutputNode.SetObject($pIMFActivate) If Not $hResult Then $hResult = $oIMFTopology.AddNode($pOutputNode) If Not $hResult Then $hResult = $oOutputNode.SetUINT32($MF_TOPONODE_NOSHUTDOWN_ON_REMOVE, True) ;~ If Not $hResult Then $hResult = $oOutputNode.SetUINT32($MF_TOPONODE_STREAMID, 0) ConsoleWrite(StringFormat("(%d,0) Add OutputNode for strm %d, hr = 0x%08x", @ScriptLineNumber, $i, $hResult) & @CRLF) ; Connect the source node to the output node. $hResult = $oSourceNode.ConnectOutput(0, $pOutputNode, 0) ConsoleWrite(StringFormat("(%d,0) Connect Nodes, hr = 0x%08x", @ScriptLineNumber, $hResult) & @CRLF) EndIf Next $hResult = $oIMFMediaSession.SetTopology($MFSESSION_SETTOPOLOGY_IMMEDIATE, $pIMFTopology) ;MF_E_TOPO_MISSING_SOURCE = C00D521A ConsoleWrite(StringFormat("\r\n(%d,0) Set Toplology, hr = 0x%08x\r\n", @ScriptLineNumber, $hResult) & @CRLF) GUISetState(@SW_SHOW, $hWnd) $tGUID = __COM_CreateGUID() Local $tVtPropEmpty = DllStructCreate("align 2;ushort vt;word Pad[3]") DllStructSetData($tVtPropEmpty, "vt", $VT_EMPTY) $hResult = $oIMFMediaSession.Start($tGUID, $tVtPropEmpty) ConsoleWrite(StringFormat("(%d,0) Start, hr = 0x%08x", @ScriptLineNumber, $hResult) & @CRLF) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd $hResult = $oIMFMediaSession.Close() Sleep(1000) $hResult = $oIMFMediaSource.Shutdown() $hResult = $oIMFMediaSession.Shutdown() _MF_Shutdown() ; =============================================================== Func __COM_CreateGUID($sGUID = "{00000000-0000-0000-0000-000000000000}", $pAddress = 0) Local $tGUID = ($pAddress And IsPtr($pAddress)) ? DllStructCreate($tagGUID, $pAddress) : DllStructCreate($tagGUID) Local $aGUID = StringSplit(StringRegExpReplace($sGUID, "[{}]", ""), "-", 2) If UBound($aGUID) <> 5 Then Return SetError($ERROR_INVALID_PARAMETER, 0, False) DllStructSetData($tGUID, 1, Dec($aGUID[0])) DllStructSetData($tGUID, 2, Dec($aGUID[1])) DllStructSetData($tGUID, 3, Dec($aGUID[2])) DllStructSetData($tGUID, 4, Binary("0x" & $aGUID[3] & $aGUID[4])) Return $tGUID EndFunc ;==>__COM_CreateGUID Func __COM_ReadGUIDAt($pGUID) Local $tGUID, $sGUID If (Not $pGUID) Or (Not IsPtr($pGUID)) Then Return SetError($ERROR_INVALID_PARAMETER, 0, "") $tGUID = DllStructCreate($tagGUID, $pGUID) $sGUID = StringFormat("{%s-%s-%s-%s-%s}", _ Hex(DllStructGetData($tGUID, 1), 8), _ Hex(DllStructGetData($tGUID, 2), 4), _ Hex(DllStructGetData($tGUID, 3), 4), _ StringMid(DllStructGetData($tGUID, 4), 3, 4), _ StringMid(DllStructGetData($tGUID, 4), 7, 12)) Return $sGUID EndFunc ;==>__COM_ReadGUIDAt Func __COM_CompareGUIDs($tGUID1, $tGUID2) If DllStructGetSize($tGUID1) < 16 Then Return SetError($ERROR_INVALID_PARAMETER, 0, False) If DllStructGetSize($tGUID2) < 16 Then Return SetError($ERROR_INVALID_PARAMETER, 0, False) Local $tBuff1 = DllStructCreate("byte[16]", DllStructGetPtr($tGUID1)) Local $tBuff2 = DllStructCreate("byte[16]", DllStructGetPtr($tGUID2)) Return DllStructGetData($tBuff1, 1) = DllStructGetData($tBuff2, 1) EndFunc ;Wrapped funcs generally populate @error with hresult. ;So this ensures we have sensible errors if DllCall() fails.. Func __COM_GetDllError($iError = @error) Switch $iError Case 0 $iError = $ERROR_SUCCESS Case 1 $iError = $ERROR_DLL_INIT_FAILED Case Else $iError = $ERROR_INVALID_PARAMETER EndSwitch Return $iError EndFunc Func _MF_CreateMediaSession($pConfig = 0) Local $aCall = DllCall("mf.dll", "long", "MFCreateMediaSession", "ptr", $pConfig, "ptr*", 0) If @error Then Return SetError(__COM_GetDllError(), 0, 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc Func _MF_CreateTopology() Local $aCall = DllCall("mf.dll", "long", "MFCreateTopology", "ptr*", 0) If @error Then Return SetError(__COM_GetDllError(), 0, 0) Return SetError($aCall[0], 0, $aCall[1]) EndFunc Func _MF_CreateTopologyNode($iNodeType) Local $aCall = DllCall("mf.dll", "long", "MFCreateTopologyNode", "long", $iNodeType, "ptr*", 0) If @error Then Return SetError(__COM_GetDllError(), 0, 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc Func _MF_CreateAudioRendererActivate() Local $aCall = DllCall("mf.dll", "long", "MFCreateAudioRendererActivate", "ptr*", 0) If @error Then Return SetError(__COM_GetDllError(), 0, 0) Return SetError($aCall[0], 0, $aCall[1]) EndFunc Func _MF_CreateVideoRendererActivate($hVideo) Local $aCall = DllCall("mf.dll", "long", "MFCreateVideoRendererActivate", "hwnd", $hVideo, "ptr*", 0) If @error Then Return SetError(__COM_GetDllError(), 0, 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc Func _MF_Startup($iFlags = $MFSTARTUP_NOSOCKET) Local $aCall = DllCall("mfplat.dll", "long", "MFStartup", "ulong", $MF_VERSION, "dword", $iFlags) If @error Then Return SetError(__COM_GetDllError(), 0, False) Return SetError($aCall[0], 0, $aCall[0] = $S_OK) EndFunc Func _MF_Shutdown() Local $aCall = DllCall("mfplat.dll", "long", "MFShutdown") If @error Then Return SetError(__COM_GetDllError(), 0, False) Return SetError($aCall[0], 0, $aCall[0] = $S_OK) EndFunc Func _MF_CreateSourceResolver() Local $aCall = DllCall("mfplat.dll", "long", "MFCreateSourceResolver", "ptr*", 0) If @error Then Return SetError(__COM_GetDllError(), 0, False) Return SetError($aCall[0], 0, $aCall[1]) EndFunc
    2 points
  15. @Gianni The reason for the Run-Time Error 0 is related to Visual Basic. Apparently the OCX is build using VB6 and therefor, need the VB runtime MSVBVM60.DLL. There might be depending DLL's or OCX needed like COMDLG32.OCX
    2 points
  16. You were right. Now I succeed to read the content of registers using "[1] " & DllStructGetData($tRegisterData, 1, 1) & @CRLF & _ "[2] " & DllStructGetData($tRegisterData, 1, 2) & @CRLF & _ And now also works Local $RTU_Result = DllCall($hDLL, "int:cdecl", "modbus_set_debug", "ptr", $pRTU_Ptr[0], "int", 1) using an int parameter. Evidently I have been mistaken. I will proceed to test other modbus functions, then I will code some Autoit functions to manage them at the best. Than you very much for your help.
    2 points
  17. @Gianni I installed it in full and ran the test app that comes with it. And all seems to work fine. I have not tested it running the OCX in Au3 yet... when I see some time available I will give it a try
    2 points
  18. On my Forum, I have created a page that lists and distributes MF Codecs created by Microsoft. Look here.
    2 points
  19. Well, you got also my attention on it. It seems very promising, so I started to learn/code about it. I hope you do not mind, but I started a collaboration thread about this. If you should participate, it would be awesome. That way we could get faster and have greater result. Hope to see you there.
    2 points
  20. Zinthose

    Hex Edit Functions

    I needed a way to HexEdit / Patch a file to repair a common file corruption problem in a software package my company uses. I first used the AutoIt core FileOpen / FileWrite functions but this method required me to open the whole file into memory. The files I work with can be several hundred megabytes in size and easily cause out of memory errors. So, After searching / hacking I came up with this solution. I hope someone finds it useful #include <WinAPI.au3> _Demo() Func _Demo() Local Const $TestFile_Path = @ScriptDir & "\Test.Bin" Local $TestFile_ID, $bData, $Offset ;## Hex offsets / lengths of the data stored in the file. Local Const $Offset_Phone[2] = [0x012, 4] Local Const $Offset_NewToy[2] = [0x1b6, 18] Local Const $Offset_Recycle[2] = [0x594, 24] ;## Binary string of the test file. Local Const $TestFile_Data = "0x" & _ "42494E000000000000000000000000000000867530900000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000446F6E27742054617A65206D" & _ "652042726F21000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000536F796C656E742067726565" & _ "6E2069732070656F706C6521000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000" ;## Create Test File $TestFile_ID = FileOpen($TestFile_Path, 14) FileWrite($TestFile_ID, Binary($TestFile_Data)) FileClose($TestFile_ID) ;## Read the Recycle Value $bData = _HexRead($TestFile_Path, $Offset_Recycle[0], $Offset_Recycle[1]) ;## Convert data to a string and display. MsgBox(4096, Default, "Recycle:" & @CRLF & BinaryToString($bData)) ;## Change the recycle value $bData = StringToBinary("It Tastes like chicken!!") _HexWrite($TestFile_Path, $Offset_Recycle[0], $bData) ;## Read the Recycle Value $bData = _HexRead($TestFile_Path, $Offset_Recycle[0], $Offset_Recycle[1]) ;## Convert data to a string and display. MsgBox(4096, Default, "Recycle:" & @CRLF & BinaryToString($bData)) ;## Search for a specific value and display $Offset = _HexSearch($TestFile_Path, $bData) MsgBox(4096, "HexSearch Function", "Search performed to locate data stream: " & @CRLF & @TAB & $bData & @CRLF & "Result = 0x" & Hex($Offset, 3)) EndFunc #Region ;**** HexEdit Functions Func _HexWrite($FilePath, $Offset, $BinaryValue) Local $Buffer, $ptr, $bLen, $fLen, $hFile, $Result, $Written ;## Parameter Checks If Not FileExists($FilePath) Then Return SetError(1, @error, 0) $fLen = FileGetSize($FilePath) If $Offset > $fLen Then Return SetError(2, @error, 0) If Not IsBinary($BinaryValue) Then Return SetError(3, @error, 0) $bLen = BinaryLen($BinaryValue) If $bLen > $Offset + $fLen Then Return SetError(4, @error, 0) ;## Place the supplied binary value into a dll structure. $Buffer = DllStructCreate("byte[" & $bLen & "]") DllStructSetData($Buffer, 1, $BinaryValue) If @error Then Return SetError(5, @error, 0) $ptr = DllStructGetPtr($Buffer) ;## Open File $hFile = _WinAPI_CreateFile($FilePath, 2, 4, 0) If $hFile = 0 Then Return SetError(6, @error, 0) ;## Move file pointer to offset location $Result = _WinAPI_SetFilePointer($hFile, $Offset) $err = @error If $Result = 0xFFFFFFFF Then _WinAPI_CloseHandle($hFile) Return SetError(7, $err, 0) EndIf ;## Write new Value $Result = _WinAPI_WriteFile($hFile, $ptr, $bLen, $Written) $err = @error If Not $Result Then _WinAPI_CloseHandle($hFile) Return SetError(8, $err, 0) EndIf ;## Close File _WinAPI_CloseHandle($hFile) If Not $Result Then Return SetError(9, @error, 0) EndFunc Func _HexRead($FilePath, $Offset, $Length) Local $Buffer, $ptr, $fLen, $hFile, $Result, $Read, $err, $Pos ;## Parameter Checks If Not FileExists($FilePath) Then Return SetError(1, @error, 0) $fLen = FileGetSize($FilePath) If $Offset > $fLen Then Return SetError(2, @error, 0) If $fLen < $Offset + $Length Then Return SetError(3, @error, 0) ;## Define the dll structure to store the data. $Buffer = DllStructCreate("byte[" & $Length & "]") $ptr = DllStructGetPtr($Buffer) ;## Open File $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 0) If $hFile = 0 Then Return SetError(5, @error, 0) ;## Move file pointer to offset location $Pos = $Offset $Result = _WinAPI_SetFilePointer($hFile, $Pos) $err = @error If $Result = 0xFFFFFFFF Then _WinAPI_CloseHandle($hFile) Return SetError(6, $err, 0) EndIf ;## Read from file $Read = 0 $Result = _WinAPI_ReadFile($hFile, $ptr, $Length, $Read) $err = @error If Not $Result Then _WinAPI_CloseHandle($hFile) Return SetError(7, $err, 0) EndIf ;## Close File _WinAPI_CloseHandle($hFile) If Not $Result Then Return SetError(8, @error, 0) ;## Return Data $Result = DllStructGetData($Buffer, 1) Return $Result EndFunc Func _HexSearch($FilePath, $BinaryValue, $StartOffset = Default) Local $Buffer, $ptr, $hFile, $Result, $Read, $SearchValue, $Pos, $BufferSize = 2048 ;## Parameter Defaults If $StartOffset = Default Then $StartOffset = 0 ;## Parameter Checks If Not FileExists($FilePath) Then Return SetError(1, @error, 0) $fLen = FileGetSize($FilePath) If $StartOffset > $fLen Then Return SetError(2, @error, 0) If Not IsBinary($BinaryValue) Then Return SetError(3, @error, 0) If Not IsNumber($StartOffset) Then Return SetError(4, @error, 0) ;## Prep the supplied binary value for search $SearchValue = BinaryToString($BinaryValue) ;## Define the dll structure to store the data. $Buffer = DllStructCreate("byte[" & $BufferSize & "]") $ptr = DllStructGetPtr($Buffer) ;## Open File $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 1) If $hFile = 0 Then Return SetError(5, @error, 0) ;## Move file pointer to offset location $Result = _WinAPI_SetFilePointer($hFile, $StartOffset) $err = @error If $Result = 0xFFFFFFFF Then _WinAPI_CloseHandle($hFile) Return SetError(5, $err, 0) EndIf ;## Track the file pointer's position $Pos = $StartOffset ;## Start Search Loop While True ;## Read from file $Read = 0 $Result = _WinAPI_ReadFile($hFile, $ptr, $BufferSize, $Read) $err = @error If Not $Result Then _WinAPI_CloseHandle($hFile) Return SetError(6, $err, 0) EndIf ;## Prep read data for search $Result = DllStructGetData($Buffer, 1) $Result = BinaryToString($Result) ;## Search the read data for first match $Result = StringInStr($Result, $SearchValue) If $Result > 0 Then ExitLoop ;## Test for EOF and return -1 to signify value was not found If $Read < $BufferSize Then _WinAPI_CloseHandle($hFile) Return -1 EndIf ;## Value not found, Continue Tracking file pointer's position $Pos += $Read WEnd ;## Close File _WinAPI_CloseHandle($hFile) If Not $Result Then Return SetError(7, @error, 0) ;## Calculate the offset and return $Result = $Pos + $Result - 1 Return $Result EndFunc Func _WinAPI_SetFilePointer($hFile, $nDistance, $nMethod = 0) Local $nRet $nRet = DllCall("kernel32.dll", "dword", "SetFilePointer", "ptr", $hFile, "long", $nDistance, "ptr", 0, "dword", $nMethod) Return $nRet[0] EndFunc #EndRegion ** UPDATES ** Added new function: _HexSearch()
    2 points
  21. @TheAutomator there are always good things to learn from @Nine's code, but it takes time to (try to) understand it, because our knowledge of AutoIt/Windows isn't as high as his. I always said he's a great coder ! Nine uses Subclassing a lot, which seems to be the shortest way to accomplish many tasks, which would require much code when not used. For example, with the code below I can mimic a scrollbar (using 4 label controls) without subclassing, by registering WM_COMMAND & WM_NOTIFY, but it requires more code than subclassing : #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <Misc.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hRichEdit, $g_idDummy, $g_idThumb, $g_idUp, $g_idDn, $g_idBack, $g_aBack Global $g_aCheckLine[3] ; [0] = 1st visible line, [1] = last visible line, [2] = total lines Example() Func Example() ; Constants changeable in these 4 lines Local $hGui = GUICreate("Label is Scrollbar", 320, 416) Local $aEdit[4] = [10, 10, 210, 396] ; coords richedit control Local $iGap = 3 ; number of pixels between right border of edit control & vertical scrollbar Local $aUp[4] = [$aEdit[0] + $aEdit[2] + $iGap, $aEdit[1], 15, 20] ; coords Up arrow ; Nothing to change here Dim $g_aBack[4] = [$aUp[0], $aUp[1] + $aUp[3], $aUp[2], $aEdit[3] - $aUp[3] * 2] Local $aDn[4] = [$aUp[0], $aEdit[1] + $aEdit[3] - $aUp[3], $aUp[2], $aUp[3]] Local $sString For $i = 1 To 100 $sString &= @crlf & "Line " & $i Next $sString = StringTrimLeft($sString, 2) ; remove 2 first characters (@cr & @lf) $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, $sString, $aEdit[0], $aEdit[1], $aEdit[2], $aEdit[3], _ BitOR($ES_MULTILINE, $ES_AUTOVSCROLL)) $g_idUp = GUICtrlCreateLabel(Chr(241), $aUp[0], $aUp[1], $aUp[2], $aUp[3], BitOr($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 15, $FW_MEDIUM, $GUI_FONTNORMAL, "Wingdings") GUICtrlSetBkColor(-1, 0xE0DFE3) ; my GUI light grey background $g_idDn = GUICtrlCreateLabel(Chr(242), $aDn[0], $aDn[1], $aDn[2], $aDn[3], BitOr($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 15, $FW_MEDIUM, $GUI_FONTNORMAL, "Wingdings") GUICtrlSetBkColor(-1, 0xE0DFE3) ; my GUI light grey background ;======= create $g_idThumb BEFORE $g_idBack (as they overlap) . $WS_CLIPSIBLINGS style for $g_idBack $g_idThumb = GUICtrlCreateLabel("", $g_aBack[0], $g_aBack[1], 0, 0) GUICtrlSetBkColor(-1, 0xFF0000) ; red $g_idBack = GUICtrlCreateLabel("", $g_aBack[0], $g_aBack[1], $g_aBack[2], $g_aBack[3], $WS_CLIPSIBLINGS) GUICtrlSetBkColor(-1, 0x808080) ; dark grey ;======= $g_idDummy = GUICtrlCreateDummy() Local $idButton = GUICtrlCreateButton("Button", $aUp[0] + $aUp[2] + 10, $aUp[1], 60, 30) _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_SCROLLEVENTS) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW) _GUICtrlRichEdit_SetScrollPos($g_hRichEdit, 0, 0) ; good behavior when placed after GUISetState (in case total lines = total visible + 1) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($g_hRichEdit) GUIDelete($hGUI) Exit Case $g_idDummy ; triggered by WM_COMMAND . Needed to process ALL repeated clicks on labels Local $iDummyVal = GUICtrlRead($g_idDummy) Switch $iDummyVal Case $g_idUp, $g_idDn ; line up / line down _GUICtrlRichEdit_ScrollLines($g_hRichEdit, ($iDummyVal = $g_idUp) ? -1 : 1) Sleep(200) While _IsPressed("01") _GUICtrlRichEdit_ScrollLines($g_hRichEdit, ($iDummyVal = $g_idUp) ? -1 : 1) Sleep(100) WEnd Case $g_idBack ; page up / page down If BitAnd(GUICtrlGetState($g_idThumb), $GUI_SHOW) Then Local $aPosThumb, $iY, $iOpt = Opt("MouseCoordMode", 2) ; 2 = relative to client area While True $aPosThumb = ControlGetPos($hGUI, "", $g_idThumb) $iY = MouseGetPos(1) If $iY < $aPosThumb[1] Then _GUICtrlRichEdit_ScrollLineOrPage($g_hRichEdit, "pu") ElseIf $iY > $aPosThumb[1] + $aPosThumb[3] Then _GUICtrlRichEdit_ScrollLineOrPage($g_hRichEdit, "pd") EndIf Sleep(200) If Not _IsPressed("01") Then ExitLoop WEnd Opt("MouseCoordMode", $iOpt) EndIf EndSwitch Case $g_idThumb ; based on Nine's formula Local $iOpt = Opt("MouseCoordMode", 2) Local $aThumb = ControlGetPos($hGUI, "", $g_idThumb) Local $iTop = $g_aBack[1], $iTop2, $iBottom = $g_aBack[3] - $aThumb[3] Local $iY = MouseGetPos(1), $iY1 = $iY, $iY2, $iDeltaInit = $aThumb[1] - $iY While _IsPressed("01") $iY2 = MouseGetPos(1) If $iY2 <> $iY1 Then $iY2 += $iDeltaInit $iY2 = $iY2 < $iTop ? $iTop : ($iY2 > $iBottom ? $iBottom : $iY2) $iTop2 = _ScrollCalc(($iY2 - $iTop) / ($iBottom - $iTop)) _GUICtrlRichEdit_ScrollLines($g_hRichEdit, $iTop2 - $g_aCheckLine[0]) $iY1 = $iY2 EndIf Sleep(10) WEnd Opt("MouseCoordMode", $iOpt) Case $idButton _ScrollCalc() ; just to display the result of 1st visible line, last visible line, total lines ConsoleWrite("Button pressed " & $g_aCheckLine[0] & " " & $g_aCheckLine[1] & " " & $g_aCheckLine[2] & @crlf) EndSwitch WEnd EndFunc ;==>Example ;=========================================== Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam) If $tMsgFilter.hwndFrom = $g_hRichEdit Then _GUICtrlRichEdit_ScrollLines($g_hRichEdit, $tMsgFilter.wParam ? 1 : -1) Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ;=========================================== Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) If $lParam = $g_hRichEdit Then If BitShift($wParam, 16) = $EN_UPDATE Then ; Hi Word (control notification code) _ScrollUpdate() EndIf Else Local $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word (control ID) Switch $iIDFrom Case $g_idUp, $g_idDn, $g_idBack GUICtrlSendToDummy($g_idDummy, $iIDFrom) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND ;=========================================== Func _ScrollUpdate() _ScrollCalc() If $g_aCheckLine[0] = 1 And $g_aCheckLine[1] = $g_aCheckLine[2] Then GUICtrlSetState($g_idThumb, $GUI_HIDE) Return EndIf Local $fRatio = ($g_aCheckLine[1] - $g_aCheckLine[0] + 1) / $g_aCheckLine[2] Local $iThumbHeight = Int($g_aBack[3] * $fRatio), $iY Select Case $g_aCheckLine[0] = 1 $iY = $g_aBack[1] Case $g_aCheckLine[1] = $g_aCheckLine[2] $iY = $g_aBack[1] + $g_aBack[3] - $iThumbHeight Case Else Local $iTotalHiddenLines = $g_aCheckLine[2] - ($g_aCheckLine[1] - $g_aCheckLine[0] + 1) Local $fRatio2 = ($g_aCheckLine[0] - 1) / $iTotalHiddenLines Local $iYPosThumb = Int(($g_aBack[3] - $iThumbHeight) * $fRatio2) $iY = $g_aBack[1] + $iYPosThumb EndSelect GUICtrlSetPos($g_idThumb, $g_aBack[0], $iY, $g_aBack[2], $iThumbHeight) GUICtrlSetState($g_idThumb, $GUI_SHOW) EndFunc ;==>_ScrollUpdate ;=========================================== Func _ScrollCalc($nPos = 0) Local Static $aRect = _GUICtrlRichEdit_GetRECT($g_hRichEdit) Local $iCharIndex = _GUICtrlRichEdit_GetCharPosFromXY($g_hRichEdit, $aRect[0] + 2, $aRect[3] - 2) $g_aCheckLine[0] = _GUICtrlRichEdit_GetNumberOfFirstVisibleLine($g_hRichEdit) $g_aCheckLine[1] = _GUICtrlRichEdit_GetLineNumberFromCharPos($g_hRichEdit, $iCharIndex) ; last visible line $g_aCheckLine[2] = _GUICtrlRichEdit_GetLineCount($g_hRichEdit) If $nPos Then Local $iShown = $g_aCheckLine[1] - $g_aCheckLine[0] + 1 Local $iTop2 = Int($nPos * ($g_aCheckLine[2] - $iShown)) + 1 Return $iTop2 EndIf EndFunc ;==>_ScrollCalc In this script, the scroll "thumb" (a label control) has a dynamic height, it's not static as in your script (or Nine's) and its height varies with the number of total lines in the richedit control . Also I can click on the "scroll background rectangle" (another label control which overlaps with the thumb control) to scroll 1 page up/down, or on the 2 scrolls arrows (2 other label controls) to scroll 1 line up/down, as in a normal scrollbar. I'm not satisfied with the fact that clicking quickly on the scroll arrows doesn't scroll 1 line up/down each time the user clicks on a scroll arrow. I just discovered why today : clicking quickly twice on a label control doesn't trigger (twice) the corresponding Case in main loop, because it's recognized as a double click on the label control, which should be taken care of in WM_COMMAND as @Melba23 indicates here . This "annoyance" doesn't occur with button controls. [ Note : the preceding "Strikethrough" comment has been fixed in the code by using a Dummy control, triggered by WM_COMMAND and processed in main loop. ] Using Pic controls (as you do) instead of Label controls seem to work , as both are static controls. What is important is the order of creation of the 2 overlapping controls, as found in the script, e.g. the big "scroll bar rectangle" (dark grey in the pic) and the smaller "scroll thumb" (red in the pic) I scripted this only for educational purpose, because simply adding the "WS_SCROLL" style to the richedit control would solve it all, but I understand why you don't want to use WS_SCROLL (you explained it before) Maybe the script above will help you, maybe not, or maybe it will be a good occasion for you to spend some time on Nine's subclassing part & the learning of DllCallbackRegister etc... For example, see in this post how @LarsJ quickly used subclassing to efficiently solve OP's question, amazing ! Good luck Update: April 8th : simplified code in Case $g_idBack
    2 points
  22. Nine

    Shell Application Bar

    Glad you like it
    2 points
  23. KaFu

    Dlib UDF

    Hi @smbape, thanks a lot for this great UDF 😊! Finally a solution I got to work, that can perform face recognition and matching. I used your https://github.com/smbape/node-autoit-dlib-com?tab=readme-ov-file#running-examples guidance to set-up the environment and manually downloaded the two additional dlib-models required. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; Dlib UDF by smbape ; https://www.autoitscript.com/forum/topic/207773-dlib-udf/ ; Dlib Face Recognition example by KaFu ; https://github.com/davisking/dlib/blob/v19.24/python_examples/face_recognition.py #include <Misc.au3> #include "..\autoit-dlib-com\udf\dlib_udf_utils.au3" ; sample - one of the faces from the example gallery picture "2007_007763.jpg" Local $a_128D_Face_Descriptor_of_Face_to_look_for[129] = [128, -0.091833, 0.0675418, 0.00142617, -0.0139504, -0.0903373, -0.0616875, -0.0384285, -0.14486, 0.0820726, -0.0852851, 0.17568, -0.0610356, -0.145164, -0.0266639, -0.0164959, 0.113634, -0.124758, -0.103387, -0.146446, -0.045612, 0.00516588, -9.29451E-05, 0.0863597, 0.0242456, -0.14534, -0.328905, -0.123818, -0.0685623, 0.0621051, 0.00807183, 0.0105838, 0.0424884, -0.254334, -0.118144, 0.0365846, 0.0897826, -0.0123099, -0.0522731, 0.226144, 0.0407339, -0.18469, 0.0978772, 0.049654, 0.260682, 0.230801, -0.0613484, 0.0384872, -0.0580775, 0.070347, -0.190347, 0.0539085, 0.122605, 0.136734, 0.0766652, -0.029859, -0.040169, 0.0905577, 0.16567, -0.184592, 0.0334291, 0.131489, -0.105992, -0.0602567, 0.043018, 0.142796, 0.110119, -0.086098, -0.164362, 0.0712913, -0.101671, -6.08778E-05, 0.0195526, -0.136251, -0.131349, -0.324134, 0.050356, 0.397348, 0.0955416, -0.193875, 0.0465133, -0.143481, 0.0191909, 0.0440991, 0.0355733, -0.0547336, -0.0449448, -0.105943, 0.0979393, 0.154901, -0.0282238, -0.0588183, 0.193323, 0.00501542, -0.0170646, 0.0698614, 0.130419, -0.161941, -0.0505242, -0.109364, -0.042785, 0.10326, -0.0566043, 0.0215982, 0.107899, -0.215276, 0.213152, -0.0453729, -0.00757293, 0.0653693, -0.0408494, -0.0396944, -0.00927441, 0.126415, -0.17009, 0.166003, 0.15904, -0.0532249, 0.13575, 0.138663, 0.0392869, -0.0467882, 0.0669965, -0.15721, -0.0904878, 0.0118087, 0.0483355, 0.100762, 0.0341779] _Dlib_Open(_Dlib_FindDLL("opencv_world4100*"), _Dlib_FindDLL("autoit_dlib_com-*-4100*")) OnAutoItExitRegister("_OnAutoItExit") Func _OnAutoItExit() _Dlib_Close() EndFunc ;==>_OnAutoItExit Local Const $o_Dlib = _Dlib_get() If Not IsObj($o_Dlib) Then Exit 356 Local $s_Data_Path_Predictor = @ScriptDir & "\data\shape_predictor_5_face_landmarks.dat" ; https://github.com/davisking/dlib-models/raw/master/shape_predictor_5_face_landmarks.dat.bz2 Local $s_Data_Path_Face_Rec_Model = @ScriptDir & "\data\dlib_face_recognition_resnet_model_v1.dat" ; https://github.com/davisking/dlib-models/raw/master/dlib_face_recognition_resnet_model_v1.dat.bz2 ; Load all the models we need: a detector to find the faces, a shape predictor to find face landmarks so we can precisely localize the face, and finally the face recognition model. Local $o_Dlib_Frontal_Face_Detector = $o_Dlib.get_frontal_face_detector() Local $o_Dlib_Shape_Predictor = _Dlib_ObjCreate("shape_predictor").create($s_Data_Path_Predictor) Local $o_Dlib_Face_Rec_Model = _Dlib_ObjCreate("face_recognition_model_v1").create($s_Data_Path_Face_Rec_Model) ; For display of results only, not required for the operation itself Local $o_Dlib_Window = _Dlib_ObjCreate("image_window") Local $a_All_Files_found_to_process = _Dlib_FindFiles("*.jpg", @ScriptDir & "\faces\") ; Now process all the images For $s_Current_File_to_process In $a_All_Files_found_to_process $s_Current_File_to_process = @ScriptDir & "\faces\" & "\" & $s_Current_File_to_process ConsoleWrite(@CRLF & "Processing file: " & $s_Current_File_to_process & @CRLF) $o_Dlib_Image = $o_Dlib.load_rgb_image($s_Current_File_to_process) $o_Dlib_Window.clear_overlay() $o_Dlib_Window.set_title($s_Current_File_to_process) $o_Dlib_Window.set_image($o_Dlib_Image) ; Ask the detector to find the bounding boxes of each face. ; The 1 in the second argument indicates that we should upsample the image 1 time. This will make everything bigger and allow us to detect more faces. ; The third argument to run is an optional adjustment to the detection threshold, where a negative value will return more detections and a positive value fewer. $a_Detected_Faces_Rect = $o_Dlib_Frontal_Face_Detector($o_Dlib_Image, 1, 0) ; $a_Detected_Faces_Rect = $o_Dlib.extended[0] ; same result ConsoleWrite("Number of faces detected in image: " & UBound($a_Detected_Faces_Rect) & @CRLF) ; You can ask the detector to tell you the score for each detection. The score is bigger for more confident detections. $a_Detected_Faces_Confidence_Scores = $o_Dlib.extended[1] ; The idx tells you which of the face sub-detectors matched. This can be used to broadly identify faces in different orientations. $a_Detected_Faces_Matching_Filter_idx = $o_Dlib.extended[2] ; https://github.com/davisking/dlib/blob/master/dlib/image_processing/frontal_face_detector.h ; 1 = front looking ; 2 = left looking ; 3 = right looking ; 4 = front looking but rotated left ; 5 = front looking but rotated right #cs ; Show an overlay of all detected faces in preview window $o_Dlib_All_Rectangles_of_all_detected_Faces = _Dlib_ObjCreate("VectorOfRectangle") For $i_Detected_Faces_Enum = 0 To UBound($a_Detected_Faces_Rect) - 1 $o_Dlib_All_Rectangles_of_all_detected_Faces.Add($a_Detected_Faces_Rect[$i_Detected_Faces_Enum]) Next $o_Dlib_Window.add_overlay($o_Dlib_All_Rectangles_of_all_Faces) #ce ; Now process each face we found. For $i_Detected_Faces_Enum = 0 To UBound($a_Detected_Faces_Rect) - 1 $t_Detected_Face_Rectangle = $a_Detected_Faces_Rect[$i_Detected_Faces_Enum] ConsoleWrite("+ Face #" & $i_Detected_Faces_Enum + 1 & @TAB & @TAB) ConsoleWrite(StringFormat("Left: %d, Top: %d, Right: %d, Bottom: %d", $t_Detected_Face_Rectangle.left(), $t_Detected_Face_Rectangle.top(), $t_Detected_Face_Rectangle.right(), $t_Detected_Face_Rectangle.bottom()) & @CRLF) ConsoleWrite("Confidence score = " & $a_Detected_Faces_Confidence_Scores[$i_Detected_Faces_Enum] & @TAB & @CRLF) ConsoleWrite("Matching filter = " & $a_Detected_Faces_Matching_Filter_idx[$i_Detected_Faces_Enum] & @CRLF) ; Get the landmarks/parts for the face in box $t_Detected_Face_Rectangle $o_Detected_Face_Landmarks_Shape = $o_Dlib_Shape_Predictor($o_Dlib_Image, $t_Detected_Face_Rectangle) ; ; Get the landmarks/parts for the face ConsoleWrite(StringFormat("Landmark 0: %s, Landmark 1: %s ...", $o_Detected_Face_Landmarks_Shape.part(0).ToString(), $o_Detected_Face_Landmarks_Shape.part(1).ToString()) & @CRLF) ; Draw the face landmarks on the screen so we can see what face is currently being processed. $o_Dlib_Window.clear_overlay() $o_Dlib_Window.add_overlay($t_Detected_Face_Rectangle) $o_Dlib_Window.add_overlay($o_Detected_Face_Landmarks_Shape) ; Compute the 128D vector that describes the face in img identified by shape. ; It should also be noted that you can also call this function like this: ; face_descriptor = facerec.compute_face_descriptor(img, shape, 100, 0.25) ; The version of the call without the 100 gets 99.13% accuracy on LFW while the version with 100 gets 99.38%. However, the 100 makes the call 100x slower to execute, so choose whatever version you like. To explain a little, the 3rd argument tells the code how many times to ; jitter/resample the image. When you set it to 100 it executes the face descriptor extraction 100 times on slightly modified versions of the face and returns the average result. You could also pick a more middle value, such as 10, which is only 10x slower but still gets an ; LFW accuracy of 99.3%. 4th value (0.25) is padding around the face. If padding == 0 then the chip will be closely cropped around the face. Setting larger padding values will result a looser cropping. In particular, a padding of 0.5 would double the width of the cropped area, a value of ; would triple it, and so forth. There is another overload of compute_face_descriptor that can take as an input an aligned image. ConsoleWrite("Computing 128D face description vector..." & @CRLF) $o_Detected_Face_Descriptor = $o_Dlib_Face_Rec_Model.compute_face_descriptor($o_Dlib_Image, $o_Detected_Face_Landmarks_Shape) ; $o_Detected_Face_Descriptor = $o_Dlib_Face_Rec_Model.compute_face_descriptor($o_Dlib_Image, $o_Detected_Face_Landmarks_Shape, 4, 1) ConsoleWrite("$o_Detected_Face_Descriptor.ToString() = " & @TAB & @TAB & @TAB & StringReplace($o_Detected_Face_Descriptor.ToString(), @LF, ",") & @CRLF) ; It is important to generate the aligned image as dlib.get_face_chip would do it i.e. the size must be 150x150, centered and scaled. ConsoleWrite("Computing description on aligned image..." & @CRLF) ; Let's generate the aligned image using get_face_chip $o_Detected_Face_Chip_Aligned_Image = $o_Dlib.get_face_chip($o_Dlib_Image, $o_Detected_Face_Landmarks_Shape) ; https://dlib.net/python/#dlib_pybind11.get_face_chip #cs ; Show 5 jittered images without data augmentation Local $a_Jittered_Images = $o_Dlib.jitter_image($o_Detected_Face_Chip_Aligned_Image, 5) show_jittered_images($o_Dlib_Window, $a_Jittered_Images) ; Show 5 jittered images with data augmentation $a_Jittered_Images = $o_Dlib.jitter_image($o_Detected_Face_Chip_Aligned_Image, 5, True) show_jittered_images($o_Dlib_Window, $a_Jittered_Images) #ce ; Now we simply pass this chip (aligned image) to the api $o_Detected_Face_Descriptor_from_prealigned_image = $o_Dlib_Face_Rec_Model.compute_face_descriptor($o_Detected_Face_Chip_Aligned_Image) ConsoleWrite("$o_Detected_Face_Descriptor_from_prealigned_image.ToString() = " & @TAB & StringReplace($o_Detected_Face_Descriptor_from_prealigned_image.ToString(), @LF, ",") & @CRLF) $a_Detected_Face_Descriptor_128D = StringSplit($o_Detected_Face_Descriptor_from_prealigned_image.ToString(), @LF) If Not IsArray($a_128D_Face_Descriptor_of_Face_to_look_for) Then ; if no target has been set yet, use the first face found as pattern for the search If UBound($a_Detected_Face_Descriptor_128D) = 129 Then $a_128D_Face_Descriptor_of_Face_to_look_for = $a_Detected_Face_Descriptor_128D #cs ; manually create 128D target descriptor $s_128D_Face_Descriptor_of_Face_to_look_for = "$a_128D_Face_Descriptor_of_Face_to_look_for[129] = [128" For $i = 1 To 128 $s_128D_Face_Descriptor_of_Face_to_look_for &= "," & $a_128D_Face_Descriptor_of_Face_to_look_for[$i] Next $s_128D_Face_Descriptor_of_Face_to_look_for &= "]" ConsoleWrite($s_128D_Face_Descriptor_of_Face_to_look_for & @CRLF) #ce ContinueLoop 2 Else ContinueLoop ; Descriptor not valid EndIf EndIf $i_128D_Euclidean_Distance = _Euclidean_Distance_of_128D_Vectors($a_Detected_Face_Descriptor_128D, $a_128D_Face_Descriptor_of_Face_to_look_for) If $i_128D_Euclidean_Distance <= 0.5 Then ; Possible match ConsoleWrite("+ Possible MATCH, Euclidean Distance = " & @TAB & $i_128D_Euclidean_Distance & @CRLF) MsgBox(32, "Dlib Face Recognition result - Possible MATCH", "Possible Face MATCH found" & @CRLF & @CRLF _ & "Euclidean Distance to Face to look for = " & $i_128D_Euclidean_Distance _ & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF _ & "In general, if two face descriptor vectors have a Euclidean distance between them less than 0.6 then they are from the same person, otherwise they are from different people." & @CRLF & @CRLF _ & "KaFu: I found 0.5 to be more accurate, more testing required") Else ; No match ConsoleWrite("- Face does not seem to match, Euclidean Distance = " & @TAB & $i_128D_Euclidean_Distance & @CRLF) MsgBox(48, "Dlib Face Recognition result - Not matching", "Face does not seem to match" & @CRLF & @CRLF _ & "Euclidean Distance to Face to look for = " & $i_128D_Euclidean_Distance _ & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF _ & "In general, if two face descriptor vectors have a Euclidean distance between them less than 0.6 then they are from the same person, otherwise they are from different people." & @CRLF & @CRLF _ & "KaFu: I found 0.5 to be more accurate, more testing required") EndIf Next Next Func _Euclidean_Distance_of_128D_Vectors($a_Vector_1, $a_Vector_2) If UBound($a_Vector_1) <> 129 Then Return SetError(1, 0, -1) ; 1-based 128 array required If UBound($a_Vector_2) <> 129 Then Return SetError(2, 0, -1) ; https://en.wikipedia.org/wiki/Euclidean_distance Local $i_Euclidean_Distance_of_128D_Vectors For $i = 1 To 128 $i_Euclidean_Distance_of_128D_Vectors += ($a_Vector_1[$i] - $a_Vector_2[$i]) ^ 2 ; ConsoleWrite("_Euclidean_Distance_of_128D_Vectors = " & $i & @TAB & $i_128D_Vector_Euclidean_Distance & @TAB & $a_Vector_1[$i] & @TAB & $a_Vector_2[$i] & @CRLF) Next Return Sqrt($i_Euclidean_Distance_of_128D_Vectors) EndFunc ;==>_Euclidean_Distance_of_128D_Vectors Func show_jittered_images($window, $jittered_images) ; Shows the specified jittered images one by one For $i = 0 To UBound($jittered_images) - 1 Local $img = $jittered_images[$i] $window.set_image($img) MsgBox(0, "show_jittered_images", "jittered image " & $i & ": ") Next EndFunc ;==>show_jittered_images Currently the dll is compiled for 64bit, maybe you could provide a 32bit version too? Your effort is much appreciated 👍!
    2 points
  24. I'm not sure we can unfortunately Looks like I was wrong about audiograph being able to attach directly to player object. I had my classes mixed up.. Audiograph will take a mediasource object as an input, which is very different from a mediaelement. with MediaPlayer, its possible to load audio effects via the IMediaPlayerEffects interface - but it looks like you might have to build them from scratch as well! https://learn.microsoft.com/en-us/answers/questions/1280085/how-can-i-add-equalizer-effect-to-the-mediaplayer The doco is a bit light there though, so that requires a bit more digging to confirm. I'm still planning to check out some of the other stuff too. just might need a few more days.
    2 points
  25. * User SciTE info: * SCITE_USERHOME:C:\Users\Tester\AppData\Local\AutoIt v3\SciTE: * SciTEUSer.Properties: *----------------------------------------------------------------------------------------- ... ... indent.size=3 indent.size.*.au3=3 tabsize=3 ... ... change those 3 values ( in the SciTEUSer.Properties file ) to match your desire value, to the same value, and it behaves as it should. "use.tabs=1" because, that's for the tabs ?, unless you would like spaces ?, but running tidy will turn it into tabs. What @Jos said: "Just a wild guess" is right on the money. ...thinking on my feet here, ...I've never changed the defaults on SciTE and I don't see a situation where someone would do different than me but, some people do @HezzelQuartz, Tabs is what I use and to make tabs look 3 or 4 spaces long, those 3 values work fine if, using tabs. If the desire is to use spaces, then you'll run into tidy not doing that, because it uses tabs. That is my experience with v4.4.6 PS: I figure that all you care about is the line not matching the indentation and that is corrected as described above. PS2: and the user options file can be easily open by clicking the SciTE menu:
    2 points
  26. I liked it and still do. I'd add yet another like if I could, for the clarification on the relevant version
    2 points
  27. No problems CYCho, thanks for the ego boost I'm not sure if we can do Video at this point with AudioGraph. You may be able to tie to a mediaelement object that supports video - but rendering the picture requires working out XAML islands, and that is where I got stuck last time. It might also be possible to feed the input from an external source via frames, so that probably warrants investigation too. Another interesting point - the EQ looks to be related to a non-winRT XAudio2 object. So I reckon this is definitely worth looking at. The EQ looks to be an APO too, which could be relevant as @PeterVerbeek has already done a ton of work in that space! Just ask if anything is unclear with how to approach the WinRT stuff too - I realize parts are probably a bit opaque! I've included the calltips installer to help out - I recommend installing those while having a play around. Also, I'd recommend downloading and compiling the Class Explorer. That one helps decipher what exactly is expected/produced by different objects, and what interfaces are attached etc. EQDemo.zip
    2 points
  28. @argumentum I deleted my initial post : what I suggested works for older Scite versions, it won't work for OP's Scite version 4.4.6 (just tested) . So please feel free to remove your like, sorry for the inconvenience. For the record, what I suggested was to add, not only the line "indent.size=4" but also the following line in the file SciTEUser.properties (I got both lines in my properties) : indent.size.*.au3=4 On older Scite versions, without this line, indentation of au3 scripts is 3 : On older Scite versions, with this line, indentation of au3 scripts is 4 : But it doesn't seem to work with Scite 4.4.6 @HezzelQuartz Could you try Scite menu => Options => Use Monospaced Font Who knows, maybe it will solve your indentation issue ?
    2 points
  29. Skinning the cat makes it ugly. 😉 _WinAPI_SetLayeredWindowAttributes($hGUI_Child, 0x123456, 0x60) makes the child GUI transparent, too.
    2 points
  30. Another way to skin the cat : #include <WinAPISysWin.au3> #include <GUIConstants.au3> Global $hGUI = GUICreate("Parent", 350, 300, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_COMPOSITED)) GUISetBkColor(0xC0FFEE) Global $idTime = GUICtrlCreateLabel("", 0, 0, 350, 100, $SS_CENTER + $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG) GUICtrlSetColor(-1, 0xA0) GUICtrlSetFont(-1, 60, 800) GUISetState() _WinAPI_SetLayeredWindowAttributes($hGUI, 0xC0FFEE) Global $hGUI2 = GUICreate("Child", 100, 30, 125, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) Global $idButton = GUICtrlCreateButton("Test", 0, 0, 100, 30) WinSetTrans($hGUI2, "", 120) GUISetState() ShowTime() AdlibRegister(ShowTime, 1000) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton ConsoleWrite("button was pressed" & @CRLF) EndSwitch WEnd Func ShowTime() GUICtrlSetData($idTime, @HOUR & ":" & @MIN & ":" & @SEC) EndFunc ;==>_ShowTime And make the button partially transparent...
    2 points
  31. Hey, thanks a lot for all the work you put into testing this and helping to find good ways to solve the problems. This UDF would have never been as good as it is now without you
    2 points
  32. It may be the largest function in your UDF, but you figured out a more logical and more efficient way of obtaining the sharpest icons than Microsoft has done. I lost some hours of sleep just trying to make sense of it. I still don't fully understand much of the Appx/UWP stuff. It's such a mess. This is absolutely brilliant, by the way. It makes perfect sense and the best solution for DPI scaling. Coding for DPI scaling is not fun. Anyway, I have tested 2.9.5 thoroughly and I have no issues. The icons are all sharp under all of the different scaling factors that I have tested. You did an awesome job making sense out of this icon retrieving madness. Cheers!
    2 points
  33. Am famous so I hide my identity just like Clark Kent but it should not matter. In my case I hide my identity by removing the reading glasses
    2 points
  34. For those who need an AU3-only solution for decoding entities: HTMLentities.au3
    2 points
  35. I did not use Github, because I didn't think it would get that many changes, to be honest I did some commits with some versions I still had as BackUp and added everything to Github (link in the main post). So you can see at least most of the Versions differences
    2 points
  36. Things are going well at home, daughter isn't home with me yet, but in the process (I am allowed visitations at my discretion!). I've been extremely busy with jumping through hoops for the department of child safety, but I'm nearly done with a big chunk of tasks around the house, when completed I'll have some more free time to work on projects. Taking a bit longer than I had hoped for (the things around the house) but its coming along, I actually ended up turning my dining room into another makeshift bedroom, which meant I had to rearrange everything else around the house to make it work lol, but good progress and allowed me to do a deep spring cleaning of the house. 😎 Project updates will be coming! Been itching to get some coding done.
    2 points
  37. @WildByDesign Thanks again, thats a bug I overlooked when changing to many things at once 😅 Line 1669: From: __TreeListExplorer__GetPathAndLast(__TreeListExplorer__GetCurrentPath($iSystem)) To: __TreeListExplorer__GetPathAndLast(__TreeListExplorer__GetCurrentPath($iSystem) & __TreeListExplorer__GetSelected($iSystem)) So it is fixed in v2.8.1 Depending on treeviewChangesfunc(), you may want to add a check, if the folder/selection changed. If it did not change you should not have to do anything. This may prevent unnessesary calls => better performance Assuming $newItem still contains the old item from the last call ( see what I did there? 😋 ), you can simply do this: Func _selectCallback($hSystem, $sRoot, $sFolder, $sSelected) Local $sNewPath = $sRoot&$sFolder&$sSelected If $newItem<>$sNewPath Then $newItem = $sRoot&$sFolder&$sSelected $displaySelected = $sSelected treeviewChangesfunc() EndIf EndFunc I would also an encourage you to try not to use global variables (or as few as possible). That makes the code a lot easier to understand, without having to keep all the global variables in the back of your head and to remember where they change... I would also take a look at the notation, to now, how to name variables: https://www.autoitscript.com/autoit3/docs/intro/lang_variables.htm#VariableNaming An example how that would look like for the short example you provided (with some comments): ConsoleWrite(@crlf & @crlf & "-------------------" & @crlf) _selectCallback(1, "C:\Users\", "Default", "desktop.ini") _selectCallback(1, "C:\Users\", "Default", "desktop.ini") _selectCallback(1, "C:\Users\", "Default", "tmp.txt") _selectCallback(1, "C:\Users\", "Default", "tmp.txt") _selectCallback(1, "C:\Users\", "Default", "desktop.ini") ConsoleWrite("-------------------" & @crlf & @crlf) Func _selectCallback($hSystem, $sRoot, $sFolder, $sSelected) Local Static $sOldPath = -1 ; Static makes a variable "global", but only available in this function Local $sNewPath = $sRoot&$sFolder&$sSelected ; combine to path ConsoleWrite(@TAB&"Select: "&$sOldPath&" >> "&$sNewPath&@crlf) If $sOldPath<>$sNewPath Then ; check if the path changed $sOldPath = $sNewPath ; save the path to be available for the next call of this function _OnTreeViewChange($sNewPath, $sSelected) EndIf EndFunc Func _onTreeViewChange($sPath, $sSelected) ; your old treeviewChangesfunc ConsoleWrite("TreeView change: "&$sPath&" Selected: "&$sSelected&@crlf) EndFunc
    2 points
  38. UPDATE: code cleanup added minimalistic sci-fi sounds better text on buttons and they have labels now better shortcuts open and save buttons now work as intended helpfile got an update code can be tested when not compiled removed a bug Enjoy and let me know what you think PS: If anyone knows how to make the edit scroll up / down when I use the mouse to scroll, let me know. I looked at this topic, but have no clue what to make of the code:
    2 points
  39. This concept was used in my zPlayer to display long file names in a short label control. #include <GUIConstants.au3> $guiWidth = 300 $hGUI = GUICreate("Main GUI", $guiWidth, 70) $sString = "This is a long string that scrolls smoothly and infinitely in a short label control." ; Create a child GUI for scrolling label $iMargin = 10 $sGap = " " $iLabelWidth = $guiWidth - $iMargin * 2 $hChildGUI = GUICreate("", $iLabelWidth, 20, 10, 10, $WS_CHILD, -1, $hGUI) GUISetFont(12, 400, 0, "Arial") ; Create a label wide enough to hold a long string without truncation $idLabel = GUICtrlCreateLabel($sString, 0, 0, 2000, 20, BitOR($SS_NOPREFIX, $SS_LEFTNOWORDWRAP)) ; Get the string width $tmpLabel = GUICtrlCreateLabel($sString, 0, 0, -1, 20, BitOR($SS_NOPREFIX, $SS_LEFTNOWORDWRAP)) $iStringWidth = ControlGetPos($hChildGUI, "", $tmpLabel)[2] - 9 ; Label is wider than the string width by 9 pixels GUICtrlDelete($tmpLabel) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hChildGUI) ; Update the label data if the string width is larger than the label width If $iStringWidth > $iLabelWidth Then GUICtrlSetData($idLabel, $sString & $sGap & $sString) $iScrollPos = 0 $iMarquee = 0 $iScrollDelay = 40 AdlibRegister("_Marquee", $iScrollDelay) EndIf Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _Marquee() $iMarquee += 1 If $iMarquee < 3000/$iScrollDelay Then Return ; 3 seconds of halt when $sString comes to the initial position $iScrollPos -= 1 If -$iScrollPos = $iStringWidth + StringLen($sGap) * 4 Then ; Initialize the $idLabel's position $iMarquee = 0 $iScrollPos = 0 EndIf GUICtrlSetPos($idLabel, $iScrollPos, 0) EndFunc
    2 points
  40. FYI, I tested on other computers. Older computer reacts correctly as it should be expected. Faster (more recent) computer behave exactly as I am experiencing. So this is not related to my own computer. It seems to be another of those timing issues with AutoIt. Sadly not the first, not the last... For those who face the same problem as I have, here a simple solution : #include <GUIConstants.au3> #include <Constants.au3> Example() Func Example() Local $hGUI = GUICreate("Main GUI", 300, 70) GUISetState() Sleep(100) Local $hGUI2 = GUICreate("", 280, 30, 10, 10, $WS_CHILD, -1, $hGUI) GUISetFont(11) Local $idLabel = GUICtrlCreateLabel("This is a test", 0, 0, 100, 30) GUISetState() MsgBox($MB_OK, "", "Test") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example Slow down the creation of child GUI by putting a Sleep in between. It is working on all computers correctly now.
    2 points
  41. Understand what you mean now. Here a new version with no flickers. It uses a similar approach of yours. #include <GUIConstants.au3> Local $hGUI = GUICreate("Main GUI", 300, 70) Local $sString = "This is a long string that scrolls smoothly and infinitely without flickers..." GUISetState() Global $iLen = StringLen($sString) * 6.5 ; <<<<< adjust as needed or use M23 UDF StringSize for more precision Local $hGUI2 = GUICreate("", 280, 30, 10, 10, $WS_CHILD, $WS_EX_COMPOSITED, $hGUI) GUISetFont(11) Global $idLabel1 = GUICtrlCreateLabel($sString, 0, 0, $iLen, 30, $SS_LEFTNOWORDWRAP) Global $idLabel2 = GUICtrlCreateLabel($sString, $iLen, 0, $iLen, 30, $SS_LEFTNOWORDWRAP) GUISetState() AdlibRegister(Scroll, 25) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func Scroll() Local Static $iPos = 0 $iPos -= 1 If -$iPos >= $iLen Then $iPos = 0 GUICtrlSetPos($idLabel1, $iPos) GUICtrlSetPos($idLabel2, $iLen + $iPos) EndFunc
    2 points
  42. Nice mate. its possible to reduce the flicker a bit by double buffering. So hope you don't mind - but here's another approach #include <GUIConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> Global $iGUIWidth = 300 Global $hGUI = GUICreate("Main GUI", $iGUIWidth, 70) Global $sString = "This is a long string that scrolls smoothly and infinitely in a short label control." Global $iLabW = $iGUIWidth - 8, $iLabH = 30 ;The border style is here to mark the label boundry - for demo purposes! Global $hLabel = GUICtrlCreateLabel("", 4, 4, $iGUIWidth - 8, $iLabH, $WS_BORDER) GUISetState() Global $hLabGraphic, $hBuffGraphic, $hBuffBitMap Global $hBrush, $hFormat, $tLayout, $hFamily, $hFont, $iBkColour _GDIPlus_Startup() ;Graphic of the static control - its possible to draw directly to this, but we'll introduce flicker. $hLabGraphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($hLabel)) ;Create Buffer - Draw to this. Copy to the label once the image is complete. $hBuffBitMap = _GDIPlus_BitmapCreateFromGraphics($iLabW, $iLabH, $hLabGraphic) $hBuffGraphic = _GDIPlus_ImageGetGraphicsContext($hBuffBitMap) ;Create font etc.. $hBrush = _GDIPlus_BrushCreateSolid(0xFFAA0000) ;ARGB $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 12, 3) ;Size, Italic + Bold $iBkColour = BitOR(0xFF000000, _WinAPI_GetSysColor($COLOR_3DFACE)) ;dialog background colour. ; ----- Find dims of the text. --------- Global $iMargin = 4 $tLayout = _GDIPlus_RectFCreate($iMargin, 0, 1, 1) ;Text rectangle. Margin of 4 from left Local $aStrMeasure[4] ;Expand height until we can fit 2 lines ;Sanity checks are required here! This'll break if there's < 2 printable characters in the string. Do $tLayout.Height += 1 $aStrMeasure = _GDIPlus_GraphicsMeasureString($hLabGraphic, $sString, $hFont, $tLayout, $hFormat) Until $aStrMeasure[2] = 2 $tLayout.Height -= 1 ; Gets us the max height of 1 line. ;Expand width until we can fit the entire string. Do $tLayout.Width += 1 $aStrMeasure = _GDIPlus_GraphicsMeasureString($hLabGraphic, $sString, $hFont, $tLayout, $hFormat) Until $aStrMeasure[1] = StringLen($sString) ;Center vertically in the label $tLayout.Y = Floor(($iLabH - $tLayout.Height)/2) ConsoleWrite(StringFormat("text dims: [%d, %d, %d, %d]\r\n", $tLayout.X, $tLayout.Y, $tLayout.Width, $tLayout.Height)) ;-------------------------------------- ;Initial write to label - cause I'm too lazy to fix scrolling logic! _GDIPlus_GraphicsDrawStringEx($hLabGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush) Local $hTimer = TimerInit(), $iShift = 3 ; $iShift = Pos shift on each iteration. While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop ;Pause at string start. If TimerDiff($hTimer) < 2000 Then ContinueLoop ;wipe buffer _GDIPlus_GraphicsClear($hBuffGraphic, $iBkColour) ;Redraw the string at new position. $tLayout.X -= $iShift If ($tLayout.X + $tLayout.Width) < 0 Then ;If we've fallen off the label.. $tLayout.X = $iMargin ;Start at our initial position $hTimer = TimerInit() EndIf _GDIPlus_GraphicsDrawStringEx($hBuffGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush) ;Copy the buffer to the label _GDIPlus_GraphicsDrawImageRect($hLabGraphic, $hBuffBitMap, 0, 0, $iLabW, $iLabH) Sleep(40) WEnd ;Cleanup _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hBuffGraphic) _GDIPlus_ImageDispose($hBuffBitMap) _GDIPlus_GraphicsDispose($hLabGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI)
    2 points
  43. It's hard to tell the reason without knowing the internal workings of DllOpen() vs DllCall() with and without a handle. Also that it's only related to uncompiled 32bit scripts makes it even more hard to explain. And that it seems not a common problem, but only few people seem to experience (or realize) it or seem to be able to reproduce it. It seems to be related to a certain system setup only, though I think at least @UEZ, @@therks and myself stumbled over it now.
    1 point
  44. Hi KaFu, I now have a new notebook and have not looked into the problem since then because it works with ioa747's suggestion. Maybe I will make some tests. Btw, I have no problems with the CreateSemaphore code from post#1. Edit: still same problem with x86. #AutoIt3Wrapper_UseX64=n ShellExecute("C:\Users\Public\Desktop\Adobe Acrobat.lnk")
    1 point
  45. Unable to reproduce your issue, works as expected with both semaphore and file mapping. (exe, au3, and scite)
    1 point
  46. Just uploaded an updated Tidy to the Beta directory that now also has option #Tidy_ILC_Pos=-2 The -2 option will simply copy any existing Whitespace characters between the Code and InlineComment, from the existing line to the newly indented line. Try that and see if that is what you are looking for, but I thought it would be nice to make that available as well as option. 🙂
    1 point
  47. _GUICtrlComboAutoComplete ?
    1 point
  48. Did you try automating with webdriver some other browser to check if its not headless browser related problem?
    1 point
×
×
  • Create New...