Jump to content

Trouble with read inputbox


 Share

Recommended Posts

sorry for my bad english,

im a newbie in AUTOIT.

i want to make some program,,but i got trouble with read data from inputbox.

here is my code:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Opt("TrayOnEventMode", 1)
;Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("V.1.1", 237, 335, 192, 114)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")

$Label1 = GUICtrlCreateLabel("Time : ", 8, 56, 36, 17)
$Label2 = GUICtrlCreateLabel("Post : ", 8, 98, 34, 17)

$input1 = GUICtrlCreateInput("", 48, 52, 41, 21)
guictrlsetstate($input1,$GUI_DISABLE)
$input2 = GUICtrlCreateInput("", 48, 95, 41, 21)
guictrlsetstate($input2,$GUI_DISABLE)

$Label3 = GUICtrlCreateLabel("Minute", 93, 56, 36, 17)
$Label4 = GUICtrlCreateLabel("Post", 93, 100, 36, 17)
$Label9 = GUICtrlCreateLabel("The Number is =  ", 10, 320, 200, 27)

$Settings = GUICtrlCreateGroup("Settings : ", 0, 32, 137, 89, -1, $WS_EX_TRANSPARENT)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$OR = GUICtrlCreateLabel("OR", 58, 76, 22, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

;;; radio
$Radio1 = GUICtrlCreateRadio("By Time", 0, 8, 57, 17)
$Radio2 = GUICtrlCreateRadio("By Post", 80, 8, 57, 17)

;;TOMBOL start
$Button1 = GUICtrlCreateButton("START", 4, 128, 129, 17)

;;tombol stop
$Button2 = GUICtrlCreateButton("STOP", 4, 152, 129, 17)

;tombol hide
$Button3 = GUICtrlCreateButton("Hide To Tray", 4, 176, 129, 17)


GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    if $nmsg = -3 then Exit
    if $nmsg = $Radio1 then time()
    if $nmsg = $Radio2 then post()
    if $nmsg = $Button1 then Start()
        
WEnd

func Start()
    
    $read1 = GUICtrlRead($input1)
    $read2 = GUICtrlRead($input2)
    if $input1 = True Then 
        GUICtrlSetData($Label9,"The Number in Inputbox1 = " & $read1)
    sleep(20)
    ;EndIf
    Else
    $input2 = True Then 
        GUICtrlSetData($Label9,"The Number in Inputbox1 = " & $read2)
    sleep(20)
        ;MsgBox(0,"",$read2)
    ;EndIf
    EndIf
EndFunc

func post()
    GUICtrlSetState($input2,$GUI_ENABLE)
    guictrlsetstate($input1,$GUI_DISABLE)
EndFunc

func time()
    GUICtrlSetState($input1,$GUI_ENABLE)
    guictrlsetstate($input2,$GUI_DISABLE)
EndFunc

func _quit()
    Exit
EndFunc

anyone can help me to fix this???

i just want to read data from the active inputbox. could be????

thx for the help,

n sorry again for my poor english.

Link to comment
Share on other sites

Hi,

it looks like both your inputs are disabled.

Also, after

$Button1 = GUICtrlCreateButton("START", 4, 128, 129, 17)

you need to add a line like

GUICtrlSetOnEvent($Button1, "Start") when in oneventmode

to tell the script what function to run when the button is clicked.

And the same for the other button [well, not quite the same, but with the button id and function to be called changed!]

Also you dont need the $msg stuff at the end - thats for message loop mode.

Look at the GUI Reference section in the helpfile.

William

[edit] - didn't notice that oneventmode was commented out - ignore above unless you want to use that mode!

Edited by saywell
Link to comment
Share on other sites

hmm...in my mind i want to make the program run like this :

1. when i tick on Radio1 then inputbox1 is enable n inputbox2 is disable

2. when i tick on radio2 then inputbox2 is enable n inputbox1 is disable

3. when radio1 got tick (inputbox1 enable) i want to read data from that inputbox, i press START button n label9 will write the data from inputbox1

4. when radio2 got tick (inputbox2 enable) i want to read data from that inputbox, i press START button too n label9 will write the data from inputbox2

arghhhh.,.,.,im so confuse...pls help me out... :graduated:

Link to comment
Share on other sites

Replace your function with this one, see if that works out.

Func Start()<br>&nbsp;&nbsp;&nbsp; If GUICtrlRead($input1) &lt;&gt; "" Then GUICtrlSetData($Label9,"The Number in Inputbox1 = " &amp; GUICtrlRead($input1))<br>&nbsp;&nbsp;&nbsp; &nbsp;Sleep(20)<br>&nbsp;&nbsp;&nbsp; If GUICtrlRead($input2) &lt;&gt; "" Then GUICtrlSetData($Label9,"The Number in Inputbox2 = " &amp; GUICtrlRead($input2))<br>EndFunc
This suggestion is pretty much the same as JohnOne's, so I would definately suggest you try either. Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

Func Start()
    If GUICtrlRead($input1) <> "" Then GUICtrlSetData($Label9,"The Number in Inputbox1 = " & GUICtrlRead($input1))
     Sleep(20)
    If GUICtrlRead($input2) <> "" Then GUICtrlSetData($Label9,"The Number in Inputbox2 = " & GUICtrlRead($input2))
EndFunc

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

ohhh thx JohnOne n Somdcomputerguy..

ur help so much mean to me....

its work,but just still error little bit.

when i try to put data in $input1 --->label9 read it perfectly, n after i try to enable the $input2--->label9 read perfectly too,but when i try back to read back $Input1,they will not change anymore..so i must close the program :graduated:

but thanks,at least i got a enlightment,.,LOL

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