Leaderboard
Popular Content
Showing content with the highest reputation since 04/04/2025 in Posts
-
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 ;==>AppBarProc7 points
-
MiniMark (a minimalistic rtf editor)
Skeletor and 2 others reacted to TheAutomator for a topic
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.zip3 points -
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.zip3 points
-
I need an audio equalizer for my zPlayer
argumentum and 2 others reacted to MattyD for a topic
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.zip3 points -
Microsoft Media Foundation
argumentum and one other reacted to MattyD for a topic
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 -
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 ;==>ShowTrayMenu2 points
-
Microsoft Media Foundation
argumentum and one other reacted to MattyD for a topic
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]) EndFunc2 points -
Modbus RTU using libmodbus.dll
argumentum and one other reacted to Geppo for a topic
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 -
Microsoft Edge - WebView2, embed web code in your native application
argumentum and one other reacted to ptrex for a topic
2 points -
On my Forum, I have created a page that lists and distributes MF Codecs created by Microsoft. Look here.2 points
-
Need help to make a 4k video player
SOLVE-SMART and one other reacted to Nine for a topic
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 -
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
-
MiniMark (a minimalistic rtf editor)
TheAutomator and one other reacted to pixelsearch for a topic
@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_idBack2 points -
2 points
-
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
-
Something like this here: #include <Array.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> #include <WinAPISysWin.au3> #include <WinAPIGdi.au3> #include <WinAPIShellEx.au3> Global Const $WM_NOTIFYICON = $WM_USER + 1 Global Const $sWinTitle = "TrayExample" AutoItWinSetTitle($sWinTitle) Opt("TrayMenuMode", 3) Global $hHWND = WinGetHandle($sWinTitle) Global $hTaskbar = WinGetHandle("[CLASS:Shell_TrayWnd]") Global $hTray Example() Func Example() Local $idAbout = TrayCreateItem("About") TrayCreateItem("") Local $idExit = TrayCreateItem("Exit") HotKeySet("{F9}", ShowTrayMenu) $a = _WinAPI_EnumChildWindows($hTaskbar) $iPos = _ArraySearch($a, "TrayNotifyWnd", 0, 0, 0, 0, 1, 1) If Not @error Then $hTray = $a[$iPos][0] EndIf 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 If CheckMouseOverTrayIcon() = 1 And WinExists("[CLASS:#32768]") = 0 Then ShowTrayMenu() WEnd EndFunc ;==>Example Func ShowTrayMenu() _SendMessage($hHWND, $WM_NOTIFYICON, 0, $WM_LBUTTONDOWN) EndFunc ;==>ShowTrayMenu Func CheckMouseOverTrayIcon() Local $tNID = DllStructCreate("dword cbSize;hwnd hWnd;uint uID;uint uFlags") Local $hTrayWnd = _WinAPI_GetShellWindow() If $hTrayWnd = 0 Then Return -1 DllStructSetData($tNID, "cbSize", DllStructGetSize($tNID)) DllStructSetData($tNID, "hWnd", $hTray) DllStructSetData($tNID, "uID", 1) Local $tRECT = _WinAPI_ShellNotifyIconGetRect(WinGetHandle(AutoItWinGetTitle()), 1) If @error Then Return -2 Local $aPos = _WinAPI_GetPosFromRect($tRECT) Local $aMousePos = MouseGetPos() If $aMousePos[0] >= $aPos[0] And $aMousePos[0] <= $aPos[0] + $aPos[2] And $aMousePos[1] >= $aPos[1] And $aMousePos[1] <= $aPos[1] + $aPos[3] Then Return 1 EndIf Return 0 EndFunc ;==>CheckMouseOverTrayIcon Will work properly when icon is visible on the taskbar. Tested on Win11 24H2.1 point
-
Especially since they have gone up in price by 100% over the last 2 years, and now every time you use a certificate, you need a cryptographic card. Previously, the certificate could be in a file and you didn't need a cryptographic card.1 point
-
Not much I can do about that... I have no Development Certificate that I can sign the programs with, and they are way too expensive.1 point
-
Just uploaded an updated Tidy version with some new logic that now hopefully can handle all scenarios of using Tabs&Spaces as Indentation within CommentBlocks. Please give that a try and let me know if that works.1 point
-
If you are missing any GUID's, on this page, you'll find all known MediaType GUID's https://gix.github.io/media-types/1 point
-
A few interfaces for you sir! - These were semi-generated from the rust v-table documentation... I'll start working though them in the coming days. 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*);" And a couple funcs that I use to create and read guids. 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_ReadGUIDAt1 point
-
Indeed an bug so will have a look... tnx for reporting.1 point
-
Microsoft Edge - WebView2, embed web code in your native application
Gianni reacted to argumentum for a topic
..same here PS: am actually interested in OrdoPDFReader . I'll have to wait for those know about this stuff.1 point -
Microsoft Edge - WebView2, embed web code in your native application
argumentum reacted to Gianni for a topic
... a little digression from the OP Browsing the internet I came across this interesting page (https://freeware.ordoconcept.net/OrdoWebview2.php) where there is an ocx through which it should be possible to use WebView2. Actually it refers to VB6, but maybe it can be adapted here too? To test it I installed OrdoWebView2 SDK (https://freeware.ordoconcept.net/download.php?file=OrdoWebView2ActiveXControl.2.0.9.exe). I then tried to use it through this simple script which is an adaptation of a similar script by @ptrex taken from this link, but I receive an error from the ocx: "Run-time error '0'"; the methods are not executed and not even the browser is incorporated into the GUI. Does anyone know how and if it is possible to make it work here? thanks. #AutoIt3Wrapper_UseX64=N #include <GUIConstantsEx.au3> ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Load ActiveX module $hActiveX = DllOpen("C:\Windows\SysWOW64\OrdoWebView2.ocx") ; Object identifiers Global Const $sCLSID = "{56335193-C129-41AC-B94A-B26B9B7469CF}" ; retrieved from the registry Global Const $sIID = Default ; Create a simple GUI for our output Local $hWebView2 = GUICreate("WebView2 ocx test", 1000, 580, (@DesktopWidth - 1000) / 2, (@DesktopHeight - 580) / 2) GUISetState(@SW_SHOW) ;Show GUI ; Create Com Object ; Local $oWebView2 = ObjCreate("OrdoWebView2.OrdoWebView") ; HEXEDIT.HexEditCtrl.1") Local $oWebView2 = ObjCreate($sCLSID, $sIID, $hActiveX) If IsObj($oWebView2) Then MsgBox(64, "Object's info", _ "Name of Object is:...." & ObjName($oWebView2, 1) & @CRLF & _ "Description string is:.........." & ObjName($oWebView2, 2) & @CRLF & _ "ProgID is:......................" & ObjName($oWebView2, 3) & @CRLF & _ "File associated in Registry is:." & ObjName($oWebView2, 4) & @CRLF & _ "Module name in which runs is:..." & ObjName($oWebView2, 5) & @CRLF & _ "CLSID of object's coclass is:..." & ObjName($oWebView2, 6) & @CRLF & _ "IID of object's interface is:..." & ObjName($oWebView2, 7)) Else Exit MsgBox(16, '', "Error occurred") EndIf ; https://freeware.ordoconcept.net/Help/OrdoWebView2/ $oWebView2.Anchor = True $oWebView2.HomeURL = "https://www.google.com/" $oWebView2.SearchEngine = 'Google' $oWebView2.Init $GUIActiveX = GUICtrlCreateObj($oWebView2, 10, 10, ((@DesktopWidth - 1000) / 2) - 20, ((@DesktopHeight - 580) / 2)) - 20) ; GUICtrlSetResizing($GUIActiveX, $GUI_DOCKAUTO) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; COM Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "AutoItCOM", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext) SetError(1) EndFunc ;==>MyErrFunc1 point -
RichEdit issue ?
pixelsearch reacted to KaFu for a topic
Try _GUICtrlRichEdit_SetSel($hRichEdit, 0, 0).1 point -
RichEdit issue ?
argumentum reacted to pixelsearch for a topic
What a great forum with people answering so quickly, thank you guys I found this annoyance yesterday while testing thoroughly my script here, then confirmed with Nine's script found there (example 3) . As both of our scripts don't use (on purpose) a $WS_VSCROLL style while creating the richedit control, then I started the actual thread with a richedit control that uses a $WS_VSCROLL style (as it should be) and here we are... If not mistaken, this annoyance happens only when the number of total lines = number total visible lines + 1 . We can confirm it like this, using the script above : 1) Let's keep these 2 lines of code untouched, ordered like this : _GUICtrlRichEdit_SetScrollPos($hRichEdit, 0, 0) ; bad behavior when placed before GUISetState (in case total lines = total visible + 1) GUISetState(@SW_SHOW) 2) Now we increase the value in this line... If _GUICtrlRichEdit_GetNumberOfFirstVisibleLine($hRichEdit) > 1 Then ExitLoop ... by changing its "> 1" to bigger values (like > 2 , > 3 etc...) How is the display ? Well it's always correct starting from > 2 ("correct" means line 1 is visible at top) , the only value that brings a bad display is "> 1" (bad display means line 2 is visible at top) So in the end, where should be placed the following line, before or after GUISetState() ? _GUICtrlRichEdit_SetScrollPos($hRichEdit, 0, 0) My advice is it should always be placed after, because even with 10.000 lines in the richedit control, the display is immediate (not in "2 times", tested) and who knows (it may happen one day) in case the richedit control got exactly a total number of lines = total visible lines + 1 , then its display will always be correct (e.g. line 1 appearing at the top)1 point -
RichEdit issue ?
pixelsearch reacted to BigDaddyO for a topic
Same, it doesn't seem to work before displaying the UI. It doesn't set @error either.1 point -
1 point
-
Yeah, so loading media in should work the same, I just never managed to work out how to actually render the video. (If you open an mp4 you should be able to hear the audio just fine) I'll need to have fresh look at this - I kinda just ran out of steam last time... The other thing that's peaked my interest is MediaFoundation. This is the replacement for DirectShow, which is essentially a low-level player. So the benefit here is we can sidestep WinRT/UWP entirely, but presumably the cost will be manually coding things that the WinRT object "just does". Either way I'll need to throw a bunch of time at it 🙂 which is fine, but it could be a couple of weeks before I have anything definitive sorry.1 point
-
After the opencv udf, Dlib seems to be a missing library for image processing. This UDF provides a way to use dlib in AutoIt The usage is similar to the python usage of dlib Prerequisites Download and extract autoit-dlib-19.24.4-opencv-4.10.0-com-v1.4.3.7z into a folder Sources Here Documentation A generated documentation for functions is available here Examples More examples can be found here To run them, please follow these instructions Face detection #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Misc.au3> #include "autoit-dlib-com\udf\dlib_udf_utils.au3" _Dlib_Open("opencv-4.7.0-windows\opencv\build\x64\vc16\bin\opencv_world470.dll", "autoit-dlib-com\autoit_dlib_com-19.24-470.dll") OnAutoItExitRegister("_OnAutoItExit") Example() Func Example() Local Const $dlib = _Dlib_get() If Not IsObj($dlib) Then Return Local $detector = $dlib.get_frontal_face_detector() Local $win = _Dlib_ObjCreate("image_window") Local $image_path = _Dlib_FindFile("examples\faces\2008_002470.jpg") Local $img = $dlib.load_rgb_image($image_path) $win.set_image($img) ; 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. Local $dets = $detector.call($img, 1) ConsoleWrite("Number of faces detected: " & UBound($dets) & @CRLF) Local $d For $i = 0 To UBound($dets) - 1 $d = $dets[$i] ConsoleWrite(StringFormat("Detection %d: Left: %d Top: %d Right: %d Bottom: %d", _ $i, $d.left(), $d.top(), $d.right(), $d.bottom()) & @CRLF) Next $win.add_overlay($dets) hit_to_continue() EndFunc ;==>Example Func hit_to_continue() ToolTip("Hit ESC to continue", 0, 0) ConsoleWrite("Hit ESC to continue" & @CRLF) Do Sleep(50) Until _IsPressed("1B") EndFunc ;==>hit_to_continue Func _OnAutoItExit() _Dlib_Close() EndFunc ;==>_OnAutoItExit Camera face detection using opencv First, download the opencv UDF from here #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Misc.au3> #include "autoit-dlib-com\udf\dlib_udf_utils.au3" #include "autoit-opencv-com\udf\opencv_udf_utils.au3" _Dlib_Open("opencv-4.7.0-windows\opencv\build\x64\vc16\bin\opencv_world470.dll", "autoit-dlib-com\autoit_dlib_com-19.24-470.dll") _OpenCV_Open("opencv-4.7.0-windows\opencv\build\x64\vc16\bin\opencv_world470.dll", "autoit-opencv-com\autoit_opencv_com470.dll") OnAutoItExitRegister("_OnAutoItExit") Example() Func Example() Local Const $dlib = _Dlib_get() If Not IsObj($dlib) Then Return Local Const $cv = _OpenCV_get() If Not IsObj($cv) Then Return Local $detector = $dlib.get_frontal_face_detector() Local $cam = _OpenCV_ObjCreate("VideoCapture").create(0) Local $color_green = _OpenCV_Tuple(0, 255, 0) Local $line_width = 3 Local $img, $dets, $det While True If $cam.read() Then $img = $cv.extended[1] $dets = $detector.call($img) For $i = 0 To UBound($dets) - 1 $det = $dets[$i] $cv.rectangle($img, _OpenCV_Tuple($det.left(), $det.top()), _OpenCV_Tuple($det.right(), $det.bottom()), $color_green, $line_width) Next ;; Flip the image horizontally to give the mirror impression $cv.imshow("my webcam", $cv.flip($img, 1)) EndIf If _IsPressed("1B") Then ExitLoop ; esc to quit EndIf Sleep(1) WEnd $cv.destroyAllWindows() EndFunc ;==>Example Func _OnAutoItExit() _OpenCV_Close() _Dlib_Close() EndFunc ;==>_OnAutoItExit1 point
-
@SW_HIDE, $STDOUT_CHILD not working if called from a au3 include file - (Moved)
argumentum reacted to Lobo65 for a topic
Hey MVPs, simply because I didn't knew how. I played around with the WMI a bit according some example I found here in the forum, but obviously, I didn't do it properly. Your example though does exactly, what I wanted! Thank you! Anyways... the flickering must be made by some other settings, because it still occurs... I will investigate that and report here or ask you guys for supporting me, if I don't find the reason. @Jos : sorry for leading you on the wrong track1 point -
MiniMark (a minimalistic rtf editor)
TheAutomator reacted to pixelsearch for a topic
You're welcome, it was interesting to script. As I just did a new update today (7th april), may I suggest you delete the old quoted code from your last post, so we keep only the updated version ? Thanks and have a great day1 point -
MiniMark (a minimalistic rtf editor)
pixelsearch reacted to TheAutomator for a topic
Pixelsearch, I will have a look at it soon, looks promising thanks for this!1 point -
@MattyD, You are like a brilliant alchemist, transforming challenges into ingenious solutions that no one else could imagine. Though I may not have the depth of knowledge to fully harness your solution, I deeply appreciate the insight you've shared—it's inspiring and a great opportunity for me to learn. Thanks!1 point
-
MiniMark (a minimalistic rtf editor)
TheAutomator reacted to WildByDesign for a topic
Everything looks sharp, beautiful and stylish! The only real negative that I spot initially is that the custom scrollbar position does not change when using the touchpad swipe up/down gestures. A standard scrollbar in AutoIt does not have this problem.1 point -
MiniMark (a minimalistic rtf editor)
WildByDesign reacted to TheAutomator for a topic
New BETA version 4 uploaded as ZIP-file! see shortcuts section in code for the new ones installer and stable release coming soon!1 point -
1 point
-
Query to close previous instance or restore
argumentum reacted to AntS for a topic
Aha! Now, it makes sense. When the second instance is run, _Singleton() doesn't create a second mutex object, but it does recognise the existence of first. The object is lost when the first process is closed. Thank you very much for the explanation, Nine, and for the modified code. Thank you, argumentum, for the additional code and pointers. 🙂1 point -
The C:\Windows\System32 directory, contains 64-bit versions of system files and libraries. This can be confusing because, on a 64-bit system, System32 actually holds 64-bit files, while SysWOW64 holds 32-bit files. according to this, try commented / uncommented #AutoIt3Wrapper_UseX64=y #RequireAdmin #AutoIt3Wrapper_UseX64=y #include <File.au3> ConsoleWrite(@SystemDir & @CRLF) _ArrayDisplay(_FileListToArray("C:\Windows\System32")) Exit1 point
-
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.1 point
-
Skinning the cat makes it ugly. 😉 _WinAPI_SetLayeredWindowAttributes($hGUI_Child, 0x123456, 0x60) makes the child GUI transparent, too.1 point
-
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...1 point
-
RustDesk-Manager (Addressbook Inventory Manager for RustDesk)
Parsix reacted to jeff_poweruser for a topic
Hello folks, as RustDesk is a very good open source TeamViewer alternative and flexible remote helpdesk app (free to use and ability to selfhost the server e.g. in a docker-container) there were two things i missed. Address-Book for Clients/Hosts Connect to Clients from different Servers not just my own (e.g. my private hosted rustdesk-server and the company-server which have different API-Keys and IP-addresses) Solution is a kind of inventory-manager for RustDesk RustDesk-Manager need a master-passwort (set by user) for encrypting API-Keys can store the files in an individual file based config-folder (e.g to use it from different computers in a cloud-sync folder) can be used without installing the exe (runs with parameters minimizes to tray Requirements: running RustDesk-Server Instance rustdesk.exe 1.2.4 or above (commandline parameters were added - props to the rustdesk developers) this App Screenshot of the GUI: after some months of testing and improving, i want to share the code to give something back to this forum. Thanks for all useful stuff in the past and hopefully future ! Feel free to use it, change it, give a short feedback or make a donation 🤗 Yours, Stefan ________ EDIT ________ 2025-03-16: v1.0.0.16 encrypts Server-Address and Client-IDs (for existing Items just rightclick for edit and save them to encrypt Address/ID as well) saves the setting of "SaveClientPass" to Ini file instead of registry as it it a common setting for all users of a certain Config 2025-03-23: v1.0.0.20 Clientpassword is now part of editing a client -> can be displayed by asking the Masterpassword again Rustdesk-Master.au31 point -
Found a copy of 1.4 thanks to SMF 😋 in my archive drive at the location "E:\__code\TB_TurboBooster\Workbench\_testcode\FontViewer_source.zip" 🙄. Updated that too to 3.3.16.1, here's a copy of that plus the original code FontViewer_1.4.zip Additionally fixed a bug in the enumeration of the system fonts. ; $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, StringTrimLeft($REG_KEY_TRUETYPE, 5)) ; needs to be $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, StringTrimLeft($REG_KEY_TRUETYPE, 5),BitOR($KEY_QUERY_VALUE , $KEY_WOW64_32KEY))1 point
-
How to get double click in label?
pixelsearch reacted to Melba23 for a topic
Melque_Lima, There is a very useful search function at top-right of the page. A quick search found several solutions. M231 point -
UPDATE: With the addition of the ObjCreateInterface function and enhanced COM functionality by trancexxx, these interfaces are now accessible directly in AutoIt. I've rewritten the plugin as a native UDF which will work when compiled as x64 as well. I've attached the new UDF as well as updated plugin and UDF versions of my OSD Volume script. UDF Example: #include <_AudioEndpointVolume.au3> ; ## Get current volume levels $vol = _GetMasterVolumeLevel() ConsoleWrite("Get Vol Error: " & @error & @CRLF) ConsoleWrite("Volume: " & $vol & " (decibels)" & @CRLF) $vol = _GetMasterVolumeLevelScalar() ConsoleWrite("Get Vol Error: " & @error & @CRLF) ConsoleWrite("Volume: " & $vol & " (scalar)" & @CRLF) ; ## Set new volume levels ConsoleWrite("Set vol to -20db..." & @CRLF) _SetMasterVolumeLevel(-20) ConsoleWrite("Set Vol Error: " & @error & @CRLF) $vol = _GetMasterVolumeLevel() ConsoleWrite("Get Vol Error: " & @error & @CRLF) ConsoleWrite("Volume: " & $vol & " (decibels)" & @CRLF) ConsoleWrite("Set vol to scalar 30..." & @CRLF) _SetMasterVolumeLevelScalar(30) ConsoleWrite("Set Vol Error: " & @error & @CRLF) $vol = _GetMasterVolumeLevelScalar() ConsoleWrite("Get Vol Error: " & @error & @CRLF) ConsoleWrite("Volume: " & $vol & " (scalar)" & @CRLF) ; ## Get volume range information ConsoleWrite("Get range info..." & @CRLF) $aInfo = _GetVolumeRange() ConsoleWrite("Get Range Error: " & @error & @CRLF) ConsoleWrite("MinDB: " & $aInfo[0] & @CRLF) ConsoleWrite("MaxDB: " & $aInfo[1] & @CRLF) ConsoleWrite("Increment: " & $aInfo[2] & @CRLF) ; ## Set mute states ConsoleWrite("Set mute on..." & @CRLF) _SetMute(1) ConsoleWrite("Set Mute Error: " & @error & @CRLF) $mute = _GetMute() ConsoleWrite("Get Mute Error: " & @error & @CRLF) ConsoleWrite("Muted: " & $mute & @CRLF) Sleep(2000) ConsoleWrite("Set mute off..." & @CRLF) _SetMute(0) ConsoleWrite("Set Mute Error: " & @error & @CRLF) $mute = _GetMute() ConsoleWrite("Get Mute Error: " & @error & @CRLF) ConsoleWrite("Muted: " & $mute & @CRLF) ; ## Get volume step info ; ## Steps range from 0 to nStepCount - 1 ConsoleWrite("Get step info..." & @CRLF) $aInfo = _GetVolumeStepInfo() ConsoleWrite("Get Step Error: " & @error & @CRLF) ConsoleWrite("Current step: " & $aInfo[0] & @CRLF) ConsoleWrite("Total steps: 0 to " & $aInfo[1] - 1 & @CRLF) ConsoleWrite("Increase 5 steps..." & @CRLF) For $i = 1 To 5 _VolumeStepUp() Next $aInfo = _GetVolumeStepInfo() ConsoleWrite("Get Step Error: " & @error & @CRLF) ConsoleWrite("Current step: " & $aInfo[0] & @CRLF) ConsoleWrite("Decrease 2 steps..." & @CRLF) For $i = 1 To 2 _VolumeStepDown() Next $aInfo = _GetVolumeStepInfo() ConsoleWrite("Get Step Error: " & @error & @CRLF) ConsoleWrite("Current step: " & $aInfo[0] & @CRLF) OLD PLUGIN VERSION vista_vol_plugin.zip _AudioEndpointVolume.au3 VolumeOSD.zip VolumeOSD_plugin.zip1 point
-
GUICtrlCreateInput - Disable copy/ paste, right click menu and balloon pop-up
pixelsearch reacted to LarsJ for a topic
The explanations are much more complicated than the code. Here's the code: #include <GUIConstants.au3> #include <WinAPIShellEx.au3> #include <GuiEdit.au3> Opt( "MustDeclareVars", 1 ) Example() Func Example() Local $hGui = GUICreate( "Input (numbers only)", 300, 118 ) Local $idInput = GUICtrlCreateInput( "", 50, 50, 200, 18, $GUI_SS_DEFAULT_INPUT+$ES_NUMBER ) Local $hInput = GUICtrlGetHandle( $idInput ) GUICtrlCreateLabel( "No context menu, no paste, no balloontip", 50, 70, 200, 18 ) ; Register callback function to subclass Input control Local $pInputProc = DllCallbackGetPtr( DllCallbackRegister( "InputProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) ) _WinAPI_SetWindowSubclass( $hInput, $pInputProc, 9999, 0 ) ; SubclassId = 9999, $pData = 0 GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup _WinAPI_RemoveWindowSubclass( $hInput, $pInputProc, 9999 ) GUIDelete( $hGui ) Exit EndFunc ; InputProc callback function Func InputProc( $hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData ) Switch $iMsg Case $WM_CONTEXTMENU, $WM_PASTE, $EM_SHOWBALLOONTIP Return 0 EndSwitch ; Call next function in subclass chain Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0] ; _WinAPI_DefSubclassProc EndFunc1 point