Jump to content

trim from ControlGetText


erikson
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

  • Moderators

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.

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