> > I know this is totally Off-Topic, but over the 13 years I’ve been
> > on this board, I’ve seen a few off-topic requests for help from this
> > extremely skilled community. Therefore, I thought I would seek help from
> > my fellow ZTree-ers, since I’m pretty sure at least a few of you also
> > use AutoHotKey (AHK).
> >
> > In Excel (2010, but I don’t think the version matters here), I am
> > attempting to automate a string of ~55 keystrokes to be cycled ~1,200
> > times with manual keyboard input required once in the basic cycle.
> > Automating the repeat of the basic cycle is easy, and I don’t need any
> > help with that. I have the basic cycle almost down; my issue is during
> > the pause for keyboard input.
> >
> > While the basic cycle is running, certain index text from an Excel cell
> > is copied to a background clipboard manager I use named Clipboard
> > Recorder. The basic cycle pauses at the display of an Excel dialog box
> > (“Add Scenario” for those who are curious) and waits for input.
> > During the pause for keyboard input, the copied text can be manually
> > pasted from Clipboard Recorder by pressing an ALT key down and holding
> > it, then pressing the Z key once and releasing it quickly to avoid
> > auto-repeating, and then releasing the ALT key. This keystroke sequence
> > does not appear to be in conflict with Excel or any other running
> > program.
> >
> > My problem is that for the life of me, I cannot figure out how to
> > script the ALT-Z sequence in AHK so that the copied text is automatically
> > pasted into the Add Scenario dialog box. I’m pretty sure it’s a
> > variation of the SEND command in AHK, but I’ve tried many variations
> > and none of them work.
> >
> > Does anyone have any ideas how to put this keystone into my macro’s
> > basic cycle?
>
> Doug
>
> The send command would be
> send !z
>
First, sorry for the slow response, but I got fiercely busy in the interim.
Second, thanks very much for the suggestions, Ben. You can see my responses following as I tried almost all of them.
I can send the keystrokes "!z" to the right place in the dialog box, but I can't send the text that those keystrokes invoke when pressed from the keyboard.
> Have you tested sending Alt something to another app?
>
Yes. "^v" (Ctrl-V) succesfully pastes the contents of the clipboard in Excel when the main window has the focus, but it won't paste into the dialog box.
>
> Which window needs to have focus?
>
The "Add Scenario" dialog box in Excel.
> You might need to do this to change focus
> WinActivate [, WinTitle, WinText, ExcludeTitle, ExcludeText]
>
Tried that, it didn't work.
> Are you sending to soon?
> You might need to use WinWait and sleep
>
Tried that too, no luck there either.
>
> Your issue could be that the clipboard manager hooks the keyboard in a
> way that means that the AHK sent keys are not seen by the clipboard
> manager, you might need to use one of the other send* modes.
>
The idea that the clipboard manager hooks the keyboard strikes me as promising line of attack, however, I've not been able to figure out what different send* mode I should use.
> Or switch technique, have a AHK hotkey that starts the cycle at the
> Alt-z point, then one key-press per cycle.
>
Good suggestion, but it won't work. The cycle must start at a specific point.
> Other things you might need to investigate
> KeyWait Alt
> hotkey ~ and $ modifiers
>
> Ben
I got pretty frustrated at this point, and registered with the AHK Forum board and posed my problem in the "Ask For Help" section. No responses yet.
Any other suggestions would be much appreciated!