BatMan22 Posted August 25, 2017 Share Posted August 25, 2017 So I have a value copied to the clipboard, it will always be in the format... XXXXXXX-001a XXblahblahXX , is it possible to get Autoit to change the value in the clipboard from -001a to -002a, ect ect ect...? I'm loading samples on a autosampler in the lab I work at and sample names are usually something like 1708543-001a, 1708543-002a, 1708543-003a.. And I would like autoit to copy the highlighted value and change increment the second half of the sample ID.. IE Change 1708543-001a to 1708543-002a then paste it.. ? Is this possible? Help? I've attached an example of what I would like to be able to automate. Link to comment Share on other sites More sharing options...
Andreik Posted August 25, 2017 Share Posted August 25, 2017 ClipPut('XXXXXXX-001a XXblahblahX') ; Put in clipboard a test value ConsoleWrite('Before: ' & ClipGet() & @CRLF) ; Print to console what is in clipboard ClipPut(StringReplace(ClipGet(),'-001a','-002a')) ; Replace -001a with whatever you want and put back in clipboard the replaced string ConsoleWrite('After: ' & ClipGet() & @CRLF) ; Print to console what is in clipboard When the words fail... music speaks. Link to comment Share on other sites More sharing options...
BatMan22 Posted August 26, 2017 Author Share Posted August 26, 2017 (edited) How do I increment that value? Aka.. I need it to paste that value -002a then move cursor down then -003a, ect ect., also thank you for the help Edited August 26, 2017 by BatMan22 Link to comment Share on other sites More sharing options...
aleph01 Posted August 26, 2017 Share Posted August 26, 2017 A For...Next loop could increment. _aleph_ Meds. They're not just for breakfast anymore. Link to comment Share on other sites More sharing options...
BatMan22 Posted August 29, 2017 Author Share Posted August 29, 2017 Ok so.. I have progressed a few steps in the right direction. So basically it copies what I have into memory.. and changes -001a to -002a, and I can probably figure out how to loop that, but how do I get it to continue from whatever the last four of the sample are.. aka what if I start at -010a (next value would be -011a) or if I start at -002c (next value would be 003c)... I just need it to be able to incremeant the sequence for ~40 samples.. I.e. I dont need it to go from -999a to -001b. Thanks and sorry for being a newb Sleep (3000) Send("^c") ConsoleWrite('Before: ' & ClipGet() & @CRLF) ; Print to console what is in clipboard ClipPut(StringReplace(ClipGet(),'-001a','-002a')) ; Replace -001a with whatever you want and put back in clipboard the replaced string ConsoleWrite('After: ' & ClipGet() & @CRLF) ; Print to console what is in clipboard Send("^v") Link to comment Share on other sites More sharing options...
BatMan22 Posted August 30, 2017 Author Share Posted August 30, 2017 Ok so I paid someone and he fixed it for me.. lol. I posted the script below in case someone can use the source code as well. I'm going to start going through the tutorial program. Send("^c") $text = ClipGet() ConsoleWrite('Before: ' & ClipGet() & @CRLF) ; Print to console what is in clipboard $dashPosition = StringInStr($text,"-") ; Locate string position of the dash character $number = StringMid($text, $dashPosition+1,3) ; Extract the number to increment, e.g. "007" out of "1708896-007a s xxxx" $newNumber = StringFormat("%03i", $number + 1) ; Add one to number and format with leading zeros $newText = StringReplace($text, "-" & $number, "-" & $newnumber) ; Replace "-007" with "-008" ClipPut($newText) ; Update clipboard ConsoleWrite('After: ' & ClipGet() & @CRLF) ; Print to console what is in clipboard Send("^v") 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