Jump to content

GUI REFRESH


Recommended Posts

I cant seem to get my GUI to update its labels and checkboxes. I am pretty new to Autoit , so there might be something im overlooking or just dont know about. The only function to the script currently is adding server names. Please me aware that the script makes some registry changes in HKEY_LOCAL_MACHINE\SOFTWARE\ERM File Deployer . I would be appreciate any help.

#include <GUIConstants.au3>
;************************************************************VARS*****************************
Global $Checkbox[75]
Global $StatusLabel[75]
Global $serverstatus[75]
Global $ServerName[75]
Global $servertotal
Global $Counter4 = 1
;---------------------------------------------------------------------------------------------
;***********************************************************REG READS*************************
$servertotal = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\ERM File Deployer", "ServerTotal")
If $servertotal = "" then
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ERM File Deployer","ServerTotal","REG_SZ","0")
    $servertotal = 0
EndIf
IF $servertotal <> "0" THEN
for $Counter1 = 1 to $servertotal step 1
$ServerName[$Counter1] = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\ERM File Deployer", "SERVERNAME" &$Counter1)
Next
EndIf   
;----------------------------------------------------------------------------------------------
;***********************************************************FIRST LOADS************************
$Form1 = GUICreate("ERM File Deployer", 617, 775, 378, 6)
$Button1 = GUICtrlCreateButton("Exit", 8, 744, 89, 25)
$Button2 = GUICtrlCreateButton("Deploy files", 520, 744, 89, 25)
$Button3 = GUICtrlCreateButton("Add Server", 8, 8, 89, 25)
$Button4 = GUICtrlCreateButton("Server Check(s)", 8, 40, 89, 25)
$Button5 = GUICtrlCreateButton("Choose File(s)", 104, 8, 89, 25)
$Progress1 = GUICtrlCreateProgress(8, 712, 601, 17)
$Group1 = GUICtrlCreateGroup("Server List", 8, 72, 209, 625)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Server List", 312, 72, 209, 625)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Server Status", 216, 72, 89, 625)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Server Status", 520, 72, 89, 625)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button6 = GUICtrlCreateButton("Change Dest", 104, 40, 89, 25)
SETUPINFO($counter4)
GUISetState(@SW_SHOW)
DISPLAYSERVER($servertotal)
;----------------------------------------------------------------------------------------------
;**********************************************************************************************
;MENU MENU MENU MENU MENU MENU MENU MENU MENU MENU MENU MENU MENU MENU MENU MENU MENU MENU MENU
;**********************************************************************************************
While 1
    $msg = GuiGetMsg()
    IF $msg = $GUI_EVENT_CLOSE then EXIT
    IF $msg = $Button1 then EXIT    
    IF $msg = $Button3 Then
        ADDSERVER($servertotal)
        DISPLAYSERVER($servertotal)
    EndIf
    IF $msg = $Button4 Then ServerChecks($servertotal)
WEnd
;**********************************************************************************************
;MENU END MENU END MENU END MENU END MENU END MENU END MENU END MENU END MENU END MENU END MENU
;**********************************************************************************************

;************************************************FUNC ADD SERVER*******************************
FUNC ADDSERVER($servertotal)
$NewServer = InputBox("Server Name","Server Name:","","",250,20)
IF $ServerName <> "" then
$servertotal = $servertotal + 1
$ServerName[$servertotal] = $NewServer
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ERM File Deployer","ServerName" &$servertotal,"REG_SZ",$ServerName[$servertotal])
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ERM File Deployer","ServerTotal","REG_SZ",$servertotal)
Endif
Return
EndFunc
;----------------------------------------------------------------------------------------------
;************************************************FUNC DISPLAY SERVER***************************
FUNC DISPLAYSERVER($servertotal)
    For $Counter2 = 1 to $servertotal step 1
    
        GUICtrlSetData($Checkbox[$Counter2],$ServerName[$Counter2])
        GUICtrlSetState($Checkbox[$Counter2],$Gui_Show)
    
    next
        GUICtrlSetData($StatusLabel[1],"test")
        GUICtrlSetState($StatusLabel[1],$Gui_Show)
    Return
