Jump to content

Save As


sw00n
 Share

Recommended Posts

Before i go on to ask this question, yes i am a noob to AutoiT :]

I have 2 menus so far...

1 with 3 options the other with 2 options.

The First menu has a open, save as, and exit option.

I would like the "users", to enter a text then after done be able to save it as either .shader or .txt to a location/directory of their choice, and the open option to open either a .shader or .txt.

And last the Exit to exit the program completely.

Source i have so far:

#Include <GUIConstantsEx.au3>

#Include <INet.au3>

#Include <GuiButton.au3>

#Include <GuiToolBar.au3>

#InClude <StaticConstants.au3>

GuiCreate("1up Shader Maker.v1",493,210,269,216)

$input1 = GuiCtrlCreateInput(" ",7,39,150,20)

$label1 = GuiCtrlCreateLabel("Enter Your Texture Path below",6,17,250,15)

$menu1 = GUICtrlCreateMenu("File")

$open = GUICtrlCreateMenuItem("Open",$menu1)

$save = GUICtrlCreateMenuItem("Save As",$menu1)

$exit = GUICtrlCreateMenuItem("Exit",$menu1)

$help1 = GUICtrlCreateMenu("Help")

$help = GUICtrlCreateMenuItem("Help",$help1)

GuiSetState()

While 1

$msg=GuiGetMsg()

If $msg=-3 Then Exit

Wend

Link to comment
Share on other sites

bump tried this but still cant get it to work...

#Include <GUIConstantsEx.au3>
#Include <INet.au3>
#Include <GuiButton.au3>
#Include <GuiToolBar.au3>
#InClude <StaticConstants.au3>

GuiCreate("1up Shader Maker.v1",500,210,269,216)
$input1 = GuiCtrlCreateInput(" ",7,39,150,20)
$label1 = GuiCtrlCreateLabel("Enter Your Texture Path below",6,17,250,15)
$menu1 = GUICtrlCreateMenu("File")
$open = GUICtrlCreateMenuItem("Open",$menu1)
$save = GUICtrlCreateMenuItem("Save As",$menu1)
$exit = GUICtrlCreateMenuItem("Exit",$menu1)
$help1 = GUICtrlCreateMenu("Help")
$help = GUICtrlCreateMenuItem("Help",$help1)
$edit = GUICtrlCreateEdit("",200,10,270,150)
GuiSetState(@sw_show)



While 1
$msg=GuiGetMsg()
If $msg=-3 Then Exit
if $msg=$exit then exit1()
if $msg=$help then help()
if $msg=$open then open1()
Wend

func help()
    msgbox(0, "", "Enter the path or your texture, default is: textures/name here/name here")
EndFunc

func exit1()
    msgbox(0, "Exiting", "Now Exiting...")
    Exit
EndFunc

func open1()
    $message = ("Choose a .shader to open, if needed")
    $var = FileOpenDialog($message, @DesktopCommonDir & "\","List (*.txt")
    $file = $fileread($var)
if @error Then
        MsgBox(0, "", "No File(s) were selected")
    Else
Guictrlsetdata($open, $file)
Endif
EndFunc

$Save = FileSaveDialog("Save Active Proxies",@DesktopDir,"Text Files (.shader)|All Files (*.*)",18,"YourSaveListName.shader") $xFile = FileOpen($Save,8+2)

FileWrite($xFile,GuiCtrlRead($ Input1))

Link to comment
Share on other sites

  • Moderators

sw00n,

Please do not bump your posts within 24 hours. :graduated:

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. Like this! :(

I have made a few changes to your script. It was working quite well - the biggest problem was that you were reusing the $save variable which gave you problems in your GUIGetMsg loop. You might like to look at the first part of the Variables - using Global, Local and ByRef tutorial in the Wiki to see how you can reuse the same names - although I would only do so for simple temporary variables, not ControlIDs. :D

Here is the amended code:

#include <GUIConstantsEx.au3>
#include <INet.au3>
#include <GuiButton.au3>
#include <GuiToolBar.au3>
#include <StaticConstants.au3>

GUICreate("1up Shader Maker.v1", 500, 210, 269, 216)
$input1 = GUICtrlCreateInput("", 7, 39, 150, 20)
$label1 = GUICtrlCreateLabel("Enter Your Texture Path below", 6, 17, 250, 15)
$menu1 = GUICtrlCreateMenu("File")
$open = GUICtrlCreateMenuItem("Open", $menu1)
$save = GUICtrlCreateMenuItem("Save As", $menu1)
$exit = GUICtrlCreateMenuItem("Exit", $menu1)
$help1 = GUICtrlCreateMenu("Help")
$help = GUICtrlCreateMenuItem("Help", $help1)
$edit = GUICtrlCreateEdit("", 200, 10, 270, 150)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $exit
            exit1()
        Case $help
            help()
        Case $open
            open1()
        Case $save
            save()
    EndSwitch
WEnd

Func help()
    MsgBox(0, "", "Enter the path or your texture, default is: textures/name here/name here")
EndFunc   ;==>help

Func exit1()
    MsgBox(0, "Exiting", "Now Exiting...")
    Exit
EndFunc   ;==>exit1

Func open1()
    $message = ("Choose a .shader to open, if needed")
    $var = FileOpenDialog($message, @ScriptDir & "\", "List (*.shader)")
    $file = FileRead($var)
    If @error Then
        MsgBox(0, "", "No File(s) were selected")
    Else
        GUICtrlSetData($edit, $file)
    EndIf
EndFunc   ;==>open1

Func save()

    $file = FileSaveDialog("Save Active Proxies", @ScriptDir, "Text Files (.shader)|All Files (*.*)", 18, "YourSaveListName.shader")
    $xFile = FileOpen($file, 8 + 2)
    FileWrite($xFile, GUICtrlRead($Input1))

EndFunc

Please ask if you have any questions - but do not expect an answer too quickly! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

First, organize your script with all the function declarations at the bottom. Then you can see that your FileSaveDialog() and FileWrite() never get executed because the only way out of the GuiGetMsg() loop is to exit the script.

:graduated:

Edit: Well, rats. Melba23 beat me to it.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • Moderators

PsaltyDS,

Just do not PM me to complain! :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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