Sign in to follow this  
Followers 0
Golbez

help me please?

25 posts in this topic

can someone point me in the way of how to make it to when i save the inputted number.. then when i open the file it will set the number into the input box..

also i would like to know how to make it so the inputed number can only be a number or letter..

another thing i would like is so that the inputed number will be saved as the file name.

This is my attempt:

#include <GUIConstants.au3>
#NoTrayIcon

Global $defaultstatus = "Ready", $numinput, $status, $readnum

$MainWindow = GUICreate("# = Save Name", 200, 100, -1, -1)
    $numspot = GUICtrlCreateGroup("Special Number", 8, 0, 147, 49)
        $numinput = GUICtrlCreateInput("", 24, 16, 123, 21)
        GUICtrlCreateGroup("", -99, -99, 1, 1)    
    $statuslabel = GUICtrlCreateLabel ($defaultstatus,1,58,198,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

    $filemenu = GUICtrlCreateMenu ("&File")
        $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
            GUICtrlSetState(-1,$GUI_DEFBUTTON)
        $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)
        $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2)
        $saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
            GUICtrlSetState(-1,$GUI_DISABLE)
        $saveasitem = GUICtrlCreateMenuitem ("Save As",$filemenu)    
        $separator2 = GUICtrlCreateMenuitem ("",$filemenu,5)
        $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
    
    $helpmenu = GUICtrlCreateMenu ("Help")
        $infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)

    $viewmenu = GUICtrlCreateMenu("View",-1,1)
        $viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
            GUICtrlSetState(-1,$GUI_CHECKED)
        $readonlyitem = GUICtrlCreateMenuitem ("Read Only",$viewmenu)
            GUICtrlSetState(-1,$GUI_UNCHECKED)

