Leaderboard
Popular Content
Showing content with the highest reputation on 06/17/2012 in all areas
-
Text Editor v2.8 (**Updated 7-7-12**)
tryer777 reacted to LiquidNitrogen for a topic
This a Text Editor I Made to Be Like Notepad and it Turned out better than i thought it would. (Updated (7-7-12) +Added HotKeys +Added Misc. Options (All Caps, All Lowercase, Readonly +Moved Default and Custom Options to there own Menus Under Edit +Cleaned up Code a little Bit +Added Cut, Copy, And Paste to Edit Menu -There is still a small Bug with word wrap. When you turn it off it appears to be off but its not. (Adds Horizontal Scroll bar at bottom) +Im Currently working on a 'Run Script' Option and have added it under an 'Action' Menu but it is disabled. (Updated 7-3-12) +Added Word Wrap Option +Fixed Save Bug (Updated 6-29-12) +Fixed a compilation bug It Would be best to download the Archive and Extract the Script because some stuff is wierd when you copy the code and paste it into a Script. Like Hotkeys Being displayed in the Menus. #NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Icon.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIEdit.au3> #include <Misc.au3> #include <GUIStatusBar.au3> #include <GUIMenu.au3> #include <SendMessage.au3> ;Created by ReaperX FileCheck() Main() SetFileAttr() Func FileCheck() If FileExists(@ScriptDir & "/config.ini") Then $CE = IniReadSectionNames(@ScriptDir & "/config.ini") If $CE[0] > 0 Then For $i = 2 To $CE[0] If Not FileExists($CE[$i]) Then IniDelete(@ScriptDir & "/config.ini", $CE[$i]) Next EndIf Main() Else IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "11") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "wordwrap", "1") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", "") EndIf Sleep(100) EndFunc ;==>FileCheck Func Main() Global Const $GUI_TITLE = "Text Editor v2.8" Global Const $GUI_STYLE = BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS) Local $Ext = ".au3 ,.bat ,.vbs ,.htm ,.html" ; Script Types Allowed to Be Executed (Only Extensions) If IniRead(@ScriptDir & "/config.ini", "CONFIG", "wordwrap", "1") = 1 Then Global $EDIT_STYLE = BitOR($ES_WANTRETURN, $WS_VSCROLL) Else Global $EDIT_STYLE = $GUI_SS_DEFAULT_EDIT EndIf $Main = GUICreate($GUI_TITLE, 650, 280, -1, -1, $GUI_STYLE) GUISetIcon("Icon.ico") ;File Menu ======================================================================== $FileMenu = GUICtrlCreateMenu("File") $New = GUICtrlCreateMenuItem("New Ctrl+N", $FileMenu) HotKeySet("^n", "_New") $Open = GUICtrlCreateMenuItem("Open Ctrl+O", $FileMenu) HotKeySet("^o", "_Open") $Save = GUICtrlCreateMenuItem("Save Ctrl+S", $FileMenu) HotKeySet("^s", "_Save") $SaveAs = GUICtrlCreateMenuItem("Save As...", $FileMenu) GUICtrlCreateMenuItem("", $FileMenu) $Exit = GUICtrlCreateMenuItem("Exit", $FileMenu) ;================================================================================= ;View Menu ======================================================================= $ViewMenu = GUICtrlCreateMenu("View") $DocInfo = GUICtrlCreateMenuItem("Document Info", $ViewMenu) ;================================================================================= ;Action Menu ===================================================================== $ActionMenu = GUICtrlCreateMenu("Action") $Run = GUICtrlCreateMenuItem("Run Script", $ActionMenu) GUICtrlSetState($Run, $GUI_DISABLE) ;================================================================================= ;Edit Menu ======================================================================= $EditMenu = GUICtrlCreateMenu("Edit") $Undo = GUICtrlCreateMenuItem("Undo Ctrl+Z", $EditMenu, 0) HotKeySet("^z", "_Undo") GUICtrlCreateMenuItem("", $EditMenu, 1) $Cut = GUICtrlCreateMenuItem("Cut Ctrl+X", $EditMenu, 2) $Copy = GUICtrlCreateMenuItem("Copy Ctrl+C", $EditMenu, 3) $Paste = GUICtrlCreateMenuItem("Paste Ctrl+P", $EditMenu, 4) GUICtrlCreateMenuItem("", $EditMenu, 5) $Find = GUICtrlCreateMenuItem("Find... Ctrl+F", $EditMenu, 6) HotKeySet("^f", "_Find") GUICtrlCreateMenuItem("", $EditMenu, 7) ;Edit -> Default Settings Menu =================================================== Local $DefaultSett = GUICtrlCreateMenu("Default Settings", $EditMenu, 8) $DefaultFont = GUICtrlCreateMenuItem("Edit Default Font", $DefaultSett) $DefaultBGColor = GUICtrlCreateMenuItem("Edit Default BG Color", $DefaultSett) $ResetDefaults = GUICtrlCreateMenuItem("Reset Default Settings", $DefaultSett) ;================================================================================= GUICtrlCreateMenuItem("", $EditMenu, 9) ;Edit -> Custom Settings Menu ==================================================== Local $CustomSett = GUICtrlCreateMenu("Custom Settings", $EditMenu, 10) $CustomFont = GUICtrlCreateMenuItem("Set Custom Font", $CustomSett) GUICtrlSetState(-1, $GUI_DISABLE) $CustomBGColor = GUICtrlCreateMenuItem("Set Custom BG Color", $CustomSett) GUICtrlSetState(-1, $GUI_DISABLE) $EraseCustomOpt = GUICtrlCreateMenuItem("Erase Custom Settings", $CustomSett) GUICtrlSetState(-1, $GUI_DISABLE) ;================================================================================= GUICtrlCreateMenuItem("", $EditMenu, 11) $SetFileAttr = GUICtrlCreateMenuItem("Set File Attributes", $EditMenu, 12) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateMenuItem("", $EditMenu, 13) ;Edit -> Misc Options Menu ======================================================= $MiscOptions = GUICtrlCreateMenu("Misc. Options", $EditMenu, 14) Local $Readonly = GUICtrlCreateMenuItem("Readonly", $MiscOptions) GUICtrlSetState(-1, $GUI_UNCHECKED) $CAPS = GUICtrlCreateMenuItem("All Caps (Not CAPS Lock)", $MiscOptions) GUICtrlSetState(-1, $GUI_UNCHECKED) $LOWERCASE = GUICtrlCreateMenuItem("All Lowercase", $MiscOptions) GUICtrlSetState(-1, $GUI_UNCHECKED) ;================================================================================= $SelectAll = GUICtrlCreateMenuItem("Select All Ctrl+A", $EditMenu, 15) HotKeySet("^a", "_SelectAll") $TimeAndDate = GUICtrlCreateMenuItem("Insert Time/Date F7", $EditMenu, 16) HotKeySet("{F7}", "_TimeAndDate") $SpeakText = GUICtrlCreateMenuItem("Speak Highlighted Text", $EditMenu, 17) $WordWrap = GUICtrlCreateMenuItem("Word Wrap", $EditMenu, 18) If IniRead(@ScriptDir & "/config.ini", "CONFIG", "wordwrap", "1") = 1 Then GUICtrlSetState(-1, $GUI_CHECKED) Else GUICtrlSetState(-1, $GUI_UNCHECKED) EndIf ;================================================================================= ;Help Menu ======================================================================= $HelpMenu = GUICtrlCreateMenu("Help") $About = GUICtrlCreateMenuItem("About", $HelpMenu, 1) $AboutCustomSett = GUICtrlCreateMenuItem("Custom Settings", $HelpMenu, 2) ;================================================================================= ;Create Edit Control =================================================================================== Global $Edit = GUICtrlCreateEdit("", 0, 0, 650, 238, $EDIT_STYLE) ;======================================================================================================= ;Create Status bar ============================================================ Local $Parts[1] = [70] Global $StatusBar = _GUICtrlStatusBar_Create($Main, $Parts, $SB_SIMPLEID) _GUICtrlStatusBar_SetParts($StatusBar, $Parts) _GUICtrlStatusBar_SetText($StatusBar, "New Document") ;============================================================================== If FileExists("temp") Then GUICtrlSetData(-1, FileRead("temp")) ;For When and If Main() Has to be Called again. It Restores the Text in $Edit. FileDelete("temp") EndIf GUICtrlSetFont(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) GUICtrlSetBkColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) GUISetState() GUIRegisterMsg($WM_SIZE, "WM_SIZE") While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 If FileRead(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) = GUICtrlRead($Edit) Then IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit Else $Confirm = MsgBox(35, "Confirm", "Do You Want To Save Before Exiting?") If $Confirm = 6 Then If FileExists(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit EndIf $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite($SaveDir, GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit EndIf EndIf EndIf If $Confirm = 7 Then IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit EndIf Case $New _New() Case $Open _Open() Case $DefaultBGColor $NewBG = _ChooseColor(2) If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", $NewBG) GUICtrlSetBkColor($Edit, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) EndIf Case $DefaultFont $NewFont = _ChooseFont(IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), 0, 400, False, False, False, $Main) If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontsize", $NewFont[3]) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "attributes", $NewFont[1]) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontweight", $NewFont[4]) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", $NewFont[7]) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontname", $NewFont[2]) GUICtrlSetFont($Edit, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor($Edit, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) EndIf Case $ResetDefaults IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "11") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", "") MsgBox(64, "Ok", "Default Settings Reset. Your Custom Options Were not Changed.") Case $SaveAs $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then GUICtrlSetState($SetFileAttr, $GUI_ENABLE) GUICtrlSetState($CustomFont, $GUI_ENABLE) GUICtrlSetState($CustomBGColor, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) $INI = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "") $GetExt = StringTrimLeft($INI, StringLen($INI) - 3) ; Get the Extension of the Currently Opened File If StringInStr($Ext, $GetExt) Then GUICtrlSetState($Run, $GUI_ENABLE) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) GUICtrlSetState($Save, $GUI_ENABLE) _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") EndIf Case $Save _Save() Case $TimeAndDate _TimeAndDate() Case $SpeakText $SelText = _GUICtrlEdit_GetSel($Edit) If $SelText[1] = 0 Then MsgBox(16, "Error!", "Select Text First!") Else Global $Voice = ObjCreate("Sapi.SpVoice") SpeakSelectedText(0.5, 100) EndIf Case $About MsgBox(64, "About", "Text Editor" & @LF & @LF & "Version: 2.8" & @LF & @LF & "Created By ReaperX (C) 2011 - 2012") Case $Find _Find() Case $SelectAll _SelectAll() Case $DocInfo MsgBox(0, "Information", "Characters: " & _GUICtrlEdit_GetTextLen($Edit) & @LF & "Lines: " & _GUICtrlEdit_GetLineCount($Edit)) Case $Cut Send("^x") Case $Copy Send("^c") Case $Paste GUICtrlSetData($Edit, GUICtrlRead($Edit) & ClipGet()) Case $Exit If GUICtrlRead($Edit) = FileRead(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit Else $Confirm = MsgBox(35, "Confirm", "Do You Want To Save Before Exiting?") If $Confirm = 6 Then If FileExists(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) Exit EndIf $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite($SaveDir, GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit Else IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit EndIf EndIf EndIf If $Confirm = 7 Then IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit EndIf Case $Undo _Undo() Case $CustomBGColor $iFile = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!") $NewBG = _ChooseColor(2) If Not @error Then GUICtrlSetState($EraseCustomOpt, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", $iFile, "bgcolor", $NewBG) GUICtrlSetBkColor($Edit, IniRead(@ScriptDir & "/config.ini", $iFile, "bgcolor", "0xFFFFFF")) _GUICtrlStatusBar_SetText($StatusBar, "Custom Background Color Options Saved!") Sleep(1000) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!")) EndIf Case $CustomFont $iFile = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!") $NewFont = _ChooseFont(IniRead(@ScriptDir & "/config.ini", $iFile, "fontname", "Arial"), IniRead(@ScriptDir & "/config.ini", $iFile, "fontsize", "11"), IniRead(@ScriptDir & "/config.ini", $iFile, "fontcolor", "0x000000"), IniRead(@ScriptDir & "/config.ini", $iFile, "fontweight", "400")) If Not @error Then GUICtrlSetState($EraseCustomOpt, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", $iFile, "fontname", $NewFont[2]) IniWrite(@ScriptDir & "/config.ini", $iFile, "fontsize", $NewFont[3]) IniWrite(@ScriptDir & "/config.ini", $iFile, "attributes", $NewFont[1]) IniWrite(@ScriptDir & "/config.ini", $iFile, "fontweight", $NewFont[4]) IniWrite(@ScriptDir & "/config.ini", $iFile, "fontcolor", $NewFont[7]) GUICtrlSetFont($Edit, IniRead(@ScriptDir & "/config.ini", $iFile, "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", $iFile, "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", $iFile, "attributes", "0"), IniRead(@ScriptDir & "/config.ini", $iFile, "fontname", "Arial")) GUICtrlSetColor($Edit, IniRead(@ScriptDir & "/config.ini", $iFile, "fontcolor", "0x000000")) _GUICtrlStatusBar_SetText($StatusBar, "Custom Font Options Saved!") Sleep(1000) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!")) EndIf Case $EraseCustomOpt $iFile = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!") IniDelete(@ScriptDir & "/config.ini", $iFile) GUICtrlSetFont(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) GUICtrlSetBkColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) GUICtrlSetState($EraseCustomOpt, $GUI_DISABLE) _GUICtrlStatusBar_SetText($StatusBar, "Custom File Options Erased!") Sleep(1000) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!")) Case $SetFileAttr $Attr = FileGetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!")) If Not @error Then SetFileAttr() Else MsgBox(16, "Error!", "The File Attributes Could Not be Retrieved!") EndIf Case $AboutCustomSett MsgBox(0, "About Custom Settings", "Custom BG and Font Settings are for Specific Files. You can open a file and have a Specific Background and Font color set for that file and No other file. This Doesnt mess with Default Settings. Default Settings Load When the Application first Opens and When no Custom Settings are Set For Any Open File.") Case $WordWrap If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($WordWrap, $GUI_UNCHECKED) GUICtrlSetStyle($Edit, $GUI_SS_DEFAULT_EDIT) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "wordwrap", "0") Else GUICtrlSetState($WordWrap, $GUI_CHECKED) GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL)) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "wordwrap", "1") EndIf Case $CAPS If BitAND(GUICtrlRead($CAPS), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($CAPS, $GUI_UNCHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL)) Else GUICtrlSetStyle($Edit, $GUI_SS_DEFAULT_EDIT) EndIf Else GUICtrlSetState($CAPS, $GUI_CHECKED) If BitAND(GUICtrlRead($LOWERCASE), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($LOWERCASE, $GUI_UNCHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_UPPERCASE)) Else GUICtrlSetStyle($Edit, $ES_UPPERCASE) EndIf EndIf Case $Readonly If BitAND(GUICtrlRead($Readonly), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($Readonly, $GUI_UNCHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL)) Else GUICtrlSetStyle($Edit, $GUI_SS_DEFAULT_EDIT) EndIf Else GUICtrlSetState($Readonly, $GUI_CHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_READONLY)) Else GUICtrlSetStyle($Edit, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY)) EndIf EndIf Case $LOWERCASE If BitAND(GUICtrlRead($LOWERCASE), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($LOWERCASE, $GUI_UNCHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL)) Else GUICtrlSetStyle($Edit, $GUI_SS_DEFAULT_EDIT) EndIf Else GUICtrlSetState($LOWERCASE, $GUI_CHECKED) If BitAND(GUICtrlRead($CAPS), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($CAPS, $GUI_UNCHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_LOWERCASE)) Else GUICtrlSetStyle($Edit, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY)) EndIf EndIf Case $Run $INI = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "") $GetExt = StringTrimLeft($INI, StringLen($INI) - 4) ; Get the Extension of the Currently Opened File If Not $INI = "" Then If StringInStr($Ext, $GetExt) Then ShellExecute($INI) If @Error Then MsgBox(16, "Run Script", "An Error Occurred!") EndIf EndIf EndIf EndSwitch WEnd EndFunc ;==>Main Func _Open() Global $Edit, $StatusBar, $SetFileAttr, $CustomBGColor, $CustomFont, $EraseCustomOpt, $Main, $Run Local $Ext = ".au3 ,.bat ,.vbs ,.htm ,.html" ; Script Types Allowed to Be Executed (Only Extensions) If WinActive($GUI_TITLE) Then If GUICtrlRead($Edit) = FileRead(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then $File = FileOpenDialog("Choose a Readable File", @ScriptDir, "All Files (*.*)|Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)") If Not @error Then GUICtrlSetState($SetFileAttr, $GUI_ENABLE) GUICtrlSetState($CustomFont, $GUI_ENABLE) GUICtrlSetState($CustomBGColor, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $File) ;$INI = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "") ;$GetExt = StringTrimLeft($INI, StringLen($INI) - 4) ; Get the Extension of the Currently Opened File ;If StringInStr($Ext, $GetExt) Then ;GUICtrlSetState($Run, $GUI_ENABLE) ;EndIf GUICtrlSetData($Edit, FileRead($File)) $A = IniReadSection(@ScriptDir & "/config.ini", $File) If Not @error Then GUICtrlSetFont($Edit, IniRead(@ScriptDir & "/config.ini", $File, "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", $File, "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", $File, "attributes", "0"), IniRead(@ScriptDir & "/config.ini", $File, "fontname", "Arial")) GUICtrlSetColor($Edit, IniRead(@ScriptDir & "/config.ini", $File, "fontcolor", "0x000000")) GUICtrlSetBkColor($Edit, IniRead(@ScriptDir & "/config.ini", $File, "bgcolor", "0xFFFFFF")) GUICtrlSetState($EraseCustomOpt, $GUI_ENABLE) EndIf _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & $File) If StringInStr(FileGetAttrib($File), "R") Then GUICtrlSetStyle($Edit, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY)) MsgBox(48, "Text Editor", "This File is set to Readonly and cannot be edited.") EndIf EndIf Else $Confirm = MsgBox(36, "Confirm", "Do You Want To Save Before Opening a New File?") If $Confirm = 6 Then If FileExists(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(1000) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") $File = FileOpenDialog("Choose a Readable File", @ScriptDir, "All Files (*.*)|Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)") If Not @error Then GUICtrlSetState($SetFileAttr, $GUI_ENABLE) GUICtrlSetState($CustomFont, $GUI_ENABLE) GUICtrlSetState($CustomBGColor, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $File) GUICtrlSetData($Edit, FileRead($File)) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & $File) EndIf Else $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite($SaveDir, GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & $File) EndIf EndIf Else $File = FileOpenDialog("Choose a Readable File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then GUICtrlSetState($SetFileAttr, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $File) GUICtrlSetData($Edit, FileRead($File)) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & $File) EndIf EndIf EndIf EndIf EndFunc ;==>_Open Func _New() Global $Edit, $StatusBar If WinActive($GUI_TITLE) Then If GUICtrlRead($Edit) = FileRead(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then GUICtrlSetData($Edit, "") IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") GUICtrlSetFont(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) GUICtrlSetBkColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) _GUICtrlStatusBar_SetText($StatusBar, "New Document") Else $Confirm = MsgBox(36, "Confirm", "Do You Want To Save Before Starting a New File?") If $Confirm = 6 Then If FileExists(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") GUICtrlSetData($Edit, "") GUICtrlSetFont(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) GUICtrlSetBkColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) EndIf $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite($SaveDir, GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") GUICtrlSetData($Edit, "") GUICtrlSetFont(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) GUICtrlSetBkColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) _GUICtrlStatusBar_SetText($StatusBar, "New Document") EndIf Else GUICtrlSetData($Edit, "") IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") _GUICtrlStatusBar_SetText($StatusBar, "New Document") EndIf EndIf EndIf EndFunc ;==>_New Func _Save() Global $StatusBar, $SetFileAttr, $CustomBGColor, $CustomFont If WinActive($GUI_TITLE) Then If FileExists(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!")) Else $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then GUICtrlSetState($SetFileAttr, $GUI_ENABLE) GUICtrlSetState($CustomFont, $GUI_ENABLE) GUICtrlSetState($CustomBGColor, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!")) EndIf EndIf EndIf EndFunc ;==>_Save Func _SelectAll() Global $Edit If WinActive($GUI_TITLE) Then _GUICtrlEdit_SetSel($Edit, 0, _GUICtrlEdit_GetTextLen($Edit)) EndIf EndFunc ;==>_SelectAll Func _Undo() Global $Edit If WinActive($GUI_TITLE) Then _GUICtrlEdit_Undo($Edit) EndIf EndFunc ;==>_Undo Func _Find() Global $Edit If WinActive($GUI_TITLE) Then _GUICtrlEdit_Find($Edit) EndIf EndFunc ;==>_Find Func _TimeAndDate() Global $Edit If WinActive($GUI_TITLE) Then If @WDAY = 1 Then $Day = "Sunday" If @WDAY = 2 Then $Day = "Monday" If @WDAY = 3 Then $Day = "Tuesday" If @WDAY = 4 Then $Day = "Wednesday" If @WDAY = 5 Then $Day = "Thursday" If @WDAY = 6 Then $Day = "Friday" If @WDAY = 7 Then $Day = "Saturday" If @HOUR < 12 Then $i = "AM" If @HOUR > 12 Then $i = "PM" GUICtrlSetData($Edit, GUICtrlRead($Edit) & $Day & " - " & @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & " " & $i) EndIf EndFunc ;==>_TimeAndDate Func SetFileAttr() GUICreate("Set File Attributes", 200, 140) Local $Attr = FileGetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!")) Local $Readonly = GUICtrlCreateCheckbox("Readonly", 20, 20) If StringInStr($Attr, "R") Then GUICtrlSetState(-1, $GUI_CHECKED) Local $Archive = GUICtrlCreateCheckbox("Archive", 100, 20) If StringInStr($Attr, "A") Then GUICtrlSetState(-1, $GUI_CHECKED) Local $Hidden = GUICtrlCreateCheckbox("Hidden", 20, 40) If StringInStr($Attr, "H") Then GUICtrlSetState(-1, $GUI_CHECKED) Local $Compress = GUICtrlCreateCheckbox("Compress", 100, 40) If StringInStr($Attr, "C") Then GUICtrlSetState(-1, $GUI_CHECKED) Local $Apply = GUICtrlCreateButton("Apply", 40, 80, 50, 30) Local $Cancel = GUICtrlCreateButton("Cancel", 100, 80, 50, 30) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case -3 GUIDelete() ExitLoop Case $Apply ;Readonly ================================================================== If BitOR(GUICtrlRead($Readonly), $GUI_CHECKED) = $GUI_CHECKED Then FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "+R") Else FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "-R") EndIf ;Archive ==================================================================== If BitOR(GUICtrlRead($Archive), $GUI_CHECKED) = $GUI_CHECKED Then FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "+A") Else FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "-A") EndIf ;Hidden ===================================================================== If BitOR(GUICtrlRead($Hidden), $GUI_CHECKED) = $GUI_CHECKED Then FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "+H") Else FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "-H") EndIf ;Compress ================================================================= If BitOR(GUICtrlRead($Compress), $GUI_CHECKED) = $GUI_CHECKED Then FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "+C") Else FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "-C") EndIf MsgBox(64, "Ok", "File Attributes Set and Saved.") GUIDelete() ExitLoop Case $Cancel GUIDelete() ExitLoop EndSwitch WEnd EndFunc ;==>SetFileAttr Func SpeakSelectedText($iRate, $iVolume) Global $Voice Send("^C") Local $iText = ClipGet() $Voice.Rate = $iRate $Voice.Volume = $iVolume $Voice.Speak($iText) Local $iText = ClipPut("") EndFunc ;==>SpeakSelectedText Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) Global $StatusBar _GUICtrlStatusBar_Resize($StatusBar) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Heres an Archive with the Updated Script (Also Compiled Version) and the Icon. Text Editor.rar1 point -
#include <GUIConstants.au3> #include <GuiRichEdit.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $Form1 = GUICreate("Form1", 448, 269, 192, 124, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX)) $Edit1 = _GUICtrlRichEdit_Create($Form1,"", 10, 10, 428, 249) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUISetState(@SW_SHOW) _GUICtrlRichEdit_AppendTextColor($Edit1, "Hello ", "0x00FF00") _GUICtrlRichEdit_AppendTextColor($Edit1, "Autoit ", "0xFF0000") _GUICtrlRichEdit_AppendTextColor($Edit1, "World", "0x000000") _GUICtrlRichEdit_AppendText($Edit1, @CRLF & @CRLF) _GUICtrlRichEdit_AppendTextColor($Edit1, "Hello" & @CRLF, "0x00FF00") _GUICtrlRichEdit_AppendTextColor($Edit1, "Autoit" & @CRLF, "0xFF0000") _GUICtrlRichEdit_AppendTextColor($Edit1, "World" & @CRLF, "0x000000") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($Edit1) Exit EndSwitch WEnd Func _GUICtrlRichEdit_AppendTextColor($hWnd, $sText, $iColor) Local $iLength = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) Local $iCp = _GUICtrlRichEdit_GetCharPosOfNextWord($hWnd, $iLength) _GUICtrlRichEdit_AppendText($hWnd, $sText) _GUICtrlRichEdit_SetSel($hWnd, $iCp-1, $iLength + StringLen($sText)) _GUICtrlRichEdit_SetCharColor($hWnd, $iColor) _GuiCtrlRichEdit_Deselect($hWnd) EndFunc Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) $NewW = _WinAPI_LoWord($lParam) $NewH = _WinAPI_HiWord($lParam) _WinAPI_SetWindowPos($Edit1, 0, 10, 10, $NewW - 20, $NewH - 20, BitOR($SWP_NOACTIVATE, $SWP_NOZORDER)) Return $GUI_RUNDEFMSG EndFunc1 point
-
Func _GUICtrlRichEdit_AppendTextColor($hWnd, $sText, $iColor) Local $iLength = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) ; RichEdit stores text as 2 Byte Unicode chars Local $iCp = _GUICtrlRichEdit_GetCharPosOfNextWord($hWnd, $iLength) _GUICtrlRichEdit_AppendText($hWnd, $sText) _GUICtrlRichEdit_SetSel($hWnd, $iCp-1, $iLength + StringLen($sText)) ; position in 2 Byte "Unicode" _GUICtrlRichEdit_SetCharColor($hWnd, $iColor) _GuiCtrlRichEdit_Deselect($hWnd) EndFunc1 point
-
In the next 24-hours we will be rolling We have rolled out a new site-wide system for blocking users. Users who are blocked will be sent to a read-only version of the website which you can find here. There are several reasons we are doing this. This page explains some of it. First we are going to be blocking known spammers. This will affect some of you. It already has because the system was temporarily rolled into place and a few of you were blocked. We know it will affect some of you and that is why the read-only site exists. It would have been a lot easier if we hadn't made a read-only site and just left an error page for those of you who are blocked. If you are accidentally blocked please do not be upset. We will work with you as this page explains. We are trying to make this a better place. Keeping spammers out is one part of that. The other part is keeping malicious users out. That's where the Tor, public proxy and manual blocks come in. Tor and public proxies make it way too easy for a user we don't want to come back time and time again. It's happened numerous times already. It makes our lives much easier if we just out-right block all users using those tools. If those tools are the only way you can access this site (for example, you are using it to evade a work or school block on our site) then you can still continue to use them to access the read-only mirror. So what can you do on the read-only mirror? Well, read. That's about it. You can download files and browse the forum or issue tracker. If your machine happens to have a valid login cookie for the forum then it will still continue to function. However, if you log out of the forum you will not be able to log in. You can not log in to the read-only site. The read-only site is designed so that everybody can still read our content but the malicious users won't be able to mess with our content. We aren't trying to make your lives more difficult. Hopefully none of you will be affected but that's an unrealistic dream. We are trying to make this a cleaner place. A place that requires less work on our part to administrate so we can do productive things like develop AutoIt instead of baby-sit.1 point
-
This system has now been in place for nearly 3 years. It has been a huge success. There have been countless times where people have stated they would make a new account and come back. In a handful of cases they did just that. In those cases they gave me clues to obtaining dozens if not hundreds of additional proxy addresses to block. Then they were, of course, immediately blocked again never to be heard from. The take-away from this is simple. Can you evade the system? Yes, but doing so only makes it stronger. Otherwise the system stops you from coming back. In either case we benefit. So that leaves all of you with a choice: When we block you permanently, are you going to spend your time and energy making our system stronger? Or are you going to accept that you are not welcome and walk away? I welcome either eventuality because I know in the end you will be gone permanently. I'm taking this opportunity to pin this topic so it's more visible.1 point
-
The new system is in place. There are a few quirks that need worked out.1 point