Jump to content

What i need


Zaum
 Share

Recommended Posts

Hey all. I'm a novice autoit3 programmer and i had an idea to make a little simple program. The idea basically is if you have something important or maybe a few sidenotes you want to save or write down on your computer for safe keeping or to later use you could just run this program. It would create a new directory in your documents folder (only once!! so i'd have to figure out how to make have it make the dir once then once the dir is made it won't recreate it when they reopen the program) and it would have an input box to type w/e the information is then it would have a save button or some type of button to save it.

I was wondering if some of you could help me and give me some commands or w/e i might need. I've been reading around the Autoit help file and i've found a few:

DirCreate -> Create the Dir, but only once

InputBox

DateAdd -> to add the date the file text?

I would also like to find out how the user can input what to save the filename as.

I appreciate all of the help i can get.

Link to comment
Share on other sites

Check out the help file for:

FileExists

FileSaveDialog

FileSelectFolder

They should give you some nice ideas

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Here is a DirCreate example

DirCreate("d:\temp")
If @error = 0 Then
    MsgBox(0,"Error", "Directory already exists")
    EndIf


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Here is a DirCreate example

DirCreate("d:\temp")
If @error = 0 Then
    MsgBox(0,"Error", "Directory already exists")
    EndIf
Is there a way it can skip the create dir. once its been made without sending msgbox?
Link to comment
Share on other sites

Apparantly it will give an error if the file already exists. If you don't specifically do something about that error, then it will just have failed and you wont have anything to wory about.

A cleaner (reguarding error checking) method might be to do something like

If NOT FileExists("d:\temp") then
     DirCreate("d:\temp")
EndIf
Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

I've got this so far:

#include <file.au3>
;Creates the Directory "Notes" in My Documents
$line = _FileCreate(@MyDocumentsDir &"\Notes\Log1.txt")

DirCreate(@MyDocumentsDir &"\Notes")

$open = FileOpen (@DesktopCommonDir &"\notes\log1.txt", 1)


;--Input Box Text to save as notes
$text = InputBox("Notes", "What would you like saved?")




FileWriteline($text, $line)

FileClose($open)

How do i get whatever is typed in the Inputbox to be saved into the Filecreate Log1.txt?

Edited by Zaum
Link to comment
Share on other sites

this may explain each step a little better

and do what you wanted

;Creates the Directory "Notes" in My Documents
DirGetSize(@MyDocumentsDir &"\Notes")
If @error= 1 Then
    DirCreate(@MyDocumentsDir &"\Notes")
EndIf

;--Input Box Text to save as notes
$text = InputBox("Notes", "What would you like saved?")

; open file to write input and close file
$open = FileOpen (@DesktopCommonDir &"\Notes\log1.txt", 1)

; Check if file opened for writing OK
If $open = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; write the input
FileWriteline($open, $text)

; close the file
FileClose($open)

8)

NEWHeader1.png

Link to comment
Share on other sites

This is an example ( a little more complicated )

to write to a New file each day ( still in the same folder )

#include <GUIConstants.au3>
Dim $location
 

; opens a new file every time script is ran
; or New File button is pressed
New_file()


GUICreate("GUICtrlCreateDummy",450,100, 100,200)


$user = GUICtrlCreateDummy()
$button = GUICtrlCreateButton ("New File",40,70,70,20)
$cancel = GUICtrlCreateButton ("Cancel",150,70,70,20)
$notice = GUICtrlCreateLabel($location, 20, 20, 400, 20, $SS_SUNKEN)
GUISetState()

Do
  $msg = GUIGetMsg ()
     
   Select
   Case $msg = $button
        New_file()
        MsgBox(0,"new file name", $location & "   " )
        GUICtrlSetData($notice, $location)
      Case $msg = $cancel
        exit
      Case $msg = $user
        ; special action before closing
        ; ...
         exit
   EndSelect
Until $msg = $GUI_EVENT_CLOSE

;---------------------------  Start - Functions ------------------------------------------

Func New_file()
    For $x = 1 to 1000
    If Not FileExists(@ScriptDir & "\test"& $x & ".txt" ) Then
        FileWrite(@ScriptDir & "\test"& $x & ".txt", "File Started " & @MDAY & "-" & @MON & "-" & @YEAR )
        $location = @ScriptDir & "\test"& $x & ".txt"
        ExitLoop
    EndIf
Next
EndFunc

hope it helps

8)

NEWHeader1.png

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...