GUISetState ()
While 1
    $msg = GUIGetMsg()

    If $msg = $fileitem Then
        $file = FileOpenDialog("Choose file...",@ScriptDir & "\Test","Text files (*.txt)|Configeration Files (*.ini)|All (*.*))")
        If @error <> 1 Then 
            _load($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
    ElseIf $msg = $saveasitem Then
        $file = FileSaveDialog( "Choose a name.",@ScriptDir & "\Test","Text files (*.txt)|Configeration Files (*.ini)|All (*.*)",0, $numinput)
        If @error <> 1 Then 
            _save($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
        
    ElseIf $msg = $saveitem Then
        _save($file)
        GUICtrlCreateMenuitem ($file,$recentfilesmenu)
    Endif

    If $msg = $viewstatusitem Then
        If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
            GUICtrlSetState($statuslabel,$GUI_HIDE)
        Else
            GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
            GUICtrlSetState($statuslabel,$GUI_SHOW)
        EndIf
    EndIf
    If $msg = $readonlyitem Then
        If BitAnd(GUICtrlRead($readonlyitem ),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($readonlyitem,$GUI_UNCHECKED)
            GUICtrlSetState($numinput,$GUI_ENABLE)
        Else
            _disable()
        EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then Exit
    If $msg = $infoitem Then About()
WEnd
Func _save($file)
    IniWrite($file & ".ini", "Special Number", "Special Number", $numinput)
EndFunc
Func _load($file)
    $readnum = IniRead($file & ".ini", "Special Number", "Special Number","")
    MsgBox(1,"test", $readnum)
    GUICtrlSetData($numinput, $readnum)
    _disable()
EndFunc    
Func About()
    Msgbox(0,"Info","Only a test...")
EndFunc
Func _disable()
    GUICtrlSetState($readonlyitem,$GUI_CHECKED)
    GUICtrlSetState($numinput,$GUI_DISABLE)
EndFunc

Share this post


Link to post
Share on other sites



can someone point me in the way of how to make it to when i save the inputted number.. then when i open the file it will set the number into the input box..

also i would like to know how to make it so the inputed number can only be a number or letter..

another thing i would like is so that the inputed number will be saved as the file name.

This is my attempt:

#include <GUIConstants.au3>
#NoTrayIcon

Global $defaultstatus = "Ready", $numinput, $status, $readnum

$MainWindow = GUICreate("# = Save Name", 200, 100, -1, -1)
    $numspot = GUICtrlCreateGroup("Special Number", 8, 0, 147, 49)
        $numinput = GUICtrlCreateInput("", 24, 16, 123, 21)
        GUICtrlCreateGroup("", -99, -99, 1, 1)    
    $statuslabel = GUICtrlCreateLabel ($defaultstatus,1,58,198,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

    $filemenu = GUICtrlCreateMenu ("&File")
        $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
            GUICtrlSetState(-1,$GUI_DEFBUTTON)
        $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)
        $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2)
        $saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
            GUICtrlSetState(-1,$GUI_DISABLE)
        $saveasitem = GUICtrlCreateMenuitem ("Save As",$filemenu)    
        $separator2 = GUICtrlCreateMenuitem ("",$filemenu,5)
        $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
    
    $helpmenu = GUICtrlCreateMenu ("Help")
        $infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)

    $viewmenu = GUICtrlCreateMenu("View",-1,1)
        $viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
            GUICtrlSetState(-1,$GUI_CHECKED)
        $readonlyitem = GUICtrlCreateMenuitem ("Read Only",$viewmenu)
            GUICtrlSetState(-1,$GUI_UNCHECKED)

GUISetState ()
While 1
    $msg = GUIGetMsg()

    If $msg = $fileitem Then
        $file = FileOpenDialog("Choose file...",@ScriptDir & "\Test","Text files (*.txt)|Configeration Files (*.ini)|All (*.*))")
        If @error <> 1 Then 
            _load($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
    ElseIf $msg = $saveasitem Then
        $file = FileSaveDialog( "Choose a name.",@ScriptDir & "\Test","Text files (*.txt)|Configeration Files (*.ini)|All (*.*)",0, $numinput)
        If @error <> 1 Then 
            _save($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
        
    ElseIf $msg = $saveitem Then
        _save($file)
        GUICtrlCreateMenuitem ($file,$recentfilesmenu)
    Endif

    If $msg = $viewstatusitem Then
        If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
            GUICtrlSetState($statuslabel,$GUI_HIDE)
        Else
            GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
            GUICtrlSetState($statuslabel,$GUI_SHOW)
        EndIf
    EndIf
    If $msg = $readonlyitem Then
        If BitAnd(GUICtrlRead($readonlyitem ),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($readonlyitem,$GUI_UNCHECKED)
            GUICtrlSetState($numinput,$GUI_ENABLE)
        Else
            _disable()
        EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then Exit
    If $msg = $infoitem Then About()
WEnd
Func _save($file)
    IniWrite($file & ".ini", "Special Number", "Special Number", $numinput)
EndFunc
Func _load($file)
    $readnum = IniRead($file & ".ini", "Special Number", "Special Number","")
    MsgBox(1,"test", $readnum)
    GUICtrlSetData($numinput, $readnum)
    _disable()
EndFunc    
Func About()
    Msgbox(0,"Info","Only a test...")
EndFunc
Func _disable()
    GUICtrlSetState($readonlyitem,$GUI_CHECKED)
    GUICtrlSetState($numinput,$GUI_DISABLE)
EndFunc
For numbers only in the input use style $ES_NUMBER.

To read the value in the input use GuiCtrlRead($numinout). $numinout is th eID of the control not the contents.

Write the value to an ini file with IniWrite, thne when th escript starts use IniRead to read the value and use GuiCtrlSetData($numinput,$value)


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

GUICtrlSetData($numinput, $readnum)

i did use that

thank you for the number thing :)

Edited by Golbez

Share this post


Link to post
Share on other sites

GUICtrlSetData($numinput, $readnum)

i did use that

True, I wasn't paying attention, (I'm watching Germany playing Spain), but you didn't use GuiCtrlRead here though

$file = FileSaveDialog( "Choose a name.",@ScriptDir & "\Test","Text files (*.txt)|Configeration Files (*.ini)|All (*.*)",0, $numinput)

thank you for the number thing :)

That's OK.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

ok updated script...

i cant get it to load the information out of the file then display it into the window..

i cant figure out why.... the ini read is right

#include <GUIConstants.au3>
#NoTrayIcon

Global $defaultstatus = "Ready", $numinput, $status, $readnum

$MainWindow = GUICreate("# = Save Name", 200, 100, -1, -1)
    $numspot = GUICtrlCreateGroup("Special Number", 8, 0, 147, 49)
        $numinput = GUICtrlCreateInput("", 24, 16, 123, 21,$ES_NUMBER)
        GUICtrlCreateGroup("", -99, -99, 1, 1)    
    $statuslabel = GUICtrlCreateLabel ($defaultstatus,1,58,198,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

    $filemenu = GUICtrlCreateMenu ("&File")
        $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
            GUICtrlSetState(-1,$GUI_DEFBUTTON)
        $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)
        $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2)
        $saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
            GUICtrlSetState(-1,$GUI_DISABLE)
        $saveasitem = GUICtrlCreateMenuitem ("Save As",$filemenu)    
        $separator2 = GUICtrlCreateMenuitem ("",$filemenu,5)
        $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
    
    $helpmenu = GUICtrlCreateMenu ("Help")
        $infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)

    $viewmenu = GUICtrlCreateMenu("View",-1,1)
        $viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
            GUICtrlSetState(-1,$GUI_CHECKED)
        $readonlyitem = GUICtrlCreateMenuitem ("Read Only",$viewmenu)
            GUICtrlSetState(-1,$GUI_UNCHECKED)

