Sign in to follow this  
Followers 0
Zarox

I need help with String Splitting

14 posts in this topic

#1 ·  Posted (edited)

$clipboard = ClipGet()
$balance = StringSplit($clipboard, 'Balance:', 1)

When I do that it cuts it down to

290712 Points
You bet  Points
    
            
    
    
    
    
    
        
        
You can win up to 100 times the amount you bet if you land on ***** *****!

For other winning combination refer to the pay table.   
            
                                        
Home| Download Toolbar| Contact Us| Privacy Policy| Site Map| Terms and Conditions| Advertise On ********| ********Blog| ********Forum
Copyright © 2007 ********l Inc.
All trademarks and registered trademarks appearing on this site are the property of their respective owners.
Said owners do not endorse nor are they affiliated with ********.com or its promotions.

How would I split it into just that first number, 290712.

Thanks,

Zarox

Edited by Zarox

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It can be done many ways but heres an easy one.

ClipPut(Int(ClipGet()))

try that with the text you posted above in your clipboard.

Edited by P5ych0Gigabyte

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

How would I intend on putting that text into my clipboard thruogh the script. I am copying a bigger text and cutting it to that.

Thanks

Zarox

Share this post


Link to post
Share on other sites

helpfile -> "clipput"

~cdkid


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

$aSRE = StringRegExp(ClipGet(), "(?s)(?i)(?m:^|\n)(\d+)\s+Points(?m:$|\s|\r)", 1)
If IsArray($aSRE) Then MsgBox(64, "Points", $aSRE[0]);StringRegExp returns an array if the match is found, be sure to look it up


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

It can be done many ways but heres an easy one.

ClipPut(Int(ClipGet()))

try that with the text you posted above in your clipboard.

All that gets me is the number 1.

Share this post


Link to post
Share on other sites

I am still not getting it with either way that was posted. I am pretty bad at AutoIT, I know I am a loser and suck at coding but please help me out here.

Share this post


Link to post
Share on other sites

I am still not getting it with either way that was posted. I am pretty bad at AutoIT, I know I am a loser and suck at coding but please help me out here.

From the example you posted (the text of what is in the clip board) to the code I posted, I got the result you were requesting.

It's ok to be "bad" at autoit, but if you need more help than the actual answer, you need to iterate yourself on your needs much clearer.


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

From the example you posted (the text of what is in the clip board) to the code I posted, I got the result you were requesting.

It's ok to be "bad" at autoit, but if you need more help than the actual answer, you need to iterate yourself on your needs much clearer.

Alright We'll I tried to use your code, and nothing would come up. I don't want the script to compare the Clipboard with something else. I would like to just make the number 290217 into its own variable. So I can use that in an if, elseif section.

Thanks,

Zarox

Share this post


Link to post
Share on other sites

Alright We'll I tried to use your code, and nothing would come up. I don't want the script to compare the Clipboard with something else. I would like to just make the number 290217 into its own variable. So I can use that in an if, elseif section.

Thanks,

Zarox

Paste only this in SciTE
$aSRE = StringRegExp(ClipGet(), "(?s)(?i)(?m:^|\n)(\d+)\s+Points(?m:$|\s|\r)", 1)
If IsArray($aSRE) Then MsgBox(64, "Points", $aSRE[0]);StringRegExp returns an array if the match is found, be sure to look it up

Now Copy the below to your clip board (right click on all the text in the box and click copy):

290712 Points
You bet  Points
    
            
    
    
    
    
    
        
        
You can win up to 100 times the amount you bet if you land on ***** *****!

For other winning combination refer to the pay table.    
            
                                        
Home| Download Toolbar| Contact Us| Privacy Policy| Site Map| Terms and Conditions| Advertise On ********| ********Blog| ********Forum
Copyright © 2007 ********l Inc.
All trademarks and registered trademarks appearing on this site are the property of their respective owners.
Said owners do not endorse nor are they affiliated with ********.com or its promotions.

