I use AHK and Excel all day for my profession (pricing analyst for a large retail computer site) and I have some pointers that might help/clear some stuff up. Or not, just my $.02
Code:
; jump to excel
WinActivate Microsoft Excel - Book1
It's ok to change this to:
Code:
WinActivate Microsoft Excel
This way the title doesn't need to say "Book1" so you can use it in any Excel document. But for more preciseness, use this:
Code:
IfWinExist ahk_class XLMAIN
{
WinActivate
WinWaitActive ahk_class XLMAIN
}
else
{
msgbox Excel not running.`r`nStopping command.
return 1
}
The above code uses Microsoft Excel's class name, instead of it's Window Title text to activate it.
The same thing can be used with Word as well so instead of using:
Code:
WinActivate Microsoft Word - Document1
you can use:
Code:
WinActivate Microsoft Word
to use word document's not named "Document1".
When outputting the contents of the clipboard, I've found that using:
Code:
SendInput %clipboard%
is much faster than sending the keystroke to paste it:
Code:
Send, ^v
If you're going to add a return after outputting a variable like this:
Code:
; for word add a return at the end to get a new line
Send, {Return}
leaving the CRLF (`r`n) on the end of the data copied from Excel will output a return automatically so the Sending of a {Return} character is unnecessary. Although, I admit, sometimes I like to code scripts the less efficient way sometimes just so when I come back to the code later on, I can see that there's a {Return} getting sent for a reason.
Also, I think Pallie forgot a
Code:
Return
after his loop ending.
Pallie wrote:
To start with it looked daunting, the tuturial starts at too an advanced stage - it assumes you know too much. But the bit that is actually missing is only a tiny bit to explain how it fits together.
I think you'll have this with any scripting language, and yes, sometimes it can be frustrating trying to learn something new from scratch.
Just remember, most all programming languages (AHK included) use different commands and syntax to do everything. This is why it's important to understand the act of programming, what it is, and how to do it. It is at that point that you can start to learn a new programming language, such as AHK.
Here are some common questions about programming answered:
http://www.guidetoprogramming.com/main_site_conent/site_content/
_________________
My AutoHotKey.com username has changed to
GeekyAdam