GUISetState ()
While 1
    $msg = GUIGetMsg()

    If $msg = $fileitem Then
        $file = FileOpenDialog("Choose file...",@ScriptDir & "\Test","Configeration Files (*.ini)|Text files (*.txt)|All (*.*))")
        If @error <> 1 Then 
            _load($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
    ElseIf $msg = $saveasitem Then
        $file = FileSaveDialog( "Choose a name.",@ScriptDir & "\Test","Text files (*.txt)|Configeration Files (*.ini)|All (*.*)",0, GUICtrlRead($numinput))
        If @error <> 1 Then 
            _save($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
        
    ElseIf $msg = $saveitem Then
        _save($file)
        GUICtrlCreateMenuitem ($file,$recentfilesmenu)
    Endif

    If $msg = $viewstatusitem Then
        If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
            GUICtrlSetState($statuslabel,$GUI_HIDE)
        Else
            GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
            GUICtrlSetState($statuslabel,$GUI_SHOW)
        EndIf
    EndIf
    If $msg = $readonlyitem Then
        If BitAnd(GUICtrlRead($readonlyitem ),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($readonlyitem,$GUI_UNCHECKED)
            GUICtrlSetState($numinput,$GUI_ENABLE)
        Else
            _disable()
        EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then Exit
    If $msg = $infoitem Then About()
WEnd
Func _save($file)
    IniWrite($file & ".ini", "Special Number", "Special Number", GUICtrlRead($numinput))
EndFunc
Func _load($file)
    $readnum = IniRead($file & ".ini", "Special Number", "Special Number","")
    MsgBox(1,"test", $readnum)
    GUICtrlSetData($numinput, $readnum)
    _disable()
EndFunc    
Func About()
    Msgbox(0,"Info","Only a test...")
EndFunc
Func _disable()
    GUICtrlSetState($readonlyitem,$GUI_CHECKED)
    GUICtrlSetState($numinput,$GUI_DISABLE)
EndFunc

Share this post


Link to post
Share on other sites

ok updated script...

i cant get it to load the information out of the file then display it into the window..

i cant figure out why.... the ini read is right

#include <GUIConstants.au3>
#NoTrayIcon

Global $defaultstatus = "Ready", $numinput, $status, $readnum

$MainWindow = GUICreate("# = Save Name", 200, 100, -1, -1)
    $numspot = GUICtrlCreateGroup("Special Number", 8, 0, 147, 49)
        $numinput = GUICtrlCreateInput("", 24, 16, 123, 21,$ES_NUMBER)
        GUICtrlCreateGroup("", -99, -99, 1, 1)    
    $statuslabel = GUICtrlCreateLabel ($defaultstatus,1,58,198,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

    $filemenu = GUICtrlCreateMenu ("&File")
        $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
            GUICtrlSetState(-1,$GUI_DEFBUTTON)
        $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)
        $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2)
        $saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
            GUICtrlSetState(-1,$GUI_DISABLE)
        $saveasitem = GUICtrlCreateMenuitem ("Save As",$filemenu)    
        $separator2 = GUICtrlCreateMenuitem ("",$filemenu,5)
        $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
    
    $helpmenu = GUICtrlCreateMenu ("Help")
        $infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)

    $viewmenu = GUICtrlCreateMenu("View",-1,1)
        $viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
            GUICtrlSetState(-1,$GUI_CHECKED)
        $readonlyitem = GUICtrlCreateMenuitem ("Read Only",$viewmenu)
            GUICtrlSetState(-1,$GUI_UNCHECKED)

GUISetState ()
While 1
    $msg = GUIGetMsg()

    If $msg = $fileitem Then
        $file = FileOpenDialog("Choose file...",@ScriptDir & "\Test","Configeration Files (*.ini)|Text files (*.txt)|All (*.*))")
        If @error <> 1 Then 
            _load($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
    ElseIf $msg = $saveasitem Then
        $file = FileSaveDialog( "Choose a name.",@ScriptDir & "\Test","Text files (*.txt)|Configeration Files (*.ini)|All (*.*)",0, GUICtrlRead($numinput))
        If @error <> 1 Then 
            _save($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
        
    ElseIf $msg = $saveitem Then
        _save($file)
        GUICtrlCreateMenuitem ($file,$recentfilesmenu)
    Endif

    If $msg = $viewstatusitem Then
        If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
            GUICtrlSetState($statuslabel,$GUI_HIDE)
        Else
            GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
            GUICtrlSetState($statuslabel,$GUI_SHOW)
        EndIf
    EndIf
    If $msg = $readonlyitem Then
        If BitAnd(GUICtrlRead($readonlyitem ),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($readonlyitem,$GUI_UNCHECKED)
            GUICtrlSetState($numinput,$GUI_ENABLE)
        Else
            _disable()
        EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then Exit
    If $msg = $infoitem Then About()
WEnd
Func _save($file)
    IniWrite($file & ".ini", "Special Number", "Special Number", GUICtrlRead($numinput))
EndFunc
Func _load($file)
    $readnum = IniRead($file & ".ini", "Special Number", "Special Number","")
    MsgBox(1,"test", $readnum)
    GUICtrlSetData($numinput, $readnum)
    _disable()
EndFunc    
Func About()
    Msgbox(0,"Info","Only a test...")
EndFunc
Func _disable()
    GUICtrlSetState($readonlyitem,$GUI_CHECKED)
    GUICtrlSetState($numinput,$GUI_DISABLE)
EndFunc

#include <GUIConstants.au3>
#include <editconstants.au3>
#include <staticconstants.au3>

#NoTrayIcon

Global $defaultstatus = "Ready", $numinput, $status, $readnum

$MainWindow = GUICreate("# = Save Name", 200, 100, -1, -1)
    $numspot = GUICtrlCreateGroup("Special Number", 8, 0, 147, 49)
        $numinput = GUICtrlCreateInput("", 24, 16, 123, 21,$ES_NUMBER)
        GUICtrlCreateGroup("", -99, -99, 1, 1)   
    $statuslabel = GUICtrlCreateLabel ($defaultstatus,1,58,198,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

    $filemenu = GUICtrlCreateMenu ("&File")
        $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
            GUICtrlSetState(-1,$GUI_DEFBUTTON)
        $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)
        $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2)
        $saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
           ;GUICtrlSetState(-1,$GUI_DISABLE)
        $saveasitem = GUICtrlCreateMenuitem ("Save As",$filemenu)   
        $separator2 = GUICtrlCreateMenuitem ("",$filemenu,5)
        $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
   
    $helpmenu = GUICtrlCreateMenu ("Help")
        $infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)

    $viewmenu = GUICtrlCreateMenu("View",-1,1)
        $viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
            GUICtrlSetState(-1,$GUI_CHECKED)
        $readonlyitem = GUICtrlCreateMenuitem ("Read Only",$viewmenu)
            GUICtrlSetState(-1,$GUI_UNCHECKED)

GUISetState ()
While 1
    $msg = GUIGetMsg()

    If $msg = $fileitem Then
        $file = FileOpenDialog("Choose file...",@ScriptDir & "\Test","Configeration Files (*.ini)|Text files (*.txt)|All (*.*))")
        If @error <> 1 Then
            _load($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)   
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
    ElseIf $msg = $saveasitem Then
        $file = FileSaveDialog( "Choose a name.",@ScriptDir & "\Test","Text files (*.txt)|Configeration Files (*.ini)|All (*.*)",0, GUICtrlRead($numinput))
        If @error <> 1 Then
            _save($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)   
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
       
   ElseIf $msg = $saveitem Then
       $file = GUICtrlRead($numinput)
        _save($file)
        GUICtrlCreateMenuitem ($file,$recentfilesmenu)
    Endif

    If $msg = $viewstatusitem Then
        If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
            GUICtrlSetState($statuslabel,$GUI_HIDE)
        Else
            GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
            GUICtrlSetState($statuslabel,$GUI_SHOW)
        EndIf
    EndIf
    If $msg = $readonlyitem Then
        If BitAnd(GUICtrlRead($readonlyitem ),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($readonlyitem,$GUI_UNCHECKED)
            GUICtrlSetState($numinput,$GUI_ENABLE)
        Else
            _disable()
        EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then Exit
    If $msg = $infoitem Then About()
WEnd
Func _save($file)
    IniWrite($file & ".ini", "Special Number", "Special Number", GUICtrlRead($numinput))
EndFunc
Func _load($file)
    $readnum = IniRead($file, "Special Number", "Special Number","")
    MsgBox(1,"test", $readnum)
    GUICtrlSetData($numinput, $readnum)
    _disable()
EndFunc   
Func About()
    Msgbox(0,"Info","Only a test...")
EndFunc
Func _disable()
    GUICtrlSetState($readonlyitem,$GUI_CHECKED)
    GUICtrlSetState($numinput,$GUI_DISABLE)
EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

did you just add the

#include <GUIConstants.au3>

#include <editconstants.au3>

#include <staticconstants.au3>

?

edit:1

never mind i see what you did :)

ty :P

edit:2

ok so i lied i dont see everything you did xD can you give me a list so i can learn :P

edit3:

ok so i missed that you took out the & ".ini" part :D

Edited by Golbez

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Try removing ".ini" in this func

Func _load($file)
    $readnum = IniRead($file, "Special Number", "Special Number","not found")
    MsgBox(1,"test", $readnum)
    GUICtrlSetData($numinput, $readnum)
    _disable()
EndFunc

I see you've already found it

Edited by picaxe

Share this post


Link to post
Share on other sites

another problem i sound and i have no clue how to fix...

when someone gos to save it with save as for a second time the program will make a new file with ini.ini

how would i fix this?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

IniWrite adds ".ini" automatically, remove '& ".ini" in your _save func.

#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>

#NoTrayIcon

Global $defaultstatus = "Ready", $numinput, $status, $readnum

$MainWindow = GUICreate("# = Save Name", 200, 100, -1, -1)
    $numspot = GUICtrlCreateGroup("Special Number", 8, 0, 147, 49)
        $numinput = GUICtrlCreateInput("", 24, 16, 123, 21,$ES_NUMBER)
        GUICtrlCreateGroup("", -99, -99, 1, 1)    
    $statuslabel = GUICtrlCreateLabel ($defaultstatus,1,58,198,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

    $filemenu = GUICtrlCreateMenu ("&File")
        $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
            GUICtrlSetState(-1,$GUI_DEFBUTTON)
        $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)
        $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2)
        $saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
            GUICtrlSetState(-1,$GUI_DISABLE)
        $saveasitem = GUICtrlCreateMenuitem ("Save As",$filemenu)    
        $separator2 = GUICtrlCreateMenuitem ("",$filemenu,5)
        $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
    
    $helpmenu = GUICtrlCreateMenu ("Help")
        $infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)

    $viewmenu = GUICtrlCreateMenu("View",-1,1)
        $viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
            GUICtrlSetState(-1,$GUI_CHECKED)
        $readonlyitem = GUICtrlCreateMenuitem ("Read Only",$viewmenu)
            GUICtrlSetState(-1,$GUI_UNCHECKED)

