anystupidassname Posted February 14, 2008 Posted February 14, 2008 (edited) The subject says it all. I'm a noob and I need to place a 12 to 16 character number, which will be mixed in with text and other crap on the clipboard, into a variable to use with the rest of my macro. Any assistance much appreciated. I'm a kinetic learner so an example code snippet would be my favorite :-) Thanks! Edited February 15, 2008 by anystupidassname This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......
Simucal Posted February 14, 2008 Posted February 14, 2008 #include <Array.au3> $sText = "asldkjfsadf1234567890101213dsflkjsdfsdf2!" $aResult = StringRegExp($sText, "\d{12,16}", 1) If IsArray($aResult) Then _ArrayDisplay($aResult) Else MsgBox(0, "Error", "No 12-16 digits found!") EndIf Obviously you'll need to use ClipGet to get the clipboard text. AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Xenobiologist Posted February 14, 2008 Posted February 14, 2008 Hi, or did you mean getting a 12 chars long value from a text? Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
anystupidassname Posted February 14, 2008 Author Posted February 14, 2008 #include <Array.au3> $sText = "asldkjfsadf1234567890101213dsflkjsdfsdf2!" $aResult = StringRegExp($sText, "\d{12,16}", 1) If IsArray($aResult) Then _ArrayDisplay($aResult) Else MsgBox(0, "Error", "No 12-16 digits found!") EndIf Obviously you'll need to use ClipGet to get the clipboard text. Thank you! I think this will work for me. I'll know tomorrow when I have more time to work on it. This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......
anystupidassname Posted February 15, 2008 Author Posted February 15, 2008 #include <Array.au3> $sText = "asldkjfsadf1234567890101213dsflkjsdfsdf2!" $aResult = StringRegExp($sText, "\d{12,16}", 1) If IsArray($aResult) Then _ArrayDisplay($aResult) Else MsgBox(0, "Error", "No 12-16 digits found!") EndIf Obviously you'll need to use ClipGet to get the clipboard text. OK, I suspect my problem is now just a Regex issue. No matter what I've tried, it just goes to the Else msgbox. This is a sample of what needs to be parsed: Document ID: 2007082915561148 Title: 'blah' Web URL: http://piss.off.lou FOD # <Not Available> All I need is the long number but it won't always be in the same place and the long number could very easily be present more than once too. This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......
SpookMeister Posted February 15, 2008 Posted February 15, 2008 This code works for me: #include <Array.au3> $sText = ClipGet() $aResult = StringRegExp($sText, "\d{12,16}", 1) If IsArray($aResult) Then _ArrayDisplay($aResult) Else MsgBox(0, "Error", "No 12-16 digits found!") EndIf I simply highlighted and your sample, pressed CTRL-C, then ran the script [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
ProgAndy Posted February 15, 2008 Posted February 15, 2008 This works too: #include <Array.au3> $sText = "Document ID: 2007082915561148 Title: 'blah'" & @CRLF _ &"Web URL: http://piss.off.lou FOD # <Not Available>" $aResult = StringRegExp($sText, "\d{12,16}", 1) If IsArray($aResult) Then _ArrayDisplay($aResult) Else MsgBox(0, "Error", "No 12-16 digits found!") EndIf *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
anystupidassname Posted February 15, 2008 Author Posted February 15, 2008 OK, thanks. You guys rule. The whole array thing got me confused. I had to convert the array to a string with _ArrayToString. #include <Array.au3> $2 = StringReplace($1," ","") $3 = StringReplace($2,"-","") $4 = StringRegExp($3, "\d{12,16}", 1) $5 = _ArrayToString($4) msgbox(48,"",$5) This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......
Squirrely1 Posted February 15, 2008 Posted February 15, 2008 @anystupidassname - Someone once said that you can never really change your name, but only add to the number of names that you have. Das Häschen benutzt Radar
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