 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
jonathan2260
Joined: 13 May 2008 Posts: 6
|
Posted: Tue May 13, 2008 6:36 pm Post subject: Copy from clipboard to a variable |
|
|
Hi there.
I would like to know how I could use Autohotkey to grab a piece of information from the screen, in my case from within an email, it's a standard form so the position is alway the same. I imagine have to have the script select the information by double cliking on it and then doing a CTRL+C to copy to the clipboard.
I would then like to find a way to store it into a variable for later use in the script. Any ideas on how I would do this?
Thank You. |
|
| Back to top |
|
 |
sinkfaze
Joined: 19 Mar 2008 Posts: 138
|
Posted: Tue May 13, 2008 7:21 pm Post subject: |
|
|
| Code: | <select data>
Send ^c
ClipWait ; optional
MyVar = %clipboard%
return |
_________________ Have trouble searching the site for information? Try Quick Search for Autohotkey. |
|
| Back to top |
|
 |
Vinthian
Joined: 11 May 2008 Posts: 15 Location: USA
|
|
| Back to top |
|
 |
infogulch
Joined: 27 Mar 2008 Posts: 103 Location: KC, MO
|
Posted: Tue May 13, 2008 7:30 pm Post subject: |
|
|
The clipboard is a built in variable.
An example:
| Code: | #IfWinActive, %YourEmailTitle% ;change this. makes the following hotkey only work when this window is active
^!t:: ;Ctrl+alt+t
oldClip := clipboard ;save your current clipboard data to a variable to set it back later
clipboard = ;clear the clipboard
Send, ^a^c{left} ;select all, copy and remove selection
ClipWait, 1 ;wait up to one second for the clipboard to contain text
VarForClip := clipboard ;assign a variable to the current clipboard contents
clipboard := oldclip ;reset the clipboard to what you had before
MsgBox, %VarForClip%
return |
i suggest using select all instead of double clicking a word, because a word's exact position can change. For example: if you scroll the email a little bit, they send it in a different font, you added a toolbar to the top of your email client, etc. etc. Then you use different commands to uniquely find what you're looking for and pick it out.
Use these to separate the small bit of info you need away from the whole thing:
StringGetPos, OutputVar, InputVar, SearchText [, L#|R#, Offset] ;Retrieves the position of the specified substring within a string..
StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?] ;Replaces the specified substring with a new string.
StringLeft, OutputVar, InputVar, Count ;Retrieves a number of characters from the left or right-hand side of a string.
StringRight, OutputVar, InputVar, Count
StringMid, OutputVar, InputVar, StartChar [, Count , L] ;Retrieves one or more characters from the specified position in a string.
StringTrimLeft, OutputVar, InputVar, Count ;Removes a number of characters from the left or right-hand side of a string.
StringTrimRight, OutputVar, InputVar, Count
StringLen , OutputVar, InputVar ;Retrieves the count of how many characters are in a string.
Loop, Parse , InputVar [, Delimiters, OmitChars] ;Retrieves substrings (fields) from a string, one at a time.
There is also RegEx versions, and function versions of these. E.g. RegExReplace() _________________
 |
|
| Back to top |
|
 |
jonathan2260
Joined: 13 May 2008 Posts: 6
|
Posted: Sun May 25, 2008 1:26 pm Post subject: Thanks for the help |
|
|
A little late on the reply but I finally got the script to do what I wanted it to do and I just had to thank you for the post, it made it easy for me to figure it out once I understood things a little better.
StringGetPos and StringMid made the difference. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|