GUISetState ()
While 1
    $msg = GUIGetMsg()

    If $msg = $fileitem Then
        $file = FileOpenDialog("Choose file...",@ScriptDir & "\Test","Configeration Files (*.ini)|Text files (*.txt)|All (*.*))")
        If @error <> 1 Then 
            _load($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
    ElseIf $msg = $saveasitem Then
        $file = FileSaveDialog( "Choose a name.",@ScriptDir & "\Test","Text files (*.txt)|Configeration Files (*.ini)|All (*.*)",0, GUICtrlRead($numinput))
        If @error <> 1 Then 
            _save($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
        
    ElseIf $msg = $saveitem Then
        _save($file)
        GUICtrlCreateMenuitem ($file,$recentfilesmenu)
    Endif

    If $msg = $viewstatusitem Then
        If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
            GUICtrlSetState($statuslabel,$GUI_HIDE)
        Else
            GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
            GUICtrlSetState($statuslabel,$GUI_SHOW)
        EndIf
    EndIf
    If $msg = $readonlyitem Then
        If BitAnd(GUICtrlRead($readonlyitem ),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($readonlyitem,$GUI_UNCHECKED)
            GUICtrlSetState($numinput,$GUI_ENABLE)
        Else
            _disable()
        EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then Exit
    If $msg = $infoitem Then About()
WEnd
Func _save($file)
    IniWrite($file, "Special Number", "Special Number", GUICtrlRead($numinput))
EndFunc
Func _load($file)
    $readnum = IniRead($file, "Special Number", "Special Number","not found")
    MsgBox(1,"test", $readnum)
    GUICtrlSetData($numinput, $readnum)
    _disable()
EndFunc    
Func About()
    Msgbox(0,"Info","Only a test...")
EndFunc
Func _disable()
    GUICtrlSetState($readonlyitem,$GUI_CHECKED)
    GUICtrlSetState($numinput,$GUI_DISABLE)
EndFunc
Edited by picaxe

Share this post


Link to post
Share on other sites

yes i know but if it is not there then it will not add the .ini at all

Share this post


Link to post
Share on other sites

Works for me using this ini file

[Special Number]
Special Number=94357

Share this post


Link to post
Share on other sites

try to save it again with save as

Share this post


Link to post
Share on other sites

Ok try this

#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>

#NoTrayIcon

Global $defaultstatus = "Ready", $numinput, $status, $readnum

$MainWindow = GUICreate("# = Save Name", 200, 100, -1, -1)
    $numspot = GUICtrlCreateGroup("Special Number", 8, 0, 147, 49)
        $numinput = GUICtrlCreateInput("", 24, 16, 123, 21,$ES_NUMBER)
        GUICtrlCreateGroup("", -99, -99, 1, 1)    
    $statuslabel = GUICtrlCreateLabel ($defaultstatus,1,58,198,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

    $filemenu = GUICtrlCreateMenu ("&File")
        $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
            GUICtrlSetState(-1,$GUI_DEFBUTTON)
        $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)
        $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2)
        $saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
            GUICtrlSetState(-1,$GUI_DISABLE)
        $saveasitem = GUICtrlCreateMenuitem ("Save As",$filemenu)    
        $separator2 = GUICtrlCreateMenuitem ("",$filemenu,5)
        $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
    
    $helpmenu = GUICtrlCreateMenu ("Help")
        $infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)

    $viewmenu = GUICtrlCreateMenu("View",-1,1)
        $viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
            GUICtrlSetState(-1,$GUI_CHECKED)
        $readonlyitem = GUICtrlCreateMenuitem ("Read Only",$viewmenu)
            GUICtrlSetState(-1,$GUI_UNCHECKED)

GUISetState ()
While 1
    $msg = GUIGetMsg()

    If $msg = $fileitem Then
        $file = FileOpenDialog("Choose file...",@ScriptDir & "\Test","Configeration Files (*.ini)|Text files (*.txt)|All (*.*))")
        If @error <> 1 Then 
            _load($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
    ElseIf $msg = $saveasitem Then
        $file = FileSaveDialog( "Choose a name.",@ScriptDir & "\Test","Configeration Files (*.ini)|Text files (*.txt)|All (*.*)",0, GUICtrlRead($numinput))
        If @error <> 1 Then 
            _save($file & ".ini")
            GUICtrlSetState($saveitem, $GUI_ENABLE)    
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
        
    ElseIf $msg = $saveitem Then
        _save($file)
        GUICtrlCreateMenuitem ($file,$recentfilesmenu)
    Endif

    If $msg = $viewstatusitem Then
        If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
            GUICtrlSetState($statuslabel,$GUI_HIDE)
        Else
            GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
            GUICtrlSetState($statuslabel,$GUI_SHOW)
        EndIf
    EndIf
    If $msg = $readonlyitem Then
        If BitAnd(GUICtrlRead($readonlyitem ),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($readonlyitem,$GUI_UNCHECKED)
            GUICtrlSetState($numinput,$GUI_ENABLE)
        Else
            _disable()
        EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then Exit
    If $msg = $infoitem Then About()
WEnd
Func _save($file)
    IniWrite($file, "Special Number", "Special Number", GUICtrlRead($numinput))
EndFunc
Func _load($file)
    $readnum = IniRead($file, "Special Number", "Special Number","not found")
    MsgBox(1,"test", $readnum)
    GUICtrlSetData($numinput, $readnum)
    _disable()
EndFunc    
Func About()
    Msgbox(0,"Info","Only a test...")
EndFunc
Func _disable()
    GUICtrlSetState($readonlyitem,$GUI_CHECKED)
    GUICtrlSetState($numinput,$GUI_DISABLE)
EndFunc

Share this post


Link to post
Share on other sites

Just add another variable to you function call that checks to see if there is "*.ini" if not it adds it, problem solved. :)

Here is the new _save function

Func _save($file, $inifound)
    If $inifound = 0 Then
        $file = $file & ".ini"
    EndIf
    IniWrite($file, "Special Number", "Special Number", GUICtrlRead($numinput))
EndFunc

And here is the way the call should look

_save($file, StringRegExp($file,  "(.*)(\.ini)"))

Share this post


Link to post
Share on other sites

it still does it in yours..

the problem is if the person selects the file it will bring in the full name like... 123.ini

..

other idea.. it might be because i can see the file endings xD

Share this post


Link to post
Share on other sites

check my post it should work for you :)

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

check my post it should work for you :)

