Sign in to follow this  
Followers 0
IvanCodin

GUIReadInput doesn't return expected result

5 posts in this topic

I am working on a script to input information for a RAS connection. I input or select the information but do not get the results I expect. I have also placed an if then statement to test for no port selected but am only able to get it working after the case statement is completed. I can't figure out where it's goes in the script to prompt the user with a msgbox and continue the script. I must be missing something very simple but can't get it to run correctly. Thanks for your suggestion!!

CODE
#include <GUIConstants.au3>

; vars

HotKeySet("^x", "GoodBye")

$my_ver = "0.90.1"

$port = "" ; port to null

Global $GUIWidth

Global $GUIHeight

$GUIWidth = 400

$GUIHeight = 200

GUICreate("Connect Network Tool",$GUIWidth,$GUIHeight)

$trackmenu = GuiCtrlCreateContextMenu ()

$aboutitem = GuiCtrlCreateMenuitem ("About",$trackmenu)

GuiCtrlCreateMenuitem ("",$trackmenu)

$exititem = GuiCtrlCreateMenuitem ("Exit",$trackmenu)

$ok_button = GUICtrlCreateButton("OK", 5,20,30)

GuiCtrlCreateLabel("Select RAS Port", 65, 5, 100)

$radio1 = GUICtrlCreateRadio("C1", 80, 20,70)

$radio2 = GUICtrlCreateRadio("C2", 80, 40,70)

$radio3 = GUICtrlCreateRadio("C3", 80, 60,70)

$radio4 = GUICtrlCreateRadio("C4", 80, 80,70)

; fix check box later

; $cb1 = GuiCtrlCreateCheckbox("Clear ARP cache", 200, 80, 100, 30)

; GuiCtrlSetState(-1, $GUI_UNCHECKED)

; $cb1s = GUICtrlRead($cb1)

; INPUT

$rasip = GuiCtrlCreateInput("RAS IP Address", 200, 25, 100, 20)

$tele = GuiCtrlCreateInput("Telephone number", 200, 55, 100, 20)

GUISetState()

While 1

$msg = GuiGetMsg()

If $msg = $exititem Or $msg = -3 Or $msg = -1 Then ExitLoop

If $msg = $aboutitem Then Msgbox(0,"About","Network Connect Version " & $my_ver)

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $ok_button

; continue on

ExitLoop

Case $msg = $radio1

$port = "C1"

Case $msg = $radio2

$port = "C2"

Case $msg = $radio3

$port = "C3"

Case $msg = $radio4

$port = "C4"

EndSelect

WEnd

MsgBox(0, "Info", "Port from Case is " & $port)

; Where does this loop go to catch no port select in the case statement?

; If $port <> "" Then

; continue on

; Else

; MsgBox(0,"Goodbye", "The port was empty!!!", 4)

; Exit

; EndIf

; try to set variables for later use.

$portselected = GUICtrlRead($port)

$rasipinput = GUICtrlRead($rasip)

$teleinput = GUICtrlRead($tele)

Msgbox(0,"Info", "The telephone number is "& GUICtrlRead($tele) & @CRLF & "The RAS IP you entered is "& GUICtrlRead($rasip) & @CRLF & "The port you selected is " & GUICtrlRead($port))

MsgBox(0, "Info", " The port selected is " & $port)

; These return the values to test expected

Msgbox(0,"Info", "The RAS IP returned value is " & $rasipinput)

Msgbox(0,"Info", "readgui RAS IP returned value is " & GUICtrlRead($rasip))

Msgbox(0,"Info", "The telephone # returned value is " & $teleinput)

Msgbox(0,"Info", "readgui telephone # returned value is " & GUICtrlRead($tele))

Msgbox(0,"Info", "The port returned value is " & $port)

Msgbox(0,"Info", "readgui port returned value is " & GUICtrlRead($port))

MsgBox(0, "Info", "Variables set are " & $portselected & " " & $rasipinput & " " & $teleinput)

GUIDelete()

Msgbox(0,"Info", "post gui delete The port returned value is " & $port)

Msgbox(0,"Info", "post gui delete readgui port returned value is " & GUICtrlRead($port))

MsgBox(0, "Info", "post gui delete Variables set are " & $portselected & " " & $rasipinput & " " & $teleinput)

Exit

Func GoodBye()

MsgBox(4096,"", "Goodbye!")

Exit

EndFunc

CC

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I must have misunderstood you response here:

http://www.autoitscript.com/forum/index.ph...rt=#entry479359

I did read the help file and this is where I got the idea. Obviously I dont know the difference between control types. You are obvously talented at writing code and I am not. I understand the concept of a control but where can I find information as to how Autoit uses them? I used other code snippets in the forum to start this script. Looks like I picked bad examples.

Again if you can point me to a place where this is described I give it a try.

Thanks

CC

Edited by IvanCodin

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

He Means.. GUICtrlRead Is For Stuff Like...

