Jump to content

How to Clear fields created once used


JimC
 Share

Recommended Posts

I built this gui creating input using GUICTRLCREATE and reading input using GUICRLREAD statements. but I am looking for a way to clear a field or resting the field to nothing once the field has been used. Any help would be greatly aprrecited.

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <array.au3>
#include <file.au3>

Global $computer,$costcenter,$pcomputer,$amosrce,$pcostcenter,$pprimuser,$floor1


#Region ### START Koda GUI section ### Form=C:\Documents and Settings\e15850t\Desktop\Form1.kxf
$Form1 = GUICreate("AMO Mif Fix", 630, 431, 379, 121)
$Group1 = GUICtrlCreateGroup("Pc Information", 8, 16, 217, 129)
$computer=GUICtrlCreateInput("", 20, 64, 105, 30, $ES_LOWERCASE)
GUICtrlSetState(-1, $GUI_FOCUS)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Ping", 144, 64, 75, 33, 0)
$Label1 = GUICtrlCreateLabel("PC Name", 56, 40, 49, 17)
;GUICtrlCreateGroup("", -99, -99, 1, 1)


$Group2 = GUICtrlCreateGroup("User Information for PC", 8, 152, 260, 265)
$Label2 = GUICtrlCreateLabel("Cost Center", 12, 184, 59, 17)
$costcenter=GUICtrlCreateInput("", 10, 208, 75, 28, $ES_NUMBER)
GUICtrlSetLimit(-1, 5)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetState($costcenter, $gui_disable)
$Label3 = GUICtrlCreateLabel("Primary User", 12, 248, 63, 17)
$primeuser = GUICtrlCreateInput("", 8.5, 272, 230, 28,$ES_UPPERCASE)
GUICtrlSetLimit(-1, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetState($primeuser, $gui_disable)
$Label4 = GUICtrlCreateLabel("Floor:  Valid value 1 or 2", 12, 308, 120, 17)
;$Combo1 = GUICtrlCreateCombo("", 10, 328, 200, 25)
;GUICtrlSetData(-1, "1|2", "1"); add other item snd set a new default
$floor=GUICtrlCreateInput("",10, 328, 200, 25, $ES_NUMBER)
GUICtrlSetState($floor, $gui_disable)
GUICtrlSetLimit(-1, 1)
$Button3 = GUICtrlCreateButton("Modify Mif", 24, 375, 99, 33, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetState($Button3, $gui_disable) 
$Group3 = GUICtrlCreateGroup("PC Alive ?", 280, 24, 313, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Drive Mapped ?", 277, 127, 313, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group5 = GUICtrlCreateGroup("Mif Current", 282, 190, 313, 113)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label5 = GUICtrlCreateLabel("Cost Center: ", 285, 210, 63, 17)
$Label6 = GUICtrlCreateLabel("Primary User: ", 285, 230, 63, 17)
$Label7 = GUICtrlCreateLabel("Building: ", 285, 250, 63, 17)
$Label8 = GUICtrlCreateLabel("Floor: ", 285, 270, 63, 17)

$Group6 = GUICtrlCreateGroup("Mif Written", 282, 303, 313, 113)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label9 = GUICtrlCreateLabel("Cost Center: ", 285, 320, 63, 17)
$Label10 = GUICtrlCreateLabel("Primary User: ", 285, 340, 63, 17)
$Label11 = GUICtrlCreateLabel("Building: ", 285, 360, 63, 17)
$Label12 = GUICtrlCreateLabel("Floor: ", 285, 380, 63, 17)



GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$message =GUICtrlCreateLabel('                         ', 300, 50, 570, 20)
$message1=GUICtrlCreateLabel('                         ' , 300, 50, 570, 20)
$message2 = GUICtrlCreateLabel('                         ', 300, 50, 570, 20)
$message3 = GUICtrlCreateLabel('                         ', 300, 50, 570, 20)
$message4 = GUICtrlCreateLabel('                         ', 310, 140, 570, 20)
$message5 = GUICtrlCreateLabel('                         ', 310, 140, 570, 20)




While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MyPing()
        Case $Button3
             Modmif()
        
    EndSwitch
WEnd

Func MyPing()
    GUICtrlDelete($message2)
    GUICtrlDelete($message3)
    GUICtrlDelete($message4)
    GUICtrlDelete($message5)
If GUICtrlRead($computer) = '' Then
    $message = GUICtrlCreateLabel('PC name is blank !', 300, 50, 570, 20)
    Sleep(3000)
    GUICtrlDelete($message)
    Return
Else
    $pcomputer=GUICtrlRead($computer)
    $message1 = GUICtrlCreateLabel('Pinging PC:   ' & $pcomputer, 300, 50, 570, 20)
    Sleep(3000)
    GUICtrlDelete($message1)
    
EndIf   
$var = Ping($pcomputer,250)
If $var <> 0 Then
    
    $message2 = GUICtrlCreateLabel( GUICtrlRead($computer) &' is online !', 300, 50, 570, 20)
    GUICtrlSetState($Button1, $gui_disable)
    MapDrive()
    Else
    $message3 = GUICtrlCreateLabel( GUICtrlRead($computer) &' is offline !', 300, 50, 570, 20)
    
EndIf
EndFunc

Func MapDrive()
    $amosrce = DriveMapAdd("*", "\\"&$pcomputer &"\c$\uam4\clientws", 8)
    If Not @error Then
    ;msgbox(0,"AmoFix!!!","The drive was mapped as " &$amosrce,2)
        $message4 = GUICtrlCreateLabel( 'Drive mapped as ' & $amosrce, 310, 140, 570, 20)
        GUICtrlSetState($costcenter, $gui_enable)
        GUICtrlSetState($costcenter, $GUI_FOCUS)
        GUICtrlSetState($primeuser, $gui_disable)
        GUICtrlSetState($floor, $gui_disable)
        GUICtrlSetState($computer, $gui_disable)
        userinfo()
    Else
        $message5 = GUICtrlCreateLabel('The drive was not mapped !!!', 310, 140, 570, 20)
        GUICtrlSetState($Button1, $gui_enable)
        Return
    EndIf
EndFunc

Func userinfo()
    
    
    While $pcostcenter < 10000   
        $pcostcenter=GUICtrlRead($costcenter)
    WEnd
    GUICtrlSetState($costcenter, $gui_disable)
    GUICtrlSetState($primeuser, $gui_enable)
    GUICtrlSetState($primeuser, $GUI_FOCUS)
    
    While StringLen($pprimuser) < 7
        $pprimuser=GUICtrlRead($primeuser)
    ;sleep(4000)
    WEnd
    GUIctrlsetstate($floor, $gui_enable)
    GUICtrlSetState($floor, $GUI_FOCUS)
    
    While not $floor1  > 3
        $floor1=GUICtrlRead($floor)
    WEND
    
    
    GUICtrlSetState($Button3, $gui_enable)
EndFunc

func Modmif()
    GUICtrlSetState($Button3, $gui_disable)
    GUISetState($primeuser, $gui_disable)
    GUISetState($floor, $gui_disable)
    Dim $array1, $array2, $array3
    if FileExists ($amosrce &"\slmpc.mif") Then
        MsgBox(0, $amosrce &"\slmpc.mif","File exists")
    Else
        MsgBox(0, $amosrce &"\slmpc.mif","File does not exists")
    EndIf
    _FileReadToArray($amosrce &"\slmpc.mif",$array1)
    _ArrayDisplay($array1,"MIF File")
    $string1="Access=Write-Only"
    $string2="Value="
    $string3="EndAttribute"
    $test1=StringStripWS($array1[21],8)
    $result=StringCompare($string3, $test1, 2)
    if $result = 0 then 
        $message6 = GUICtrlCreateLabel("none", 350, 210, 570, 20)
        $message7 = GUICtrlCreateLabel($pcostcenter, 350, 320, 63, 17)
        _FileWriteToLine($amosrce &"\slmpc.mif",21,"    Value = "& '"'&$pcostcenter&'"',0)
    else 
        $temp=StringStripWS($array1[21],8)
        $cc=StringTrimLeft($temp,6)
        msgbox(0,"",$pcostcenter)
        $message6 = GUICtrlCreateLabel($cc, 350, 210, 570, 20)
        $message7 = GUICtrlCreateLabel($pcostcenter, 350, 320, 63, 17)
        _FileWriteToLine($amosrce &"\slmpc.mif",21,"    Value = "& '"'&$pcostcenter&'"',1)
    EndIf
    _FileReadToArray($amosrce &"\slmpc.mif",$array2)
    _ArrayDisplay($array2,"MIF File")
     $test2=StringStripWS($array2[39],8)
     $result2=Stringcompare($string3, $test2,2)
     if $result = 0 Then
         $message8 = GUICtrlCreateLabel("none", 350, 230, 570, 20)
         $message9 = GUICtrlCreateLabel($pprimuser,350, 340, 570,20)
         _fileWritetoline($amosrce &"\slmpc.mif",39, "  Value = "& '"'&$pprimuser&'"',1)
     Else
         $temp2=StringStripWS($array2[39],8)
         $pu=Stringtrimleft($temp2,6)
         $message8 = GUICtrlCreateLabel($pu, 350, 230, 570, 20)
         $message9 = GUICtrlCreateLabel($pprimuser,350, 340, 570,20)
         _fileWritetoline($amosrce &"\slmpc.mif",39, "  Value = "& '"'&$pprimuser&'"',1)
     EndIf
     _FileReadToArray($amosrce &"\slmpc.mif",$array3)
    _ArrayDisplay($array3,"MIF File")
    
;add some more code for the two remaining fields......
    
    sleep(5000)
    GUICtrlDelete($message2)
    GUICtrlDelete($message3)
    GUICtrlDelete($message4)
    GUICtrlDelete($message5)
    GUICtrlDelete($message6)
    GUICtrlDelete($message7)
    GUICtrlDelete($message8)
    GUICtrlDelete($message9)
    DriveMapDel($amosrce)
    GUICtrlSetState($Button1, $gui_enable)
    GUICtrlSetState($computer, $gui_enable)
    
    
EndFunc
Link to comment
Share on other sites

I built this gui creating input using GUICTRLCREATE and reading input using GUICRLREAD statements. but I am looking for a way to clear a field or resting the field to nothing once the field has been used. Any help would be greatly aprrecited.

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <array.au3>
#include <file.au3>

Global $computer,$costcenter,$pcomputer,$amosrce,$pcostcenter,$pprimuser,$floor1


#Region ### START Koda GUI section ### Form=C:\Documents and Settings\e15850t\Desktop\Form1.kxf
$Form1 = GUICreate("AMO Mif Fix", 630, 431, 379, 121)
$Group1 = GUICtrlCreateGroup("Pc Information", 8, 16, 217, 129)
$computer=GUICtrlCreateInput("", 20, 64, 105, 30, $ES_LOWERCASE)
GUICtrlSetState(-1, $GUI_FOCUS)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Ping", 144, 64, 75, 33, 0)
$Label1 = GUICtrlCreateLabel("PC Name", 56, 40, 49, 17)
;GUICtrlCreateGroup("", -99, -99, 1, 1)


$Group2 = GUICtrlCreateGroup("User Information for PC", 8, 152, 260, 265)
$Label2 = GUICtrlCreateLabel("Cost Center", 12, 184, 59, 17)
$costcenter=GUICtrlCreateInput("", 10, 208, 75, 28, $ES_NUMBER)
GUICtrlSetLimit(-1, 5)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetState($costcenter, $gui_disable)
$Label3 = GUICtrlCreateLabel("Primary User", 12, 248, 63, 17)
$primeuser = GUICtrlCreateInput("", 8.5, 272, 230, 28,$ES_UPPERCASE)
GUICtrlSetLimit(-1, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetState($primeuser, $gui_disable)
$Label4 = GUICtrlCreateLabel("Floor:  Valid value 1 or 2", 12, 308, 120, 17)
;$Combo1 = GUICtrlCreateCombo("", 10, 328, 200, 25)
;GUICtrlSetData(-1, "1|2", "1"); add other item snd set a new default
$floor=GUICtrlCreateInput("",10, 328, 200, 25, $ES_NUMBER)
GUICtrlSetState($floor, $gui_disable)
GUICtrlSetLimit(-1, 1)
$Button3 = GUICtrlCreateButton("Modify Mif", 24, 375, 99, 33, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetState($Button3, $gui_disable) 
$Group3 = GUICtrlCreateGroup("PC Alive ?", 280, 24, 313, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Drive Mapped ?", 277, 127, 313, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group5 = GUICtrlCreateGroup("Mif Current", 282, 190, 313, 113)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label5 = GUICtrlCreateLabel("Cost Center: ", 285, 210, 63, 17)
$Label6 = GUICtrlCreateLabel("Primary User: ", 285, 230, 63, 17)
$Label7 = GUICtrlCreateLabel("Building: ", 285, 250, 63, 17)
$Label8 = GUICtrlCreateLabel("Floor: ", 285, 270, 63, 17)

$Group6 = GUICtrlCreateGroup("Mif Written", 282, 303, 313, 113)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label9 = GUICtrlCreateLabel("Cost Center: ", 285, 320, 63, 17)
$Label10 = GUICtrlCreateLabel("Primary User: ", 285, 340, 63, 17)
$Label11 = GUICtrlCreateLabel("Building: ", 285, 360, 63, 17)
$Label12 = GUICtrlCreateLabel("Floor: ", 285, 380, 63, 17)



GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$message =GUICtrlCreateLabel('                         ', 300, 50, 570, 20)
$message1=GUICtrlCreateLabel('                         ' , 300, 50, 570, 20)
$message2 = GUICtrlCreateLabel('                         ', 300, 50, 570, 20)
$message3 = GUICtrlCreateLabel('                         ', 300, 50, 570, 20)
$message4 = GUICtrlCreateLabel('                         ', 310, 140, 570, 20)
$message5 = GUICtrlCreateLabel('                         ', 310, 140, 570, 20)




While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MyPing()
        Case $Button3
             Modmif()
        
    EndSwitch
WEnd

Func MyPing()
    GUICtrlDelete($message2)
    GUICtrlDelete($message3)
    GUICtrlDelete($message4)
    GUICtrlDelete($message5)
If GUICtrlRead($computer) = '' Then
    $message = GUICtrlCreateLabel('PC name is blank !', 300, 50, 570, 20)
    Sleep(3000)
    GUICtrlDelete($message)
    Return
Else
    $pcomputer=GUICtrlRead($computer)
    $message1 = GUICtrlCreateLabel('Pinging PC:   ' & $pcomputer, 300, 50, 570, 20)
    Sleep(3000)
    GUICtrlDelete($message1)
    
EndIf   
$var = Ping($pcomputer,250)
If $var <> 0 Then
    
    $message2 = GUICtrlCreateLabel( GUICtrlRead($computer) &' is online !', 300, 50, 570, 20)
    GUICtrlSetState($Button1, $gui_disable)
    MapDrive()
    Else
    $message3 = GUICtrlCreateLabel( GUICtrlRead($computer) &' is offline !', 300, 50, 570, 20)
    
EndIf
EndFunc

Func MapDrive()
    $amosrce = DriveMapAdd("*", "\\"&$pcomputer &"\c$\uam4\clientws", 8)
    If Not @error Then
;msgbox(0,"AmoFix!!!","The drive was mapped as " &$amosrce,2)
        $message4 = GUICtrlCreateLabel( 'Drive mapped as ' & $amosrce, 310, 140, 570, 20)
        GUICtrlSetState($costcenter, $gui_enable)
        GUICtrlSetState($costcenter, $GUI_FOCUS)
        GUICtrlSetState($primeuser, $gui_disable)
        GUICtrlSetState($floor, $gui_disable)
        GUICtrlSetState($computer, $gui_disable)
        userinfo()
    Else
        $message5 = GUICtrlCreateLabel('The drive was not mapped !!!', 310, 140, 570, 20)
        GUICtrlSetState($Button1, $gui_enable)
        Return
    EndIf
EndFunc

Func userinfo()
    
    
    While $pcostcenter < 10000   
        $pcostcenter=GUICtrlRead($costcenter)
    WEnd
    GUICtrlSetState($costcenter, $gui_disable)
    GUICtrlSetState($primeuser, $gui_enable)
    GUICtrlSetState($primeuser, $GUI_FOCUS)
    
    While StringLen($pprimuser) < 7
        $pprimuser=GUICtrlRead($primeuser)
;sleep(4000)
    WEnd
    GUIctrlsetstate($floor, $gui_enable)
    GUICtrlSetState($floor, $GUI_FOCUS)
    
    While not $floor1  > 3
        $floor1=GUICtrlRead($floor)
    WEND
    
    
    GUICtrlSetState($Button3, $gui_enable)
EndFunc

func Modmif()
    GUICtrlSetState($Button3, $gui_disable)
    GUISetState($primeuser, $gui_disable)
    GUISetState($floor, $gui_disable)
    Dim $array1, $array2, $array3
    if FileExists ($amosrce &"\slmpc.mif") Then
        MsgBox(0, $amosrce &"\slmpc.mif","File exists")
    Else
        MsgBox(0, $amosrce &"\slmpc.mif","File does not exists")
    EndIf
    _FileReadToArray($amosrce &"\slmpc.mif",$array1)
    _ArrayDisplay($array1,"MIF File")
    $string1="Access=Write-Only"
    $string2="Value="
    $string3="EndAttribute"
    $test1=StringStripWS($array1[21],8)
    $result=StringCompare($string3, $test1, 2)
    if $result = 0 then 
        $message6 = GUICtrlCreateLabel("none", 350, 210, 570, 20)
        $message7 = GUICtrlCreateLabel($pcostcenter, 350, 320, 63, 17)
        _FileWriteToLine($amosrce &"\slmpc.mif",21,"    Value = "& '"'&$pcostcenter&'"',0)
    else 
        $temp=StringStripWS($array1[21],8)
        $cc=StringTrimLeft($temp,6)
        msgbox(0,"",$pcostcenter)
        $message6 = GUICtrlCreateLabel($cc, 350, 210, 570, 20)
        $message7 = GUICtrlCreateLabel($pcostcenter, 350, 320, 63, 17)
        _FileWriteToLine($amosrce &"\slmpc.mif",21,"    Value = "& '"'&$pcostcenter&'"',1)
    EndIf
    _FileReadToArray($amosrce &"\slmpc.mif",$array2)
    _ArrayDisplay($array2,"MIF File")
     $test2=StringStripWS($array2[39],8)
     $result2=Stringcompare($string3, $test2,2)
     if $result = 0 Then
         $message8 = GUICtrlCreateLabel("none", 350, 230, 570, 20)
         $message9 = GUICtrlCreateLabel($pprimuser,350, 340, 570,20)
         _fileWritetoline($amosrce &"\slmpc.mif",39, "  Value = "& '"'&$pprimuser&'"',1)
     Else
         $temp2=StringStripWS($array2[39],8)
         $pu=Stringtrimleft($temp2,6)
         $message8 = GUICtrlCreateLabel($pu, 350, 230, 570, 20)
         $message9 = GUICtrlCreateLabel($pprimuser,350, 340, 570,20)
         _fileWritetoline($amosrce &"\slmpc.mif",39, "  Value = "& '"'&$pprimuser&'"',1)
     EndIf
     _FileReadToArray($amosrce &"\slmpc.mif",$array3)
    _ArrayDisplay($array3,"MIF File")
    
;add some more code for the two remaining fields......
    
    sleep(5000)
    GUICtrlDelete($message2)
    GUICtrlDelete($message3)
    GUICtrlDelete($message4)
    GUICtrlDelete($message5)
    GUICtrlDelete($message6)
    GUICtrlDelete($message7)
    GUICtrlDelete($message8)
    GUICtrlDelete($message9)
    DriveMapDel($amosrce)
    GUICtrlSetState($Button1, $gui_enable)
    GUICtrlSetState($computer, $gui_enable)
    
    
EndFunc
too lazy to read it all, but.. basically

$Email = GUICtrlCreateInput($Mail, 224, 200, 129, 21, BitOR(128, 0x00800000));set it to a specific thing


GUICtrlSetData($email,"");clear the box
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
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...