Sign in to follow this  
Followers 0
Cybertek

gui button help

4 posts in this topic

#1 ·  Posted (edited)

hey guys I need some help on this one....not sure where I am going wrong

I am building a script to auto install software that requires a server name

I got the gui to recognize a standard server and input that info later on (in this case a message box)

there is a chance that we would need to manually input a server name so I created a radio button with input box

if you click on the radio button for the standard server everything works the way I want it to

but when I click on the manual button the script is not grabbing the info in the input box

Can someone take a look at this and please tell me what I am doing wrong....i've been through the help file with no luck

thanks in advance,

Cybertek

Code so far:

#include <GUIConstantsEx.au3>

#include <EditConstants.au3>

#include <String.au3>

Global $svar, $sServer, $SMatch, $iStart, $iEnd, $server2

Global $Jserver

Global $server,$btn, $btn2, $msg, $radio1, $radio2

software_gui()

Func software_gui()

GUICreate("software Install", 250, 200)

GUISetState()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$sServer = RegRead("HKEY_CURRENT_USER\Network\P", "RemotePath")

$SMatch = _StringBetween($sServer, '\\\\', '\\', -1, 1)

$SMatch = StringRegExp($sServer, '(?<=\\\\)([^\\]*)', 1)

$iStart = StringInStr($sServer, '\\') + 2

$iEnd = StringInStr($sServer, '\', 0, 1, $iStart)

If $iStart And $iEnd Then

$server = StringMid($sServer, $iStart, $iEnd-$iStart)

EndIf

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$radio1= GUICtrlCreateRadio("software Server.", 35, 25)

GUICtrlCreateInput($server, 55, 45, 150, 20)

$radio2 = GUICtrlCreateRadio("Alternative Server.", 35,95)

$sever2 = GUICtrlCreateInput("", 55, 115, 150, 20)

$btn = GUICtrlCreateButton("Next", 80, 160)

$btn2 = GUICtrlCreateButton("Cancle", 120, 160)

While $msg <> $GUI_EVENT_CLOSE

$msg = GUIGetMsg()

Select

Case $msg = $btn

;;;;;;;;;;;;;;;;;;;;;;;;

;;this part is working;;

;;;;;;;;;;;;;;;;;;;;;;;;

If $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED Then

$Jserver = $server

GUIDelete()

MsgBox(0,"", $Jserver)

ExitLoop

EndIf

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;this part is part that is Not working;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

If $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED Then

GUIDelete()

$Jserver = $server2

MsgBox(0, "Server", $Jserver)

ExitLoop

EndIf

Case $msg = $btn2

Exit

ExitLoop

EndSelect

WEnd

GUIDelete()

EndFunc

Edited by Cybertek

Share this post


Link to post
Share on other sites



$sever2 = GUICtrlCreateInput("", 55, 115, 150, 20)

What is $sever2? :)

Try this

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <String.au3>

Global $svar,$sServer,$sMatch,$iStart,$iEnd,$server2
Global $Jserver
Global $server,$btn,$btn2,$msg,$radio1,$radio2

software_gui()

Func software_gui()
    GUICreate("Software Install",250,200)
    GUISetState()
    $sServer = RegRead("HKEY_CURRENT_USER\Network\P","RemotePath")
    $sMatch = _StringBetween($sServer,'\\\\','\\',-1,1)
    $sMatch = StringRegExp($sServer,'(?<=\\\\)([^\\]*)',1)
    $iStart = StringInStr($sServer,'\\') + 2
    $iEnd = StringInStr($sServer,'\',0,1,$iStart)
    If $iStart And $iEnd Then
        $server = StringMid($sServer,$iStart,$iEnd-$iStart)
    EndIf
    $radio1 = GUICtrlCreateRadio("Software Server",35,25)
    GUICtrlCreateInput($server,55,46,150,20)
    $radio2 = GUICtrlCreateRadio("Alternative Server",35,95)
    $server2 = GUICtrlCreateInput("",55,116,150,20)
    $btn = GUICtrlCreateButton("Next",80,160)
    $btn2 = GUICtrlCreateButton("Cancle",120,160)
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $btn
                If $radio1 And BitAND(GUICtrlRead($radio1),$GUI_CHECKED) = $GUI_CHECKED Then
                    $Jserver = $server
                    GUIDelete()
                    MsgBox(0,"",$Jserver)
                    ExitLoop
                ElseIf $radio2 And BitAND(GUICtrlRead($radio2),$GUI_CHECKED) = $GUI_CHECKED Then
                    $Jserver = $server2
                    GUIDelete()
                    MsgBox(0,"Server",$Jserver)
                    ExitLoop
                EndIf
            Case $msg = $btn2
                ExitLoop
        EndSelect
    WEnd
    GUIDelete()
EndFunc

Share this post


Link to post
Share on other sites

$sever2 = GUICtrlCreateInput("", 55, 115, 150, 20)

this is the manually entered server(if the default is not correct)

this is the problem that I am having. what ever I enter here is not returned in the msgbox

ElseIf $radio2 And BitAND(GUICtrlRead($radio2),$GUI_CHECKED) = $GUI_CHECKED Then

$Jserver = $server2

GUIDelete()

MsgBox(0,"Server",$Jserver)

$Jserver is going to be used later on as a variable based on the info gathered from this gui

the else if statement did not help....I actually tried that without any luck

Thanks in advance

Share this post


Link to post
Share on other sites

oh, you need grabbing info from the input box

$Jserver = GuiCtrlRead($server2)

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