it does ty...

i didnt see your post when i posted mine xD

edit...

wait is seems its not working for me now..

did i put it in right?

#include <GUIConstants.au3>
#include <editconstants.au3>
#include <staticconstants.au3>

#NoTrayIcon

Global $defaultstatus = "Ready", $numinput, $status, $readnum

$MainWindow = GUICreate("# = Save Name", 200, 100, -1, -1)
    $numspot = GUICtrlCreateGroup("Special Number", 8, 0, 147, 49)
        $numinput = GUICtrlCreateInput("", 24, 16, 123, 21,$ES_NUMBER)
        GUICtrlCreateGroup("", -99, -99, 1, 1)  
    $statuslabel = GUICtrlCreateLabel ($defaultstatus,1,58,198,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

    $filemenu = GUICtrlCreateMenu ("&File")
        $newitem = GUICtrlCreateMenuitem ("New",$filemenu)
        $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
            GUICtrlSetState(-1,$GUI_DEFBUTTON)
        $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)
        $saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
           GUICtrlSetState(-1,$GUI_DISABLE)
        $saveasitem = GUICtrlCreateMenuitem ("Save As",$filemenu)  
        $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
  
    $helpmenu = GUICtrlCreateMenu ("Help")
        $infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)

    $viewmenu = GUICtrlCreateMenu("View",-1,1)
        $viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
            GUICtrlSetState(-1,$GUI_CHECKED)
        $readonlyitem = GUICtrlCreateMenuitem ("Read Only",$viewmenu)
            GUICtrlSetState(-1,$GUI_UNCHECKED)

