| View previous topic :: View next topic |
| Author |
Message |
Sergio
Joined: 16 Mar 2008 Posts: 25 Location: Brooklyn
|
Posted: Tue Mar 25, 2008 8:03 am Post subject: Editing Copied text |
|
|
My old programming is barely coming back to me, but I think the term I'm looking for is shifting a stack? I plan on copying a block of text that is always identical in format: it is a date. IE 02.23.07. I need to delete the last six characters. How do I do this? The inverse is also necessary. On the proposed date (IE 02.23.07), what if I need to delete the first six characters? Eventually this will be used to convert 02.23.07 into 23, February 2007 _________________
 |
|
| Back to top |
|
 |
BoBoĻ Guest
|
Posted: Tue Mar 25, 2008 10:46 am Post subject: |
|
|
StringTrimLeft/-Right
StringMid
FormatTime
A_YYYY/MM/DD
... |
|
| Back to top |
|
 |
Sergio
Joined: 16 Mar 2008 Posts: 25 Location: Brooklyn
|
Posted: Tue Mar 25, 2008 10:25 pm Post subject: |
|
|
Thanks. I've looked into it but I'm having a hard time figuring this out. Please excuse the newbie question. How would I use StringTrimLeft/-Right to delete six characters from the right? _________________
 |
|
| Back to top |
|
 |
System Monitor
Joined: 09 Mar 2007 Posts: 392 Location: Unknown
|
Posted: Tue Mar 25, 2008 11:27 pm Post subject: |
|
|
| Code: | | Stringtrimright,yourtrimmedvariable,YOURVARIABLE,6 |
I think that will work  _________________
 |
|
| Back to top |
|
 |
Sergio
Joined: 16 Mar 2008 Posts: 25 Location: Brooklyn
|
Posted: Thu Mar 27, 2008 8:34 pm Post subject: Works |
|
|
Yeah, works like a charm. Thanks man! _________________
 |
|
| Back to top |
|
 |
RingDingDing
Joined: 26 Mar 2008 Posts: 12
|
Posted: Fri Mar 28, 2008 4:27 am Post subject: |
|
|
This falls somewhere near what I want to do with my clipboard.
There is a string I want to extract from the clipboard, but it is in a different place most times. The string length is variable too, as it is a measure of hitpoints in a game I am playing.
I want to be able to extract the number, ie I need to be able to keep a check on the number represented by 675. As this can be 1,2,3 or 4 digits long, I'm not sure how to go about it.
Life: 675 / 1522
I've been experimenting with StringReplace, but I must admit that I am very very new to all this, and picking out the right expressions to use is mindblowing! |
|
| Back to top |
|
 |
RingDingDing
Joined: 26 Mar 2008 Posts: 12
|
Posted: Fri Mar 28, 2008 5:45 am Post subject: |
|
|
Can anyone see where I am going wrong with this? It might help my understanding of what I am doing. The idea is to grab the text from Google (or any other page), and strip out the string I am looking for (in this case "Search" and the 10 characters after it.
Thanks!
| Code: |
F1::
Run www.google.com
WinWait, Google - Internet Exlorer
Sleep 500
click 780,780
Sleep 500
Send ^a
Sleep 50
Send ^c
Sleep 50
MsgBox, The text is `n%clipboard%
Haystack = %clipboard%
Needle = Search
StringGetPos, pos, Haystack, %Needle%
if pos >= 0
MsgBox, The string was found at position %pos%.
SubStr (%clipboard%, %pos%, 10)
MsgBox, The string is now: %SubStr% |
|
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Fri Mar 28, 2008 8:20 am Post subject: |
|
|
| Quote: | | SubStr (%clipboard%, %pos%, 10) |
| Code: | | SubStr := SubStr(clipboard, pos, 10) |  |
|
| Back to top |
|
 |
RingDingDing
Joined: 26 Mar 2008 Posts: 12
|
Posted: Fri Mar 28, 2008 9:05 am Post subject: |
|
|
AWESOME!
Nearly there now....do you have any suggestions how to reduce the following string to just the first number, regardless of how many digits there are?
ie I want to extract the number 666 in this example.
Life: 666 / 1615
Thanks! |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Fri Mar 28, 2008 9:12 am Post subject: |
|
|
| Code: | Haystack = Life: 666 / 1615
RegExMatch(Haystack, "\d+", HP)
MsgBox % HP |
|
|
| Back to top |
|
 |
RingDingDing
Joined: 26 Mar 2008 Posts: 12
|
Posted: Fri Mar 28, 2008 12:29 pm Post subject: |
|
|
Really going good now, almost got it working perfect.
Just need one more thing sorting and I think I have it done.
When in battle, the Life: xxx / xxx string is displayed twice. Once for the enemy, once for you.
Because your own string is the second one, it doesn't work right.
How do I select the second string?
Really appreciate all this help, I'm coming on great with what I need to achieve! |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Fri Mar 28, 2008 1:23 pm Post subject: |
|
|
| Code: | Haystack =
(
Life: 1019 / 1700
Life: 666 / 1615
)
RegExMatch(Haystack, "s)Life:.*Life: (\d+)", HP)
MsgBox % HP1 |
|
|
| Back to top |
|
 |
RingDingDing
Joined: 26 Mar 2008 Posts: 12
|
Posted: Fri Mar 28, 2008 1:56 pm Post subject: |
|
|
Thanks for that tip Lexikos. I had achieved what I needed with a sloppy method (StringTrimLeft) to remove the offending first string, but I'm sure your code is much more professional
My code is working completely now, I believe I can tweak it as required over time.
Many thanks. |
|
| Back to top |
|
 |
|