Jump to content

Search the Community

Showing results for tags 'richtext'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 4 results

  1. 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 function: minimalistic program that edits custom rtf files version: 3 made by: TheAutomator project: https://www.autoitscript.com/forum/topic/212763-minimark-a-minimalistic-rtf-editor todo: • make find and replace work better • custom scrollbar control is buggy • make user level install possible (requested by argumentum) • allow dropping files to gui • add shortcut to incert and change checkmarks • add upper/lower case function • add incert dcurrent time and date function • consider sort lines, remove duplicate lines, remove whitespace button • add file changed indicator • add option to silence sounds • add right click menu on edit • consider bigger gui • check if programfiles exist when opened wanna help debugging the AutoIT rich edit? https://www.autoitscript.com/trac/autoit/ticket/4038#ticket 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) #ce #region ;**** directives created by autoit3wrapper_gui **** #autoit3wrapper_icon=setup\icon.ico #autoit3wrapper_outfile_x64=minimark\MiniMark.exe #autoit3wrapper_usex64=y #endregion ;**** directives created by autoit3wrapper_gui **** #notrayicon #include <guirichedit.au3> #include <guiconstants.au3> #include <winapisyswin.au3> #region constants const $font_lucida = 'lucida console' const $font_handel = 'handelgothic bt' const $image_gui_background = @scriptdir & '\gui.bmp' const $image_blue = @scriptdir & '\blue.bmp' const $image_bold = @scriptdir & '\bold.bmp' const $image_default = @scriptdir & '\default.bmp' const $image_exit = @scriptdir & '\exit.bmp' const $image_green = @scriptdir & '\green.bmp' const $image_italic = @scriptdir & '\italic.bmp' const $image_open = @scriptdir & '\open.bmp' const $image_red = @scriptdir & '\red.bmp' const $image_save = @scriptdir & '\save.bmp' const $image_struck = @scriptdir & '\struck.bmp' const $image_under = @scriptdir & '\under.bmp' const $image_white = @scriptdir & '\white.bmp' const $image_search_background = @scriptdir & '\search.bmp' const $image_case_on = @scriptdir & '\case_on.bmp' const $image_case_off = @scriptdir & '\case_off.bmp' const $image_word_on = @scriptdir & '\word_on.bmp' const $image_word_off = @scriptdir & '\word_off.bmp' const $image_find = @scriptdir & '\find.bmp' const $image_next = @scriptdir & '\next.bmp' const $image_replace = @scriptdir & '\replace.bmp' const $image_all = @scriptdir & '\all.bmp' const $image_close = @scriptdir & '\close.bmp' const $sound_start = @scriptdir & '\start.wav' const $sound_click = @scriptdir & '\click.wav' const $sound_alert = @scriptdir & '\alert.wav' const $sound_stop = @scriptdir & '\stop.wav' const $color_gui_transparant = 0xff00ff const $color_title = 0x999999 const $color_edit_background = 0x00323232 const $color_scroll_gray = 0x4d4d4d const $color_edit_gray = 0x00b4b4b4 const $color_edit_red = 0x006600ff const $color_edit_green = 0x0000ff66 const $color_edit_blue = 0x00ff6600 const $color_edit_white = 0x00ffffff const $file_manual = @scriptdir & '\MiniMark.mnm' #endregion func wrong_filetype($file) ; check if filetype is *.mnm if stringright($file, 4) <> '.mnm' then msgbox(48, 'Wrong file type!', 'You can only use *.mnm files with this program.') return true endif endfunc if $cmdline[0] = 0 Or wrong_filetype($cmdline[1]) then local $cmdline = [1, $file_manual] ; no / wrong input file -> opens minimark.mnm func title_get() ; extract filename to display as title local $path_split = stringsplit($cmdline[1], '\', 3) return stringtrimright($path_split[ubound($path_split)-1], 4) endfunc soundplay($sound_start) ; startup sound #region gui $form = guicreate('MiniMark', 380, 400, default, default, $ws_popup, $ws_ex_layered) guisetbkcolor($color_gui_transparant) guictrlcreatepic($image_gui_background, 0, 0, 380, 400) guictrlsetstate(default, $gui_disable) $edit = _guictrlrichedit_create($form, '', 20, 50, 260, 330, bitor($es_multiline, $es_autovscroll, $es_nohidesel), 0) ; $es_nohidesel for visible selection when using search functions _guictrlrichedit_setbkcolor($edit, $color_edit_background) load_file() guiregistermsg($wm_command, wm_command) func wm_command($hwnd, $imsg, $wparam, $lparam) ; we need this becouse rich edit keeps changing to default style if $edit <> $lparam then return $gui_rundefmsg if _guictrlrichedit_istextselected($edit) then return $gui_rundefmsg if _guictrlrichedit_getfont($edit)[1] <> $font_lucida then _guictrlrichedit_setfont($edit, 9, $font_lucida) _guictrlrichedit_setcharcolor($edit, $color_edit_gray) endif return $gui_rundefmsg endfunc _guictrlrichedit_seteventmask($edit, $enm_scrollevents) guiregistermsg($wm_notify, wm_notify) func wm_notify($hwnd, $imsg, $wparam, $lparam) local $tfilter = dllstructcreate($tagmsgfilter, $lparam) if $tfilter.hwndfrom = $edit then _guictrlrichedit_scrolllines($tfilter.hwndfrom, $tfilter.wparam ? 1 : -1) return $gui_rundefmsg endfunc $scroll = guictrlcreatelabel('', 300, 60, 10, 20) GUICtrlSetBkColor(Default, $color_scroll_gray) $button_exit = guictrlcreatepic($image_exit, 320, 40, 50, 20) guictrlsettip(default, 'Quit the program.', 'escape') $button_open = guictrlcreatepic($image_open, 320, 70, 50, 20) guictrlsettip(default, 'Open a new *.mnm file.', 'ctrl + o') $button_save = guictrlcreatepic($image_save, 320, 100, 50, 20) guictrlsettip(default, 'Save the current file.', 'ctrl + s') $button_bold = guictrlcreatepic($image_bold, 320, 130, 50, 20) guictrlsettip(default, 'Make selection bold.', 'ctrl + b') $button_italic = guictrlcreatepic($image_italic, 320, 160, 50, 20) guictrlsettip(default, 'Make selection italic.', 'ctrl + i') $button_struck = guictrlcreatepic($image_struck, 320, 190, 50, 20) guictrlsettip(default, 'Make selection struck.', 'ctrl + t') $button_under = guictrlcreatepic($image_under, 320, 220, 50, 20) guictrlsettip(default, 'Make selection underlined.', 'ctrl + u') $button_red = guictrlcreatepic($image_red, 320, 250, 50, 20) guictrlsettip(default, 'Make selection red.', 'shift + ctrl + r') $button_green = guictrlcreatepic($image_green, 320, 280, 50, 20) guictrlsettip(default, 'Make selection green.', 'shift + ctrl + g') $button_blue = guictrlcreatepic($image_blue, 320, 310, 50, 20) guictrlsettip(default, 'Make selection blue.', 'shift + ctrl + b') $button_white = guictrlcreatepic($image_white, 320, 340, 50, 20) guictrlsettip(default, 'Make selection white.', 'shift + ctrl + w') $button_default = guictrlcreatepic($image_default, 320, 370, 50, 20) guictrlsettip(default, 'Make selection default style and gray.', 'shift + ctrl + d') $button_search = guictrlcreatedummy() $title = guictrlcreatelabel(title_get(), 10, 10, 360, 20, bitor($ss_centerimage, $ss_center), $gui_ws_ex_parentdrag) ; use label to drag form guictrlsettip(default, $cmdline[1]) ; display full path on mouse over guictrlsetfont(default, 12, 400, 0, $font_handel) guictrlsetcolor(default, $color_title) guictrlsetbkcolor(default, $gui_bkcolor_transparent) _winapi_setlayeredwindowattributes($form, $color_gui_transparant) ; 0xff00ff is set as the transparant gui color guisetstate(@SW_SHOW, $form) #endregion #region searchbox $search = guicreate('Search', 310, 130, default, default, $ws_popup, $ws_ex_layered) guisetbkcolor($color_gui_transparant) guictrlcreatepic($image_search_background, 0, 0, 310, 130) guictrlsetstate(default, $gui_disable) $find_box = GUICtrlCreateInput('', 15, 40, 200, 20, $es_autohscroll, 0) GUICtrlSetColor(Default, $color_edit_gray) GUICtrlSetBkColor(Default, $color_edit_background) guictrlsetfont(default, 12, 400, 0, $font_handel) $replace_box = GUICtrlCreateInput('', 15, 70, 200, 20, $es_autohscroll, 0) GUICtrlSetColor(Default, $color_edit_gray) GUICtrlSetBkColor(Default, $color_edit_background) guictrlsetfont(default, 12, 400, 0, $font_handel) $checkbox_case = guictrlcreatepic($image_case_on, 230, 40, 70, 20) guictrlsettip(default, 'Toggle casesence.') $toggle_case = True $checkbox_word = guictrlcreatepic($image_word_off, 230, 70, 70, 20) guictrlsettip(default, 'Toggle whole word only.') $toggle_word = False $button_find = guictrlcreatepic($image_find, 10, 100, 50, 20) guictrlsettip(default, 'Search for the string in the first input field.') $button_next = guictrlcreatepic($image_next, 70, 100, 50, 20) guictrlsettip(default, 'Search for the next match.') $button_replace = guictrlcreatepic($image_replace, 130, 100, 50, 20) guictrlsettip(default, 'Replace current selection and look for the next match.') $button_all = guictrlcreatepic($image_all, 190, 100, 50, 20) guictrlsettip(default, 'Replace all matches.') $button_close = guictrlcreatepic($image_close, 250, 100, 50, 20) guictrlsettip(default, 'Close the find and replace window.') $title = guictrlcreatelabel('Find And Replace', 10, 10, 290, 20, bitor($ss_centerimage, $ss_center), $gui_ws_ex_parentdrag) ; use label to drag form guictrlsetfont(default, 12, 400, 0, $font_handel) guictrlsetcolor(default, $color_title) guictrlsetbkcolor(default, $gui_bkcolor_transparent) _winapi_setlayeredwindowattributes($search, $color_gui_transparant) ; 0xff00ff is set as the transparant gui color #endregion #Region shortcuts dim $hotkeysaccel[13][2] = [ _ ["+^d", $button_default], _ ["^b", $button_bold], _ ["^i", $button_italic], _ ["^u", $button_under], _ ["^t", $button_struck], _ ["+^r", $button_red], _ ["+^g", $button_green], _ ["+^b", $button_blue], _ ["+^w", $button_white], _ ["^o", $button_open], _ ["^s", $button_save], _ ["^f", $button_search], _ ["{esc}", $button_exit] _ ] guisetaccelerators($hotkeysaccel, $form) #EndRegion func load_file() _guictrlrichedit_deselect($edit) _guictrlrichedit_streamfromfile($edit, $cmdline[1]) _guictrlrichedit_setmodified($edit, false) _GUICtrlRichEdit_EmptyUndoBuffer($edit) endfunc func save() _guictrlrichedit_deselect($edit) Local $var = _guictrlrichedit_streamtovar($edit) $var = stringtrimright($var, 9) & "}" $file = fileopen($cmdline[1], $fo_overwrite) filewrite($file, $var) fileclose($file) _guictrlrichedit_setmodified($edit, false) ;~ _guictrlrichedit_streamtofile($edit, $cmdline[1]) ; bug adds new paragraph every time (see ticket) endfunc func check_save_changes() if _guictrlrichedit_ismodified($edit) then if msgbox(8228,'Save changes?','So you wanna save your work first?') = 6 then save() ; 6 = yes, 7 = no endif endfunc func quit() check_save_changes() soundplay($sound_stop, 1) _guictrlrichedit_destroy($edit) guidelete() exit endfunc func open() check_save_changes() soundplay($sound_click) Local $file = FileOpenDialog('Open new MiniMark file...', @DesktopDir, 'MiniMark file (*.mnm)', 3, '', $form) if @error Or wrong_filetype($file) then soundplay($sound_alert) return endif $cmdline[1] = $file load_file() GUICtrlSetData($title, title_get()) endfunc func colorize($color) ; if already in selected color -> make default color again if _guictrlrichedit_getcharcolor($edit) <> $color then _guictrlrichedit_setcharcolor($edit, $color) else _guictrlrichedit_setcharcolor($edit, $color_edit_gray) endif soundplay($sound_click) endfunc func stylize($style) ; if already in selected style -> undo style if stringinstr(_guictrlrichedit_getcharattributes($edit), $style & '+') then _guictrlrichedit_setcharattributes($edit, '-' & $style) else _guictrlrichedit_setcharattributes($edit, '+' & $style) endif soundplay($sound_click) endfunc func find() ; work in progress local $find_text = guictrlread($find_box) if $find_text = '' then return _guictrlrichedit_setsel($edit, 0, 0) local $selection = _guictrlrichedit_findtext($edit, $find_text, True, $toggle_case, $toggle_word) if $selection <> -1 then _guictrlrichedit_setsel($edit, $selection, $selection + stringlen($find_text)) endif endfunc func find_next() ; work in progress local $find_text = guictrlread($find_box) if $find_text = '' then return local $current_sel = _guictrlrichedit_getsel($edit)[1] local $selection = _guictrlrichedit_findtextinrange($edit, $find_text, $current_sel, Default, $toggle_case, $toggle_word) if _guictrlrichedit_getsel($edit)[0] = $current_sel then $selection = _guictrlrichedit_findtextinrange($edit, $find_text, 0, Default, $toggle_case, $toggle_word) endif if isarray($selection) then _guictrlrichedit_setsel($edit, $selection[0], $selection[1]) endif endfunc func replace() ; work in progress local $replace_text = guictrlread($replace_box) if $replace_text = '' then return _guictrlrichedit_replacetext($edit, $replace_text) find() endfunc func replace_all() ; work in progress local $find_text = guictrlread($find_box) local $replace_text = guictrlread($replace_box) if $find_text = '' then return _guictrlrichedit_setsel($edit, 0, 0) local $selection do $selection = _guictrlrichedit_findtext($edit, $find_text, True, $toggle_case, $toggle_word) if $selection = -1 then exitloop _guictrlrichedit_setsel($edit, $selection, $selection + stringlen($find_text)) _guictrlrichedit_replacetext($edit, $replace_text) until false endfunc #Region scrollbar $scroll_drag = False ; are we dragging the scroll button? Func check_scroll_clicked() ; always sets $scroll_cursor variable Local $scroll_cursor = GUIGetCursorInfo($form) If _ $scroll_cursor[0] >= 300 And _ $scroll_cursor[0] <= 310 And _ $scroll_cursor[1] >= 60 And _ $scroll_cursor[1] <= 369 _ Then $scroll_drag = True EndFunc Func scroll() ; label : 300, 60, 10, 20 bar: 300, 60, 10, 310 lies visible: around 28 Local $scroll_x = 300 ; x of $scroll control at all times Local $scroll_min_y = 60, $scroll_max_y = 350 ; range of y movement for $scroll (top of frame till bottom - height) $scroll_cursor = GUIGetCursorInfo($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($scroll, $scroll_x, $scroll_cursor) ; drag scroll button within range of background bar $scroll_ratio = ($scroll_cursor - $scroll_min_y) / ($scroll_max_y - $scroll_min_y) ; calculate scroll position percentage between 0 and 1 $scroll_last = _GUICtrlRichEdit_GetLineCount($Edit) If $scroll_last > 27 then $scroll_last -= 25 ; scroll to end but not over end $scroll_first = _GUICtrlRichEdit_GetNumberOfFirstVisibleLine($edit) $scroll_calculate = Int($scroll_ratio * $scroll_last) - $scroll_first ; calculate where to walk to consolewrite(_GUICtrlRichEdit_GetLineCount($Edit) & '---' & $scroll_calculate & '---' & $scroll_ratio & @CRLF) _GUICtrlRichEdit_ScrollLines($edit, $scroll_calculate) EndFunc #endregion while 1 switch guigetmsg() case $gui_event_close, $button_exit quit() case $GUI_EVENT_PRIMARYDOWN check_scroll_clicked() Case $GUI_EVENT_MOUSEMOVE If $scroll_drag Then scroll() Case $GUI_EVENT_PRIMARYUP $scroll_drag = False case $button_open open() case $button_save if _guictrlrichedit_ismodified($edit) then save() ; only overwrite when needed soundplay($sound_click) endif case $button_bold stylize('bo') case $button_italic stylize('it') case $button_struck stylize('st') case $button_under stylize('un') case $button_red colorize($color_edit_red) case $button_green colorize($color_edit_green) case $button_blue colorize($color_edit_blue) case $button_white colorize($color_edit_white) case $button_default colorize($color_edit_gray) ; _guictrlrichedit_setcharattributes($edit, '-bo-it-un-st') Case $button_search soundplay($sound_click) GUICtrlSetData($find_box, _GUICtrlRichEdit_GetSelText($edit)) guisetstate(@SW_SHOW, $search) Case $checkbox_case $toggle_case = not $toggle_case GUICtrlSetImage($checkbox_case, $toggle_case ? $image_case_on : $image_case_off) soundplay($sound_click) Case $checkbox_word $toggle_word = not $toggle_word GUICtrlSetImage($checkbox_word, $toggle_word ? $image_word_on : $image_word_off) soundplay($sound_click) Case $button_find find() Case $button_next find_next() Case $button_replace replace() Case $button_all replace_all() Case $button_close soundplay($sound_click) GUISetState(@SW_HIDE, $search) endswitch wend And here is the code for the installer: #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 3.zip
  2. Hello, i would like to know why isnt anything displayed on the combo box. i used this example and added it to my code Autoit Example : #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Dim $sRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" GUICreate("Test", 400, 100) $cCombo_Font = GUICtrlCreateCombo("", 10, 10, 170, 20, 2097474);HELPHERE GUICtrlSetData($cCombo_Font, _RegEnumVal($sRegKey)) $cLabel = GUICtrlCreateLabel("Font preview", 230, 10, 155, 20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $cCombo_Font GUICtrlSetFont($cLabel, 10, Default, Default, GUICtrlRead($cCombo_Font)) EndSwitch WEnd Func _RegEnumVal($sKey) Local $i = 1, $sVal, $sResult While 1 $sVal = RegEnumVal($sKey, $i) If @error Then ExitLoop $i += 1 $sResult &= $sVal & "|" WEnd Return StringRegExpReplace($sResult, " \(.*?\)", "") EndFunc ;==>_RegEnumVal And my code: #NoTrayIcon #include <Misc.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiEdit.au3> #include <String.au3> #include <GuiRichEdit.au3> #include <GuiToolbar.au3> #include <GuiImageList.au3> $WIDTH = 500 $HEIGHT = 380 $EXT1 = "|Rich Text File (*.rtf)" $EXT2 = "|ODF Text (*.odt)" $EXT3 = "|All Files(*.*)" $EXT = $EXT1 & $EXT2 $SETTINGS = "Settings.ini" Dim $FONTKEY = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" Global $FILESAVE, $FILEOPEN = "", $SAVES, $SAVE, $FILEOPENED = 0 Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp $MAINGUI = GUICreate("Text Editor", $WIDTH, $HEIGHT, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE) $TOOLBAR = _GUICtrlToolbar_Create($MAINGUI) _GUIImageList_AddIcon($TOOLBAR, @SystemDir & "\shell.dll", -1) $IMAGES = _GUIImageList_Create(24,24) _GUICtrlToolbar_SetImageList($TOOLBAR, $IMAGES) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, -1);AndHereIfYouCouldTHX _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, -2) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 3) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 4) _GUICtrlToolbar_AddButtonSep($TOOLBAR) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 5) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 6) $EDITBOX = _GUICtrlRichEdit_Create($MAINGUI, "This is a test.", 10, 35, $WIDTH - 20, $HEIGHT - 70, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $FONTCOMBOBOX = GUICtrlCreateCombo("", $WIDTH - 170, 10, 160, 20, 2097474);HELPMEHERE GUICtrlSetData($FONTCOMBOBOX, _RegEnumVal($FONTKEY));ALSOHERE $FONTSIZECOMBOBOX = GUICtrlCreateCombo("", $WIDTH - 200, 10, 20, 20, 2097474);FuncForPreviousLineAtTheEnd $FILE = GUICtrlCreateMenu("File") $NEW = GUICtrlCreateMenuItem("New", $FILE) $OPEN = GUICtrlCreateMenuItem("Open...", $FILE) $SAVE = GUICtrlCreateMenuItem("Save", $FILE) $SAVEAS = GUICtrlCreateMenuItem("Save As...", $FILE) $PRINT = GUICtrlCreateMenuItem("Print...", $FILE) GUICtrlCreateMenuItem("", $FILE) $EXIT = GUICtrlCreateMenuItem("Exit", $FILE) $EDIT = GUICtrlCreateMenu("Edit") $UNDO = GUICtrlCreateMenuItem("Undo", $EDIT) $REDO = GUICtrlCreateMenuItem("Redo", $EDIT) $SEPARATOR = GUICtrlCreateMenuItem("", $EDIT) $FONT = GUICtrlCreateMenuItem("Font test", $EDIT) $SEPARATOR1 = GUICtrlCreateMenuItem("", $EDIT) $CUT = GUICtrlCreateMenuItem("Cut", $EDIT) $COPY = GUICtrlCreateMenuItem("Copy", $EDIT) $PASTE = GUICtrlCreateMenuItem("Paste", $EDIT) GUISetState(@SW_SHOW & $GUI_ACCEPTFILES) While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE If _GUICtrlEdit_CanUndo($EDITBOX) Then $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?") If $SAVECHANGES = 6 And $FILEOPENED = 0 Then SaveAs() _GUICtrlRichEdit_Destroy($hRichEdit) Exit EndIf If $SAVECHANGES = 6 And $FILEOPENED = 1 Then FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) Exit EndIf If $SAVECHANGES = 7 Then ExitLoop Exit EndIf EndIf If Not _GUICtrlEdit_CanUndo($EDITBOX) Then Exit Case $Msg = $OPEN $FILEOPEN = FileOpenDialog("Open", $FILEOPEN, $EXT) $TEXT = _GUICtrlRichEdit_StreamFromFile($EDITBOX, $FILEOPEN) _GUICtrlRichEdit_ReplaceText($EDITBOX, $TEXT) $FILEOPENED = 1 Case $Msg = $NEW If _GUICtrlEdit_CanUndo($EDITBOX) Then $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?") If $SAVECHANGES = 6 And $FILEOPENED = 0 Then SaveAs() EndIf If $SAVECHANGES = 6 And $FILEOPENED = 1 Then FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) EndIf If $SAVECHANGES = 7 Then GUICtrlSetData($EDITBOX, "") If $SAVECHANGES = 2 Then Sleep(1) EndIf If Not _GUICtrlEdit_CanUndo($EDITBOX) Then GUICtrlSetData($EDITBOX, "") $FILEOPENED = 0 Case $Msg = $EXIT If _GUICtrlEdit_CanUndo($EDITBOX) Then $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?") If $SAVECHANGES = 6 And $FILEOPENED = 0 Then SaveAs() _GUICtrlRichEdit_Destroy($hRichEdit) Exit EndIf If $SAVECHANGES = 6 And $FILEOPENED = 1 Then FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) Exit EndIf If $SAVECHANGES = 7 Then ExitLoop If $SAVECHANGES = 2 Then Sleep(1) EndIf EndIf If Not _GUICtrlEdit_CanUndo($EDITBOX) Then Exit Case $Msg = $SAVEAS GUICtrlSetState($EDITBOX, $GUI_DISABLE) SaveAs() $FILEOPENED = 1 GUICtrlSetState($EDITBOX, $GUI_ENABLE) Case $Msg = $SAVE And $FILEOPENED = 1 FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) _GUICtrlEdit_EmptyUndoBuffer($EDITBOX) Case $Msg = $SAVE And $FILEOPENED = 0 GUICtrlSetState($EDITBOX, $GUI_DISABLE) SaveAs() $FILEOPENED = 1 GUICtrlSetState($EDITBOX, $GUI_ENABLE) Case $Msg = $SAVE And $FILEOPENED = 0 GUICtrlSetState($EDITBOX, $GUI_DISABLE) SaveAs() $FILEOPENED = 1 GUICtrlSetState($EDITBOX, $GUI_ENABLE) Case $Msg = $PRINT $PRINTMSGBOX = MsgBox(35, "Text Editor", "Are you sure you want to print this page?") Select Case $PRINTMSGBOX = 6 If FileExists("Print.txt") Then FileDelete("Print.txt") EndIf FileWrite("Print.txt", GUICtrlRead($EDITBOX)) $PRINTFILE = "Print.txt" _FilePrint($PRINTFILE) FileDelete($PRINTFILE) EndSelect Case $Msg = $UNDO _GUICtrlRichEdit_Undo($EDITBOX) Case $Msg = $REDO _GUICtrlRichEdit_Redo($EDITBOX) Case _GUICtrlEdit_CanUndo($EDITBOX) And $SAVES = 1 GUICtrlSetState($SAVE, $GUI_ENABLE) Case $Msg = $CUT _GUICtrlRichEdit_Cut ($EDITBOX) Case $Msg = $COPY _GUICtrlRichEdit_Copy ($EDITBOX) Case $Msg = $PASTE _GUICtrlRichEdit_Paste ($EDITBOX) Case Not _GUICtrlEdit_CanUndo($EDITBOX) And $SAVES = 0 GUICtrlSetState($SAVE, $GUI_DISABLE) $SAVES = 1 Case $Msg = $FONT _GUICtrlRichEdit_SetFont($EDITBOX, $FONTSIZECOMBOBOX, "Times New Roman") Case $FONTCOMBOBOX _GUICtrlRichEdit_SetFont($EDITBOX, $FONTSIZECOMBOBOX, GUICtrlRead($FONTCOMBOBOX)) EndSelect WEnd Exit Func SaveAs() $FILESAVEAS = FileSaveDialog("Save As", "", "Text Document (*.txt)|All Files (*.*)") If Not @error Then $STRING = StringSplit($FILESAVEAS, ".") If $STRING[0] = 1 Then FileDelete($FILESAVEAS) _GUICtrlRichEdit_StreamToFile($EDITBOX, $FILESAVEAS &".rtf") Else _GUICtrlRichEdit_StreamToFile($EDITBOX, $FILESAVEAS &".rtf") EndIf EndIf EndFunc Func _RegEnumVal($sKey) Local $i = 1, $sVal, $sResult While 1 $sVal = RegEnumVal($sKey, $i) If @error Then ExitLoop $i += 1 $sResult &= $sVal & "|" WEnd Return StringRegExpReplace($sResult, " \(.*?\)", "") EndFunc ;==>_RegEnumVal So the problem is that The second combo box is blank Icons in taskbar are not appearing (don't really care for now, .dll file for icon in attachement) problem with $FONTCOMBOBOX = GUICtrlCreateCombo("", 10, 10, 200, 20, Bitor($CBS_SORT,$CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_VSCROLL) (BitOR gave me a weird error) Thanks ! Autoit newbie ico.dll
  3. Hey ya'll! Quick question: Is it possible to make text in a _GUICtrlRichEdit_Create:ed control strikethrough, much like you can do with the GUICtrlSetFont:s Attribute-parameter? It has to able to do so with selected text and not with everything in the control. Thanks in advance, zvvyt
  4. When I stream richtedit content to a .rtf file and want to open it, word tells me the file is locked by another user (I guess it's my program). Now, if I close my program or open the file in read-only mode, the document is empty. Here's the code I used: $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}" $where = FileSaveDialog("Plan Speichern", $MyDocsFolder,"Rich Text Files (*.rtf)", 2) If StringInStr($where,".rtf") Then _FileCreate($where) $infile = _GUICtrlRichEdit_StreamToFile($Edit1, $where) Else $where = $where & ".rtf" _FileCreate($where) $infile = _GUICtrlRichEdit_StreamToFile($Edit1, $where) EndIf Why is the document locked and has no content?
×
×
  • Create New...