Now click F5 in SciTE... You'll see it gives you exactly what you asked for.

How you are using it in your own script is a mystery only you can provide the answer to us on.


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

Thanks for the help. I know that step works now, I just couldn't understand.

1WinActivate("Mozilla Firefox", "")
2Send("^a")
3Send("^c")
4$test = ClipGet()
5$test2 = StringSplit( $test, 'Balance:', 1 )
6ClipPut($test2) 
7$aSRE = StringRegExp(ClipGet(), "(?s)(?i)(?m:^|\n)(\d+)\s+Points(?m:$|\s|\r)", 1)
8If IsArray($aSRE) Then MsgBox(64, "Points", $aSRE[0])

Alright this isn't my whole script just a test to get it working.

1. Selects the Firefox Window

2. Selects All

3. Copies All

4. Makes $test become the clipboard

5. Splits $test into the test I have posted before

6. How do I do this?

7. Your code

8. Your code

Nothing comes up I am sure I have the 6th line wrong, I am just not sure how to do it.

Thanks,

Zarox

Share this post


Link to post
Share on other sites

;Based on your example only:

Opt("WinTitleMatchMode", 2)
Global $sTitle = "Mozilla Firefox", $hWnd = WinGetHandle($sTitle)
Global $sClipText, $aSplit, $sHoldOutput, $aSRE
;1
If WinExists($hWnd) And Not WinActive($hWnd) Then WinActivate($hWnd)
;2
Send("^a");I'd probably try and see if ControlSend() worked here
;3
Send("^c");Same as above with ControlSend... You could also combine the two I believe
;4
$sClipText = ClipGet()
;5
If StringInStr($sClipText, "Balance:") Then;Let's make sure that Balance is even in there
;6
    $aSplit = StringSplit($sClipText, "Balance:", 1)
    For $iCC = 1 To UBound($aSplit) - 1;Loop through the array created
;7
        $aSRE = StringRegExp($aSplit[$iCC], "(?s)(?i)(?m:^|\n)(\d+)\s+Points(?m:$|\s|\r)", 1);Regexp the split array string
;8
        If IsArray($aSRE) Then ;If we found what we are looking for
            $sHoldOutput = $aSRE[0]
            ExitLoop
        EndIf
    Next
Else
    MsgBox(16, "Error", "Balance: wasn't found.")
    Exit
EndIf

If $sHoldOutput <> "" Then 
    MsgBox(64, "Found", "The found output was: " & $sHoldOutput)
Else
    MsgBox(16, "Error", "We found no Points.")
EndIf


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

#13 ·  Posted (edited)

I'm curious if this one works though, maybe getting rid of StringSplit() all together:

;Based on your example only:

Opt("WinTitleMatchMode", 2)
Global $sTitle = "Mozilla Firefox", $hWnd = WinGetHandle($sTitle)
Global $sHoldOutput, $aSRE
;1
If WinExists($hWnd) And Not WinActive($hWnd) Then WinActivate($hWnd)
;2
Send("^a");I'd probably try and see if ControlSend() worked here
;3
Send("^c");Same as above with ControlSend... You could also combine the two I believe
$aSRE = StringRegExp(ClipGet(), "(?s)(?i)Balance\:\s*(\d+)\s+Points", 3)
If IsArray($aSRE) Then 
    $sHoldOutput = $aSRE[0]
Else
    MsgBox(16, "Error", "Balance: wasn't found.")
    Exit
EndIf

If $sHoldOutput <> "" Then 
    MsgBox(64, "Found", "The found output was: " & $sHoldOutput)
Else
    MsgBox(16, "Error", "We found no Points.")
EndIf
From your example, it looks like you are trying to get the string between two things.

Edit:

Got rid of StringBetween, not really what you want when it's number specific I think.

Edited by SmOke_N

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

The bottom one didn't work but the top did.

Thank you very much,

Zarox

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