TSolo315 MturkCrowd
Six years of turking experience

Click and Scroll

Simulate mouse clicks and page scrolling

1

Click


The AHK click command can be used to simulate a mouse click (right or left) at your mouse pointer. Screen coordinates can also be provided to click at the given coordinates. To send a single left click simply use the command click. If you wanted to click twice you would write click 2. To send a right click use click right. To click at specified coordinates use click 100, 100 (or click right 100, 100). The first number is the X coordinate and the second is the Y coordinate. Coordinates are relative to the active window. If you want to click multiple times at the specified coordinates add a click count click 200, 200, 3.

2

Taking Advantage of the Click Command


There are several practical applications for using the click command. The default behaviour of double clicking plain text in a web browser is often to highlight the entire word (tripple clicking will highlight the entire section). You can use this in a script to allow you to copy words or sections by hovering your pointer over them and using a hotkey. Here is an example:


f1::
click 2 ; double click
sendinput ^c ; copy the text
sendinput ^t ; open a new tab
sleep 200 ; short sleep
sendinput ^v ; paste (focus normally defaults to the address bar when a new tab is opened)
sleep 100 ; short sleep
sendinput {enter} ; enter press
return

The default behavior of most browsers when you send a term in the address bar is to search for it using your default search engine. This script will copy the word under your cursor, open a new tab, and search for that word in that tab.

The click command can also be used to make sure a certain part of the page is focused before running the rest of the commands for a given hotkey. Pressing the tab key will focus the next field starting from the last place you clicked so you can use this behavior to control where a tab press will initially focus. You can also use click right to send a right click and then use the up and down keys to navigate the right click context menu.

3

Scrolling


Page scrolling can be simulated using the command click wheelup or click wheeldown. Just like standard click command you can set a number after the wheelup or wheeldown command to determine how far you will scroll: wheeldown 20. Practical uses of scrolling include scrolling down a specified amount after a hotkey runs, or scrolling all the way to the top of the page. An alternate way to send this command is by using sendinput {wheeldown 20}.

4

Practical Example



f2:
click 3 ; tripple click
sendinput ^c ; copy
sendinput ^+{tab} ; control-shift-tab to switch to previous tab
sendinput {tab} ; tab press to jump to next field (like a text input)
sendinput ^v ; paste
sendinput ^{tab} ; control-tab to switch to next tab
click wheeldown 50 ; scroll down 50 clicks
return

A script like this might help in a sitation where you are gathering data from a given website to paste into text fields in a HIT. the f2 hotkey would copy the section under your cursor, switch to the previous tab (the tab with the HIT in it), send a tab press to jump to the next field, paste the info, switch back to the website tab, and finally scroll down the page (ideally to where you would need to grab the next piece of information).

Next Tutorial: Variable Basics