Jump to content
Sign in to follow this  
au3scr

simple notepad

Recommended Posts

Bug dedected or something wrong here

It drips me ope dialog over and over again and file path appears in edit but not text from file..how i can make appear text from file

#include <GUIConstants.au3>


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 611, 411, 193, 115)
$Edit1 = GUICtrlCreateedit("", 0, 32, 609, 377)
GUICtrlSetData(-1, "")
$save = GUICtrlCreateButton("save", 8, 0, 75, 25, 0)
$open = GUICtrlCreateButton("open", 88, 0, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $save
        Case $open
             $open = FileOpenDialog("Select file:", GUICtrlRead($Edit1), "text (*.txt;*.ini;*.au3;*.inf)")
            If @error Then ContinueLoop
             GUICtrlSetData($Edit1,$open)
             $Edit1 = FileRead ($open,2)
             ClipPut($Edit1)
    Send("^v")
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

If $open is a control ID then don't assign it any other value.

#include <GUIConstants.au3>


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 611, 411, 193, 115)
$Edit1 = GUICtrlCreateedit("", 0, 32, 609, 377)
GUICtrlSetData(-1, "")
$save = GUICtrlCreateButton("save", 8, 0, 75, 25, 0)
$open = GUICtrlCreateButton("open", 88, 0, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $save
        Case $open
             $path = FileOpenDialog("Select file:","", "text (*.txt;*.ini;*.au3;*.inf)")
            If Not @error Then
                GUICtrlSetData($Edit1,FileRead($path))
            EndIf           
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Here is the save function.

#include <GUIConstants.au3>

$Form1 = GUICreate("Form1", 611, 411, 193, 115)
$Edit1 = GUICtrlCreateedit("", 0, 32, 609, 377)
GUICtrlSetData(-1, "")
$save = GUICtrlCreateButton("save", 8, 0, 75, 25, 0)
$open = GUICtrlCreateButton("open", 88, 0, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $save
             $SaveFile = FileSaveDialog("Select Location to Save:", "", "Text (*.TXT|*.INI|*.au3|*.INF)")
             $ReadEdit = GuiCtrlRead($Edit1)
             FileWrite($SaveFile, $ReadEdit)
        Case $open
             $path = FileOpenDialog("Select file:","", "text (*.txt;*.ini;*.au3;*.inf)")
            If Not @error Then
                GUICtrlSetData($Edit1,FileRead($path))
            EndIf         
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Next problem .I tryed to make save function but it dont wipe old file.. it adds stuff that i writed to old text and other problem is.. i dont change title when i open file

Can anyone help pls?

#include <GUIConstants.au3>
Global $path = @DocumentsCommonDir
Global $title = "Unknown"

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate($title, 611, 411, 193, 115)
$Edit1 = GUICtrlCreateedit("", 0, 32, 609, 377)
GUICtrlSetData(-1, "")
$save = GUICtrlCreateButton("save", 8, 0, 75, 25, 0)
$open = GUICtrlCreateButton("open", 88, 0, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $save 
             $nano = GUICtrlRead($Edit1)
             $savetext = FileWrite ($path,$nano)
        Case $open
             $path = FileOpenDialog("Select file:","", "all (*.*)")
            If Not @error Then
                GUICtrlSetData($Edit1,FileRead($path))
            EndIf         
            $title = $path
    EndSwitch
WEnd

Here is the save function.

Script closes when i click save Edited by au3scr

Share this post


Link to post
Share on other sites

Ok, after some editing, study this script(And use it if you want.):

#cs
 ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.8.1
    Author:         Justin Reno
    
    Script Function:
    A simple notepad to study.
    
#ce ----------------------------------------------------------------------------

#include <GUIConstants.au3>
#include <File.au3>
#include <String.au3>
#include <GuiEdit.au3>

$Form1 = GUICreate("Text Editor", 634, 447, -1, -1, $WS_Overlappedwindow, $WS_MaximizeBox)
$Edit = GUICtrlCreateEdit("", 0, 0, 633, 425)
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem2 = GUICtrlCreateMenuItem("New", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("Open", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("Save", $MenuItem1)
$MenuItem5 = GUICtrlCreateMenuItem("Print", $MenuItem1)
$MenuSep = GUICtrlCreateMenuItem("", $MenuItem1)
$MenuItem6 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem7 = GUICtrlCreateMenu("Edit")
$MenuItem8 = GUICtrlCreateMenuItem("Insert Current Time", $MenuItem7)
$MenuSep = GUICtrlCreateMenuItem("", $MenuItem7)
$MenuItem9 = GUICtrlCreateMenuItem("Reverse Text", $MenuItem7)
$MenuSep = GUICtrlCreateMenuItem("", $MenuItem7)
$MenuItem10 = GUICtrlCreateMenuItem("Word Count", $MenuItem7)
$MenuSep = GUICtrlCreateMenuItem("", $MenuItem7)
$MenuItem11 = GUICtrlCreateMenuItem("Copy", $MenuItem7)
$MenuItem12 = GUICtrlCreateMenuItem("Paste", $MenuItem7)
$MenuSep = GUICtrlCreateMenuItem("", $MenuItem7)
$MenuItem13 = GUICtrlCreateMenuItem("Undo", $MenuItem7)
$MenuSep = GUICtrlCreateMenuItem("", $MenuItem7)
$MenuItem15 = GUICtrlCreateMenuItem("Font", $MenuItem7)
$MenuItem16 = GUICtrlCreateMenu("Speak")
$MenuItem17 = GUICtrlCreateMenuItem("Speak Text", $MenuItem16)
$MenuItem18 = GUICtrlCreateMenuItem("Stop Speaking", $MenuItem16)
$MenuItem19 = GUICtrlCreateMenu("About")
$MenuItem20 = GUICtrlCreateMenuItem("About", $MenuItem19)
GUISetState(@SW_SHOW)

While 1
    $Time = "" & @HOUR & ":" & @MIN & ":" & @SEC & ""
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MenuItem2
            GUICtrlSetData($Edit, "")
            WinSetTitle($Form1, "", "Text Editor")
        Case $MenuItem3
            $FileOpen = FileOpenDialog("Text Editor : Open File", "", "Text Files(*.txt;*.html)")
            $FileOpenread = FileRead($FileOpen)
            GUICtrlSetData($Edit, $FileOpenread)
            WinSetTitle($Form1, "", "Text Editor - " & $FileOpen & "")
        Case $MenuItem4
            $FileSave = FileSaveDialog("Text Editor : Save File", "", "Text Files(*.txt;*.html)")
            $EditSave = GUICtrlRead($Edit)
            FileWrite($FileSave, $EditSave)
            MsgBox(0, "Text Editor", "File Saved.")
            WinSetTitle($Form1, "", "Text Editor - " & $FileSave & "")
        Case $MenuItem5
            $EditReadPrint = GUICtrlRead($Edit)
            FileWrite(@TempDir & "\print.txt", $EditReadPrint)
            _FilePrint(@TempDir & "\print.txt")
            FileDelete(@TempDir & "\print.txt")
        Case $MenuItem6
            Exit
        Case $MenuItem8
            ControlSend($Form1, "", $Edit, $Time)
        Case $MenuItem9
            $EditReadReverse = GUICtrlRead($Edit)
            $StringRev = _StringReverse($EditReadReverse)
            GUICtrlSetData($Edit, $StringRev)
        Case $MenuItem10
            $EditReadCount = GUICtrlRead($Edit)
            $ReadCountSplit = StringSplit($EditReadCount, " ")
            $WordCount = $ReadCountSplit[0]
            $AllWords = $WordCount
            MsgBox(0, "Text Editor", "Word Count: " & $AllWords & "")
        Case $MenuItem11
            $EditReadCopy = GUICtrlRead($Edit)
            ClipPut($EditReadCopy)
        Case $MenuItem12
            $ClipGetCopy = ClipGet()
            $EditReadPaste = GUICtrlRead($Edit)
            GUICtrlSetData($Edit, $EditReadPaste & $ClipGetCopy)
        Case $MenuItem13
            _GUICtrlEditUndo($Edit)
        Case $MenuItem15
            $EditChooseFont = _ChooseFont()
            $Font = GUICtrlSetFont($Edit, $EditChooseFont[3], $EditChooseFont[4], $EditChooseFont[1], $EditChooseFont[2])
            $Color = GUICtrlSetColor($Edit, $EditChooseFont[7])
        Case $MenuItem17
            $Speech = ObjCreate("SAPI.SpVoice")
            $EditTextRead = GUICtrlRead($Edit)
            $Speech.Speak ($EditTextRead)
        Case $MenuItem18
            $Speech = ObjCreate("SAPI.SpVoice")
        Case $MenuItem20
            MsgBox(0, "Text Editor", "Text Editor made for Au3scr by Justin Reno.")
    EndSwitch
WEnd

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...