Jump to content

write at text file without opening txt editor?


jim1
 Share

Recommended Posts

Hello i want to make a prog that u press checkboxes and write some text in input and then save thinks in a txt file with a button but without opening any notepads.

Also how exactly i can make window smaller from left? i made some buttons that extend gui 2 work fine but the first one doesnt do anything because it doesnt let me to make smaller the left side of gui, if i try to make it smaller it eats right side, how can i do that?

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Opt('GUIResizeMode', 802) 
$Form1 = GUICreate("Diaulos v1.1", 471, 217, -1, -1, -1, $WS_EX_ACCEPTFILES)
$Button1 = GUICtrlCreateButton("(Not allowed)", 168, 88, 33, 33, $BS_BITMAP)
GUICtrlSetImage(-1, ".\images\arrow_right.bmp", 0)
$Button2 = GUICtrlCreateButton("(Not allowed)", 304, 180, 33, 33, $BS_BITMAP)
GUICtrlSetImage(-1, ".\images\arrow_down.bmp", 0)
$Button3 = GUICtrlCreateButton("(Not allowed)", 432, 88, 33, 33, $BS_BITMAP)
GUICtrlSetImage(-1, ".\images\arrow_left.bmp", 0)
$Label1 = GUICtrlCreateLabel("Step 1 Drop files", 280, 8, 82, 17)
$Label2 = GUICtrlCreateLabel("Step 2", 172, 64, 35, 17)
$Label3 = GUICtrlCreateLabel("Step 3", 264, 188, 35, 17)
$Label4 = GUICtrlCreateLabel("Step 4", 428, 64, 35, 17)
$But1 = GUICtrlCreateButton("Chemistry", 392, 264, 65, 25, 0)
$But2 = GUICtrlCreateButton("Physic", 392, 296, 65, 25, 0)
$But3 = GUICtrlCreateButton("Biology", 392, 328, 65, 25, 0)
$Label5 = GUICtrlCreateLabel("Enter your name here first", 200, 236, 124, 17)
$Label6 = GUICtrlCreateLabel("Choose lesson", 388, 236, 73, 17)
$name = GUICtrlCreateInput("", 172, 264, 169, 21)
$But8 = GUICtrlCreateButton("Create folder", 200, 296, 117, 29, 0)
$But4 = GUICtrlCreateButton("Rar folder", 488, 32, 73, 25, 0)
$But9 = GUICtrlCreateButton("Preview", 488, 64, 73, 25, 0)
$But5 = GUICtrlCreateButton("Send files", 488, 96, 73, 25, 0)
$cListBox = GUICtrlCreateList("", 225, 47, 190, 125)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$Group1 = GUICtrlCreateGroup("Class", 4, 20, 49, 81)
$Checkbox1 = GUICtrlCreateCheckbox("A", 12, 36, 41, 17)
$Checkbox2 = GUICtrlCreateCheckbox("B", 12, 56, 45, 17)
$Checkbox3 = GUICtrlCreateCheckbox("C", 12, 76, 49, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Specialization", 64, 20, 93, 81)
$Checkbox4 = GUICtrlCreateCheckbox("Informatics", 68, 36, 85, 17)
$Checkbox5 = GUICtrlCreateCheckbox("Medicine", 68, 56, 85, 17)
$Checkbox6 = GUICtrlCreateCheckbox("Engineering", 68, 76, 81, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label7 = GUICtrlCreateLabel("Comments", 52, 108, 53, 17)
$input1 = GUICtrlCreateInput("write comments here", 4, 132, 153, 21)
$Input2 = GUICtrlCreateInput("Write Name", 8, 224, 149, 21)
$Input3 = GUICtrlCreateInput("Job", 8, 252, 149, 21)
$Label8 = GUICtrlCreateLabel("Your info", 56, 196, 46, 17)
$But11 = GUICtrlCreateButton("Send data", 44, 292, 69, 21, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
        DirRemove(@ScriptDir & "\teacher1files\" & GUICtrlRead($Name), 1)
            Exit
        Case $GUI_EVENT_DROPPED
            GUICtrlSetData($cListBox, @GUI_DRAGFILE & @CRLF, 1)
        EndSwitch
        if $msg = $But4 Then
            Dim $sWinRAR = @ScriptDir & '\winrar\'
Run($sWinRAR & 'winrar a ".\t1files" ".\teacher1files"')
            EndIf
        If $msg = $But5 then
            SoundPlay("Sounds/Connecting.mp3")
            EndIf
        if $msg = $But3 then
            SoundPlay("Sounds/bio.mp3")
            DirCreate(@SCRIPTDIR &"\teacher1files\"& GUICtrlRead($Name) &"\Biology")
            Filecopy(@GUI_DRAGFILE , @scriptdir & "\teacher1files\" & GUICtrlRead($Name) & "\" & guictrlread($But3)  & "\")
            EndIf
            if $msg = $But1 then
            SoundPlay("")
            DirCreate(@SCRIPTDIR &"\teacher1files\"& GUICtrlRead($Name) &"\Chemistry")
            Filecopy(@GUI_DRAGFILE , @scriptdir & "\teacher1files\" & GUICtrlRead($Name) & "\" & guictrlread($But1)  & "\")
            EndIf
            if $msg = $But2 then
            SoundPlay("Sounds/Physic.mp3")
            DirCreate(@SCRIPTDIR &"\teacher1files\"& GUICtrlRead($Name) &"\Physic")
            Filecopy(@GUI_DRAGFILE , @scriptdir & "\teacher1files\" & GUICtrlRead($Name) & "\" & guictrlread($But2)  & "\")
            EndIf
        if $msg = $but8 Then
            DirCreate(@SCRIPTDIR &"\teacher1files\"& GUICtrlRead($Name))
        EndIf
        if $msg = $but9 Then
            ShellExecute("t1files.rar")
        EndIf
        if $msg=$button1 Then
        endif
        if $msg=$button2 Then
            winmove("","",default,default,477, 392)
        endif
        if $msg=$button3 Then
            winmove("","",default,default,595, 249)
            endif
               if $msg=$but11 then
                        endif
WEnd
Link to comment
Share on other sites

Look up FileWrite and FileWriteLine func in the help file.

For the resize, I suppose you'd have to do a resize and move operation (if using the winmove func), just offset the co-ord by how much you shrink/grow. Also check out GUICtrlSetResizing in the helpfile

Edited by spudw2k
Link to comment
Share on other sites

Size Matters... lol

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Opt('GUIResizeMode', 802)

Global $sWinRAR = @ScriptDir & '\winrar\'

;$Form1 = GUICreate("Diaulos v1.1", 471, 217, -1, -1, -1, $WS_EX_ACCEPTFILES)
$Form1 = GUICreate("Diaulos v1.1", 600, 400, -1, -1, -1, $WS_EX_ACCEPTFILES)
$Button1 = GUICtrlCreateButton("(Not allowed)", 168, 88, 33, 33, $BS_BITMAP)
GUICtrlSetImage(-1, ".\images\arrow_right.bmp", 0)
$Button2 = GUICtrlCreateButton("(Not allowed)", 304, 180, 33, 33, $BS_BITMAP)
GUICtrlSetImage(-1, ".\images\arrow_down.bmp", 0)
$Button3 = GUICtrlCreateButton("(Not allowed)", 432, 88, 33, 33, $BS_BITMAP)
GUICtrlSetImage(-1, ".\images\arrow_left.bmp", 0)
$Label1 = GUICtrlCreateLabel("Step 1 Drop files", 280, 8, 82, 17)
$Label2 = GUICtrlCreateLabel("Step 2", 172, 64, 35, 17)
$Label3 = GUICtrlCreateLabel("Step 3", 264, 188, 35, 17)
$Label4 = GUICtrlCreateLabel("Step 4", 428, 64, 35, 17)
$But1 = GUICtrlCreateButton("Chemistry", 392, 264, 65, 25, 0)
$But2 = GUICtrlCreateButton("Physic", 392, 296, 65, 25, 0)
$But3 = GUICtrlCreateButton("Biology", 392, 328, 65, 25, 0)
$Label5 = GUICtrlCreateLabel("Enter your name here first", 200, 236, 124, 17)

$Test_Button =  GUICtrlCreateButton("** TEST ME **", 20, 350, 124, 30)

$Label6 = GUICtrlCreateLabel("Choose lesson", 388, 236, 73, 17)
$name = GUICtrlCreateInput("Name", 172, 264, 169, 21)
$But8 = GUICtrlCreateButton("Create folder", 200, 296, 117, 29, 0)
$But4 = GUICtrlCreateButton("Rar folder", 488, 32, 73, 25, 0)
$But9 = GUICtrlCreateButton("Preview", 488, 64, 73, 25, 0)
$But5 = GUICtrlCreateButton("Send files", 488, 96, 73, 25, 0)
$cListBox = GUICtrlCreateList("", 225, 47, 190, 125)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$Group1 = GUICtrlCreateGroup("Class", 4, 20, 49, 81)
$Checkbox1 = GUICtrlCreateCheckbox("A", 12, 36, 30, 17) ; 41 was too long
$Checkbox2 = GUICtrlCreateCheckbox("B", 12, 56, 45, 17) ; change the 45
$Checkbox3 = GUICtrlCreateCheckbox("C", 12, 76, 49, 17) ; change the 49
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Specialization", 64, 20, 93, 81)
$Checkbox4 = GUICtrlCreateCheckbox("Informatics", 68, 36, 85, 17)
$Checkbox5 = GUICtrlCreateCheckbox("Medicine", 68, 56, 85, 17)
$Checkbox6 = GUICtrlCreateCheckbox("Engineering", 68, 76, 81, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label7 = GUICtrlCreateLabel("Comments", 52, 108, 53, 17)
$input1 = GUICtrlCreateInput("write comments here", 4, 132, 153, 21)
$Input2 = GUICtrlCreateInput("Write Name", 8, 224, 149, 21)
$Input3 = GUICtrlCreateInput("Job", 8, 252, 149, 21)
$Label8 = GUICtrlCreateLabel("Your info", 56, 196, 46, 17)
$But11 = GUICtrlCreateButton("Send data", 44, 292, 69, 21, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            DirRemove(@ScriptDir & "\teacher1files\" & GUICtrlRead($name), 1)
            Exit
        Case $GUI_EVENT_DROPPED
            GUICtrlSetData($cListBox, @GUI_DragFile & @CRLF, 1)
        
        Case $Test_Button
            $Info1 = GUICtrlRead($Name)
            $Info2 = GUICtrlRead($Input1)
            $Checked1 = _IsChecked($Checkbox1) 
            $Checked4 = _IsChecked($Checkbox4)
            
            FileWrite(@ScriptDir & "\Text.txt", $Info1 & @CRLF)
            FileWrite(@ScriptDir & "\Text.txt", $Info2 & @CRLF)
            FileWrite(@ScriptDir & "\Text.txt", $Checked1 & @CRLF)
            FileWrite(@ScriptDir & "\Text.txt", $Checked4 & @CRLF)
            
            ; for testing
            ShellExecute(@ScriptDir & "\Text.txt")
        
        ; Place ALL the "If $Msg = " here in the Case Area
    EndSwitch
    If $Msg = $But4 Then
        Run($sWinRAR & 'winrar a ".\t1files" ".\teacher1files"')
    EndIf
    If $Msg = $But5 Then
        SoundPlay("Sounds/Connecting.mp3")
    EndIf
    If $Msg = $But3 Then
        SoundPlay("Sounds/bio.mp3")
        DirCreate(@ScriptDir & "\teacher1files\" & GUICtrlRead($name) & "\Biology")
        FileCopy(@GUI_DragFile, @ScriptDir & "\teacher1files\" & GUICtrlRead($name) & "\" & GUICtrlRead($But3) & "\")
    EndIf
    If $Msg = $But1 Then
        SoundPlay("")
        DirCreate(@ScriptDir & "\teacher1files\" & GUICtrlRead($name) & "\Chemistry")
        FileCopy(@GUI_DragFile, @ScriptDir & "\teacher1files\" & GUICtrlRead($name) & "\" & GUICtrlRead($But1) & "\")
    EndIf
    If $Msg = $But2 Then
        SoundPlay("Sounds/Physic.mp3")
        DirCreate(@ScriptDir & "\teacher1files\" & GUICtrlRead($name) & "\Physic")
        FileCopy(@GUI_DragFile, @ScriptDir & "\teacher1files\" & GUICtrlRead($name) & "\" & GUICtrlRead($But2) & "\")
    EndIf
    If $Msg = $But8 Then
        DirCreate(@ScriptDir & "\teacher1files\" & GUICtrlRead($name))
    EndIf
    If $Msg = $But9 Then
        ShellExecute("t1files.rar")
    EndIf
    If $Msg = $Button1 Then
    EndIf
    If $Msg = $Button2 Then
        WinMove("", "", Default, Default, 477, 392)
    EndIf
    If $Msg = $Button3 Then
        WinMove("", "", Default, Default, 595, 249)
    EndIf
    If $Msg = $But11 Then
    EndIf
WEnd


; ----------- Functions -----------------

Func _IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

thanks a lot with the help i have only 3 more quesions about it

1)for they gui i want when it is opened to be see only drop box and the 3 buttons near steps, so those buttons will extend gui. If i change numbers in form it shrings right side instead of left and i dont know how to shrink left side.

2)in the chekcboxes if checke it only write true orfalse at txt file how can i make it to write name of checkboxes that are checkd?

3)also can u explain a bit how this works?

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