#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Webpad.ico #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; AutoIt Version: 3.3.0.0 ;; ;; ;; ;; Template AutoIt script. ;; ;; ;; ;; AUTHOR: TheSaint ;; ;; ;; ;; SCRIPT FUNCTION: A minimal Text Editor to use/assist when posting on the web. ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Script generated by AutoBuilder 0.8 Prototype ; GUI FUNCTIONS ; BufferGUI(), DurationGUI(), WebpadButtonGUI() ; FUNCTIONS ; AddLeadingNumber($job), AddLeadingSpace($job), CharacterCountReport($show), DetermineOddOrEven($number) ; JoinLinesQuery($from), LoadSavedBackup($load), RemoveLeadingSpaces($job), SaveTextBackup() #include #include #include #include #include #include #include #include _Singleton("web-pad-thsaint") Global $Button_case, $Button_clear, $Button_copy, $Button_exit, $Button_find, $Button_ontop Global $Button_save, $Button_tab, $Button_x, $Button_x2 Global $Combo_extras, $Edit_text, $Group_asd, $Group_extras, $Group_stb, $Input_buff, $Input_dur Global $Label_buff, $Label_but, $Label_char, $Label_min, $Label_sav, $Updown_buff, $Updown_dur Global $Copy_menu, $Edit_menu, $File_menu, $Help_menu, $Lines_menu, $Mode_menu, $Save_menu, $Search_menu Global $About_item, $Active_item, $Ask_item, $Auto_item, $Backup_item, $Bkup_item_1, $Bkup_item_2 Global $Bkup_item_3, $Bkup_item_4, $Bkup_item_5, $Blank_item, $Blanks_item, $Buff_item, $Char_item_cnt Global $Clear_item, $Copy_item, $Export_item, $Fast_item, $Fix_item, $Font_item_dec, $Font_item_inc Global $Get_item, $Hist_item, $Import_item, $Info_item, $Job_item, $Last_item, $Load_item Global $Minclear_item, $Minimize_item, $Mode_item, $Multi_item, $Next_item, $Number_item, $One_item Global $Query_item, $Quick_item, $Quote_item, $Rem_item, $Remove_item, $Search_item, $Space_item Global $Spaces_item, $Time_item, $Trailing_item, $Unact_item, $Undo_item, $Update_item, $Wrap_item Global $aa, $actwin, $after, $ans, $ask, $autosave, $backup, $bakfle, $bakfle_1, $bakfle_2 Global $bakfle_3, $bakfle_4, $bakfle_5, $bb, $before, $begin, $bleft, $btop, $buffer, $BufferSet Global $butpos, $c, $case, $chars, $check, $chunk, $cliptx, $copyclr, $copyone, $count, $del, $diff Global $digit, $Duration, $end, $extra, $extras, $fast, $file, $find, $findmode, $fix, $fixes Global $Floatbut, $fndbak, $fndlen, $font, $from, $getclr, $h, $hang, $hdif, $height, $histfle Global $hunk, $icofle, $icoX, $import, $inifle, $insert, $job, $l, $last, $left, $line, $line_1 Global $line_2, $line_3, $lines, $load, $lump, $minclear, $mincopy, $mins, $msecs, $next, $num, $numb Global $number, $odd, $ontop, $original, $pass, $pos, $prev, $query, $quick, $quot_1, $quot_2, $quote Global $quotes, $remblank, $remove, $removes, $remtxt, $resized, $savfle, $Scriptname, $shell, $show Global $shown, $skip, $style, $succ, $text, $textlen, $top, $total, $two, $txtcnt, $txpos, $undo Global $version, $w, $wdif, $Webpad, $width, $winpos, $wins, $wintit, $wrap, $zero $histfle = @ScriptDir & "\History.txt" $inifle = @ScriptDir & "\Settings.ini" $savfle = @ScriptDir & "\Saved.txt" $bakfle_1 = @ScriptDir & "\Saved_1.txt" $bakfle_2 = @ScriptDir & "\Saved_2.txt" $bakfle_3 = @ScriptDir & "\Saved_3.txt" $bakfle_4 = @ScriptDir & "\Saved_4.txt" $bakfle_5 = @ScriptDir & "\Saved_5.txt" $version = "2.5" $Scriptname = "Web Pad v" & $version If IniRead($inifle, "Program Name", "version", "") = "" Then IniWrite($inifle, "Program Window", "left", "") IniWrite($inifle, "Program Window", "top", "") IniWrite($inifle, "Program Window", "width", "") IniWrite($inifle, "Program Window", "height", "") IniWrite($inifle, "Program Name", "version", $version) EndIf $left = IniRead($inifle, "Program Window", "left", "") If $left <> "" Then $wdif = IniRead($inifle, "Program Window", "width_dif", "") $hdif = IniRead($inifle, "Program Window", "height_dif", "") $width = IniRead($inifle, "Program Window", "width", "") $height = IniRead($inifle, "Program Window", "height", "") If $left < 0 Then $left = 0 ElseIf $left > (@DesktopWidth - $width) Then $left = @DesktopWidth - $width EndIf $width = $width - $wdif $top = IniRead($inifle, "Program Window", "top", "") If $top < 0 Then $top = 0 ElseIf $top > (@DesktopHeight - $height) Then $top = @DesktopHeight - $height EndIf $height = $height - $hdif Else $left = -1 $top = -1 $width = 360 $height = 410 EndIf $wrap = IniRead($inifle, "Edit Text", "wrap", "") If $wrap = "" Then $wrap = 1 IniWrite($inifle, "Edit Text", "wrap", $wrap) EndIf If $wrap = 1 Then $style = $ES_WANTRETURN + $WS_VSCROLL + $ES_AUTOVSCROLL Else $style = $ES_WANTRETURN + $WS_VSCROLL + $WS_HSCROLL + $ES_AUTOVSCROLL + $ES_AUTOHSCROLL EndIf $Webpad = GuiCreate($Scriptname, $width, $height, $left, $top, $WS_OVERLAPPED + $WS_CAPTION + $WS_SYSMENU + $WS_VISIBLE _ + $WS_CLIPSIBLINGS + $WS_MINIMIZEBOX + $WS_SIZEBOX, $WS_EX_TOPMOST) ; FILE MENU $File_menu = GUICtrlCreateMenu("&File") $Load_item = GUICtrlCreateMenuItem("Load", $File_menu) GUICtrlCreateMenuItem("", $File_menu) $Import_item = GUICtrlCreateMenuItem("Import from clipboard", $File_menu) GUICtrlCreateMenuItem("", $File_menu) $Export_item = GUICtrlCreateMenuItem("Export to clipboard", $File_menu) GUICtrlCreateMenuItem("", $File_menu) $Active_item = GUICtrlCreateMenuItem("Export to Active Window", $File_menu) ; $Edit_menu = GUICtrlCreateMenu("&Edit") $Clear_item = GUICtrlCreateMenuItem("Clear", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Undo_item = GUICtrlCreateMenuItem("Undo", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Font_item_inc = GUICtrlCreateMenuItem("Increase Font Size", $Edit_menu) $Font_item_dec = GUICtrlCreateMenuItem("Decrease Font Size", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Char_item_cnt = GUICtrlCreateMenuItem("Character Count Report", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Lines_menu = GUICtrlCreateMenu("Each Line", $Edit_menu) $Multi_item = GUICtrlCreateMenuItem("Multi Job", $Lines_menu) GUICtrlCreateMenuItem("", $Lines_menu) $Job_item = GUICtrlCreateMenuItem("About Multi Job", $Lines_menu) GUICtrlCreateMenuItem("", $Lines_menu) GUICtrlCreateMenuItem("", $Lines_menu) $Number_item = GUICtrlCreateMenuItem("Add leading number", $Lines_menu) GUICtrlCreateMenuItem("", $Lines_menu) $Space_item = GUICtrlCreateMenuItem("Add leading space", $Lines_menu) GUICtrlCreateMenuItem("", $Lines_menu) $Spaces_item = GUICtrlCreateMenuItem("Remove leading spaces", $Lines_menu) GUICtrlCreateMenuItem("", $Lines_menu) $Trailing_item = GUICtrlCreateMenuItem("Remove trailing spaces", $Lines_menu) GUICtrlCreateMenuItem("", $Lines_menu) $Blanks_item = GUICtrlCreateMenuItem("Remove blanks", $Lines_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Auto_item = GUICtrlCreateMenuItem("Auto import with Copy", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $One_item = GUICtrlCreateMenuItem("Copy First Line, Remove + Reduce", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Wrap_item = GUICtrlCreateMenuItem("Text Wrap", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Minimize_item = GUICtrlCreateMenuItem("Minimize on copy", $Edit_menu) ;~ $Restore_item = GUICtrlCreateMenuItem("Import clipboard on restore", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Minclear_item = GUICtrlCreateMenuItem("Minimize on clear", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Blank_item = GUICtrlCreateMenuItem("Remove blank lines on Import", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Ask_item = GUICtrlCreateMenuItem("Query Removal of trailing spaces", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Unact_item = GUICtrlCreateMenuItem("Undo active window setting", $Edit_menu) GUICtrlCreateMenuItem("", $Edit_menu) $Last_item = GUICtrlCreateMenuItem("Get last active window setting", $Edit_menu) ; $Save_menu = GUICtrlCreateMenu("&Autosave") $Backup_item = GUICtrlCreateMenuItem("Enabled", $Save_menu) $Time_item = GUICtrlCreateMenuItem("Duration", $Save_menu) GUICtrlCreateMenuItem("", $Save_menu) $Bkup_item_1 = GUICtrlCreateMenuItem("Saved 1", $Save_menu) $Bkup_item_2 = GUICtrlCreateMenuItem("Saved 2", $Save_menu) $Bkup_item_3 = GUICtrlCreateMenuItem("Saved 3", $Save_menu) $Bkup_item_4 = GUICtrlCreateMenuItem("Saved 4", $Save_menu) $Bkup_item_5 = GUICtrlCreateMenuItem("Saved 5", $Save_menu) GUICtrlCreateMenuItem("", $Save_menu) $Next_item = GUICtrlCreateMenuItem("Next Backup Number", $Save_menu) ; $Search_menu = GUICtrlCreateMenu("&Search") $Search_item = GUICtrlCreateMenuItem("Find", $Search_menu) GUICtrlCreateMenuItem("", $Search_menu) $Mode_item = GUICtrlCreateMenuItem("Quick Mode", $Search_menu) GUICtrlCreateMenuItem("", $Search_menu) $Buff_item = GUICtrlCreateMenuItem("Result Buffer", $Search_menu) ; $Copy_menu = GUICtrlCreateMenu("&Copy") $Get_item = GUICtrlCreateMenuItem("Clear clipboard on Get", $Copy_menu) GUICtrlCreateMenuItem("", $Copy_menu) $Copy_item = GUICtrlCreateMenuItem("Clear text field on Copy", $Copy_menu) GUICtrlCreateMenuItem("", $Copy_menu) $Update_item = GUICtrlCreateMenuItem("Update Undo Text", $Copy_menu) ; $Mode_menu = GUICtrlCreateMenu("&Mode") $Fix_item = GUICtrlCreateMenuItem("Fix Mode", $Mode_menu) $Rem_item = GUICtrlCreateMenuItem("Remove Mode", $Mode_menu) GUICtrlCreateMenuItem("", $Mode_menu) $Remove_item = GUICtrlCreateMenuItem("Remove", $Mode_menu) GUICtrlCreateMenuItem("", $Mode_menu) $Query_item = GUICtrlCreateMenuItem("Quick Fix + Query", $Mode_menu) $Quick_item = GUICtrlCreateMenuItem("Quick Fix", $Mode_menu) $Quote_item = GUICtrlCreateMenuItem("Quotes Only", $Mode_menu) $Fast_item = GUICtrlCreateMenuItem("Fast (No Quotes)", $Mode_menu) ; $Help_menu = GUICtrlCreateMenu("&Help") $Info_item = GUICtrlCreateMenuItem("Info", $Help_menu) GUICtrlCreateMenuItem("", $Help_menu) $Hist_item = GUICtrlCreateMenuItem("History", $Help_menu) GUICtrlCreateMenuItem("", $Help_menu) $About_item = GUICtrlCreateMenuItem("About", $Help_menu) ; ; CONTROLS ;$Button_ontop = GUICtrlCreateCheckbox ("On" & @LF & "Top", 10, 10, 40, 40, $BS_PUSHLIKE + $BS_MULTILINE) $Button_ontop = GUICtrlCreateCheckbox ("ON TOP", 10, 10, 44, 18, $BS_PUSHLIKE + $BS_MULTILINE) GUICtrlSetResizing($Button_ontop, $GUI_DOCKALL) GUICtrlSetFont($Button_ontop, 6, 500, 0, "Small Fonts") GUICtrlSetTip($Button_ontop, "Make program window be on top of others!") $Button_clear = GuiCtrlCreateButton ("CLEAR", 10, 30, 44, 20) GUICtrlSetResizing($Button_clear, $GUI_DOCKALL) GUICtrlSetFont($Button_clear, 6, 600, 0, "Small Fonts") GUICtrlSetTip($Button_clear, "Make program window be on top of others!") $Group_extras = GUICtrlCreateGroup("Extras", 64, 5, 71, 45) GUICtrlSetResizing($Group_extras, $GUI_DOCKALL) $Combo_extras = GUICtrlCreateCombo("", 73, 20, 53, 21) GUICtrlSetResizing($Combo_extras, $GUI_DOCKALL) GUICtrlSetTip($Combo_extras, "Choose extra formatting for selected text!") $Button_case = GuiCtrlCreateButton("Aa", 145, 10, 40, 40, $BS_ICON) GUICtrlSetResizing($Button_case, $GUI_DOCKALL) GUICtrlSetFont($Button_case, 14, 600) GUICtrlSetTip($Button_case, "Toggle the case of currently selected text!") $Button_tab = GuiCtrlCreateButton("TAB", 195, 10, 40, 40) GUICtrlSetResizing($Button_tab, $GUI_DOCKALL) GUICtrlSetFont($Button_tab, 7, 600, 0, "Small Fonts") GUICtrlSetTip($Button_tab, "Add a TAB from current position!") $Button_find = GuiCtrlCreateButton("FIND", 245, 10, 45, 40) GUICtrlSetResizing($Button_find, $GUI_DOCKALL) GUICtrlSetFont($Button_find, 7, 600, 0, "Small Fonts") GUICtrlSetTip($Button_find, "Search for text!") $Button_save = GuiCtrlCreateButton("SAVE", 300, 10, 50, 40) GUICtrlSetResizing($Button_save, $GUI_DOCKALL) GUICtrlSetFont($Button_save, 7, 600, 0, "Small Fonts") GUICtrlSetTip($Button_save, "Save current text to file!") $Button_copy = GuiCtrlCreateButton("COPY", 360, 10, 45, 40) GUICtrlSetResizing($Button_copy, $GUI_DOCKALL) GUICtrlSetFont($Button_copy, 7, 600, 0, "Small Fonts") GUICtrlSetTip($Button_copy, "Copy all Text to clipboard!") $Button_exit = GuiCtrlCreateButton("Exit", 415, 10, 40, 40, $BS_ICON) GUICtrlSetResizing($Button_exit, $GUI_DOCKALL) GUICtrlSetTip($Button_exit, "Minimize or Exit program and save window size & position!") ; $Edit_text = GuiCtrlCreateEdit("", 10, 65, $width - 20, $height - 100, $style) GUICtrlSetResizing($Edit_text, $GUI_DOCKBORDERS) ; ; OS SETTINGS $shell = @SystemDir & "\shell32.dll" If StringLeft(@OSVersion, 5) <> "WIN_9" And @OSVersion <> "WIN_ME" Then ; WIN_NT4, WIN_2000, WIN_XP, WIN_2003 $icofle = $shell $icoX = -28 Else $icofle = $shell $icoX = -7 EndIf GUICtrlSetImage($Button_exit, $icofle, $icoX, 1) ;GUICtrlSetImage($Button_case, "Fontsize.ico", 0, 1) ; ; SETTINGS $left = IniRead($inifle, "Program Window", "left", "") If $left = "" Then $winpos = WinGetPos($Webpad, "") IniWrite($inifle, "Program Window", "left", $winpos[0]) IniWrite($inifle, "Program Window", "top", $winpos[1]) IniWrite($inifle, "Program Window", "width", $winpos[2]) IniWrite($inifle, "Program Window", "height", $winpos[3]) $wdif = $winpos[2] - 360 $hdif = $winpos[3] - 410 IniWrite($inifle, "Program Window", "width_dif", $wdif) IniWrite($inifle, "Program Window", "height_dif", $hdif) Else $wdif = IniRead($inifle, "Program Window", "width_dif", "") $hdif = IniRead($inifle, "Program Window", "height_dif", "") EndIf ; $extras = "Quote|Code|Link" GUICtrlSetData($Combo_extras, $extras, "Quote") ; $ontop = IniRead($inifle, "Program Window", "ontop", "") If $ontop = "" Then $ontop = 1 IniWrite($inifle, "Program Window", "ontop", $ontop) EndIf If $ontop = 1 Then GUICtrlSetState($Button_ontop, $GUI_CHECKED) Else WinSetOnTop($Webpad, "", 0) EndIf ; $bakfle = IniRead($inifle, "Saved Backup File", "next", "") If $bakfle = "" Then $bakfle = 1 IniWrite($inifle, "Saved Backup File", "next", $bakfle) EndIf ; $autosave = IniRead($inifle, "Save Backup Files", "auto", "") If $autosave = "" Then $autosave = 1 IniWrite($inifle, "Save Backup Files", "auto", $autosave) EndIf If $autosave = 1 Then GUICtrlSetState($Backup_item, $GUI_CHECKED) $begin = TimerInit() EndIf ; $mins = IniRead($inifle, "Autosave Duration", "mins", "") If $mins = "" Then $mins = 1 IniWrite($inifle, "Autosave Duration", "mins", $mins) EndIf $msecs = $mins * 60 $msecs = $msecs * 1000 ; $findmode = IniRead($inifle, "Text Search", "mode", "") If $findmode = "" Then $findmode = "quick" IniWrite($inifle, "Text Search", "mode", $findmode) EndIf If $findmode = "quick" Then GUICtrlSetState($Mode_item, $GUI_CHECKED) EndIf ; $buffer = IniRead($inifle, "Text Search", "buffer", "") If $buffer = "" Then $buffer = 5 IniWrite($inifle, "Text Search", "buffer", $buffer) EndIf ; $mincopy = IniRead($inifle, "On Copy", "minimize", "") If $mincopy = 1 Then GUICtrlSetState($Minimize_item, $GUI_CHECKED) ; $minclear = IniRead($inifle, "On Clear", "minimize", "") If $minclear = 1 Then GUICtrlSetState($Minclear_item, $GUI_CHECKED) ; $remblank = IniRead($inifle, "Remove Blank Lines", "import", "") If $remblank = 1 Then GUICtrlSetState($Blank_item, $GUI_CHECKED) ; GUICtrlSetState($Unact_item, $GUI_DISABLE) ; $insert = "" $resized = "" ; If $wrap = 1 Then GUICtrlSetState($Wrap_item, $GUI_CHECKED) ; $import = IniRead($inifle, "Import With Copy", "auto", "") If $import = 1 Then GUICtrlSetData($Button_copy, "GET") GUICtrlSetState($One_item, $GUI_DISABLE) GUICtrlSetState($Auto_item, $GUI_CHECKED) EndIf ; $copyone = IniRead($inifle, "First Line Remove Reduce", "copy", "") If $copyone = 1 Then GUICtrlSetData($Button_copy, "ONE") GUICtrlSetState($Auto_item, $GUI_DISABLE) GUICtrlSetState($One_item, $GUI_CHECKED) EndIf ; $ask = IniRead($inifle, "Trailing Spaces Removal", "query", "") If $ask = 1 Then GUICtrlSetState($Ask_item, $GUI_CHECKED) $digit = IniRead($inifle, "Trailing Spaces Removal", "digit", "") EndIf ; $getclr = IniRead($inifle, "Clipboard On Get", "clear", "") If $getclr = 1 Then GUICtrlSetState($Get_item, $GUI_CHECKED) EndIf ; $copyclr = IniRead($inifle, "Text On Copy", "clear", "") If $copyclr = 1 Then GUICtrlSetState($Copy_item, $GUI_CHECKED) EndIf ; $query = IniRead($inifle, "Fix Mode", "query", "") If $query = "" Then $query = 4 IniWrite($inifle, "Fix Mode", "query", $query) ElseIf $query = 1 Then GUICtrlSetState($Query_item, $GUI_CHECKED) EndIf $quick = IniRead($inifle, "Fix Mode", "quick", "") If $quick = "" Then $quick = 4 IniWrite($inifle, "Fix Mode", "quick", $quick) ElseIf $quick = 1 Then GUICtrlSetState($Quick_item, $GUI_CHECKED) EndIf $quote = IniRead($inifle, "Fix Mode", "quote", "") If $quote = "" Then $quote = 4 IniWrite($inifle, "Fix Mode", "quote", $quote) ElseIf $quote = 1 Then GUICtrlSetState($Quote_item, $GUI_CHECKED) EndIf $fast = IniRead($inifle, "Fix Mode", "fast", "") If $fast = "" Then $fast = 4 IniWrite($inifle, "Fix Mode", "fast", $fast) ElseIf $fast = 1 Then GUICtrlSetState($Fast_item, $GUI_CHECKED) EndIf $fix = IniRead($inifle, "Process", "mode", "") $remove = IniRead($inifle, "Remove", "mode", "") If $fix = 1 Then GUICtrlSetData($Button_find, "FIX") GUICtrlSetState($Search_menu, $GUI_DISABLE) GUICtrlSetState($Fix_item, $GUI_CHECKED) Else If $remove = 1 Then GUICtrlSetData($Button_find, "REM") GUICtrlSetState($Search_menu, $GUI_DISABLE) GUICtrlSetState($Rem_item, $GUI_CHECKED) Else GUICtrlSetState($Remove_item, $GUI_DISABLE) EndIf GUICtrlSetState($Query_item, $GUI_DISABLE) GUICtrlSetState($Quick_item, $GUI_DISABLE) GUICtrlSetState($Quote_item, $GUI_DISABLE) GUICtrlSetState($Fast_item, $GUI_DISABLE) EndIf ; $pass = "" ; $hang = 0 $undo = "" $shown = "" GUICtrlSetState($Undo_item, $GUI_DISABLE) GuiSetState() While 1 ;~ If $insert = 1 Then ;~ If _IsPressed("01") Then ;~ $insert = "" ;~ Sleep(500) ;~ Send("^v") ;~ EndIf ;~ EndIf $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_exit ; Minimize or Exit program and save window size & position If _IsPressed("11") Then WinSetState($Webpad, "", @SW_MINIMIZE) WebpadButtonGUI() Else If $autosave = 1 Then SaveTextBackup() GUIDelete($Webpad) If $resized = 1 Then IniWrite($inifle, "Program Window", "left", $winpos[0]) IniWrite($inifle, "Program Window", "top", $winpos[1]) IniWrite($inifle, "Program Window", "width", $winpos[2]) IniWrite($inifle, "Program Window", "height", $winpos[3]) EndIf ExitLoop EndIf Case $msg = $GUI_EVENT_RESIZED ; Prevents window from being resized too small. If WinActive($Webpad, "") Then $resized = 1 $winpos = WinGetPos($Webpad, "") If ($winpos[2] - $wdif) < 465 Then WinMove($Webpad, "", $winpos[0], $winpos[1], 465 + $wdif, $winpos[3]) EndIf If ($winpos[3] - $hdif) < 180 Then WinMove($Webpad, "", $winpos[0], $winpos[1], $winpos[2], 180 + $hdif) EndIf EndIf Case $msg = $Button_tab ; Add a TAB from current position or check first character If _IsPressed("11") Then ; Check first character $text = GUICtrlRead($Edit_text) ;$text = ClipGet() If $text <> "" Then $c1 = StringLeft($text, 1) For $asc = 1 To 255 If $c1 == Chr($asc) Then MsgBox(262208, "First Character Check", "Chr = " & $asc & @LF & "Asc = " & Chr($asc), 0) EndIf Next EndIf Else ; Add a TAB from current position ControlFocus($Webpad, "", $Edit_text) ClipPut("") Send("^c") $text = ClipGet() If $text <> "" Then $textlen = StringLen($text) + 1 $text = $text & @TAB Else $textlen = 1 $text = @TAB EndIf ClipPut($text) Send("^v") ;Send("+{LEFT " & $textlen & "}") EndIf Case $msg = $Button_save ; Save current text to file $text = GUICtrlRead($Edit_text) If $text <> "" Then $file = FileOpen($savfle, 2) FileWrite($file, $text) FileClose($file) EndIf Case $msg = $Button_ontop ; Toggle program window Ontop setting If GUICtrlRead($Button_ontop) = $GUI_CHECKED Then $ontop = 1 WinSetOnTop($Webpad, "", 1) Else $ontop = 4 WinSetOnTop($Webpad, "", 0) EndIf IniWrite($inifle, "Program Window", "ontop", $ontop) Case $msg = $Button_copy Or $msg = $Export_item ; Export = current text (copy all) to clipboard If _IsPressed("11") Or GUICtrlRead($Button_copy) = "GET" Then $text = ClipGet() If $getclr = 1 Then ClipPut("") If $remblank = 1 Then $text = StringReplace($text, @CRLF & @CRLF, @CRLF) $text = StringReplace($text, "�", "-") $text = StringReplace($text, Chr(0), "-") ;$text = StringReplace($text, "?", "-") ;For $asc = 0 To 31 ;For $asc = 128 To 255 ;If StringInStr($text, Chr($asc)) > 0 Then ; $text = StringReplace($text, Chr($asc), "-") ; MsgBox(262177, "Found ASC", $asc) ; ExitLoop ;EndIf ;Next If StringLeft($text, 1) = @CRLF Then $text = StringTrimLeft($text, 1) ;$text = StringStripWS($text, 3) If $ask = 1 Then If StringRight($text, 1) = " " Then If ($digit = 1 And StringInStr($text, "1") < 1) Or $digit = "" Then $ans = MsgBox(262177, "Trailing Spaces Query", "Do you want to remove existing trailing space(s) ?", 0) If $ans = 1 Then $text = StringStripWS($text, 2) EndIf EndIf EndIf EndIf If $copyone = 1 Then $ans = MsgBox(262177, "Leading Spaces Query", "Remove existing leading space(s) for each line?", 0) If $ans = 1 Then RemoveLeadingSpaces("one") EndIf EndIf GUICtrlSetData($Edit_text, "") GUICtrlSetData($Edit_text, $text) $undo = $text If $undo <> "" Then GUICtrlSetState($Undo_item, $GUI_ENABLE) If GUICtrlRead($Button_copy) <> "ONE" Then GUICtrlSetData($Button_copy, "COPY") CharacterCountReport(1) Else $text = GUICtrlRead($Edit_text) If $copyone = 1 Then If $text <> "" Then GUICtrlSetData($Edit_text, "") $pos = StringInStr($text, @CRLF) If $pos > 0 Then $line = StringLeft($text, $pos - 1) $text = StringMid($text, $pos + 2) Else $line = $text $text = "" EndIf ClipPut($line) GUICtrlSetData($Edit_text, $text) EndIf Else If $text <> "" Then ClipPut($text) If $copyclr = 1 Then GUICtrlSetData($Edit_text, "") $undo = $text EndIf EndIf If $mincopy = 1 Then WinSetState($Webpad, "", @SW_MINIMIZE) If $actwin = "" Then $ans = MsgBox(262177, "Active Window Query", _ "You can if you like, now specify a window to work with on" & @LF & _ "Copy and Minimize. To do this, close this dialog using the" & @LF & _ "OK button, then click on (activate/restore/start) desired " & @LF & _ "window, then right click on it's title bar. On success, you" & @LF & _ "should be presented with a title dialog. After that, and" & @LF & _ "until the program closes, the window will be automatically" & @LF & _ "restored/activated for you when clicking on Copy." & @LF & @LF & _ "Do you want to do this?" & @LF & @LF & _ "NOTE - If you select CANCEL, then you won't get asked" & @LF & _ "this again, until you restart the program. That last part" & @LF & _ "is also required to change the setting to another.", 0) If $ans = 1 Then Sleep(500) While 1 If _IsPressed("02") Then $actwin = WinGetHandle("[ACTIVE]", "") If @error <> 1 And $actwin <> "" Then IniWrite($inifle, "Active Window", "handle", $actwin) MsgBox(262208, "Active Window Handle", $actwin, 0) Sleep(500) GUICtrlSetState($Unact_item, $GUI_ENABLE) ;$wintit = WinGetTitle("[ACTIVE]", "") ;$wintit = WinGetTitle("[LAST]", "") ;$wintit = WinGetTitle($actwin, "") $wins = WinList() For $w = 1 To $wins[0][0] If $wins[$w][1] = $actwin Then $wintit = $wins[$w][0] ExitLoop EndIf Next ;MsgBox(262208, "Active Window Title", $wintit, 0) MsgBox(262208, "Active Window Title", $wintit & " (" & $actwin & ")", 0) IniWrite($inifle, "Active Window", "title", $wintit) Else MsgBox(262192, "Error", "Active window could not be determined.", 0) EndIf ExitLoop Else Sleep(500) EndIf WEnd ElseIf $ans = 2 Then $actwin = "no" EndIf ElseIf $actwin <> "no" Then $succ = WinActivate($actwin, "") If $succ = 0 Then $wintit = IniRead($inifle, "Active Window", "title", "") $pos = StringInStr($wintit, "[") If $pos > 0 Then $wintit = StringLeft($wintit, $pos - 1) $succ = WinActivate($wintit, "") If $succ = 1 Then $actwin = WinGetHandle($wintit, "") MsgBox(262208, "Active Window Title", $wintit & " (" & $actwin & ")", 0) EndIf EndIf EndIf If $import = 1 Then GUICtrlSetData($Button_copy, "GET") EndIf EndIf Case $msg = $Button_case ; Toggle case of selected text or Character Count Report If _IsPressed("11") Then ; Character Count Report CharacterCountReport(2) Else ; Toggle case of selected text ControlFocus($Webpad, "", $Edit_text) ClipPut("") Send("^c") $text = ClipGet() If $text <> "" Then $textlen = StringLen($text) If $original = "" Then $original = $text $text = _StringProper($text) $case = "title" Else If $original = $text Then If $case = "title" Then $case = "upper" $text = StringUpper($text) ElseIf $case = "upper" Then $case = "lower" $text = StringLower($text) ElseIf $case = "lower" Then $case = "title" $text = _StringProper($text) EndIf Else $original = $text $text = _StringProper($text) $case = "title" EndIf EndIf ClipPut($text) Send("^v") Send("+{LEFT " & $textlen & "}") EndIf EndIf Case $msg = $Combo_extras ; Choose extra formatting for selected text $extra = GUICtrlRead($Combo_extras) ControlFocus($Webpad, "", $Edit_text) ClipPut("") Send("^c") $text = ClipGet() If $text <> "" Then $textlen = StringLen($text) + 15 Else $textlen = 15 EndIf If $extra = "Quote" Then ; Add quote for currently selected text or at cursor point If StringLeft($text, 7) = "[quote]" Then $text = StringReplace($text, "[quote]", "") $text = StringReplace($text, "[/quote]", "") $textlen = StringLen($text) Else $text = "[quote]" & $text & "[/quote]" EndIf ElseIf $extra = "Link" Then ; Add link quotes for currently selected text or at cursor point If StringLeft($text, 8) = "[url='']" Then $text = StringReplace($text, "[url='']", "") $text = StringReplace($text, "[/url]", "") $textlen = StringLen($text) Else $textlen = $textlen -1 $text = "[url='']" & $text & "[/url]" EndIf ElseIf $extra = "Code" Then ; Add code quotes for currently selected text or at cursor point If StringLeft($text, 8) = "[autoit]" Then $text = StringReplace($text, "[autoit]", "") $text = StringReplace($text, "[/autoit]", "") $textlen = StringLen($text) Else $textlen = $textlen + 2 $text = "[autoit]" & $text & "[/autoit]" EndIf EndIf ClipPut($text) Send("^v") Send("+{LEFT " & $textlen & "}") Case $msg = $Wrap_item ; Text Wrap $text = GUICtrlRead($Edit_text) GUICtrlDelete($Edit_text) If $wrap = 1 Then $wrap = 4 GUICtrlSetState($Wrap_item, $GUI_UNCHECKED) $style = $ES_WANTRETURN + $WS_VSCROLL + $WS_HSCROLL + $ES_AUTOVSCROLL + $ES_AUTOHSCROLL Else $wrap = 1 GUICtrlSetState($Wrap_item, $GUI_CHECKED) $style = $ES_WANTRETURN + $WS_VSCROLL + $ES_AUTOVSCROLL EndIf IniWrite($inifle, "Edit Text", "wrap", $wrap) $Edit_text = GuiCtrlCreateEdit("", 10, 65, $width - 20, $height - 100, $style) GUICtrlSetResizing($Edit_text, $GUI_DOCKBORDERS) GUICtrlSetData($Edit_text, $text) Case $msg = $Update_item ; Update Undo Text If $undo <> "" Then $ans = MsgBox(262177, "Update Undo Query", _ "Are you sure you want to update the" & @LF & _ "UNDO text with the current text?" & @LF & @LF & _ "NOTE - This cannot be undone.", 0) Else $ans = 1 EndIf If $ans = 1 Then $text = GUICtrlRead($Edit_text) $undo = $text If $undo = "" Then GUICtrlSetState($Undo_item, $GUI_DISABLE) Else GUICtrlSetState($Undo_item, $GUI_ENABLE) EndIf EndIf Case $msg = $Undo_item ; Undo If $undo <> "" Then $text = GUICtrlRead($Edit_text) If $text <> "" Then $ans = MsgBox(262193, "Undo Query", _ "Are you sure you want to replace any" & @LF & _ "current text with the UNDO text?" & @LF & @LF & _ "NOTE - This cannot be undone.", 0) Else $ans = 1 EndIf If $ans = 1 Then $text = $undo GUICtrlSetData($Edit_text, "") GUICtrlSetData($Edit_text, $text) If GUICtrlRead($Button_copy) = "COPY" And $import = 1 Then GUICtrlSetData($Button_copy, "GET") EndIf EndIf EndIf Case $msg = $Unact_item ; Undo active window setting $actwin = "" GUICtrlSetState($Unact_item, $GUI_DISABLE) Case $msg = $Trailing_item ; Each Line - Remove trailing spaces $text = GUICtrlRead($Edit_text) If $text <> "" Then $lines = StringSplit($text, @CRLF) $text = "" For $l = 1 To $lines[0] If $lines[$l] <> "" Then $text = $text & @CRLF & StringStripWS($lines[$l], 2) Else $text = $text & @CRLF EndIf Next GUICtrlSetData($Edit_text, "") GUICtrlSetData($Edit_text, $text) EndIf Case $msg = $Time_item ; Autosave Duration If $ontop = 1 Then WinSetOnTop($Webpad, "", 0) DurationGUI() If $ontop = 1 Then WinSetOnTop($Webpad, "", 1) Case $msg = $Spaces_item ; Each Line - Remove leading spaces RemoveLeadingSpaces("") Case $msg = $Space_item ; Each Line - Add leading space AddLeadingSpace("") Case $msg = $Search_item Or $msg = $Button_find ; Search or Fix or Remove If $remove = 1 Then $text = GUICtrlRead($Edit_text) If $text <> "" Then GUICtrlSetState($Button_find, $GUI_DISABLE) $chars = StringLen($text) $lump = StringSplit($text, @CRLF, 1) $total = $lump[0] ;MsgBox(262192, "Line Count", $total) $text = "" $removes = 0 $remtxt = IniRead($inifle, "Fix Mode", "remove", "") If $remtxt = "" Then MsgBox(262192, "Remove Error", _ "No removal text has been specified." & @LF & @LF & _ "Click the 'Remove' menu item (below" & @LF & _ "Remove Mode) to specify all removal" & @LF & _ "text, etc.", 0) Else For $h = 1 To $total If $h > 1 Then $prev = $lump[$h - 1] $prev = StringRight($prev, 70) Else $prev = "" EndIf $hunk = $lump[$h] If $h < $total Then $next = $lump[$h + 1] $next = StringLeft($next, 70) Else $next = "" EndIf $check = StringSplit($remtxt, "|") For $c = 1 To $check[0] $numb = StringStripWS($hunk, 3) If StringInStr($hunk, $check[$c]) > 0 Or ($check[$c] = "##" And StringIsDigit($numb)) Then $ans = MsgBox(262193, "Removal Query", _ "[[Previous line has the text]]" & @LF & _ $prev & @LF & @LF & _ "[The following line contains the removal text]" & @LF & _ $hunk & @LF & @LF & _ "[[Next line has the text]]" & @LF & _ $next & @LF & @LF & _ "Do you want to remove the contains line?", 0) If $ans = 1 Then ;$hunk = @CRLF $hunk = "" $text = $text & @CRLF $removes = $removes + 1 EndIf ExitLoop EndIf Next If $text = "" Then $text = $hunk ElseIf $hunk <> "" Then $text = $text & @CRLF & $hunk EndIf Next If $text <> "" Then GUICtrlSetData($Edit_text, "") GUICtrlSetData($Edit_text, $text) MsgBox(262208, "Result", $removes & " lines were removed." _ & @LF & @LF & "We started with " & $chars & " characters," _ & @LF & "and finished with " & StringLen($text) & " characters." _ & @LF & "A reduction of " & ($chars - StringLen($text)) & " characters.", 0) EndIf GUICtrlSetState($Button_find, $GUI_ENABLE) EndIf EndIf ElseIf $fix = 1 Then $text = GUICtrlRead($Edit_text) If $text <> "" Then GUICtrlSetState($Button_find, $GUI_DISABLE) $chars = StringLen($text) $lump = StringSplit($text, @CRLF, 1) $total = $lump[0] ;MsgBox(262192, "Line Count", $total) $text = "" $fixes = 0 ; $ans = MsgBox(262193, "Space Fix Query", _ "Do you want a quick pass to occur, that just removes" & @LF & _ "any trailing spaces after a fullstop (or period)?" & @LF & @LF & _ "NOTE - This will also include any fullstop nested inside" & @LF & _ "double or single quotes. All Question and Exclamation" & @LF & _ "marks are also processed in the same way too." & @LF & @LF & _ "THIS ONLY APPLIES TO THE END OF A LINE.", 0) If $ans = 1 Then For $h = 1 To $total $hunk = $lump[$h] If StringRight($hunk, 2) = ". " Or StringRight($hunk, 3) = ".' " Or StringRight($hunk, 3) = '." ' _ Or StringRight($hunk, 2) = "? " Or StringRight($hunk, 3) = "?' " Or StringRight($hunk, 3) = '?" ' _ Or StringRight($hunk, 2) = "! " Or StringRight($hunk, 3) = "!' " Or StringRight($hunk, 3) = '!" ' Then $hunk = StringStripWS($hunk, 2) $fixes = $fixes + 1 EndIf If $text = "" Then $text = $hunk Else $text = $text & @CRLF & $hunk EndIf Next If $text <> "" Then GUICtrlSetData($Edit_text, "") GUICtrlSetData($Edit_text, $text) MsgBox(262208, "Result", $fixes & " lines had trailing spaces removed." _ & @LF & @LF & "We started with " & $chars & " characters," _ & @LF & "and finished with " & StringLen($text) & " characters." _ & @LF & "A reduction of " & ($chars - StringLen($text)) & " characters.", 0) EndIf ElseIf $ans = 2 Then If $remtxt = "" And $pass = "" Then $remtxt = IniRead($inifle, "Fix Mode", "remove", "") If $remtxt <> "" Then $ans = MsgBox(262177, "Removal Query", _ "Remove has not been enabled, but it contains one or more values." & @LF & @LF & _ "Do you wish to Enable the Remove option?", 0) If $ans = 2 Then $remtxt = "" $pass = 1 EndIf EndIf EndIf For $h = 1 To $total $hunk = $lump[$h] $hunk = StringReplace($hunk, @CR, "") $hunk = StringReplace($hunk, @LF, "") If $h < $total Then $next = $lump[$h + 1] $next = StringReplace($next, @CR, "") $next = StringReplace($next, @LF, "") EndIf If $remtxt <> "" Then $check = StringSplit($remtxt, "|") For $c = 1 To $check[0] If StringInStr($hunk, $check[$c]) > 0 Or ($check[$c] = "##" And StringIsDigit($hunk)) Then $ans = MsgBox(262193, "Removal Query", _ "The following line contains the removal text." & @LF & @LF & _ $hunk & @LF & @LF & _ "Do you want to remove the line?", 0) If $ans = 1 Then ;$hunk = @CRLF $hunk = "" $text = $text & @CRLF $fixes = $fixes + 1 EndIf ExitLoop EndIf Next EndIf ;If $h = 1 Then If $text = "" Then $text = $hunk ElseIf $hunk <> "" Then $end = StringRight($text, 1) $two = StringRight($text, 2) ;MsgBox(262192, "$end $two", "'" & $end & "' + '" & $two & "'") If $end = "." Or $end = "!" Or $end = "?" Or $two = '."' Or $two = '!"' Or $two = '?"' _ Or $two = '.”' Or $two = '!”' Or $two = '?”' _ Or $two = ".'" Or $two = "!'" Or $two = "?'" _ Or $two = ".’" Or $two = "!’" Or $two = "?’" _ Or $two = '. ' Or $two = '! ' Or $two = '? ' Then ;MsgBox(262192, "Section", "1") If StringIsLower(StringLeft($hunk, 1)) And $quote = 4 Then ;MsgBox(262192, "Section", "1a") If $end = " " Then $text = $text & $hunk Else $text = $text & " " & $hunk EndIf $fixes = $fixes + 1 Else ;MsgBox(262192, "Section", "1b") If (StringRight($text, 3) == "Mr." Or StringRight($text, 4) == "Mr. ") And $quote = 4 Then ;MsgBox(262192, "Section", "1b1") If $end = " " Then $text = $text & $hunk Else $text = $text & " " & $hunk EndIf $fixes = $fixes + 1 ElseIf (StringRight($text, 3) == "St." Or StringRight($text, 4) == "St. ") And $quote = 4 Then JoinLinesQuery(2) Else ;MsgBox(262192, "Section", "1b2") If $fast = 4 Then ;MsgBox(262192, "Section", "1b2a") If $two = '. ' Or $two = '! ' Or $two = '? ' Then JoinLinesQuery(2) Else JoinLinesQuery(1) EndIf Else $text = $text & @CRLF & $hunk EndIf EndIf EndIf Else ;MsgBox(262192, "Section", "2") If (StringIsLower(StringLeft($hunk, 1)) Or $two = ',"' Or $two = ',”' Or $two = ', ' Or $end = ',' Or $two = ",'" Or $two = ",’" _ Or $two = '‚"' Or $two = '‚”' Or $two = '‚ ' Or $end = '‚' Or $two = "‚'" Or $two = "‚’" _ Or StringIsDigit(StringLeft($hunk, 1))) And $quote = 4 Then ;Or $two = ';"' Or $two = ';”' Or $two = '; ' Or $end = ';' Or $two = ";'" Or $two = ";’" _ ;MsgBox(262192, "Section", "2a") ;MsgBox(262192, "Hunk", StringLeft($hunk, 3)) If $end = " " Or $end = "-" Or $end = @CRLF Or $end = @CR Or $end = @LF Or $end = "" Then $text = $text & $hunk Else $text = $text & " " & $hunk EndIf $fixes = $fixes + 1 Else ;MsgBox(262192, "Section", "2b") JoinLinesQuery(2) EndIf EndIf EndIf If _IsPressed("11") Then $ans = MsgBox(262177, "Abort Query", _ "Do you really want to abort the Fix?" & @LF & @LF & _ "No changes will be made to original" & @LF & _ "text if you do, all are discarded.", 0) If $ans = 1 Then $text = GUICtrlRead($Edit_text) ExitLoop EndIf EndIf Next If $text <> "" Then GUICtrlSetData($Edit_text, "") GUICtrlSetData($Edit_text, $text) MsgBox(262208, "Result", $fixes & " lines had to be fixed (joined correctly)." _ & @LF & @LF & "We started with " & $chars & " characters," _ & @LF & "and finished with " & StringLen($text) & " characters." _ & @LF & "A reduction of " & ($chars - StringLen($text)) & " characters.", 0) EndIf EndIf GUICtrlSetState($Button_find, $GUI_ENABLE) EndIf Else $last = IniRead($inifle, "Text Search", "last", "") $find = InputBox("Text Search", "Text to search for.", $last, "", 200, 130, -1, -1, "", $Webpad) If Not @error And $find <> "" Then IniWrite($inifle, "Text Search", "last", $find) $fndlen = StringLen($find) $fndbak = $fndlen - 1 If $findmode = "quick" Then $text = GUICtrlRead($Edit_text) If $text <> "" Then $txtcnt = StringLen($text) $txpos = 1 While 1 $cliptx = StringMid($text, $txpos, $fndlen) If $cliptx = "" Then ;If $find > 9 Then MsgBox(262192, "Error Check 1", $find, 0) $ans = MsgBox(262177, "Search Result", _ "[1] End of text has been reached." & @LF & @LF & _ "Do you want to start again?", 0) If $ans = 1 Then ; Start Again $txpos = 1 If StringIsDigit($find) Then $ans = MsgBox(262177, "Search Query", "Do you want to INCREMENT the find number? " & $find & @LF & @LF & _ "CANCEL = Repeat search for same value.", 0) If $ans = 1 Then $find = $find + 1 $fndlen = StringLen($find) $fndbak = $fndlen - 1 EndIf EndIf ElseIf $ans = 2 Then ; Stop ExitLoop EndIf Else ; This below was relocated to the above Else, from just another further check. ; Not sure why I missed this first time around, as a nothing result has no need ; to do anything but exit or restart at beginning, and anything else (as it was) ; is plain wrong ... oh well. If StringLen($cliptx) = $fndlen Then $skip = "" If StringIsDigit($find) Then $before = StringMid($text, $txpos - 1, 1) If StringIsDigit($before) Then $skip = 1 Else $after = StringMid($text, $txpos + $fndlen, 1) If StringIsDigit($after) Then $skip = 1 EndIf EndIf EndIf If $cliptx = $find And $skip = "" Then $del = "" $chunk = StringMid($text, $txpos - $buffer, $buffer) & "| " $chunk = $chunk & StringMid($text, $txpos, $fndlen) $chunk = $chunk & " |" & StringMid($text, $txpos + $fndlen, $buffer) $ans = MsgBox(262177, "Search Result", "Do you want to DELETE the found text?" & @LF & @LF & $chunk, 0) If $ans = 1 Then $del = 1 $text = StringLeft($text, $txpos - 1) & StringMid($text, $txpos + $fndlen) $text = StringStripWS($text, 3) $txtcnt = StringLen($text) GUICtrlSetData($Edit_text, "") GUICtrlSetData($Edit_text, $text) EndIf ;$ans = MsgBox(262182, "Search Result", _ $ans = MsgBox(262438, "Search Result", _ "CANCEL = Abort." & @LF & _ "TRY AGAIN = Search for same text again." & @LF & _ "CONTINUE = Start again & Increment if search text is numeric.", 0) If $ans = 2 Then ; Stop ExitLoop ElseIf $ans = 10 Then ; Continue If $del <> 1 Then $txpos = $txpos + 1 EndIf ElseIf $ans = 11 Then ; Start Again $txpos = 1 If StringIsDigit($find) Then $find = $find + 1 $fndlen = StringLen($find) $fndbak = $fndlen - 1 EndIf EndIf Else If $txpos = $txtcnt And StringIsDigit($find) Then $ans = MsgBox(262177, "Search Result", "Do you want to INCREMENT the search text? " & $find & @LF & @LF & _ "CANCEL = Abort & Exit.", 0) If $ans = 1 Then ; Start Again $find = $find + 1 $fndlen = StringLen($find) $fndbak = $fndlen - 1 $txpos = 1 Else ; Stop ExitLoop EndIf Else $txpos = $txpos + 1 EndIf EndIf Else ;If $find > 9 Then MsgBox(262192, "Error Check 2", $find & @LF & $cliptx & @LF & $fndlen & @LF & $txtcnt & @LF & $txpos, 0) If $txpos = $txtcnt And StringIsDigit($find) Then $ans = MsgBox(262177, "Search Result", "Do you want to INCREMENT the search text? " & $find & @LF & @LF & _ "CANCEL = Progress report.", 0) If $ans = 1 Then ; Start Again $find = $find + 1 $fndlen = StringLen($find) $fndbak = $fndlen - 1 $txpos = 1 Else $ans = MsgBox(262177, "Search Result", _ "[2] End of text has been reached." & @LF & @LF & _ "Do you want to start again?", 0) If $ans = 1 Then ; Start Again $txpos = 1 ElseIf $ans = 2 Then ; Stop ExitLoop EndIf EndIf Else $ans = MsgBox(262177, "Search Result", _ "[3] End of text has been reached." & @LF & @LF & _ "Do you want to start again?", 0) If $ans = 1 Then ; Start Again $txpos = 1 If StringIsDigit($find) Then $ans = MsgBox(262177, "Search Query", "Do you want to INCREMENT the find number? " & $find & @LF & @LF & _ "CANCEL = Repeat search for same value.", 0) If $ans = 1 Then $find = $find + 1 $fndlen = StringLen($find) $fndbak = $fndlen - 1 EndIf EndIf ElseIf $ans = 2 Then ; Stop ExitLoop EndIf EndIf EndIf ; EndIf WEnd EndIf Else WinActivate($Webpad, "") GUICtrlSetState($Edit_text, $GUI_FOCUS) Send("^{HOME}") $count = 1 While 1 Send("+{RIGHT " & $fndlen & "}") Send("^c") $cliptx = ClipGet() If $cliptx = "" Then ExitLoop If StringLen($cliptx) = $fndlen Then If $cliptx = $find Then $del = "" $ans = MsgBox(262177, "Search Result", "Do you want to delete the found text?", 0) If $ans = 1 Then $del = 1 Send("{DELETE}") EndIf ;$ans = MsgBox(262182, "Search Result", _ $ans = MsgBox(262438, "Search Result", _ "CANCEL = Abort." & @LF & _ "TRY AGAIN = Search for same text again." & @LF & _ "CONTINUE = Start again & Increment if search text is numeric.", 0) WinActivate($Webpad, "") If $ans = 2 Then ExitLoop ElseIf $ans = 10 Then If $del <> 1 Then Send("{LEFT}") Send("{RIGHT}") EndIf ElseIf $ans = 11 Then Send("^{HOME}") If StringIsDigit($find) Then $find = $find + 1 $fndlen = StringLen($find) $fndbak = $fndlen - 1 EndIf EndIf Else If $fndlen > 1 Then Send("{LEFT " & $fndbak & "}") Else Send("{LEFT}") Send("{RIGHT}") EndIf EndIf ClipPut("") Else $ans = MsgBox(262177, "Search Result", "Do you want to continue?", 0) If $ans = 1 Then Send("{RIGHT}") ElseIf $ans = 2 Then ExitLoop EndIf EndIf If StringRight($count, 1) = 0 Then If _IsPressed("11") Then $ans = MsgBox(262177, "Search Result", "Do you want to abort the search?", 0) If $ans = 1 Then ExitLoop EndIf EndIf EndIf $count = $count + 1 WEnd EndIf EndIf EndIf Case $msg = $Remove_item ; Fix Mode - Remove $remtxt = IniRead($inifle, "Fix Mode", "remove", "") $remtxt = InputBox("Remove Line Query", "OK = Enable (requires text). CANCEL = Disable." _ & @LF & @LF & "Use a pipe inbetween entries to indicate more than one" _ & @LF & "removal. The use of two hashes (##) indicates removal" _ & @LF & "of a number only line." _ & @LF & @LF & "Remove a line if it contains the following text.", _ $remtxt, "", 300, 200, -1, -1, "", $Webpad) If Not @error And $remtxt <> "" Then IniWrite($inifle, "Fix Mode", "remove", $remtxt) Else $remtxt = "" EndIf Case $msg = $Rem_item ; Remove Mode If $remove = 1 Then $remove = 4 GUICtrlSetState($Rem_item, $GUI_UNCHECKED) GUICtrlSetData($Button_find, "FIND") GUICtrlSetState($Search_menu, $GUI_ENABLE) GUICtrlSetState($Query_item, $GUI_DISABLE) GUICtrlSetState($Quick_item, $GUI_DISABLE) GUICtrlSetState($Quote_item, $GUI_DISABLE) GUICtrlSetState($Fast_item, $GUI_DISABLE) Else $remove = 1 GUICtrlSetState($Rem_item, $GUI_CHECKED) GUICtrlSetData($Button_find, "REM") GUICtrlSetState($Search_menu, $GUI_DISABLE) If $fix = 1 Then $fix = 4 IniWrite($inifle, "Process", "mode", $fix) GUICtrlSetState($Fix_item, $GUI_UNCHECKED) GUICtrlSetState($Query_item, $GUI_DISABLE) GUICtrlSetState($Quick_item, $GUI_DISABLE) GUICtrlSetState($Quote_item, $GUI_DISABLE) GUICtrlSetState($Fast_item, $GUI_DISABLE) EndIf EndIf IniWrite($inifle, "Remove", "mode", $remove) Case $msg = $Quote_item ; Fix Mode - Quotes Only If $quote = 1 Then $quote = 4 GUICtrlSetState($Quote_item, $GUI_UNCHECKED) Else $quote = 1 GUICtrlSetState($Quote_item, $GUI_CHECKED) If $fast = 1 Then $fast = 4 IniWrite($inifle, "Fix Mode", "fast", $fast) GUICtrlSetState($Fast_item, $GUI_UNCHECKED) ElseIf $quick = 1 Then $quick = 4 IniWrite($inifle, "Fix Mode", "quick", $quick) GUICtrlSetState($Quick_item, $GUI_UNCHECKED) ElseIf $query = 1 Then $query = 4 IniWrite($inifle, "Fix Mode", "query", $query) GUICtrlSetState($Query_item, $GUI_UNCHECKED) EndIf EndIf IniWrite($inifle, "Fix Mode", "quote", $quote) Case $msg = $Quick_item ; Fix Mode - Quick Fix If $quick = 1 Then $quick = 4 GUICtrlSetState($Quick_item, $GUI_UNCHECKED) Else $quick = 1 GUICtrlSetState($Quick_item, $GUI_CHECKED) If $fast = 1 Then $fast = 4 IniWrite($inifle, "Fix Mode", "fast", $fast) GUICtrlSetState($Fast_item, $GUI_UNCHECKED) ElseIf $quote = 1 Then $quote = 4 IniWrite($inifle, "Fix Mode", "quote", $quote) GUICtrlSetState($Quote_item, $GUI_UNCHECKED) ElseIf $query = 1 Then $query = 4 IniWrite($inifle, "Fix Mode", "query", $query) GUICtrlSetState($Query_item, $GUI_UNCHECKED) EndIf EndIf IniWrite($inifle, "Fix Mode", "quick", $quick) Case $msg = $Query_item ; Fix Mode - Query Fix If $query = 1 Then $query = 4 GUICtrlSetState($Query_item, $GUI_UNCHECKED) Else $query = 1 GUICtrlSetState($Query_item, $GUI_CHECKED) If $fast = 1 Then $fast = 4 IniWrite($inifle, "Fix Mode", "fast", $fast) GUICtrlSetState($Fast_item, $GUI_UNCHECKED) ElseIf $quote = 1 Then $quote = 4 IniWrite($inifle, "Fix Mode", "quote", $quote) GUICtrlSetState($Quote_item, $GUI_UNCHECKED) ElseIf $quick = 1 Then $quick = 4 IniWrite($inifle, "Fix Mode", "quick", $quick) GUICtrlSetState($Quick_item, $GUI_UNCHECKED) EndIf EndIf IniWrite($inifle, "Fix Mode", "query", $query) Case $msg = $One_item ; Copy First Line, Remove + Reduce If $copyone = 1 Then GUICtrlSetState($Auto_item, $GUI_ENABLE) $copyone = 4 GUICtrlSetState($One_item, $GUI_UNCHECKED) GUICtrlSetData($Button_copy, "COPY") Else GUICtrlSetState($Auto_item, $GUI_DISABLE) $copyone = 1 GUICtrlSetState($One_item, $GUI_CHECKED) GUICtrlSetData($Button_copy, "ONE") EndIf IniWrite($inifle, "First Line Remove Reduce", "copy", $copyone) Case $msg = $Number_item ; Each Line - Add leading number AddLeadingNumber("") Case $msg = $Next_item ; Next Backup Number MsgBox(262208, "Save Query", "The next file to be used for the" & @LF & _ "Autosave backup, is 'Saved " & $bakfle & "'.", 0) Case $msg = $Multi_item ; Each Line - Multi Job RemoveLeadingSpaces("job") AddLeadingNumber("job") If Not _IsPressed("10") Then AddLeadingSpace("job") Case $msg = $Mode_item ; Search - Quick Mode If $findmode = "quick" Then $findmode = "no" GUICtrlSetState($Mode_item, $GUI_UNCHECKED) Else $findmode = "quick" GUICtrlSetState($Mode_item, $GUI_CHECKED) EndIf IniWrite($inifle, "Text Search", "mode", $findmode) Case $msg = $Minimize_item ; Minimize on copy If $mincopy = 1 Then $mincopy = 4 GUICtrlSetState($Minimize_item, $GUI_UNCHECKED) Else $mincopy = 1 GUICtrlSetState($Minimize_item, $GUI_CHECKED) EndIf IniWrite($inifle, "On Copy", "minimize", $mincopy) Case $msg = $Minclear_item ; Minimize on clear If $minclear = 1 Then $minclear = 4 GUICtrlSetState($Minclear_item, $GUI_UNCHECKED) Else $minclear = 1 GUICtrlSetState($Minclear_item, $GUI_CHECKED) EndIf IniWrite($inifle, "On Clear", "minimize", $minclear) Case $msg = $Load_item ; Load last saved text file $file = FileOpen($savfle, 0) $text = FileRead($file) If $text <> "" Then GUICtrlSetData($Edit_text, $text) FileClose($file) Case $msg = $Last_item ; Get last active window setting $actwin = IniRead($inifle, "Active Window", "handle", "") If $actwin <> "" Then GUICtrlSetState($Unact_item, $GUI_ENABLE) Case $msg = $Job_item ; About Multi Job MsgBox(262208, "Multi Job Information", "The following processes will occur in the listed order." & @LF & @LF & _ "(1) Leading spaces removed." & @LF & _ "(2) Leading number added." & @LF & _ "(3) Leading space added." & @LF & @LF & _ "NOTE - Holding down SHIFT will cancel 3rd process." & @LF & _ "The usual CTRL prompts will not occur, though the" & @LF & _ "CTRL options will work if the key is held down, but" & @LF & _ "this one for all scenario is not recommended.", 0) Case $msg = $Info_item ; Program Information MsgBox(262208, "Program Information", _ "The 'Web Pad' program window can be resized as well as re-positioned," & @LF & _ "which will be remembered by the program, between uses." & @LF & @LF & _ "Autosave, once enabled, will backup continually to one of five files, after" & @LF & _ "the specified time in minutes has elapsed, and if text exists in the Editor." & @LF & _ "Each one of the backup files can be loaded (recalled) for the Editor, by" & @LF & _ "clicking on its entry in the 'Autosave' menu." & @LF & _ "After the specified amount of time has passed five times, the backups" & @LF & _ "will begin to be over-written (recycled)." & @LF & _ "When the program closes, it also saves, using the cycle of backups." & @LF & @LF & _ "The manual 'Save' (button) file is independent to the five backup files." & @LF & @LF & _ "Highlighted text in the Editor, can be placed within 'Quotes' or 'Code" & @LF & _ "Tags' or 'Link Tags' or have it's 'Case' toggled or those tags inserted." & @LF & @LF & _ "Holding down the CTRL key when the Exit button is clicked, puts the" & @LF & _ "program into special minimized mode, with a floating restore button." & @LF & @LF & _ "Holding down the CTRL key when searching in slow mode, should give" & @LF & _ "you a prompt dialog with an option to cancel." & @LF & @LF & _ "Holding down the CTRL key when the Copy button is clicked, will clear" & @LF & _ "the Edit window and import text from the clipboard." & @LF & @LF & _ "Searching in Quick Mode will not result in any text being highlighted or" & @LF & _ "selected in the Edit window, it is just used for checking &/or deletions." & @LF & @LF & _ "Fix instead of Find/Search will display (depending on settings) the end" & @LF & _ "of one line and the start of the next, giving the option to join. It can" & @LF & _ "even help in some cases, with a broken quoted line. Any lines that are" & @LF & _ "obviously broken are automatically fixed/joined, except in Quotes Only." & @LF & _ "In normal mode (not Quick, Quotes or Fast), each non-repaired line is" & @LF & _ "displayed for comparison. Quotes are always checked, except in Fast." & @LF & _ "Fix may need to be run more than once to achieve the desired result." & @LF & _ "Holding down CTRL key during Fix process presents an Abort Query.", 0) Case $msg = $Import_item ; Import to current text from clipboard If ClipGet() <> "" Then ControlFocus($Webpad, "", $Edit_text) Send("^v") EndIf Case $msg = $Hist_item ; View the History File If FileExists($histfle) Then ShellExecute($histfle) Case $msg = $Get_item ; Clear clipboard on Get If $getclr = 1 Then $getclr = 4 GUICtrlSetState($Get_item, $GUI_UNCHECKED) Else $getclr = 1 GUICtrlSetState($Get_item, $GUI_CHECKED) EndIf IniWrite($inifle, "Clipboard On Get", "clear", $getclr) Case $msg = $Font_item_inc ; Increase Font Size If $font = "" Or $font = 8 Then $font = 9 ElseIf $font = 7 Then $font = 8 ElseIf $font = 9 Then $font = 10 ElseIf $font = 10 Then $font = 11 ElseIf $font = 11 Then $font = 12 ElseIf $font = 12 Then $font = 14 ElseIf $font = 14 Then $font = 15 ElseIf $font = 15 Then $font = 16 EndIf GUICtrlSetFont($Edit_text, $font) Case $msg = $Font_item_dec ; Decrease Font Size If $font = "" Or $font = 9 Then $font = 8 ElseIf $font = 16 Then $font = 15 ElseIf $font = 15 Then $font = 14 ElseIf $font = 14 Then $font = 12 ElseIf $font = 12 Then $font = 11 ElseIf $font = 11 Then $font = 10 ElseIf $font = 10 Then $font = 9 ElseIf $font = 8 Then $font = 7 EndIf GUICtrlSetFont($Edit_text, $font) Case $msg = $Fix_item ; Fix Mode If $fix = 1 Then $fix = 4 GUICtrlSetState($Fix_item, $GUI_UNCHECKED) GUICtrlSetData($Button_find, "FIND") GUICtrlSetState($Search_menu, $GUI_ENABLE) GUICtrlSetState($Query_item, $GUI_DISABLE) GUICtrlSetState($Quick_item, $GUI_DISABLE) GUICtrlSetState($Quote_item, $GUI_DISABLE) GUICtrlSetState($Fast_item, $GUI_DISABLE) Else $fix = 1 GUICtrlSetState($Fix_item, $GUI_CHECKED) GUICtrlSetData($Button_find, "FIX") GUICtrlSetState($Search_menu, $GUI_DISABLE) GUICtrlSetState($Query_item, $GUI_ENABLE) GUICtrlSetState($Quick_item, $GUI_ENABLE) GUICtrlSetState($Quote_item, $GUI_ENABLE) GUICtrlSetState($Fast_item, $GUI_ENABLE) If $remove = 1 Then $remove = 4 IniWrite($inifle, "Remove", "mode", $remove) GUICtrlSetState($Rem_item, $GUI_UNCHECKED) EndIf EndIf IniWrite($inifle, "Process", "mode", $fix) Case $msg = $Fast_item ; Fix Mode - Fast (No Quotes) If $fast = 1 Then $fast = 4 GUICtrlSetState($Fast_item, $GUI_UNCHECKED) Else $fast = 1 GUICtrlSetState($Fast_item, $GUI_CHECKED) If $quote = 1 Then $quote = 4 IniWrite($inifle, "Fix Mode", "quote", $quote) GUICtrlSetState($Quote_item, $GUI_UNCHECKED) ElseIf $quick = 1 Then $quick = 4 IniWrite($inifle, "Fix Mode", "quick", $quick) GUICtrlSetState($Quick_item, $GUI_UNCHECKED) EndIf EndIf IniWrite($inifle, "Fix Mode", "fast", $fast) Case $msg = $Copy_item ; Clear text field on Copy If $copyclr = 1 Then $copyclr = 4 GUICtrlSetState($Copy_item, $GUI_UNCHECKED) Else $copyclr = 1 GUICtrlSetState($Copy_item, $GUI_CHECKED) EndIf IniWrite($inifle, "Text On Copy", "clear", $copyclr) Case $msg = $Clear_item Or $msg = $Button_clear ; Clear current text If $undo = "" Then $text = GUICtrlRead($Edit_text) If $text <> "" Then $undo = $text GUICtrlSetState($Undo_item, $GUI_ENABLE) Else GUICtrlSetState($Undo_item, $GUI_DISABLE) EndIf EndIf GUICtrlSetData($Edit_text, "") $shown = "" If $import = 1 Then GUICtrlSetData($Button_copy, "GET") If $minclear = 1 Then WinSetState($Webpad, "", @SW_MINIMIZE) Case $msg = $Char_item_cnt ; Character Count Report CharacterCountReport(2) Case $msg = $Buff_item ; Search Text Buffer If $ontop = 1 Then WinSetOnTop($Webpad, "", 0) BufferGUI() If $ontop = 1 Then WinSetOnTop($Webpad, "", 1) Case $msg = $Blanks_item ; Each Line - Remove blanks $text = GUICtrlRead($Edit_text) If $text <> "" Then $lines = StringSplit($text, @CRLF) $text = "" For $l = 1 To $lines[0] If $lines[$l] <> "" Then $text = $text & $lines[$l] If $l <> $lines[0] Then $text = $text & @CRLF EndIf Next ;$text = StringStripWS($text, 1) GUICtrlSetData($Edit_text, "") GUICtrlSetData($Edit_text, $text) EndIf Case $msg = $Blank_item ; Remove blank lines on Import If $remblank = 1 Then $remblank = 4 GUICtrlSetState($Blank_item, $GUI_UNCHECKED) Else $remblank = 1 GUICtrlSetState($Blank_item, $GUI_CHECKED) MsgBox(262208, "Special Feature", _ "Remove blank lines on Import, only works with the" & @LF & _ "CTRL key plus COPY button import method.", 0) EndIf IniWrite($inifle, "Remove Blank Lines", "import", $remblank) Case $msg = $Bkup_item_5 ; Load Saved Backup 5 LoadSavedBackup($bakfle_5) Case $msg = $Bkup_item_4 ; Load Saved Backup 4 LoadSavedBackup($bakfle_4) Case $msg = $Bkup_item_3 ; Load Saved Backup 3 LoadSavedBackup($bakfle_3) Case $msg = $Bkup_item_2 ; Load Saved Backup 2 LoadSavedBackup($bakfle_2) Case $msg = $Bkup_item_1 ; Load Backup Saved 1 LoadSavedBackup($bakfle_1) Case $msg = $Backup_item ; Enable Auto Backup If $autosave = 1 Then $autosave = 4 GUICtrlSetState($Backup_item, $GUI_UNCHECKED) Else $autosave = 1 GUICtrlSetState($Backup_item, $GUI_CHECKED) $begin = TimerInit() EndIf IniWrite($inifle, "Save Backup Files", "auto", $autosave) Case $msg = $Auto_item ; Auto import with Copy If $import = 1 Then GUICtrlSetState($One_item, $GUI_ENABLE) $import = 4 GUICtrlSetState($Auto_item, $GUI_UNCHECKED) GUICtrlSetData($Button_copy, "COPY") Else GUICtrlSetState($One_item, $GUI_DISABLE) $import = 1 GUICtrlSetState($Auto_item, $GUI_CHECKED) GUICtrlSetData($Button_copy, "GET") EndIf IniWrite($inifle, "Import With Copy", "auto", $import) Case $msg = $Ask_item ; Query Removal of trailing spaces If $ask = 1 Then $ask = 4 GUICtrlSetState($Ask_item, $GUI_UNCHECKED) $digit = "" Else $ask = 1 GUICtrlSetState($Ask_item, $GUI_CHECKED) $ans = MsgBox(262177, "Spaces Query", _ "Do you only want to be queried if the number 1" & @LF & _ "(digit) is not found in the imported text?" & @LF & @LF & _ "NOTE - This is usually in relation to a specific" & @LF & _ "Search scenario, which may not be applicable" & @LF & _ "to current user.", 0) If $ans = 1 Then $digit = 1 ElseIf $ans = 2 Then $digit = "" EndIf EndIf IniWrite($inifle, "Trailing Spaces Removal", "query", $ask) IniWrite($inifle, "Trailing Spaces Removal", "digit", $digit) Case $msg = $Active_item ; Export to Active Window $text = GUICtrlRead($Edit_text) If $text <> "" Then ClipPut($text) $ans = MsgBox(262209, "Export Instructions", _ "These instructions allow you to export text from the Editor," & @LF & _ "to the location of the cursor in a program window." & @LF & @LF & _ "(1) Get the receiving window ready for text insertion." & @LF & _ "(2) Then close this dialog." & @LF & _ "(3) Then click where you want the text to appear.", 0) If $ans = 1 Then $insert = 1 EndIf EndIf Case $msg = $About_item ; About the program MsgBox(262208, "About The Program", _ "Web Pad is a minimal Text Editor to use and assist with posting on the" & @LF & _ "web, that has a backup & autosave facility and other useful features," & @LF & _ "primarily designed for use on Forums (i.e. AutoIt) and Facebook, etc." & @LF & @LF & _ "© TheSaint - Conceived on the 28th July 2013." & @LF & _ "(latest update by TheSaint in March 2014).", 0) Case Else ;;; If $insert = 1 Then If _IsPressed("01") Then $insert = "" Sleep(500) Send("^v") EndIf EndIf ; If $autosave = 1 Or $undo = "" Then If $hang = 100 Then $hang = 0 $text = GUICtrlRead($Edit_text) If $text <> "" Then If $shown = "" Then CharacterCountReport(1) EndIf If $undo = "" Then $undo = $text GUICtrlSetState($Undo_item, $GUI_ENABLE) EndIf If $autosave = 1 Then $diff = TimerDiff($begin) If $diff > $msecs Then SaveTextBackup() $begin = TimerInit() EndIf EndIf Else $shown = "" EndIf EndIf $hang = $hang + 1 EndIf EndSelect ; WEnd Exit Func BufferGUI() $BufferSet = GuiCreate("", 250, 80, -1, -1, $WS_OVERLAPPED + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST) ; $Group_stb = GuiCtrlCreateGroup("Result Text Buffer", 10, 10, 170, 60) $Label_buff = GuiCtrlCreateLabel("Buffer with", 20, 32, 55, 20, $SS_LEFT + $SS_CENTERIMAGE) $Input_buff = GuiCtrlCreateInput("", 75, 32, 40, 20) $Updown_buff = GUICtrlCreateUpdown($Input_buff) GUICtrlSetLimit($Updown_buff, 25, 1) $Label_char = GuiCtrlCreateLabel("characters", 120, 32, 50, 20, $SS_LEFT + $SS_CENTERIMAGE) ; $Button_x2 = GuiCtrlCreateButton("Exit", 190, 15, 50, 55, $BS_ICON) ; ; SETTINGS GUICtrlSetImage($Button_x2, $icofle, $icoX, 1) ; GUICtrlSetData($Input_buff, $buffer) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_x2 ; Exit BufferSet window GUIDelete($BufferSet) ExitLoop Case $msg = $Updown_buff ; Buffer for Search Text result $buffer = GUICtrlRead($Input_buff) IniWrite($inifle, "Text Search", "buffer", $buffer) Case Else ; EndSelect WEnd EndFunc ;=> BufferGUI (GUI) Func DurationGUI() $Duration = GuiCreate("", 235, 80, -1, -1, $WS_OVERLAPPED + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST) ; $Group_asd = GuiCtrlCreateGroup("Autosave Duration", 10, 10, 155, 60) $Label_sav = GuiCtrlCreateLabel("Save every", 20, 32, 60, 20, $SS_LEFT + $SS_CENTERIMAGE) $Input_dur = GuiCtrlCreateInput("", 80, 32, 30, 20) $Updown_dur = GUICtrlCreateUpdown($Input_dur) GUICtrlSetLimit($Updown_dur, 9, 1) $Label_min = GuiCtrlCreateLabel("minutes", 115, 32, 40, 20, $SS_LEFT + $SS_CENTERIMAGE) ; $Button_x = GuiCtrlCreateButton("Exit", 175, 15, 50, 55, $BS_ICON) ; ; SETTINGS GUICtrlSetImage($Button_x, $icofle, $icoX, 1) ; GUICtrlSetData($Input_dur, $mins) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_x ; Exit duration window GUIDelete($Duration) ExitLoop Case $msg = $Updown_dur ; Autosave every number of minutes $mins = GUICtrlRead($Input_dur) IniWrite($inifle, "Autosave Duration", "mins", $mins) $msecs = $mins * 60 $msecs = $msecs * 1000 Case Else ; EndSelect WEnd EndFunc ;=> DurationGUI (GUI) Func WebpadButtonGUI() $bleft = IniRead($inifle, "Button Window", "left", "") If $bleft <> "" Then If $bleft < 0 Or $bleft > (@DesktopWidth - 72) Then $bleft = -1 $btop = IniRead($inifle, "Button Window", "top", "") If $btop < 0 Or $btop > (@DesktopHeight - 90) Then $btop = -1 Else $bleft = -1 $btop = -1 EndIf $Floatbut = GuiCreate("Click Me", 75, 90, $bleft, $btop, $WS_OVERLAPPED + $WS_VISIBLE + $WS_CLIPSIBLINGS, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW) $Label_but = GUICtrlCreateLabel(@LF & "WEB" & @LF & "PAD", 0, 0, 70, 70, $SS_NOTIFY + $SS_CENTER) GUICtrlSetBkColor($Label_but, 0x000000) GUICtrlSetColor($Label_but, 0xFFFFFF) GUICtrlSetFont($Label_but, 10, 600) GUICtrlSetTip($Label_but, "Click to restore the Web Pad program window!") GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Label_but ; Exit button and save window size & position $butpos = WinGetPos($Floatbut, "") GUIDelete($Floatbut) IniWrite($inifle, "Button Window", "left", $butpos[0]) IniWrite($inifle, "Button Window", "top", $butpos[1]) WinSetState($Webpad, "", @SW_RESTORE) ExitLoop Case Else ;;; EndSelect WEnd EndFunc ;=> WebpadButtonGUI (GUI) Func AddLeadingNumber($job) $text = GUICtrlRead($Edit_text) If $text <> "" Then $lines = StringSplit($text, @CRLF) $text = "" ;$num = 1 $num = InputBox("Add Leading Number", "Specify number to start at.", 1, "", 200, 130, -1, -1, "", $Webpad) If Not @error And StringIsDigit($num) Then $zero = IniRead($inifle, "Add Leading Number", "zeros", 0) $zero = InputBox("Add Leading Number", "Specify number of zeros.", $zero, "", 200, 130, -1, -1, "", $Webpad) If Not @error And StringIsDigit($zero) Then IniWrite($inifle, "Add Leading Number", "zeros", $zero) If $job = "" Then MsgBox(262208, "Add Leading Number", "Hold down CTRL to keep blank lines.", 0) For $l = 1 To $lines[0] If $lines[$l] <> "" Then If $zero > 0 Then $num = StringRight("0000000000" & $num, $zero + 1) $text = $text & @CRLF & $num & ". " & $lines[$l] $num = $num + 1 ElseIf _IsPressed("11") Then $text = $text & @CRLF & $lines[$l] EndIf Next $text = StringStripWS($text, 3) GUICtrlSetData($Edit_text, "") GUICtrlSetData($Edit_text, $text) EndIf EndIf EndIf EndFunc ;=> AddLeadingNumber Func AddLeadingSpace($job) $text = GUICtrlRead($Edit_text) If $text <> "" Then $lines = StringSplit($text, @CRLF) $text = "" If $job = "" Then MsgBox(262208, "Add Leading Space", "Hold down CTRL to keep blank lines.", 0) For $l = 1 To $lines[0] If $lines[$l] <> "" Then If $text = "" Then $text = " " & $lines[$l] Else $text = $text & @CRLF & " " & $lines[$l] EndIf ElseIf _IsPressed("11") Then $text = $text & @CRLF EndIf Next GUICtrlSetData($Edit_text, "") GUICtrlSetData($Edit_text, $text) EndIf EndFunc ;=> AddLeadingSpace Func CharacterCountReport($show) If $show > 1 Then $text = GUICtrlRead($Edit_text) ;$text = ClipGet() If $text <> "" Then $chars = StringLen($text) If $chars > 29999 Or $show > 1 Then $lump = StringSplit($text, @CRLF, 1) $total = $lump[0] $cntmsg = "Total number of characters = " & $chars & _ @LF & "Total number of lines = " & $total EndIf If $chars > 29999 Then $show = 2 $shown = 1 $cntmsg = $cntmsg & @LF & @LF & "WARNING - While you can still use some of" _ & @LF & "the various options of this program, when" _ & @LF & "the Character Count is above 30,000, any" _ & @LF & "manual editing, except for deletion, is not" _ & @LF & "available until below that count. Using the" _ & @LF & "FIX option should not be affected." & @LF _ & @LF & "After any reductions, use the 'Character" _ & @LF & "Count Report' to reset the warning state." Else $shown = "" EndIf If $show > 1 Then MsgBox(262208, "Character Count Report", $cntmsg, 0) EndIf EndIf EndFunc ;=> CharacterCountReport Func DetermineOddOrEven($number) If StringInStr($number / 2, ".") > 0 Then Return "odd" Else Return "even" EndIf EndFunc ;=> DetermineOddOrEven Func JoinLinesQuery($from) $quotes = StringSplit($hunk, '"') $quotes = $quotes[0] If $quotes > 1 Then $quotes = $quotes - 1 $odd = DetermineOddOrEven($quotes) Else $odd = "even" EndIf If $odd = "even" Then ; Check for alternate quotes/parentheses If StringInStr($hunk, '”') > 0 Then $quot_1 = StringSplit($hunk, '“') $quot_2 = StringSplit($hunk, '”') If $quot_1[0] = $quot_2[0] Then $odd = "even" Else $odd = "odd" EndIf EndIf EndIf If $odd = "odd" Then $line_1 = StringRight($text, 445) If StringLen($text) > 445 Then $line_1 = "(1) ... " & $line_1 Else $line_1 = "(1) " & $line_1 EndIf ; ;$line_2 = "(2) " & $hunk $aa = 60 $line_2 = StringLeft($hunk, $aa) While 1 $bb = StringMid($hunk, $aa + 1, 60) If $bb <> "" Then $line_2 = $line_2 & @LF & $bb $aa = $aa + 60 Else ExitLoop EndIf WEnd $line_2 = "(2) " & $line_2 ; ;$line_3 = "(3) " & $next $aa = 60 $line_3 = StringLeft($next, $aa) While 1 $bb = StringMid($next, $aa + 1, 60) If $bb <> "" Then $line_3 = $line_3 & @LF & $bb $aa = $aa + 60 Else ExitLoop EndIf WEnd $line_3 = "(3) " & $line_3 ; $ans = MsgBox(262449, "Join Lines Query (" & $h & " of " & $total & ") - QUOTES", _ "Do you want to join the following lines (no carriage return)?" & @LF & @LF & _ $line_1 & "|" & @LF & @LF & _ $line_2 & @LF & @LF & _ $line_3 & @LF & @LF & _ "CANCEL = Join them using a carriage return inbetween." & @LF & @LF & _ "NOTE - Line 2 has an unbalanced number of quotes.", 0) Else If ($quote = 4 And $quick = 4 And $query = 4) Or ($query = 1 And $from = 2) Then ;MsgBox(262192, "$end $two", "'" & $end & "' + '" & $two & "'") ;MsgBox(262192, "$query $from", "'" & $query & "' + '" & $from & "'") $line_1 = StringRight($text, 50) $line_1 = StringSplit($line_1, @CRLF, 1) $line_1 = $line_1[$line_1[0]] ;If StringLen($text) > 50 Then If StringLen($text) > StringLen($line_1) Then $line_1 = "(1) ... " & $line_1 Else $line_1 = "(1) " & $line_1 EndIf $line_1 = StringReplace($line_1, @CRLF, "") $line_1 = StringReplace($line_1, @CR, "") $line_1 = StringReplace($line_1, @LF, "") ;$line_2 = StringLeft($hunk, 45) ;If StringLen($hunk) > 45 Then ; $line_2 = "(2) " & $line_2 & " ..." ;Else ; $line_2 = "(2) " & $line_2 ;EndIf ; ;$line_2 = "(2) " & $hunk $aa = 60 $line_2 = StringLeft($hunk, $aa) While 1 $bb = StringMid($hunk, $aa + 1, 60) If $bb <> "" Then $line_2 = $line_2 & @LF & $bb $aa = $aa + 60 Else ExitLoop EndIf WEnd $line_2 = "(2) " & $line_2 ; ;$line_3 = "(3) " & $next $aa = 60 $line_3 = StringLeft($next, $aa) While 1 $bb = StringMid($next, $aa + 1, 60) If $bb <> "" Then $line_3 = $line_3 & @LF & $bb $aa = $aa + 60 Else ExitLoop EndIf WEnd $line_3 = "(3) " & $line_3 ; $ans = MsgBox(262433, "Join Lines Query (" & $h & " of " & $total & ")", _ "Do you want to join the following lines (no carriage return)?" & @LF & @LF & _ $line_1 & "|" & @LF & @LF & _ $line_2 & @LF & @LF & @LF & _ $line_3 & @LF & @LF & _ "CANCEL = Join them using a carriage return inbetween.", 0) ;$line_2 & @LF & @LF & _ Else $ans = 2 EndIf EndIf If $ans = 1 Then If $end = " " Or $end = "-" Then $text = $text & $hunk Else $text = $text & " " & $hunk EndIf $fixes = $fixes + 1 ElseIf $ans = 2 Then $text = $text & @CRLF & $hunk EndIf EndFunc ;=> JoinLinesQuery Func LoadSavedBackup($load) $ans = MsgBox(262177, "Save Query", _ "Do you wish to backup the current text in the Editor," & @LF & _ "before replacing it with the selected backup?" & @LF & @LF & _ "NOTE - This might replace the oldest backup.", 0) If $ans = 1 Then SaveTextBackup() EndIf $file = FileOpen($load, 0) $text = FileRead($file) If $text <> "" Then GUICtrlSetData($Edit_text, $text) FileClose($file) EndFunc ;=> LoadSavedBackup Func RemoveLeadingSpaces($job) If $job <> "one" Then $text = GUICtrlRead($Edit_text) If $text <> "" Then $lines = StringSplit($text, @CRLF) $text = "" If $job = "" Then MsgBox(262208, "Remove Leading Spaces", "Hold down CTRL to keep blank lines.", 0) For $l = 1 To $lines[0] If $lines[$l] <> "" Then If $text = "" Then $text = StringStripWS($lines[$l], 1) Else $text = $text & @CRLF & StringStripWS($lines[$l], 1) EndIf ElseIf _IsPressed("11") Then $text = $text & @CRLF EndIf Next GUICtrlSetData($Edit_text, "") GUICtrlSetData($Edit_text, $text) EndIf EndFunc ;=> RemoveLeadingSpaces Func SaveTextBackup() $text = GUICtrlRead($Edit_text) If $text <> "" Then SplashTextOn("", "Saving!", 140, 80, -1, -1, 33) If $bakfle = 1 Then $backup = $bakfle_1 $bakfle = 2 ElseIf $bakfle = 2 Then $backup = $bakfle_2 $bakfle = 3 ElseIf $bakfle = 3 Then $backup = $bakfle_3 $bakfle = 4 ElseIf $bakfle = 4 Then $backup = $bakfle_4 $bakfle = 5 ElseIf $bakfle = 5 Then $backup = $bakfle_5 $bakfle = 1 EndIf IniWrite($inifle, "Saved Backup File", "next", $bakfle) $file = FileOpen($backup, 2) FileWrite($file, $text) FileClose($file) Sleep(250) SplashOff() EndIf EndFunc ;=> SaveTextBackup