AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Editing Copied text

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Sergio



Joined: 16 Mar 2008
Posts: 25
Location: Brooklyn

PostPosted: Tue Mar 25, 2008 8:03 am    Post subject: Editing Copied text Reply with quote

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
View user's profile Send private message
BoBoĻ
Guest





PostPosted: Tue Mar 25, 2008 10:46 am    Post subject: Reply with quote

StringTrimLeft/-Right
StringMid
FormatTime
A_YYYY/MM/DD
...
Back to top
Sergio



Joined: 16 Mar 2008
Posts: 25
Location: Brooklyn

PostPosted: Tue Mar 25, 2008 10:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
System Monitor



Joined: 09 Mar 2007
Posts: 392
Location: Unknown

PostPosted: Tue Mar 25, 2008 11:27 pm    Post subject: Reply with quote

Code:
Stringtrimright,yourtrimmedvariable,YOURVARIABLE,6

I think that will work Very Happy
_________________
Back to top
View user's profile Send private message Visit poster's website
Sergio



Joined: 16 Mar 2008
Posts: 25
Location: Brooklyn

PostPosted: Thu Mar 27, 2008 8:34 pm    Post subject: Works Reply with quote

Yeah, works like a charm. Thanks man!
_________________
Back to top
View user's profile Send private message
RingDingDing



Joined: 26 Mar 2008
Posts: 12

PostPosted: Fri Mar 28, 2008 4:27 am    Post subject: Reply with quote

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
View user's profile Send private message
RingDingDing



Joined: 26 Mar 2008
Posts: 12

PostPosted: Fri Mar 28, 2008 5:45 am    Post subject: Reply with quote

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
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Fri Mar 28, 2008 8:20 am    Post subject: Reply with quote

Quote:
SubStr (%clipboard%, %pos%, 10)

Code:
SubStr := SubStr(clipboard, pos, 10)
Question
Back to top
View user's profile Send private message
RingDingDing



Joined: 26 Mar 2008
Posts: 12

PostPosted: Fri Mar 28, 2008 9:05 am    Post subject: Reply with quote

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
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Fri Mar 28, 2008 9:12 am    Post subject: Reply with quote

Code:
Haystack = Life: 666 / 1615
RegExMatch(Haystack, "\d+", HP)
MsgBox % HP
Back to top
View user's profile Send private message
RingDingDing



Joined: 26 Mar 2008
Posts: 12

PostPosted: Fri Mar 28, 2008 12:29 pm    Post subject: Reply with quote

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
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Fri Mar 28, 2008 1:23 pm    Post subject: Reply with quote

Code:
Haystack =
(
Life: 1019 / 1700
Life: 666 / 1615
)
RegExMatch(Haystack, "s)Life:.*Life: (\d+)", HP)
MsgBox % HP1
Back to top
View user's profile Send private message
RingDingDing



Joined: 26 Mar 2008
Posts: 12

PostPosted: Fri Mar 28, 2008 1:56 pm    Post subject: Reply with quote

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 Smile

My code is working completely now, I believe I can tweak it as required over time.

Many thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group