EndFunc 
;----------------------------------------------------------------------------------------------
;************************************************FUNC SERVER CHECKS****************************
Func ServerChecks($servertotal)
    $YPOS1 = "80"
    $YPOS2 = "80"
for $Counter3 = 1 to $servertotal step 1
$PINGTIME = Ping($ServerName[$counter3],250)
If @error = 0 Then  $serverstatus[$counter3] = "Online"
If @error <> 0 Then $serverstatus[$counter3] = "Offline"
        If $Counter3 < "38" then
        $YPOS1 = $YPOS1 + "16"
        $StatusLabel[$Counter3] = GUICtrlCreateLabel($serverstatus[$counter3], 224, $YPOS1 , 75, 17)
        Else
        $YPOS2 = $YPOS2 + 16
        $StatusLabel[$Counter3] = GUICtrlCreateLabel($serverstatus[$Counter3], 528, $YPOS2, 75, 17)
        EndIf
    next
    Return
EndFunc
;----------------------------------------------------------------------------------------------
Func SETUPINFO($counter4)

    $YPOS1 = "80"
    $YPOS2 = "80"
    for $counter4 = 1 to 74 step 1
        
        If $Counter4 < "38" then
        $YPOS1 = $YPOS1 + "16"
        $Checkbox[$Counter4] = GUICtrlCreateCheckbox($ServerName[$Counter4], 16, $YPOS1 , 193, 17)
        GUICTRLSetState($Checkbox[$Counter4],$GUI_hide)
        $StatusLabel[$Counter4] = GUICtrlCreateLabel($serverstatus[$counter4], 224, $YPOS1 , 75, 17)
        GUICTRLSetState($StatusLabel[$Counter4],$GUI_hide)
        Else
        $YPOS2 = $YPOS2 + "16"
        $Checkbox[$Counter4] = GUICtrlCreateCheckbox($ServerName[$Counter4], 320, $YPOS2, 193, 17)
        GUICTRLSetState($Checkbox[$Counter4],$GUI_hide)
        $StatusLabel[$Counter4] = GUICtrlCreateLabel($serverstatus[$Counter4], 528, $YPOS2, 75, 17)
        GUICTRLSetState($StatusLabel[$Counter4],$GUI_hide)
        EndIf
        
    next    
EndFunc
Link to comment
Share on other sites

very nice and clean looking script... good use of for/next loops with creation, display and everything

i tried to read it all and most of it appears correct... i dont want to run it on my computer

but i noticed this

FUNC ADDSERVER($servertotal)
$NewServer = InputBox("Server Name","Server Name:","","",250,20)
IF $ServerName <> "" then
..................blah

maybe you wanted this

FUNC ADDSERVER($servertotal)
$NewServer = InputBox("Server Name","Server Name:","","",250,20)
IF $NewServer <> "" then
....................... blah

8)

NEWHeader1.png

Link to comment
Share on other sites

That was a mistake on my part, thank you.

I would realy like some help with the GUI refresh problem that I have. If you dont want to run the script because of the registry entries, then you can use the following line to get rid of all registry entries created by the script.

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\ERM File Deployer")

I would appreciate it alot.

Link to comment
Share on other sites

IF $msg = $Button3 Then
        ADDSERVER($servertotal)
        DISPLAYSERVER($servertotal)
    EndIf
Hi DemonAngel I still new using AutoIt but, the problem with you script is the above peace of code. It doesnt make sense to me but, even that $servertotal you declare global variable it doesnt hold the right value when it calls displayserver function. I add some MSGBOX to your code so I can pin point the problem. When you hit add addserver function will return 1 but displayserver will get 0.

What I will do to fix the problem is to have the function t return the value of $servertotal or used ByRef

Hope this help you..

Take a look to the MSGBOXES

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
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...