Jump to content

Securepad, my own text editor


maqleod
 Share

Recommended Posts

borrowed the template from an early version of SimplePad and borrowed a few things from Ay-eye-Pad, and then I added a whole lot more.

Let me know what you think (I know its all been done, and I know there's nothing too fancy here, I was just trying to be as thorough as possible for what I did)

#AutoIt3Wrapper_aut2exe=C:\Program Files\AutoIt3\aut2exe\Aut2Exe.exe
#AutoIt3Wrapper_icon=C:\Documents and Settings\Jared Epstein\My Documents\Scripting Projects\Securepad.1 RC1\Icons\securepad.ico
#AutoIt3Wrapper_outfile=C:\Documents and Settings\Jared Epstein\My Documents\Scripting Projects\Securepad.1 RC1\Securepad.exe
#AutoIt3Wrapper_Compression=0
#AutoIt3Wrapper_Res_Description=AutoIt v3 Compiled Script
;Securepad
;v.0.1
;written by MaQleod (with some help from Sandman, JustinReno and msCreator)
#include <GuiConstants.au3>
#include <GuiEdit.au3>
#include <TextEdit.au3>
#include <String.au3>
#include <Misc.au3>
#include <File.au3>
#NoTrayIcon

FileSetAttrib("data.ini","+SH")

$wordwrapcheck = IniRead("data.ini","WordWrap","wrap","0")
$passwordcheck = IniReadSection("data.ini", "Admin")
if not @error then
if $passwordcheck[1][1] <> "" then
$passinput = InputBox("Password Required","Please enter your password","","*")
if $passinput <> _StringEncrypt(0,$passwordcheck[1][1],"9&g%j#4!8*y&f@3%v",5) then
MsgBox(64, "Error", "You do not have sufficient access to open this application.")
Exit
endif
endif
endif

Dim $voice = ObjCreate("Sapi.SpVoice")

HotKeySet("^n", "New")          ; Control+N
HotKeySet("^o", "Open")         ; Control+O
HotKeySet("^s", "Save")         ; Control+S
HotKeySet("^+s", "SaveAs")      ; Control+Shift+S
HotKeySet("^p", "Print")        ; Control+P
HotKeySet("^t", "SpeakText")    ; Control+T
HotKeySet("^z", "Undo")         ; Control+Z
HotKeySet("^x", "Cut")          ; Control+X
HotKeySet("^c", "Copy")         ; Control+C
HotKeySet("^v", "Paste")        ; Control+V
HotKeySet("^a", "SelectAll")    ; Control+A
HotKeySet("^f", "Find")         ; Control+H
HotKeySet("^h", "Replace")      ; Control+F
HotKeySet("^g", "GoTo")         ; Control+G
HotKeySet("{F3}", "FindNext")   ; F3

$name = "Securepad"
$version = "v.0.1"

$parent = GUICreate($name,627,447,193,115,BitOr($GUI_SS_DEFAULT_GUI,$WS_MINIMIZEBOX,$WS_MAXIMIZEBOX,$WS_SYSMENU,$WS_SIZEBOX))
Opt("RunErrorsFatal", 0)
if $wordwrapcheck = "1" then
$edit = GUICtrlCreateEdit("",0,0,625,425,$WS_VSCROLL+$ES_WANTRETURN+$ES_AUTOVSCROLL,0)
elseif $wordwrapcheck = "0" then
$edit = GUICtrlCreateEdit("",0,0,625,425,-1,0)
endif
GuiCtrlSetResizing($edit,$GUI_DOCKBORDERS)
GUICtrlSetLimit($edit,200000)

if $CmdLine[0] > 0 then
$filetype = StringRight($CmdLine[1], 3)
if $filetype = "spt" then
$title = WinGetTitle($name,"")
WinSetTitle($title,"",$name & " - " & $CmdLine[1] & "")
$defile = FileRead($CmdLine[1])
$docde = IniRead("data.ini","Encryption","Key","!$@#%&*")
$decrypt = _StringEncrypt(0,$defile,$docde,3)
GUICtrlSetData($edit,$decrypt)
_GUICtrlEditEmptyUndoBuffer($edit)
else
$title = WinGetTitle($name,"")
WinSetTitle($title,"",$name & " - " & $CmdLine[2] & "")
$defile = FileRead($CmdLine[2])
GUICtrlSetData($edit,$defile)
_GUICtrlEditEmptyUndoBuffer($edit)
endif
endif

$fileopt = GUICtrlCreateMenu("&File")
$open = GUICtrlCreateMenuItem("Open CTRL+O",$fileopt)
$new = GUICtrlCreateMenuItem("New   CTRL+N",$fileopt)
$save = GUICtrlCreateMenuItem("Save CTRL+S",$fileopt)
$saveas = GUICtrlCreateMenuItem("Save As    CTRL+SHIFT+S",$fileopt)
$print = GUICtrlCreateMenuItem("Print   CTRL+P",$fileopt)
GUICtrlCreateMenuItem("",$fileopt)
$speak = GUICtrlCreateMenuItem("Speak Text  CTRL+T",$fileopt)
GUICtrlCreateMenuItem("",$fileopt)
$exit = GUICtrlCreateMenuItem("Exit",$fileopt)
$editopt = GUICtrlCreateMenu("&Edit")
$undo = GUICtrlCreateMenuItem("Undo CTRL+Z",$editopt)
GUICtrlCreateMenuItem("",$editopt)
$cut = GUICtrlCreateMenuItem("Cut   CTRL+X",$editopt)
$copy = GUICtrlCreateMenuItem("Copy CTRL+C",$editopt)
$paste = GUICtrlCreateMenuItem("Paste   CTRL+V",$editopt)
$selectall = GUICtrlCreateMenuItem("Select All  CTRL+A",$editopt)
GUICtrlCreateMenuItem("",$editopt)
$find = GUICtrlCreateMenuItem("Find CTRL+F",$editopt)
$findnext = GUICtrlCreateMenuItem("Find Next    F3",$editopt)
$replace = GUICtrlCreateMenuItem("Repalce   CTRL+H",$editopt)
$goto = GUICtrlCreateMenuItem("Go To    CTRL+G",$editopt)
$formatopt = GUICtrlCreateMenu ("&Format")
$wordwrap = GUICtrlCreateMenuitem ("Word Wrap",$formatopt)
if $wordwrapcheck = "1" then
GUICtrlSetState($wordwrap,$GUI_CHECKED)
elseif $wordwrapcheck <> "0" then
GUICtrlSetState($wordwrap,$GUI_UNCHECKED)
endif
$fontedit = GUICtrlCreateMenuitem ("Font",$formatopt)
$configureopt = GUICtrlCreateMenu ("&Configure")
$pass = GUICtrlCreateMenuitem ("Set/Change Password",$configureopt)
$key = GUICtrlCreateMenuitem ("Change Encryption Key",$configureopt)
$options = GUICtrlCreateMenuitem ("Options",$configureopt)
$helpopt = GUICtrlCreateMenu("&About")
$about = GUICtrlCreateMenuItem("About",$helpopt)
$help = GUICtrlCreateMenuItem("Helpt",$helpopt)

$dummymenu = GUICtrlCreateDummy()
$contextmenu = GUICtrlCreateContextMenu($dummymenu)
$undocontext = GUICtrlCreateMenuItem("Undo",$contextmenu)
GUICtrlCreateMenuItem("",$contextmenu)
$cutcontext = GUICtrlCreateMenuItem("Cut",$contextmenu)
$copycontext = GUICtrlCreateMenuItem("Copy",$contextmenu)
$pastecontext = GUICtrlCreateMenuItem("Paste",$contextmenu)
$selectallcontext = GUICtrlCreateMenuItem("Select All",$contextmenu)
GUICtrlCreateMenuItem("",$contextmenu)
$findcontext = GUICtrlCreateMenuItem("Find",$contextmenu)
$findnextcontext = GUICtrlCreateMenuItem("Find Next",$contextmenu) 
$replacecontext = GUICtrlCreateMenuItem("Repalce",$contextmenu)
$gotocontext = GUICtrlCreateMenuItem("Go To",$contextmenu)

GUISetState()
Do
$msg = GUIGetMsg()

$CurInfo = GUIGetCursorInfo($parent)
Select
Case $CurInfo[3] = 1 And $CurInfo[4] = $edit
ShowMenu($parent, $contextmenu)
EndSelect

if $msg = $wordwrap then
if BitAnd(GUICtrlRead($wordwrap),$GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($wordwrap,$GUI_UNCHECKED)
IniWrite("data.ini","WordWrap","wrap","0")
$wordwrapinput = GuiCtrlRead($edit)
$wordwrapmodify = _GUICtrlEditGetModify($edit)
GuiCtrlDelete($edit)
$edit = GUICtrlCreateEdit("",0,0,625,425,-1,0)
GuiCtrlSetData($edit,$wordwrapinput)
_GUICtrlEditSetModify($edit,$wordwrapmodify)
else
GUICtrlSetState($wordwrap,$GUI_CHECKED)
IniWrite("data.ini","WordWrap","wrap","1")
$wordwrapinput = GuiCtrlRead($edit)
GuiCtrlDelete($edit)
$wordwrapmodify = _GUICtrlEditGetModify($edit)
$edit = GUICtrlCreateEdit("",0,0,625,425,$WS_VSCROLL+$ES_WANTRETURN+$ES_AUTOVSCROLL,0)
GuiCtrlSetData($edit,$wordwrapinput)
_GUICtrlEditSetModify($edit,$wordwrapmodify)
endif
endif

if $msg = $open then
Open()
endif

if $msg = $new then
New()
IniWrite("data.ini","Font","font","Arial")
IniWrite("data.ini","Font","size","10")
IniWrite("data.ini","Font","style","Normal")
endif

if $msg = $save then
Save()
endif

if $msg = $saveas then
SaveAs()
endif

if $msg = $print then
Print()
endif

if $msg = $speak then
SpeakText()
endif

if $msg = $undo or $msg = $undocontext then
Undo()
endif

if $msg = $cut or $msg = $cutcontext then
Cut()
endif

if $msg = $copy or $msg = $copycontext then
Copy()
endif

if $msg = $paste or $msg = $pastecontext then
Paste()
endif

if $msg = $selectall or $msg = $selectallcontext then
SelectAll()
endif

if $msg = $find or $msg = $findcontext then
Find()
endif

if $msg = $findnext or $msg = $findnextcontext then
FindNext()
endif

if $msg = $replace or $msg = $replacecontext then
Replace()
endif

if $msg = $goto or $msg = $gotocontext then
GoTo()
endif

if $msg = $exit then
ExitLoop
endif

if $msg = $options then
$child4 = GUICreate("Options",220, 220,-1,-1,-1,$WS_EX_ACCEPTFILES,$parent)
;$replaceshell = GuiCtrlCreateCheckbox("Associate with .txt file type",10,15,140,20)
;$replaceshellcheck = IniRead("data.ini","Shell",".txt","0")
;if $replaceshellcheck = 0 then
;GuiCtrlSetState($replaceshell,$GUI_UNCHECKED)
;elseif $replaceshellcheck = 1 then
;GuiCtrlSetState($replaceshell,$GUI_CHECKED)
;endif
$okoption = GUICtrlCreateButton ("OK",35,170,75,25)
$canceloption = GUICtrlCreateButton ("Cancel",115,170,75,25)
GUISetState()
Do
$msg4 = GUIGetMsg()
if $msg4= $okoption then
;if GuiCtrlRead($replaceshell) = $GUI_CHECKED then
;IniWrite("data.ini","Shell",".txt","1")
;Run("regedit.exe /e oldtxt.reg HKCR\.txt")
;elseif GuiCtrlRead($replaceshell) = $GUI_UNCHECKED then
;IniWrite("data.ini","Shell",".txt","0")
;Run("regedit.exe /s oldtxt.reg")
;endif
ExitLoop
endif
if $msg4= $canceloption then
ExitLoop
endif
Until $msg4 = $GUI_EVENT_CLOSE
GUIDelete($child4)
endif

if $msg = $fontedit then
$child3 = GUICreate("Font",320, 130,-1,-1,-1,$WS_EX_ACCEPTFILES,$parent)
$defaultfont = IniRead("data.ini","Font","font","Arial")
$defaultsize = IniRead("data.ini","Font","size","10")
$defaultstyle = IniRead("data.ini","Font","style","Normal")
$fontlist = _FontGetList(0)
GuiCtrlCreateLabel("Choose a Font:",10,15,80,20)
$fontselect = GuiCtrlCreateCombo("Arial",95,10,215,20)
For $i = 1 to $fontlist[0]
GuiCtrlSetData($fontselect,$fontlist[$i],$defaultfont)
Next
GuiCtrlCreateLabel("Font Size:",10,40,80,20)
$fontsize = GuiCtrlCreateCombo("2",95,35,45,20)
GuiCtrlSetData($fontsize,"4|5|6|7|8|9|10|11|12|14|16|18|20|22|24|26|28|30|32|36|48|72",$defaultsize)
GuiCtrlCreateLabel("Font Style:",10,65,80,20)
$fontstyle = GuiCtrlCreateCombo("Normal",95,60,75,20)
GuiCtrlSetData($fontstyle,"Italic|Underline|Strike",$defaultstyle)
$setfont = GuiCtrlCreateButton("Set Font",75,90,75,25)
$cancelfont = GuiCtrlCreateButton("Cancel",155,90,75,25)
GUISetState()
Do
$msg3 = GUIGetMsg()
if $msg3 = $setfont then
if GuiCtrlRead($fontstyle) = "Normal" then
$attribute = 0
elseif GuiCtrlRead($fontstyle) = "Italic" then
$attribute = 2
elseif GuiCtrlRead($fontstyle) = "Underline" then
$attribute = 4
elseif GuiCtrlRead($fontstyle) = "Strike" then
$attribute = 8
endif
GUICtrlSetFont($edit,GuiCtrlRead($fontsize),400,$attribute,GuiCtrlRead($fontselect))
IniWrite("data.ini","Font","font",GuiCtrlRead($fontselect))
IniWrite("data.ini","Font","size",GuiCtrlRead($fontsize))
IniWrite("data.ini","Font","style",GuiCtrlRead($fontstyle))
ExitLoop
endif
if $msg3 = $cancelfont then
ExitLoop
endif
Until $msg3 = $GUI_EVENT_CLOSE
GUIDelete($child3)
endif

if $msg = $key then
$password = IniRead("data.ini", "Admin","Password","")
if $password = "" then
MsgBox(0,"Error","You must set a Password to use this function.")
$msg = $pass
elseif $password <> "" then
$child5 = GUICreate("Change Encryption Key",220, 220,-1,-1,-1,$WS_EX_ACCEPTFILES,$parent)
Opt("RunErrorsFatal",0)
$currentkey = IniRead("data.ini","Encryption","Key","!$@#%&*")
GuiCtrlCreateLabel("Encryption Key:",10,13,75,20)
$keyinput = GuiCtrlCreateInput($currentkey,85,10,75,20)
$keyok = GUICtrlCreateButton ("OK",35,170,75,25)
$keycancel = GUICtrlCreateButton ("Cancel",115,170,75,25)
GUISetState()
Do
$msg5 = GUIGetMsg()
if $msg5 = $keyok then
IniWrite("data.ini","Encryption","Key",GuiCtrlRead($currentkey))
ExitLoop
endif
if $msg5 = $keycancel then
ExitLoop
endif
Until $msg5 = $GUI_EVENT_CLOSE
GUIDelete($child5)
endif
endif

if $msg = $pass then
$password = IniRead("data.ini", "Admin","Password","")
if $password = "" then
$child2 = GUICreate("Set Admin Pass",250, 250,-1,-1,-1,$WS_EX_ACCEPTFILES,$parent)
Opt("RunErrorsFatal", 0)
GUICtrlCreateLabel ("You have not set an Admin Pass, please do so.", 45, 30, 150,30)
GUICtrlCreateLabel ("Enter Password:", 25, 90, 50,30)
$adminpass = GUICtrlCreateInput("",  105, 95, 75,20,$ES_PASSWORD)
GUICtrlCreateLabel ("Re-enter Password:", 25, 120, 50,30)
$adminpasscheck = GUICtrlCreateInput("",  105, 125, 75,20,$ES_PASSWORD)
$passencrypt = GUICtrlCreateInput("",  105, 150, 75,20,$ES_PASSWORD)
GUICtrlSetState(-1,$GUI_HIDE)
$passok = GUICtrlCreateButton ("OK", 35, 190, 75,25)
$passcancel = GUICtrlCreateButton ("Cancel", 115, 190, 75,25)
GUISetState()
Do
$msg2 = GUIGetMsg()
if $msg2 = $passok then
if (GUICtrlRead($adminpass)) = (GUICtrlRead($adminpasscheck)) then
GuiCtrlSetData($passencrypt,_StringEncrypt(1,(GUICtrlRead($adminpass)),"9&g%j#4!8*y&f@3%v",5))
IniWrite("data.ini", "Admin", "Password", (GUICtrlRead($passencrypt)))
ExitLoop
else
MsgBox(64, "Error", "Passwords did not match, please re-enter passwords.")
endif
endif
if $msg2 = $passcancel then
ExitLoop
endif
Until $msg2 = $GUI_EVENT_CLOSE
GUIDelete($child2)
else
$child2 = GUICreate("Change Admin Pass",250, 250,-1,-1,-1,$WS_EX_ACCEPTFILES,$parent)
Opt("RunErrorsFatal", 0)
GUICtrlCreateLabel ("Old Password:", 25, 30, 50,30)
$adminpassold = GUICtrlCreateInput("",  135, 30, 75,20,$ES_PASSWORD)
GUICtrlCreateLabel ("New Password:", 25, 90, 50,30)
$adminpass = GUICtrlCreateInput("",  135, 90, 75,20,$ES_PASSWORD)
GUICtrlCreateLabel ("Re-enter Password:", 25, 150, 50,30)
$adminpasscheck = GUICtrlCreateInput("",  135, 150, 75,20,$ES_PASSWORD)
$passencrypt = GUICtrlCreateInput("",  105, 150, 75,20,$ES_PASSWORD)
GUICtrlSetState(-1,$GUI_HIDE)
$passok = GUICtrlCreateButton ("OK", 35, 190, 75,25)
$passcancel = GUICtrlCreateButton ("Cancel", 115, 190, 75,25)
GUISetState()
Do
$msg2 = GUIGetMsg()
if $msg2 = $passok then
GuiCtrlSetData($passencrypt,_StringEncrypt(0,$pass[1][1],"9&g%j#4!8*y&f@3%v",5))
if (GUICtrlRead($adminpass)) = (GUICtrlRead($adminpasscheck)) AND (GUICtrlRead($adminpassold)) = (GUICtrlRead($passencrypt)) then
GuiCtrlSetData($passencrypt,_StringEncrypt(1,(GUICtrlRead($adminpass)),"9&g%j#4!8*y&f@3%v",5))
IniWrite("data.ini", "Admin", "Password", (GUICtrlRead($passencrypt)))
MsgBox(64, "Success", "Your password has been changed.")
ExitLoop
elseif (GUICtrlRead($adminpass)) <> (GUICtrlRead($adminpasscheck)) then
MsgBox(64, "Error", "Passwords did not match, please re-enter passwords.")
elseif (GUICtrlRead($adminpassold)) <> (GUICtrlRead($passencrypt)) then
MsgBox(64, "Error", "You do not have sufficient access to make this change.")
GUICtrlSetData($adminpass,"")
GUICtrlSetState($adminpass,$GUI_FOCUS)
endif
endif
if $msg2 = $passcancel then
ExitLoop
endif
Until $msg2 = $GUI_EVENT_CLOSE
GUIDelete($child2)
endif
endif

if $msg = $about then
$child1 = GUICreate("About",220, 220,-1,-1,-1,$WS_EX_ACCEPTFILES,$parent)
$font = "Ariel"
Opt("RunErrorsFatal",0)
GUICtrlCreateLabel($name & " " & $version,50,30,150,30)
GUICtrlSetFont(-1,10,400,$font)
GUICtrlCreateIcon("icons\securepad.ico",-1,85,65,48,48)
GUICtrlCreateLabel("Written By MaQleod", 55,120,150,30)
GUICtrlSetFont (-1,10, 400, $font)
$aboutok = GUICtrlCreateButton ("OK",75,170,75,25)
GUISetState()
Do
$msg1 = GUIGetMsg()
if $msg1 = $aboutok then
ExitLoop
endif
Until $msg1 = $GUI_EVENT_CLOSE
GUIDelete($child1)
endif

Until $msg = $GUI_EVENT_CLOSE
OnClose()
IniWrite("data.ini","Font","font","Arial")
IniWrite("data.ini","Font","size","10")
IniWrite("data.ini","Font","style","Normal")
GUIDelete()

Func Open()
$modifycheck = _GUICtrlEditGetModify($edit)
if $modifycheck <> 0 then
$yesno = MsgBox(3,"Info","Would you like to save the current document?")
if $yesno = 7 then
OpenFile()
elseif $yesno = 6 then
Save()
OpenFile()
elseif $yesno = 2 then
endif
else
OpenFile()
endif
EndFunc

Func OpenFile()
$fileopen = FileOpenDialog("Open File", "", "Securepad Files(*.spt)|Text Files(*.txt)|AutoIt Files(*.au3)")
if @error then
else
$filetype = StringRight($fileopen, 3)
if $filetype = "spt" then
$title = WinGetTitle($name,"")
WinSetTitle($title,"",$name & " - " & $fileopen & "")
$defile = FileRead($fileopen)
$docde = IniRead("data.ini","Encryption","Key","!$@#%&*")
$decrypt = _StringEncrypt(0,$defile,$docde,3)
GUICtrlSetData($edit,$decrypt)
_GUICtrlEditEmptyUndoBuffer($edit)
_GUICtrlEditSetModify($edit,0)
else
$title = WinGetTitle($name,"")
WinSetTitle($title,"",$name & " - " & $fileopen & "")
$defile = FileRead($fileopen)
GUICtrlSetData($edit,$defile)
_GUICtrlEditEmptyUndoBuffer($edit)
_GUICtrlEditSetModify($edit,0)
endif
endif
EndFunc

Func New()
$modifycheck = _GUICtrlEditGetModify($edit)
if $modifycheck <> 0 then
$yesno = MsgBox(3,"Info","Would you like to save the current document?")
if $yesno = 7 then
$title = WinGetTitle($name,"")
WinSetTitle($title,"",$name)
GUICtrlSetData($edit, "")
_GUICtrlEditEmptyUndoBuffer($edit)
_GUICtrlEditSetModify($edit,"False")
elseif $yesno = 6 then
Save()
$title = WinGetTitle($name,"")
WinSetTitle($title,"",$name)
GUICtrlSetData($edit, "")
_GUICtrlEditEmptyUndoBuffer($edit)
_GUICtrlEditSetModify($edit,"False")
elseif $yesno = 2 then
endif
else
$title = WinGetTitle($name,"")
WinSetTitle($title,"",$name)
GUICtrlSetData($edit, "")
_GUICtrlEditEmptyUndoBuffer($edit)
_GUICtrlEditSetModify($edit,"False")
endif
EndFunc

Func Save()
$title = WinGetTitle($name,"")
if $title = $name then
SaveAs()
else
$filetype = StringRight($title, 3)
if $filetype = "spt" then
$filesavedialog = StringTrimLeft($title,12)
FileDelete($filesavedialog)
$docen = IniRead("data.ini","Encryption","Key","!$@#%&*")
$encrypt = _StringEncrypt(1,GUICtrlRead($edit),$docen,3)
FileWrite($filesavedialog,$encrypt)
elseif $filetype = "txt" or $filetype = "au3" then
$filesavedialog = StringTrimLeft($title,12)
FileDelete($filesavedialog)
FileWrite($filesavedialog,GuiCtrlRead($edit))
_GUICtrlEditSetModify($edit,"False")
endif
endif
EndFunc

Func SaveAs()
$filesavedialog = FileSaveDialog("Save File","","Securepad Files(*.spt)|Text Files(*.txt)|AutoIt Files(*.au3)")
if @error then
else
$filetype = StringRight($filesavedialog, 3)
if $filetype = "spt" then
FileDelete($filesavedialog)
$docen = IniRead("data.ini","Encryption","Key","!$@#%&*")
$encrypt = _StringEncrypt(1,GUICtrlRead($edit),$docen,3)
FileWrite($filesavedialog,$encrypt)
$title = WinGetTitle($name,"")
WinSetTitle($title,"",$name & " - " & $filesavedialog & "")
_GUICtrlEditSetModify($edit,"False")
elseif $filetype = "txt" then
FileWrite($filesavedialog,GuiCtrlRead($edit))
$title = WinGetTitle($name,"")
WinSetTitle($title,"",$name & " - " & $filesavedialog & "")
_GUICtrlEditSetModify($edit,"False")
elseif $filetype = "au3" then
FileWrite($filesavedialog,GuiCtrlRead($edit))
$title = WinGetTitle($name,"")
WinSetTitle($title,"",$name & " - " & $filesavedialog & "")
_GUICtrlEditSetModify($edit,"False")
else
$filesavedialog &= ".txt"
FileWrite($filesavedialog,GuiCtrlRead($edit))
$title = WinGetTitle($name,"")
WinSetTitle($title,"",$name & " - " & $filesavedialog & "")
_GUICtrlEditSetModify($edit,"False")
endif
endif
EndFunc

Func Print()
$readeditprint = GUICtrlRead($edit)
$filewriteprint = FileWrite(@TempDir & "\printtest.txt",$readeditprint)
$file = @TempDir & "\printtest.txt"
_FilePrint($file)
Sleep(500)
FileDelete(@TempDir & "\printtest.txt")
EndFunc

Func Speak($text, $rate, $volme)
$voice.Rate = $rate
$voice.Volume = $volme
$voice.Speak($text)
EndFunc

Func SpeakText()
$texttoread = GUICtrlRead($edit)
Speak($texttoread,0,100)
EndFunc

Func Undo()
_GUICtrlEditUndo($edit)
EndFunc

Func Cut()
ClipPut(ControlCommand($parent, "", $edit, "GetSelected", ""))
_GUICtrlEditReplaceSel($edit,"True","")
EndFunc

Func Copy()
ClipPut(ControlCommand($parent, "", $edit, "GetSelected", ""))
EndFunc

Func Paste()
$clipboard = ClipGet()
_GUICtrlEditReplaceSel($edit,"True",$clipboard)
EndFunc

Func SelectAll()
_GUICtrlEditSetSel($edit, 0, -1)
EndFunc

Func Find()
$lastfind = IniRead("data.ini","Find","last","")
$case = IniRead("data.ini","Find","case","0")
$child8= GUICreate("Find",220, 120,-1,-1,-1,$WS_EX_ACCEPTFILES,$parent)
Opt("RunErrorsFatal",0)
$texttofind = GuiCtrlCreateInput($lastfind,15,25,100,20)
$findcase = GuiCtrlCreateCheckbox("Case Sensitive",125,25,100,20)
if $case = "1" then
GuiCtrlSetState($findcase,$GUI_CHECKED)
endif
$findtext = GUICtrlCreateButton ("Find",60,60,75,25)
GUISetState()
Do
$msg8 = GUIGetMsg()
if $msg8 = $findtext then
if GUICtrlRead($findcase) = $GUI_CHECKED then
$casesense = 1
elseif GUICtrlRead($findcase) = $GUI_UNCHECKED then
$casesense = 0
endif
$findsel = StringInStr(GuiCtrlRead($edit),GuiCtrlRead($texttofind),$casesense,1)
if $findsel <> 0 then
_GUICtrlEditSetSel($edit, $findsel - 1, $findsel + StringLen(GuiCtrlRead($texttofind)) - 1)
IniWrite("data.ini","Find","last",GuiCtrlRead($texttofind))
IniWrite("data.ini","Find","occurance",2)
if $casesense = 1 then
IniWrite("data.ini","Find","case","1")
elseif $casesense = 0 then
IniWrite("data.ini","Find","case","0")
endif
ExitLoop
elseif $findsel = 0 then
MsgBox(0, "Find", "Securepad cannot find the string in the document.")
endif
endif
Until $msg8 = $GUI_EVENT_CLOSE
GUIDelete($child8)
EndFunc

Func FindNext()
$findoccurance = IniRead("data.ini","Find","occurance","1")
$lastfind = IniRead("data.ini","Find","last","")
$case = IniRead("data.ini","Find","case","0")
$findsel = StringInStr(GuiCtrlRead($edit),$lastfind,$case,$findoccurance)
if $findsel <> 0 then
_GUICtrlEditSetSel($edit, $findsel - 1, $findsel + StringLen($lastfind) - 1)
elseif $findsel = 0 then
IniWrite("data.ini","Find","occurance",1)
$findoccurance = IniRead("data.ini","Find","occurance","1")
$lastfind = IniRead("data.ini","Find","last","")
$case = IniRead("data.ini","Find","case","0")
$findsel = StringInStr(GuiCtrlRead($edit),$lastfind,$case,$findoccurance)
_GUICtrlEditSetSel($edit, $findsel - 1, $findsel + StringLen($lastfind) - 1)
endif
IniWrite("data.ini","Find","occurance",$findoccurance + 1)
EndFunc

Func Replace()
$lastfind = IniRead("data.ini","Find","last","")
$case = IniRead("data.ini","Find","case","0")
$child9= GUICreate("Replace",260,160,-1,-1,-1,$WS_EX_ACCEPTFILES,$parent)
Opt("RunErrorsFatal",0)
GuiCtrlCreateLabel("Text to Find:",25,28,75,20)
GuiCtrlCreateLabel("Replace With:",25,53,75,20)
$texttofind = GuiCtrlCreateInput($lastfind,105,25,100,20)
$texttoreplace = GuiCtrlCreateInput($lastfind,105,50,100,20)
$findcase = GuiCtrlCreateCheckbox("Case Sensitive",15,80,90,20)
$exclude = GuiCtrlCreateCheckbox("Exclude if Within a Word",115,80,135,20)
if $case = "1" then
GuiCtrlSetState($findcase,$GUI_CHECKED)
endif
$replacetext = GUICtrlCreateButton ("Replace First",35,105,75,25)
$replacealltext = GUICtrlCreateButton ("Replace All",135,105,75,25)
GUISetState()
Do
$msg9 = GUIGetMsg()
if $msg9 = $replacetext then
if GUICtrlRead($findcase) = $GUI_CHECKED then
$casesense = 1
elseif GUICtrlRead($findcase) = $GUI_UNCHECKED then
$casesense = 0
endif
$findsel = StringInStr(GuiCtrlRead($edit),GuiCtrlRead($texttofind),$casesense,1)
if $findsel <> 0 then
_GUICtrlEditSetSel($edit,$findsel - 1, $findsel + StringLen(GuiCtrlRead($texttofind)) - 1)
_GUICtrlEditReplaceSel($edit,"True",GuiCtrlRead($texttoreplace))
IniWrite("data.ini","Find","last",GuiCtrlRead($texttofind))
IniWrite("data.ini","Find","occurance",2)
if $casesense = 1 then
IniWrite("data.ini","Find","case","1")
elseif $casesense = 0 then
IniWrite("data.ini","Find","case","0")
endif
ExitLoop
elseif $findsel = 0 then
MsgBox(0, "Find", "Securepad cannot find the string in the document.")
endif
endif
if $msg9 = $replacealltext then
if GUICtrlRead($findcase) = $GUI_CHECKED then
$casesense = 1
elseif GUICtrlRead($findcase) = $GUI_UNCHECKED then
$casesense = 0
endif
$replaceall = _TextEditGetCharPos(GuiCtrlRead($edit),GuiCtrlRead($texttofind))
$findsel = StringInStr(GuiCtrlRead($edit),GuiCtrlRead($texttofind),$casesense,1)
if $findsel <> 0 then
_GUICtrlEditSetSel($edit,$findsel - 1, $findsel + StringLen(GuiCtrlRead($texttofind)) - 1)
_GUICtrlEditReplaceSel($edit,"True",GuiCtrlRead($texttoreplace))
IniWrite("data.ini","Find","last",GuiCtrlRead($texttofind))
IniWrite("data.ini","Find","occurance",2)
if $casesense = 1 then
IniWrite("data.ini","Find","case","1")
elseif $casesense = 0 then
IniWrite("data.ini","Find","case","0")
endif
For $i = 2 to $replaceall[0]
FindNext()
_GUICtrlEditReplaceSel($edit,"True",GuiCtrlRead($texttoreplace))
Next
ExitLoop
elseif $findsel = 0 then
MsgBox(0, "Find", "Securepad cannot find the string in the document.")
endif
endif
Until $msg9 = $GUI_EVENT_CLOSE
GUIDelete($child9)
Endfunc

Func GoTo()
$editlinecount = _GUICtrlEditGetLineCount($edit)
$currentline = _GUICtrlEditLineFromChar($edit,-1) + 1
$child10 = GUICreate("Go To Line",175,75,-1,-1,-1,$WS_EX_ACCEPTFILES,$parent)
Opt("RunErrorsFatal",0)
GuiCtrlCreateLabel("Go to line:",10,12,55,20)
$lineinput = GuiCtrlCreateInput("",70,10,35,20)
$go = GUICtrlCreateButton ("Go",10,40,75,25)
$gocancel = GUICtrlCreateButton ("Cancel",90,40,75,25)
GUISetState()
Do
$msg10 = GUIGetMsg()
if $msg10 = $go then
$linemove = GuiCtrlRead($lineinput) - $currentline
$title = WinGetTitle($name,"")
WinActivate($title,"")
if $linemove < 0 then
$abs = Abs($linemove)
Send("{HOME}")
Send("{UP " & $abs & "}")
elseif $linemove > 0 then
$abs = Abs($linemove)
Send("{HOME}")
Send("{DOWN " & $abs & "}")
endif
;_GUICtrlEditLineScroll($edit,0,$linemove)
ExitLoop
endif
if $msg10 = $gocancel then
ExitLoop
endif
Until $msg10 = $GUI_EVENT_CLOSE
GUIDelete($child10)
EndFunc

Func OnClose()
$modifycheck = _GUICtrlEditGetModify($edit)
if $modifycheck <> 0 then
$title = WinGetTitle($name,"")
if $title = $name then
$yesno = MsgBox(4,"Info","Would you like to save the current document?")
if $yesno = 7 then
elseif $yesno = 6 then
SaveAs()
endif
else
$file = StringTrimLeft($title,22)
$defile = FileRead($file)
$docde = IniRead("data.ini","Encryption","Key","!$@#%&*")
$decrypt = _StringEncrypt(0,$defile,$docde,3)
if GUICtrlRead($edit) <> $decrypt then
$yesno = MsgBox(4,"Info","Would you like to save the current document?")
if $yesno = 7 then
elseif $yesno = 6 then
SaveAs()
endif
else
endif
endif
endif
IniWrite("data.ini","Find","last","")
IniWrite("data.ini","Find","case","0")
IniWrite("data.ini","Find","occurance","1")
EndFunc

Func ShowMenu($hWnd, $nContextID)
Local $hMenu = GUICtrlGetHandle($nContextID)
$arPos = MouseGetPos()
Local $x = $arPos[0]
Local $y = $arPos[1]
DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc

this is the sourcepack with all needed files (includes innosetup script for the installer which will install all the registry keys to create the shell context menu and file icon for the file type .spt)

securepad0.1sourcepack.zip

Edited by maqleod
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

Errors:

==> Duplicate function name.:

Func Copy()

==> Duplicate function name.:

Func Paste()

Then.. it opens a window called TextEdit 1.0. I close it and it takes me to Securepad but doesn't close the previous window. When I go to format-->font I get this:

==> Unknown function name.:

$fontlist = _FontGetList(0)

$fontlist = ^ ERROR

I'm sure you already knew all this anyway... Keep working!

Link to comment
Share on other sites

Errors:

Then.. it opens a window called TextEdit 1.0. I close it and it takes me to Securepad but doesn't close the previous window. When I go to format-->font I get this:

I'm sure you already knew all this anyway... Keep working!

actually, no, I didn't know it did that, never got those errors, but I'll test on other machines and look into why it does it.

ok the fontlist error is because you don't have the the textedit.au3 include which has that function, should have realized that last night but I was already really tired.

Edited by maqleod
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

Nice only... The options wont work...

If i press Option it will show a blank GuiCreate()

EDIT:(5 sec later :)) I live the Speak function ^^

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Nice only... The options wont work...

If i press Option it will show a blank GuiCreate()

I haven't actually added any options...that will come later.

Despite a few spelling errors and some bugs.

Great work! keep it up.

thx, but what bugs? can you give me some details so I can fix them?

Edited by maqleod
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

PLEASE PLEASE PLEASE***GIVE CREDIT TO ME AND SANDMAN SOMEWHERE IN THE SCRIPT!!!!!!

ok, I will, although the only function of yours I didn't completely rewrite was the speak/speak text, so I'll definitely credit you on that, and for sandman the only part I borrowed was the cmdline part, but I also completely rewrote that section as well. I mostly just used your scripts as examples for ideas to expand upon, but I did use the same dimensions as you for the starting window size. I should also credit msCreator for the function to add the context menu within the edit box.

EDIT: for some reason the forum won't let me edit that particular entry, so I will add it all into the scripts and update it soon.

EDIT: ok, I added a line with credits, sorry bout that

Edited by maqleod
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...