Jump to content
Szaky

Split String

Recommended Posts

Szaky

Hi, 

i'm a new here, a need some help to split a text for Ex.   " This is a test 10 of 1000 " (without quotes).

What i need is the numbers .. "10" & "1000". The text is not changeing only the numbers . the Script is looping. if pixel color exist then it will show a GUI whit those actual numbers. 

 

 

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
Global $GREEN = 0x00B050
Global $RED = 0xFF0000
Global $get = "[CLASS:Notepad]" ;=====================> Title: Untitled - Notepad


While 1
    Global $color = PixelSearch(1120,455,1140,465,0x00B050) ; 0x00B050 = Green color
If IsArray($color) = True Then show()

WEnd


Func show()
Global $readT = ControlGetText($get,"","Edit1")
Local $hGUI = GUICreate("Example",1200,300,250,2)
GUISetState(@SW_SHOW)

 

;Label 1 : First Digits "10"
        Local $sFont = "Tahoma"
        GUISetFont(70,400, $sFont)
        $lb1 = GUICtrlCreateLabel($readT,2,2,1200,100)
        GUICtrlSetStyle($lb1,$SS_Center)
        GUICtrlSetColor($lb1,$RED)

 

;Label 2 : First Digits "1000"
        Local $sFont = "Tahoma"
        GUISetFont(70, 900, $sFont)
        $lb2 = GUICtrlCreateLabel($readT,2,150,1200,100)
        GUICtrlSetStyle($lb2,$SS_Center)
        GUICtrlSetColor($lb2,$GREEN)


Sleep(5000) ;================================> The Time before the GUI gose down.!
GUIDelete($hGUI)

EndFunc

Share this post


Link to post
Share on other sites
mikell

This means extract the numbers from the string rather than splitting
Use a regular expression for this

#Include <Array.au3>

$str = " This is a test 10 of 1000 "
$res = StringRegExp($str, '\d+', 3)   ; \d+ : one or more digits
 _ArrayDisplay($res)

 

Share this post


Link to post
Share on other sites
Szaky

Hi mikell,

 

it was hard for me to understand where to implement in my script , but at the end i have the result .. 

Thanks for the replay. it's useful & works perfect. 

(Sorry for my bad english expression. i'm from Romania :( )

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

×