Jump to content

FileSaveDialog


Recommended Posts

Ok. I need to know how to actually save a file when you type in an input box. and than later retreiving the file as a text. heres what i got so far...

-the problem that im having is that it is not actually saving, can anybody help me?

#include <GuiConstants.au3>

GuiCreate("My Shortcuts", 381, 222,-1, -1,  )


$filemenu = GUICtrlCreateMenu ("&File")
$fileitem = GUICtrlCreateMenuitem ("&Open...",$filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$recentfilesmenu = GUICtrlCreateMenu ("&Recent Files",$filemenu,1)
$recentsavedsmenu = GUICtrlCreateMenu ("&Recent Saved Files",$filemenu,1)
$separator1 = GUICtrlCreateMenuitem ("",$filemenu,3)
$Fileexit = GUICtrlCreateMenuitem ("&Exit    Alt+F4",$filemenu)

$viewmenu = GUICtrlCreateMenu("&View")
$view = GUICtrlCreateMenuitem("&Veiw Hotkeys", $viewmenu)
GUICtrlSetState(-1,$GUI_UNCHECKED)

$Aboutmenu = GUICtrlCreateMenu ("Help")
$About = GUICtrlCreateMenuitem("About Shortcut", $Aboutmenu)

$Group_1 = GuiCtrlCreateGroup("Shortcut List:", 20, 20, 340, 160)
$Label_2 = GuiCtrlCreateLabel("Log In Google", 40, 60, 100, 20)
$Label_3 = GuiCtrlCreateLabel("Log In Myspace", 40, 90, 100, 20)
$Label_4 = GuiCtrlCreateLabel("Ctrl + Shift + M", 270, 90, 80, 20)
GUICtrlSetState(-1,$GUI_HIDE)
$Label_5 = GuiCtrlCreateLabel("Log In Angelfire", 40, 120, 100, 20)
$Label_6 = GuiCtrlCreateLabel("Ctrl + Shift + B", 270, 60, 70, 20)
GUICtrlSetState(-1,$GUI_HIDE)
$Label_7 = GuiCtrlCreateLabel("Ctrl + Shift + A", 270, 120, 80, 20)
GUICtrlSetState(-1,$GUI_HIDE)
$Button_8 = GuiCtrlCreateButton("Close", 40, 150, 50, 20)
$input_1 = GUICtrlCreateInput("",100,150,175,20)
$note = GUICtrlGetState($input_1)
$button_9 = GUICtrlCreateButton("Save Note", 280,150,70,20)
GuiSetState()


While 1
    
    $msg = GuiGetMsg()
    If $msg = $button_9 Then
        $bob = FileSaveDialog( "Choose a name...", @HomeDrive, "Text (*.ini;*.txt)", 2, "note.txt")
        Msgbox(0, "Selected listbox entry", GUICtrlRead($input_1))
        If @error <> 1 Then GUICtrlCreateMenuitem ($bob,$recentsavedsmenu)
    EndIf 
    
    
    If $msg = $fileitem Then
        $file = FileOpenDialog("Choose file...",@HomeDrive,"All (*.*)|Images (*.JPG;*.bmp)|Videos (*.avi;*.mpg)", 1+4)
        If @error <> 1 Then GUICtrlCreateMenuitem ($file,$recentfilesmenu)
    EndIf 
    
    If $msg = $GUI_EVENT_CLOSE Or $msg = $Button_8 Or $msg = $Fileexit Then 
        ExitLoop
        EndIf
    If $msg = $GUI_EVENT_CLOSE Or $msg = $Button_8 Or $msg = $Fileexit Then 
        ExitLoop
    EndIf
    If $msg = $view Then
        If BitAnd(GUICtrlRead($view),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($view,$GUI_UNCHECKED)
            GUICtrlSetState($Label_4,$GUI_HIDE)
            GUICtrlSetState($Label_6,$GUI_HIDE)
            GUICtrlSetState($Label_7,$GUI_HIDE)
        Else
            GUICtrlSetState($view,$GUI_CHECKED)
            GUICtrlSetState($label_4,$GUI_SHOW)
            GUICtrlSetState($label_6,$GUI_SHOW)
            GUICtrlSetState($label_7,$GUI_SHOW)
        EndIf
    EndIf
    

WEnd
Exit

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

If $msg = $button_9 Then
        $bob = FileSaveDialog( "Choose a name...", @HomeDrive, "Text (*.ini;*.txt)", 2, "note.txt")
        If Not @error Then 
            GUICtrlCreateMenuitem ($bob,$recentsavedsmenu)
;~          Msgbox(0, "Selected listbox entry", GUICtrlRead($input_1))
            FileDelete($bob)
            FileWrite($bob, GUICtrlRead($input_1))
        EndIf
 EndIf

Edited by Zedna
Link to comment
Share on other sites

Ok, now i have another one. now that i can save it. how can i open the file and see the text in an guictlcreatedit?

heres what i got

If $i= $open Then
        $openfile = FileOpenDialog("Choose file...",@HomeDrive,"Text (*.ini;*.txt)", 1+4)
        If @error <> 1 Then 
            FileOpen ($openfile, 0)
            $read = FileRead ($openfile, 1)

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

Ok, now i have another one. now that i can save it. how can i open the file and see the text in an guictlcreatedit?

heres what i got

If $i= $open Then
        $openfile = FileOpenDialog("Choose file...",@HomeDrive,"Text (*.ini;*.txt)", 1+4)
        If @error <> 1 Then 
            FileOpen ($openfile, 0)
            $read = FileRead ($openfile, 1)
GUICtrlSetData ($edit, $read)
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...