Sign in to follow this  
Followers 0
snowman533

Help with some additional features

9 posts in this topic

#1 ·  Posted (edited)

Hey guys, im working on a file maker

extremely efficient in setting up projects by allowing the user to pre-create the necessary files beforehand by removing the need to use notepad for file creation

works beautifully, and i must admit its the best damn thing ive made ;) (i use it on a daily basis) theres just a few things missing, see the comments in the code for what i need

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>
#Include <TreeViewConstants.au3>
#include <TVExplorer.au3>

$gui=GUICreate("File Maker", 500, 130)
GUISetState(@SW_SHOW, $gui)
$BtnCreateFile=GUICtrlCreateButton("Create", 10, 80, 50, 20) ;I want this to be "clicked" when Enter is pressed
$BtnExit=GUICtrlCreateButton("Exit", 440, 10, 50, 20)
$TxtDir = GUICtrlCreateInput("",10,10,200,20)
$BtnBrowse =GUICtrlCreateButton("Browse",220,10,50,20)
$TxtFile = GUICtrlCreateInput("file.extension",10,50,200,20)
$BtnCreateDir = GUICtrlCreateButton("Make Dir",280, 10, 50, 20)

While 1
        $msg = GUIGetMsg()
        if $msg = $BtnCreateFile then CreateFile()
        if $msg = $BtnBrowse then GetDir()
        if $msg = $BtnCreateDir then CreateDir()
        if $msg = $BtnExit then ExitLoop
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
        GUIDelete()
        
Func GetDir()
    $DirInput = FileSelectFolder("Where to Create your files?", "")
    GUICtrlSetData($TxtDir, $DirInput) ;Needed a function here to make getting the dir selected a bit easier
EndFunc
        
Func Createfile()
    $dir = GUICtrlRead($TxtDir)
    $file = GUICtrlRead($TxtFile)
    FileWrite($dir & '\' & $file,"")
    if @error then MsgBox(0, "Failure", "Something went wrong, make sure the file is entered and the directory has been created") 
        ;this msg doesnt show, need a better error detection method
    EndFunc 
    ;didnt see the need for a confirmation msg to say that the file was created 
    ;as that would cause a small loss of time
    ;so long as the above error doesnt show, the user is free to make as many files as needed

Func CreateDir()
    $dir = GUICtrlRead($TxtDir)
    DirCreate($dir)
    if not @error then MsgBox(0, "Success", "Dir created")
EndFunc

edit: once its fixed and polished, ill publish it and post a link here :)

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites



$BtnCreateFile=GUICtrlCreateButton("Create", 10, 80, 50, 20, 0x0001)

Also if you are open to criticism; put some error handling in there. Look at your GetDir() function: What's going to happen if I click Cancel on the FileSelectFolder() dialog?


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

probably because that menu doesn't have anywhere near all the file types in it.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

probably because that menu doesn't have anywhere near all the file types in it.

You are prompted for a name and you can type every extention that you want.

Just select a word ducement and overtype the standart name by "test.txt".

See what happens.

And you can add models for whatever filetypes you have.

My *.txt is empty and my *.au3 has my standard au3 header.


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

I'm aware of that but it may not be as simple as

$sName = "test"
$sExt= ".pgm"
For $i = 1 To 4
    FileWrite($sName & $i & $sExt, "")
Next

Even though I usually use the context menu method myself.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Why don't use context menu item "NEW" in Explorer?

because thats slower than using my program, more clicks = more time wasted

second, you can't make anywhere near as many file types with that than what you can with mine, my program gives infinite functionality, no matter what file type you need

third, yes you can rename the txt files you create with new to create almost any filetype but again its SLOW, AND lets not forget the potential file corruption that does occur from that from time to time

the NEW context would be used mainly for if your only making a few files, but if you are mass file creating for a big project then NEW kinda makes the whole file making process slow

i forgot to mention that this also doubles as a mass directory maker, why use NEW when you can create a directory containing say 5-10 consecutivefolders eg: folder1\subfolder\childfolder\sibling\ (took me 5 seconds to write that whereas with NEW that would have taken a good 2 mins

of course everyone has their uses for stuff but for me NEW context is time wasting , and i generally dont get much time to go on the computer

$BtnCreateFile=GUICtrlCreateButton("Create", 10, 80, 50, 20, 0x0001)

that doesnt seem to do anything in terms of keypresses, i once saw a keypress command but i cant find it, maybe that was AHK...

Also if you are open to criticism; put some error handling in there. Look at your GetDir() function: What's going to happen if I click Cancel on the FileSelectFolder() dialog?

Thanks for the feedback GEOSoft :), heres the fix:

Func GetDir()
    $DirLast = GUICtrlRead($TxtDir)
    $DirInput = FileSelectFolder("Where to Create your files?", "")
    If $DirInput = "" then GUICtrlSetData($DirInput, $DirLast)
    If $DirInput <> "" then GUICtrlSetData($TxtDir, $DirInput)
EndFunc

is there a way to check if theres anything inside a directory containing files of 0 bytes for my CreateDir function?

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I would have handled that a bit differently

Func GetDir()
    $DirLast = GUICtrlRead($TxtDir)
    $DirInput = FileSelectFolder("Where to Create your files?", "")
    If @Error OR $DirInput = "" then
        GUICtrlSetData($DirInput, $DirLast)
    Else    
        GUICtrlSetData($TxtDir, $DirInput)
    EndIf
EndFunc

Also you might want to check the control styles in the help file. I'm going from memory when I say 0x0001 is the style for default button.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Thanks GEOSoft, ill have a look later, just having a quick look at replies before i go to work :)


Intermediate AutoIt/Autohotkey User

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  
Followers 0