I just started using AHK (v. ???) (just DL'ed & installed it yesterday, Sep 29, 2016) My knowledge of coding/scripting is very basic.
I have a couple of basic questions that I hope you can give me a clue :
1. How would I find out which version of AHK I'm using?
2. How would I script 'Edit Mode' in MS-Excel v. 2010? Just sending F2 doesn't seem to work...
Here's the FULL story of my problem:
I am in the process of creating an index of all my recipe collections (mostly all .TXT files) which is quite extensive and a few years old. In the past, I collected recipes that I've gotten mostly from the web. There are no particular recipes, just any that sounded good to me & also a few that came from my wife...
In this process, I started using MS-Excel 2010 since I thought it would be up to the task and I'm familiar enough with it (though, I'm by no means an expert.) My first hurdle in creating this index was the fact that of the 7 binders, none have numbered pages. OK, cleared that hurdle to my satisfaction. Next, entering all those recipe titles... (sigh) I'm afraid all I know is entering them one-by-one, manually.
I started the long & tedious process of entering the data of my collection in Excel. Yes, Excel has a built-in macro function which I tried, but it wouldn't do what I needed, phooey(sp.) Later, I thought AHK should do what I'm needing. After all, I'd used AHK years ago and was quite pleased with it. The only negative thing about it (to me) was the help (actually,lack of) for novices like me, help did exist, but it left a LOT to be desired. This current version, although not perfect, is vastly improved, IMO!
Anyway, I learned how to create a script in this current version of AHK fairly easily. I'll include it below so that someone can tell me how to get it to do what I'm needing:
I'm needing to copy the original recipe title and paste it into the adjacent cell where I can modify it (by cutting the title's last word, backspacing, Home to the 1st character position of the cell, paste the last word back in at this new positition, then add a comma & a space at the end of the pasted word) (I'm sort of creating an easier-to-find filename here.)
Example:
Spicy Fish & Okra Stew Stew, Spicy Fish & Okra
^^^ original title ^^^^^ ^^^^^^ After ^^^^^^^^
^^^ original cell ^^^^^^ ^^^^ Adjacent cell ^^^^^
The script then just moves Excel's cell pointer to the next recipe title's cell. (The easy part)
Trouble is, I can't seem to get this script to work. I THINK it's because I'm not getting into edit cell mode in Excel (usually invoked by pressing F2.) This is why I'm seeking your help. As far as I know, this script SHOULD work, but it doesn't. Can you tell me what's wrong, please?
Incidentally file=Untitled.html][/code], this script follows the same keystrokes (as far as I know) as I would use manually in Excel... I've poured over this script countless times and though I've modified it several times, nothing I've done has worked.
PS
You'll notice a lot of Msgbox commands in this script. They're there only for debugging purposes. I plan on removing them all when I get the script working. Is there a better/easier command for single stepping of the script's execution?
I forgot to mention: The main reason that I thought that sending F2 isn't working is because I don't see any of the cell's text being highlighted, I SHOULD see this, shouldn't I?
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future ; AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed ; and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive Microsoft Excel non-commercial use - Rec Coll Binders tst.xlsx
; Only active in MS Excel "Rec Coll binders tst.xlsx"
;
; Begin hot key Win + z
;
#z::
sendplay ,{f2} ; edit cell
msgbox sendinput 'f2' (edit cell)
;
SetKeyDelay 500
sendplay {end} ; ensure we're at the end of the cell's contents
msgbox sendplay {end} (ensure we're at the end of the cell's contents)
;
SetKeyDelay 500
sendplay {shift} & {home} ; Highlight the cell's entire contents
msgbox sendplay {shift} & {home} (Highlight the cell's entire contents)
;
SetKeyDelay 500
sendplay {control} & c ; copy the highlighted text
msgbox sendplay {control} & c (copy the highlighted text)
;
SetKeyDelay 500
sendplay {enter}
msgbox sendplay {enter} (exit edit mode)
;
SetKeyDelay 500
sendplay {right} ; goto the next cell to the right
SetKeyDelay 500
sendplay {up} ; goto the next cell to the right
msgbox sendplay {right}+DELAY+sendplay {up} (goto next cell on the right)
;
; Adjacent cell copy is pasted
;
SetKeyDelay 500
sendplay {control} & v ; paste the clipboard's contents
msgbox sendplay {control} & v (paste the clipboard's contents)
;
SetKeyDelay 500
sendplay ,{f2} ; edit cell
msgbox sendplay <f2> (edit the new cell's contents)
;
SetKeyDelay 500
sendplay {control} & {left} ;move the cursor one word to the left
sendplay {shift} & {end} ; highlight the last word only
msgbox (highlight the last word only)
;
SetKeyDelay 500
sendplay {control} & x ; delete that word + place it into the clipboard
msgbox sendplay {control} & x (delete last word & place in clipboard)
;
SetKeyDelay 500
sendplay {bs}{home} ; remove the trailing space & position the cursor home
msgbox {bs}{home} (remove the trailing space & position the cursor home)
;
SetKeyDelay 500
sendplay {control} & v,{space} ; Paste clipboard & add comma & space
msgbox {control} & v,{space} (Paste clipboard & add comma & space)
;
SetKeyDelay 500
sendplay {enter}{left} ; position the cell pointer for the next recipe title
msgbox sendplay {enter}{left} (position the cell pointer for the next title)
;
return