Sign in to follow this  
Followers 0
keozen

Help with Form (likley n00b question)

6 posts in this topic

Ok, firstly I apologise if I'm being stupid. I only discovered AutoIT 2 hours ago and am trying to jump into the deep end already.

The problem I'm having is with reading the contents of input boxes as strings.

Basically (in the below code) I want to be able to (eventually) read each seperate text box as a seperate string. Then, when I press the "Update Prices" button the program will take the numbers inputted into the boxes and input them into my work's system (leaving the boxes populated with the data so I can just change one or two boxes, then do it again, etc).

I'm trying to get it working with just one field for the moment (pasting into notepad) to try and figure out how I do it (If I can get that working I can finish it myself from there). I can get it to read the initial contents of the input fields and send them to notepad, but if I change the value it still sends that initial value.

Help!

Ohh, and 2nd problem, why does it not close the window when I click "x"?

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        Matt Dyson <keo@keozen.com>
;
; Script Function:
;   To save time at work
;
; ----------------------------------------------------------------------------

; Script Start

; GUI
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
GuiCreate("Price Ammendment Time Saver", 460, 270)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)
GUISetState ()  

; INPUT
GuiCtrlCreateLabel("Cloth Code:", 5, 10)
$pr1 = GuiCtrlCreateInput("test", 65, 5, 130, 20)
$prodcode = GUICtrlRead($pr1)

;Column 1 Header
GuiCtrlCreateInput("100.00", 5, 40, 50, 20)
;Column 1 (in couples)
GuiCtrlCreateInput("100.00", 5, 65, 50, 20)
GuiCtrlCreateInput("100.00", 60, 65, 50, 20)
GuiCtrlCreateInput("100.00", 5, 90, 50, 20)
GuiCtrlCreateInput("100.00", 60, 90, 50, 20)
GuiCtrlCreateInput("100.00", 5, 115, 50, 20)
GuiCtrlCreateInput("100.00", 60, 115, 50, 20)
GuiCtrlCreateInput("100.00", 5, 140, 50, 20)
GuiCtrlCreateInput("100.00", 60, 140, 50, 20)
GuiCtrlCreateInput("100.00", 5, 165, 50, 20)
GuiCtrlCreateInput("100.00", 60, 165, 50, 20)

;Column 2 Header
GuiCtrlCreateInput("100.00", 120, 40, 50, 20)
;Column 2 (in couples)
GuiCtrlCreateInput("100.00", 120, 65, 50, 20)
GuiCtrlCreateInput("100.00", 175, 65, 50, 20)
GuiCtrlCreateInput("100.00", 120, 90, 50, 20)
GuiCtrlCreateInput("100.00", 175, 90, 50, 20)
GuiCtrlCreateInput("100.00", 120, 115, 50, 20)
GuiCtrlCreateInput("100.00", 175, 115, 50, 20)
GuiCtrlCreateInput("100.00", 120, 140, 50, 20)
GuiCtrlCreateInput("100.00", 175, 140, 50, 20)
GuiCtrlCreateInput("100.00", 120, 165, 50, 20)
GuiCtrlCreateInput("100.00", 175, 165, 50, 20)

;Column 3 Header
GuiCtrlCreateInput("100.00", 235, 40, 50, 20)
;Column 3 (in couples)
GuiCtrlCreateInput("100.00", 235, 65, 50, 20)
GuiCtrlCreateInput("100.00", 290, 65, 50, 20)
GuiCtrlCreateInput("100.00", 235, 90, 50, 20)
GuiCtrlCreateInput("100.00", 290, 90, 50, 20)
GuiCtrlCreateInput("100.00", 235, 115, 50, 20)
GuiCtrlCreateInput("100.00", 290, 115, 50, 20)
GuiCtrlCreateInput("100.00", 235, 140, 50, 20)
GuiCtrlCreateInput("100.00", 290, 140, 50, 20)
GuiCtrlCreateInput("100.00", 235, 165, 50, 20)
GuiCtrlCreateInput("100.00", 290, 165, 50, 20)

;Column 4 Header
GuiCtrlCreateInput("100.00", 350, 40, 50, 20)
;Column 4 (in couples)
GuiCtrlCreateInput("100.00", 405, 65, 50, 20)
GuiCtrlCreateInput("100.00", 350, 65, 50, 20)
GuiCtrlCreateInput("100.00", 405, 90, 50, 20)
GuiCtrlCreateInput("100.00", 350, 90, 50, 20)
GuiCtrlCreateInput("100.00", 405, 115, 50, 20)
GuiCtrlCreateInput("100.00", 350, 115, 50, 20)
GuiCtrlCreateInput("100.00", 405, 140, 50, 20)
GuiCtrlCreateInput("100.00", 350, 140, 50, 20)
GuiCtrlCreateInput("100.00", 405, 165, 50, 20)
GuiCtrlCreateInput("100.00", 350, 165, 50, 20)


; PROGRESS
GuiCtrlCreateProgress(30, 230, 400, 20)
GuiCtrlSetData(-1, 0)
GuiCtrlCreateLabel("Program by Matt to save tedious mind numbing time wasting.", 85, 250)

; BUTTON
$start = GuiCtrlCreateButton("Update Prices", 180, 200, 100, 20)
GUICtrlSetOnEvent(-1, "startpressed")

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Func startpressed()
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send($prodcode)
EndFunc

Share this post


Link to post
Share on other sites



1

Opt("GUIOnEventMode", 1) this is event mode so $msg = GUIGetMsg() doesnt work well together

2

you need to read the input "after" the user has placed info in it

in your function you need

$prodcode = GUICtrlRead($pr1)

Send($prodcode)

you may need to place $prodcode as a global variable

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

1

Opt("GUIOnEventMode", 1) this is event mode so $msg = GUIGetMsg() doesnt work well together

2

you need to read the input "after" the user has placed info in it

in your function you need

$prodcode = GUICtrlRead($pr1)

Send($prodcode)

you may need to place $prodcode as a global variable

8)

Ok, the reading of the string now works ( Thank-You! ).

Just the exit problem now (Your point 1). Is there any work around for this? Or if all else fails is there any way to make an "Exit" button (if so how).

Keozen the n00b says thanks again!

Share this post


Link to post
Share on other sites

I shortened down the code for all the inputs to this:

Global $Left[9] = [0, 5, 60, 120, 175, 235, 290, 350, 405]

For $i = 1 To 8
    If Mod ($i, 2) = 1 Then GUICtrlCreateInput ("100.00", $Left[$i], 40, 50, 20)
    For $j = 1 To 5
        GuiCtrlCreateInput("100.00", $Left[$i], 65 + ($j-1)*25, 50, 20)
    Next
Next

Of course, you're going to want to store those in an array so that you can access them later. But you can figure that out yourself.

Share this post


Link to post
Share on other sites

Thank-You everyone. I now have the full basics working and it is closeable. All I need to do now is knuckle down and write the input function so that it will put everything I type into my work system. Should be easy, just time consuming.

Thanks again all!

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