Allen Posted September 23, 2006 Share Posted September 23, 2006 Hello everyone. I need some help on how to code my script to analyze what is in the clipboard (got there via Ctrl-Copy), and look for any number with exactly 9 digits in it (an account number). Is there an easy way to do this? Thanks for all your help! Link to comment Share on other sites More sharing options...
The Kandie Man Posted September 23, 2006 Share Posted September 23, 2006 Can you tell what exactly you are copying this stuff from? Is is a web page, a word document, or what? Have you written anything so far, i would like to add to it if you have instead of starting from scratch. The more detail you give us, the better we can make the script. It is hard to make something when you don't have all the facts for what it is supposed to do. "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
cppman Posted September 23, 2006 Share Posted September 23, 2006 maybe something like this: $str = StringSplit(ClipGet(), " ") if (IsArray($str)) Then For $i = 1 to $str[0] if (StringLen($str[$i]) == 9) Then MsgBox(0, "", $str[$i]) Else ContinueLoop EndIf Next Else EndIf Puts any 9 letter words in a message box. Miva OS Project Link to comment Share on other sites More sharing options...
Allen Posted September 23, 2006 Author Share Posted September 23, 2006 Thanks for that code.... well... what I'm trying to do is... automate cancelling people's accounts. So what happens is they send emails, that either I can process or I can't process. If I can process it, I then have to alt-tab which activates the window of another little interface where I then type in the 9 digit account number that is located somewhere in the message (sometimes customers don't provide account numbers, in which case I would reroute to another email pool), then press enter. And i want to be able to just press the NUMPAD1 to press Control-A (to highlight everything), then Control C to copy to clipboard. Then shuffle everything in the clipboard through a string until I find a string with 9 digits. The only little thing I see wrong with the awesome code posted right before this message is that it won't catch if say there are some letters or colon then inbetween is the 9 digit number... Such as asdf123456789asdfgh or :123456789. Hmm,, thanks again for ur great expertise =) Link to comment Share on other sites More sharing options...
cppman Posted September 23, 2006 Share Posted September 23, 2006 Func _DoIt($string) $str = StringSplit($string, " ") For $i = 1 to $str[0] For $j = 32 to 47 $str[$i] = StringReplace($str[$i], Chr($j), "", StringLen($str[$i])) Next For $k = 58 to 255 $str[$i] = StringReplace($str[$i], Chr($k), "", StringLen($str[$i])) Next Next local $ret_string For $i = 1 to $str[0] if (StringLen($str[$i]) == 9) Then Return $str[$i] Else ContinueLoop EndIf Next Return -1 EndFunc ; example $test = _DoIt("t124h532124is 93958 jf349 dks03958") MsgBox(0, "", $test) Hopefully this helps you Miva OS Project Link to comment Share on other sites More sharing options...
CoePSX Posted September 23, 2006 Share Posted September 23, 2006 (edited) The best thing to do is to use StringRegExp. $ClipboardData = ClipGet() $RegExp = StringRegExp ($ClipboardData, "(\d{9})", 1) If IsArray ($RegExp) Then MsgBox (0, "Number", $RegExp[0]) EndIf Edited September 23, 2006 by CoePSX [quote name='Valik' post='301213' date='Jan 31 2007, 10:36 PM']You seem to have a habit of putting things in the wrong place. I feel sorry for any female you attempt to have sex with.[/quote][font="Lucida Sans Unicode"]╔══════════════════════════════╗║░░██░░░░░░░░██░░███░░░████░░░█║║░█░░█░░██░░█░░█░█░░█░█░░░░█░█░║║░█░░░░█░░█░████░███░░░██░░░█░░║║░█░░█░█░░█░█░░░░█░░░░░░░█░█░█░║║░░██░░░██░░░██░░█░░░░███░█░░░█║╚══════════════════════════════╝[/font] Link to comment Share on other sites More sharing options...
Allen Posted September 23, 2006 Author Share Posted September 23, 2006 The best thing to do is to use StringRegExp. $ClipboardData = ClipGet() $RegExp = StringRegExp ($ClipboardData, "(\d{9})", 1) If IsArray ($RegExp) Then MsgBox (0, "Number", $RegExp[0]) EndIf Hmm, that is so awesome ... but one last tiny little problem. I need it to catcH ONLY 9 numbers... so let's say the email has the message along the lines of "Hello. My account number is :12345334342342:." How do I test the entire string for ONLY 9 numbers and no more and no less. If it doesn't find anything, then of course the @Extended will return a 0. Thanks! Link to comment Share on other sites More sharing options...
ce526 Posted November 21, 2011 Share Posted November 21, 2011 (edited) I bet this is been solved already since this thread is 5 years ago... I am just adding this for future reference for whoever visit this page... $ClipBoard = ClipGet() If (StringRegExp($ClipBoard, "^d{9}$")) Then MsgBox("", "ClipBoard", "9 digits is copied to ClipBoard: " & $ClipBoard) Else MsgBox("", "ClipBoard", "ClipBoard is not 9 digits") EndIf Edited November 21, 2011 by ce526 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now