$Input = GUICtrlCreateInput ("", 50, 50, 50, 50)
MsgBox (0,"Test", GUICtrlRead ($Input,0)oÝ÷ ØÚ-jëh×6$Input = ('Hello')
MsgBox (0,"Test", GUICtrlRead ($Input,0)oÝ÷ Øà'u.   ©Ã¡8b±«­¢+Ù±½°ÀÌØíYÈô ÌäíQÍÐÌäì¤oÝ÷ Øìµæ9ö®¶­sdvÆö&Âb33cµf ¢b33cµf"Òb33µFW7Bb33²

For Any More Help You Can Add Me On Msn = 'maxell225@hotmail.com' :)

Edited by John2006

Latest Projects :- New & Improved TCP Chat

Share this post


Link to post
Share on other sites

I am working on a script to input information for a RAS connection. I input or select the information but do not get the results I expect. I have also placed an if then statement to test for no port selected but am only able to get it working after the case statement is completed. I can't figure out where it's goes in the script to prompt the user with a msgbox and continue the script. I must be missing something very simple but can't get it to run correctly. Thanks for your suggestion!!

CODE
#include <GUIConstants.au3>

; vars

HotKeySet("^x", "GoodBye")

$my_ver = "0.90.1"

$port = "" ; port to null

Global $GUIWidth

Global $GUIHeight

$GUIWidth = 400

$GUIHeight = 200

GUICreate("Connect Network Tool",$GUIWidth,$GUIHeight)

$trackmenu = GuiCtrlCreateContextMenu ()

$aboutitem = GuiCtrlCreateMenuitem ("About",$trackmenu)

GuiCtrlCreateMenuitem ("",$trackmenu)

$exititem = GuiCtrlCreateMenuitem ("Exit",$trackmenu)

$ok_button = GUICtrlCreateButton("OK", 5,20,30)

GuiCtrlCreateLabel("Select RAS Port", 65, 5, 100)

$radio1 = GUICtrlCreateRadio("C1", 80, 20,70)

$radio2 = GUICtrlCreateRadio("C2", 80, 40,70)

$radio3 = GUICtrlCreateRadio("C3", 80, 60,70)

$radio4 = GUICtrlCreateRadio("C4", 80, 80,70)

; fix check box later

; $cb1 = GuiCtrlCreateCheckbox("Clear ARP cache", 200, 80, 100, 30)

; GuiCtrlSetState(-1, $GUI_UNCHECKED)

; $cb1s = GUICtrlRead($cb1)

; INPUT

$rasip = GuiCtrlCreateInput("RAS IP Address", 200, 25, 100, 20)

$tele = GuiCtrlCreateInput("Telephone number", 200, 55, 100, 20)

GUISetState()

While 1

$msg = GuiGetMsg()

If $msg = $exititem Or $msg = -3 Or $msg = -1 Then ExitLoop

If $msg = $aboutitem Then Msgbox(0,"About","Network Connect Version " & $my_ver)

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $ok_button

; continue on

ExitLoop

Case $msg = $radio1

$port = "C1"

Case $msg = $radio2

$port = "C2"

Case $msg = $radio3

$port = "C3"

Case $msg = $radio4

$port = "C4"

EndSelect

WEnd

MsgBox(0, "Info", "Port from Case is " & $port)

; Where does this loop go to catch no port select in the case statement?

; If $port <> "" Then

; continue on

; Else

; MsgBox(0,"Goodbye", "The port was empty!!!", 4)

; Exit

; EndIf

; try to set variables for later use.

$portselected = GUICtrlRead($port)

$rasipinput = GUICtrlRead($rasip)

$teleinput = GUICtrlRead($tele)

Msgbox(0,"Info", "The telephone number is "& GUICtrlRead($tele) & @CRLF & "The RAS IP you entered is "& GUICtrlRead($rasip) & @CRLF & "The port you selected is " & GUICtrlRead($port))

MsgBox(0, "Info", " The port selected is " & $port)

; These return the values to test expected

Msgbox(0,"Info", "The RAS IP returned value is " & $rasipinput)

Msgbox(0,"Info", "readgui RAS IP returned value is " & GUICtrlRead($rasip))

Msgbox(0,"Info", "The telephone # returned value is " & $teleinput)

Msgbox(0,"Info", "readgui telephone # returned value is " & GUICtrlRead($tele))

Msgbox(0,"Info", "The port returned value is " & $port)

Msgbox(0,"Info", "readgui port returned value is " & GUICtrlRead($port))

MsgBox(0, "Info", "Variables set are " & $portselected & " " & $rasipinput & " " & $teleinput)

GUIDelete()

Msgbox(0,"Info", "post gui delete The port returned value is " & $port)

Msgbox(0,"Info", "post gui delete readgui port returned value is " & GUICtrlRead($port))

MsgBox(0, "Info", "post gui delete Variables set are " & $portselected & " " & $rasipinput & " " & $teleinput)

Exit

Func GoodBye()

MsgBox(4096,"", "Goodbye!")

Exit

EndFunc

CC

I think that what you're confused about is using the value of a variable. It's not like reading a control.

Instead of

$portselected = GUICtrlRead($port)
$rasipinput = GUICtrlRead($rasip)
$teleinput = GUICtrlRead($tele)

you only need

$portselected = $port
$rasipinput = $rasip
$teleinput = $tele

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

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