GUISetState ()
While 1
    $msg = GUIGetMsg()

    If $msg = $fileitem Then
        $file = FileOpenDialog("Choose file...",@ScriptDir & "\Test","Configeration Files (*.ini)|All (*.*))")
        If @error <> 1 Then
            _load($file)
            GUICtrlSetState($saveitem, $GUI_ENABLE)  
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
    ElseIf $msg = $saveasitem Then
        $file = FileSaveDialog( "Choose a name.",@ScriptDir & "\Test","Configeration Files (*.ini)|All (*.*)",0, GUICtrlRead($numinput))
        If @error <> 1 Then
            _save($file, StringRegExp($file,  "(.*)(\.ini)"))
            GUICtrlSetState($saveitem, $GUI_ENABLE)  
            GUICtrlCreateMenuitem ($file,$recentfilesmenu)
        EndIf
      
   ElseIf $msg = $saveitem Then
       $file = GUICtrlRead($numinput)
        _save($file, StringRegExp($file,  "(.*)(\.ini)"))
        GUICtrlCreateMenuitem ($file,$recentfilesmenu)
    Endif

    If $msg = $viewstatusitem Then
        If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
            GUICtrlSetState($statuslabel,$GUI_HIDE)
        Else
            GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
            GUICtrlSetState($statuslabel,$GUI_SHOW)
        EndIf
    EndIf
    If $msg = $readonlyitem Then
        If BitAnd(GUICtrlRead($readonlyitem ),$GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState($readonlyitem,$GUI_UNCHECKED)
            GUICtrlSetState($numinput,$GUI_ENABLE)
        Else
            _disable()
        EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then Exit
    If $msg = $infoitem Then About()
WEnd
Func _save($file, $inifound)
    If $inifound = 0 Then
        $file = $file & ".ini"
    EndIf
    IniWrite($file, "Special Number", "Special Number", GUICtrlRead($numinput))
EndFunc
Func _load($file)
    $readnum = IniRead($file, "Special Number", "Special Number","Error reading.")
    MsgBox(1,"test", $readnum)
    GUICtrlSetData($numinput, $readnum)
    _disable()
EndFunc  
Func About()
    Msgbox(0,"Info","Only a test...")
EndFunc
Func _disable()
    GUICtrlSetState($readonlyitem,$GUI_CHECKED)
    GUICtrlSetState($numinput,$GUI_DISABLE)
EndFunc
Edited by Golbez

Share this post


Link to post
Share on other sites

What isn't working?

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

it still saves it as test.ini.ini

nvm im retarted

Edited by Golbez

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