Wait on user keystrokes
crystal007
![]()
- Joined: Sep 22, 2010
- Posts: 2
Hello everyone,
I have just started to explore Winautomation and it looks great so far. However, I'm puzzling around to figure out how I can create an action to make the makro wait on a specific user keystroke before it proceeds. Thats what I want to realise:
On first start of the makro it gets date and time and writes it to a file "memo.txt", after that it should wait until the user presses Ctrl + C (on copying text from any active window), write the clipboard content into memo.txt and goes back to the state to wait on user keystrokes Ctrl + C. So as long as the makro runs, every new clipboard content is appended to the already existing content in memo.txt. The purpose is a kind of hidden memo file that I don't have to switch to, paste and save manually every time, but just have to highlight, hit Ctrl+C and its appended to the memo file. (Based on the intermediary example 1, Paste to text file, but with the difference that it does not only run once and then stops, but stays on "standby" so to speak and does that every time again, when something new is copied to the clipboard).
Until date/time it works fine, but I couldn't find this command to wait on keystroke, although I would think that this is a very common and often repeated action that we do countless times a day and is one of the most important to automate. I tried "send keys" with Ctrl + C but don't see any "wait" command other than xx seconds (can't use that since of course I can't know beforehand, how many seconds elapse until the copy action will occur) or process etc. So it doesn't wait but jumps back and forth without pasting clipboard content. I have also tried to put the {Control}({C}) into a variable %hotkeyCopy% and use "If %hotkeyCopy% = true then Get Clipboard text , Write text to file. But doesn't work as well.
So basically I would like to have it do this:
If user hits Ctrl + C then get Clipboard text and write this text into memo.txt (and have it repeat this as long as the makro is running). Does anyone have an idea how I can do this?
Thank you in advance
Sabine
Samantha
![]()
- Joined: Apr 23, 2010
- Posts: 2326
crystal007
![]()
- Joined: Sep 22, 2010
- Posts: 2
Hello Samantha,
Thank you so much for your help and your script.
I did make 3 versions already of my memo makro, but since I wanted to compile it, so it can be used from a USB stick for example, I didn't think on the option with the triggers. Though, actually, if as exe file it can also be started with a hotkey. I also wanted that the date is only written one time, in the first entry of the same day, as it gets quite inconvenient, if for example we paste different text pieces that belong together into the memo and later have to remove all the dates manually. So my first versions write the date/time into the memo, open a display which waits until you copy a text and click OK, then it appends the memo and reopens the display box. Works, but is not really convenient too with the box and always having to click okay.
Now your script is a very beautiful help and inspiration. I have modified it, so it is now writing the date and time the first time that day only, and every other copy/paste action is written without date and time. I have used my very first regular expression for this (by following the regular expression thread and getting Expresso) and am quite excited that it works :)
If you want and for anyone else who wants it, I attach the job below (called it "Memo Butler").
Thaks again
Sabine
Samantha
![]()
- Joined: Apr 23, 2010
- Posts: 2326
rasselas
![]()
- Joined: Oct 21, 2012
- Posts: 2
Hello, I would like to know if there is an answer to the question, "Is there a way to wait on user keystrokes without requiring an intervening dialog window"?
Example, I usually make it a habit that when writing an automation-task to store my existing clipboard text into a variable, so that when the task is finished, it will automatically restore whatever text was pre-existing in my clipboard.
However, some tasks I write will store an intermediate value into the clipboard, and will then wait on me to decide whether that content should be pasted or not... therefore, the task cannot simply overwrite the clipboard (with my original content) until such time as I am sure I no longer need the intermediary value stored in the clipboard (ie., i have pasted or chosen not to paste).
Currently I suppose I would first have to invoke a dialogue window, and then click the ok button, before the program can decide. If it could detect whether I have already pressed ctrl+v then it would know whether it can restore the original contents of the clipboard. (of course that leaves the problem of deciding not to paste...)
Thanks for taking the time to ponder on this.
Rasselas
Samantha
![]()
- Joined: Apr 23, 2010
- Posts: 2326
You could use a Wait for Hotkey Action, to have the system wait for your mark to set of.. I'm attaching a sample script with a part of code that you could paste into yours to get things done!
Hope this helps!

Samantha