Sign in to follow this  
Followers 0
EX10TION

taking integer values only from clipboard

8 posts in this topic

just need help to extract integers from this:

$speed = _ClipBoard_GetData()

so if the clipboard had "kijs123ki8 9 asd3" speed will = 123893

thanks

Share this post


Link to post
Share on other sites



#include <Array.au3>

ClipPut('lolol12ll12')
$speed = StringRegExp(ClipGet(), '[0-9]', 3)
If Not @error Then
    MsgBox(0, '', _ArrayToString($speed, ''))
Else
    MsgBox(0, '', 'No numbers found')
EndIf

Share this post


Link to post
Share on other sites

just need help to extract integers from this:

so if the clipboard had "kijs123ki8 9 asd3" speed will = 123893

thanks

$s = "kijs123ki8 9 asd3" 
;speed will = 123893
$speed = StringRegExpReplace($s,"[^0-9]","")
ConsoleWrite( $speed & @CRLF)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

just need help to extract integers from this:

so if the clipboard had "kijs123ki8 9 asd3" speed will = 123893

thanks

My suggestion would be to iterate through the string 1 character at a time and if you hit a number store that in a temp variable. Once the process complets you will have your number.

Share this post


Link to post
Share on other sites

$s = "kijs123ki8 9 asd3" 
;speed will = 123893
$speed = StringRegExpReplace($s,"[^0-9]","")
ConsoleWrite( $speed & @CRLF)
better way than mine, I forgot the ''^'' xD

Share this post


Link to post
Share on other sites

thanks for the fast reply dudes... and it worked out ^^

Share this post


Link to post
Share on other sites

uhm okay i forgot about the decimal point

my program copies something like this

text text text 61.2384 text

and i need that decimal point.. :)

Share this post


Link to post
Share on other sites

nvm... figured it out lol...

$speed = StringRegExpReplace($s,"[^0-9.]","")

u just add it after the 9 :)

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