Jump to content

Basic Question - how do I read from an GUI input field


Recommended Posts

Local $idM80, $idM40, $idM30, $idM20, $idM17, $idM15, $idM12, $idM10, $idAll, $page, $iMsg

    GUICreate("K6TU TimeViewer", 630, 80)

    ; GUICtrlCreateLabel("Please select a band!", 10, 100, 10)
    $idM80 = GUICtrlCreateButton("80M", 10, 10, 50, 20)
    $idM40 = GUICtrlCreateButton("40M", 80, 10, 50, 20)
    $idM30 = GUICtrlCreateButton("30M", 150, 10, 50, 20)
    $idM20 = GUICtrlCreateButton("20M", 220, 10, 50, 20)
    $idM17 = GUICtrlCreateButton("17M", 290, 10, 50, 20)
    $idM15 = GUICtrlCreateButton("15M", 360, 10, 50, 20)
    $idM12 = GUICtrlCreateButton("12M", 430, 10, 50, 20)
    $idM10 = GUICtrlCreateButton("10M", 500, 10, 50, 20)
    $idAll = GUICtrlCreateButton("ALL", 570, 10, 50, 20)
    $UTCTime = GUICtrlCreateInput("UTC= ",10,40,90,20)
    $page = 6

    GUISetState() ; display the GUI

    Do
        $iMsg = GUIGetMsg()

        Select
            Case $iMsg = $idM80
                Run('"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /A page="'& $page &'" "C:\Predictions\UTC_80.pdf"')
            Case $iMsg = $idM40
                Run('"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /A page="'& $page &'" "C:\Predictions\UTC_40.pdf"')
            Case $iMsg = $idM30

First day coding in AutoIt, so a real, true newbie.   In the above code is currently have $page set to 6.  I want to read the numeric value UTC from $UTCTime = GUICtrlCreateInput("UTC= ",10,40,90,20) when a button is pushed into $page, which is used in subsequent Run statements.

How do I get the value of $page from the field?   Basic, I know, but I'm stumped.

Any advice and suggests are greatly appreciated.

Thanks!

Link to comment
Share on other sites

To read that Input, you would use something like -

$InputValue = GUICtrlRead($UTCTime)

 

P.S. Have you tried any of the tutorials? They will help you gain a better grasp of things.

EDIT

Just for reference, Mike originally started asking his questions about this >here.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Yes, I have read a number of the Tutorials.  They are filled with immensely useful information that I do not yet understand.   I will get my head around this eventually.    I've been retired out of IT for a few years and the little grey cells are slow to waken.

Thanks for all your help!

Link to comment
Share on other sites

 

$ReadPage = GUICtrlCreateInput("Page= ",10,40,90,20)
; $page = 6
 
GUISetState() ; display the GUI
 
Do
$iMsg = GUIGetMsg()
 
Select
Case $iMsg = $idM80
; 80M button is clicked
$page = GUICtrlRead($ReadPage)
; read value of page
Run('"C:Program Files (x86)AdobeReader 11.0ReaderAcroRd32.exe" /A page="'& $page &'" "C:PredictionsUTC_80.pdf"')
; get the input page from the PDF file
 
 

I'm just not getting it.   I was thinking(hoping)  that $page = GUICtrlRead($ReadPage) would make $page value the value entered into the Page= field.

Edited by MikeK6MKF
Link to comment
Share on other sites

I'm a bit confused at what you are wanting to do overall.

At the moment, you have set the text value of Page= in your input field, when you create that input.

That means the return by GUICtrlRead($ReadPage) will return that text for $page, unless you have typed or placed some other text in the Input.

You need to be clearer about the whole thing from start to finish.

Page= has no connection to any other value you may have assigned earlier, to the variable $page

In fact, when you read the Input with current code, you are replacing any value, that $page might have had, with whatever is currently in the Input.

Page= is just the text Page=, it is not a placeholder for anything, like a variable would be (i.e. $page).

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

When troubleshooting your code, as suggested MsgBox's displaying variable values, is your best friend.

I'm not sure that you have a grasp of what and how a variable works though. Hence our confusion, and the recommendation that you try the basic tutorials.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

You had the " in the wrong spot
 
You want it to look like this:
C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe /A "page=6" "C:\Predictions\UTC_80.pdf"

 

Try:

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


$lblPageNumber = GUICtrlCreateLabel("Enter Page #:", 10, 20)
$ReadPage = GUICtrlCreateInput("", 10,40,90,20, $ES_NUMBER) ;Numbers Only

$page = GUICtrlRead($ReadPage)
Run('C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe /A "page=' & $page & '" "C:\Predictions\UTC_80.pdf"')
Edited by KenNichols
[topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner!
Link to comment
Share on other sites

Any change that you are thinking of something that would remind me of the old-school GWBASIC: INPUT "ENTER NAME: "; NAME ?

Does this example help? I guess this is what you're trying to do.

$gui = GUICreate("test", 500, 500)

$pageLabel = GUICtrlCreateLabel("enter page:", 10, 10, 100, 20)
$pageInput = GUICtrlCreateInput("default value", 120, 10, 350, 20)

$okButton = GUICtrlCreateButton("OK", 50, 50, 100)

GUISetState()

While 1

    $msg = GUIGetMsg()

    If $msg == $okButton Then
        $contentOfPageInputControl = GUICtrlRead($pageInput)
        MsgBox(0, "result", "content of the $pageInput control: " & $contentOfPageInputControl)
        Exit
    EndIf

    Sleep(10)
WEnd

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

@KenNichols - Well picked up. I hadn't noticed he'd put the double quote in the wrong place.

Should have been before Page= and not after.

A little error in his copying.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Thanks for all your help.   I have this all straightened out now and the script is pretty much doing what I need it to do.  I tried the Auto123 Tutorial and the first one I tried threw a compiler error, so I have this messed up too most likely.

Been retired so long, brain density has set in.

Sorry for the trouble.

Link to comment
Share on other sites

Just as an FYI, there's no need to compile a script to run it. You can run it from SciTE, if that's what you're using as an editor, or you can run the script using the AutoIt3.exe program. You only need to compile when the script is complete and ready to be used on a computer other than where AutoIt is installed.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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