Sign in to follow this  
Followers 0
ktvegas

Pulling the text value from a control

3 posts in this topic

Hi guys.

I am still very new but am trying my best to learn autoit. I have a piece of software on my system which contains a text box with a set list of words that appear depending on which alarm has been triggered (or blank in the case of no alarm)

When I move the mouse over this box using the auto-it window it has a ClassNameNN and Control ID and the text is listed when text is visible in the window.

The ClassNameNN is: Static1

Is there a way for me to monitor this and basically say (pardon my syntax)

If Static1 = "Entry" then $alarm="Entry"

Sorry for the lack of elegance in my description - hope this enough for someone to get the gist and help me.

Thanks!

Share this post


Link to post
Share on other sites



You should be able to use ControlGetText(), to read the edit control, and store it in a variable. The variable can be checked for your alarm code. The script could check this, on a periodical basis.

Share this post


Link to post
Share on other sites

Quick example:

dim $static1,$alarm
AdlibEnable("check")

#include <GUIConstants.au3>

GUICreate("My GUI", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput ( "", 10,  5, 300, 20)
GUICtrlSetState(-1,$GUI_ACCEPTFILES)
GUICtrlCreateInput ("", 10,  35, 300, 20)  ; will not accept drag&drop files
$btn = GUICtrlCreateButton ("Ok", 40,  75, 60, 20)

GUISetState () 

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
           Case $msg = $btn
               exitloop
       EndSelect
Wend

MsgBox (4096, "drag drop file", GUICtrlRead($file))




func check()
    $static1=controlgettext("My GUI","","Edit1")
    If $Static1 = "Entry" then $alarm="Entry"
    tooltip("text is:" & $static1 & @crlf & "alarm test=" & $alarm,0,0)
EndFunc

Just don't expect this to work within the same script if you use inputbox, as input box stops execution until the box is closed.

ex:

AdlibEnable("timer")
sleep(3000); it will count for 3 seconds
InputBox("test","did the timer in the upper left corner stop?"); it will not count while this is up
sleep(3000); I have it count again after clicked


func timer()
    tooltip(@sec,0,0)
EndFunc

AutoIt3, the MACGYVER Pocket Knife for computers.

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