Jump to content
Sign in to follow this  
Vladi243

GUICtrlRead

Recommended Posts

Vladi243

I created a simple GUI with inputbox and button.

The problem is that the value that I put in the inputbox isn't read.

I tried 2 scripts.

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 293, 117, 301, 284)
$Input1 = GUICtrlCreateInput("", 67, 24, 150, 21)
$Button1 = GUICtrlCreateButton("OK", 104, 72, 81, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;Events
GUICtrlSetOnEvent($Button1, "clicked")
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func clicked()
    GUIDelete()
    Run ("C:\Program Files\Mozilla Firefox\firefox.exe")
    Sleep (5000)
    Send ("{TAB 2}")
    $ReadInput1=GUICtrlRead ($Input1) 
    Send ($ReadInput1);Its not working. Sending only the number "0".
EndFunc

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 293, 117, 301, 284)
$Input1 = GUICtrlCreateInput("", 67, 24, 150, 21)
$Button1 = GUICtrlCreateButton("OK", 104, 72, 81, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;Events
GUICtrlSetOnEvent($Button1, "clicked")
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func clicked()
    GUIDelete()
    Run ("C:\Program Files\Mozilla Firefox\firefox.exe")
    Sleep (5000)
    Send ("{TAB 2}")
    Send (GUICtrlRead ($Input1));Its not working. Sending only the number "0".
EndFunc

What's wrong with my script.

Share this post


Link to post
Share on other sites
Kyme

you can read gui if youre Form1 it's close....make it to don't close when you press "Ok" or use IniWrite/IniRead

hope to help you :)

Share this post


Link to post
Share on other sites
Vladi243

OK, I'll try it later.

Thank you.

Share this post


Link to post
Share on other sites
TnTProductions

sorry i found even more errors but now its fixed so here is finished code

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 293, 117, 301, 284)
$Input1 = GUICtrlCreateInput("", 67, 24, 150, 21)
$Button1 = GUICtrlCreateButton("OK", 104, 72, 81, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Select 
        Case $nMsg = $GUI_EVENT_CLOSE
            ExitLoop

    GUIDelete()
    Run ("C:\Program Files\Mozilla Firefox\firefox.exe")
    Sleep (5000)
    Send ("{TAB 2}")
    Case $nMsg = $button1
    $ReadInput1 = GUICtrlRead($Input1)
    Send($ReadInput1);Its not working. Sending only the number "0".
EndSelect
WEnd

P.S add an exit functions its real annoying not being able to exit your script!!! :)

Edited by TnTProductions

"FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"

Share this post


Link to post
Share on other sites
Vladi243

This script isn't working. When I press on OK button there are no reaction. I want that after pressing on OK, it will continue the script.

Share this post


Link to post
Share on other sites
sandin
Vladi243

I'm trying to create a bot that writing and sending commands in the browser instead of me.

The script above is just a simple example, so I can learn how to use with GUICtrlRead(). As I've already said, this function doesn't working for me.

Share this post


Link to post
Share on other sites
sandin

Share this post


Link to post
Share on other sites
enaiman

IMO, your problem is that you're deleting the GUI first and try to read from it after ... and that can't work.

What you can do is: read the value prior to deleting.

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode
Dim $StringToSend
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 293, 117, 301, 284)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitFunc")
$Input1 = GUICtrlCreateInput("", 67, 24, 150, 21)
$Button1 = GUICtrlCreateButton("OK", 104, 72, 81, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;Events
GUICtrlSetOnEvent($Button1, "clicked")
GUISetState()

While 1
    Sleep(200)
WEnd

Func clicked()
    $StringToSend = GUICtrlRead ($Input1)
    MsgBox(0, "Sending to Firefox", $StringToSend)
    GUIDelete()
    Run ("C:\Program Files\Mozilla Firefox\firefox.exe")
    Sleep (5000)
    Send ("{TAB 2}")
    Send ($StringToSend);Its not working. Sending only the number "0".
EndFunc

Func ExitFunc()
    Exit
EndFunc

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Vladi243

Thanks guys!!!

The both scripts is sending my input:).

Share this post


Link to post
Share on other sites
rasim

Vladi243

Don`t mix GUIOnEventMode with GUIGetMsg.

Share this post


Link to post
Share on other sites
Vladi243

Vladi243

Don`t mix GUIOnEventMode with GUIGetMsg.

OK, but why???

Share this post


Link to post
Share on other sites
sandin

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  

×