Sign in to follow this  
Followers 0
erikson

trim from ControlGetText

4 posts in this topic

heloo!

i have a gui with some radio buttons like Key: 1 , Key: 3 etc

i have

GUICtrlSetOnEvent(-1, "getkey")

and

Func getkey()

FileWrite ("c:\test.txt", ControlGetText("","",@GUI_CtrlId) )

EndFunc

in the file c:\test.txt appear the choice that i made from gui window , like Key: 1 or Key: 3

all i whant is to trim " @GUI_CtrlId " to give me the choice i made without "Key: " , like "1" or "3" etc

Share this post


Link to post
Share on other sites



Opt('GUIONEVENTMODE', 1)
$GUI = GUICreate('', 50, 50, -1, -1, 0x80000000)
$B = GUICtrlCreateButton('Key: 1', 0, 0, 50, 50)
GUICtrlSetOnEvent($B, '_EVENTHANDLER')
GUISetState()

While 1
    Sleep(100000)
WEnd

Func _EVENTHANDLER()
    Switch @GUI_CtrlId
        Case $B
            Local $aArray = StringRegExp(ControlGetText('', '', $B), '(?i)key:\s*(.*?)$', 1)
            If IsArray($aArray) Then MsgBox(64, 'Example', 'Found:' & @CR & $aArray[0])
            Exit
    EndSwitch
    Return ''
EndFunc


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

a faster method

$String = ControlGetText("","",@GUI_CtrlId)

$OutPut = StringRight($String, StringInStr($String, "Key: ") + 1)

Share this post


Link to post
Share on other sites

a faster method

$String = ControlGetText("","",@GUI_CtrlId)

$OutPut = StringRight($String, StringInStr($String, "Key: ") + 1)

Not hardly.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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