There are many times when you need to run a test involving repeating certain keystrokes and mouse clicks on an application. This might be for example as part of testing the robustness of a GUI interface that you just created. You essentially want to make sure that repeated use of the buttons and data entering does not lead to any issue.
To achieve this, you would first start doing this test manually. However, doing it manually will not only have time constraints but will also limit the number of iterations of the test that one would do. To address and overcome such problems, Autohotkey is an excellent tool. This windows tool enables you to automate anything from remembering keystrokes, mouse clicks and replaying them to remapping keys and buttons on your mouse/keyboard.
It comes with an in built recorder which you can use to first record your keystrokes and mouse clicks. The actions can then be saved in a script which when run later would replicate the actions recorded earlier. There is an excellent tutorial on their website for learning about the various features of this tool.
The following video shows how autohotkey can be used to achieve the mouse click and keystroke replication.
- An excel sheet is made and two cells are highlighted with yellow background where the mouse click and keystrokes would happen. Lets call them cell1 and cell2
- AutoScriptWriter which is a recorder that comes installed with Autohotkey is started using <StartMenu-Programs-AutoHotKey>. Once the recorder is started by pressing the red record button on top left, it shows a <Stop> button which can be clicked to stop recording.
- Mouse is clicked on cell1 and a value of 1 is entered in it from the keyboard
- Mouse is clicked on cell2 and a value of 2 is entered in it from the keyboard
- Mouse is clicked on cell1 and a value of 3 is entered in it from the keyboard
- Mouse is clicked on cell2 and a value of 4 is entered in it from the keyboard
- Stop button is pressed to stop recording. All the actions done are converted in to a script by the recorder.
- In this script, the default delay between mouse clicks / keystrokes is generated with a value of 100 which is 100 ms. This is very small for the naked eye to notice and hence is changed to 3000ms or 3s.
- The script is saved on the hard disk. On right clicking the script, there is a <Compile Script> option which when clicked will generate an .exe file
- This .exe file when executed would repeat all the actions that were recorded and hence would again write the values in the cells of the excel sheet. As you can notice in the video, before running the exe file, the cells of the excel sheet are cleared and now on running this script -- they get populated with the values of 1,2,3,4 as we has specified earlier.
Note the the video does not have an associated audio. So I would request you to go through the description given above once -- before going ahead and viewing the video.
Do share your views on the tool.