Pages

Showing posts with label Automation. Show all posts
Showing posts with label Automation. Show all posts

2025/09/25

AutoHotkey (FREE) – Hold Down a Mouse Button with a Keyboard Shortcut on Windows 11

I don’t know the reason why people want to do this thing, it might be because of the computer screen is too big to drag something for too long. The script helps, just move the mouse, not holding anything.


I found the script here https://stackoverflow.com/questions/1993003/holding-down-the-left-mouse-button-in-autohotkey


The code is below.


F2::

alt := not alt

if (alt)

{

Click down

}

else

{

Click up

}

Return



Code explanation:

Pressing F2 (FN+F2) will hold down a left mouse button.


Usage: run the code (read how-to below), locate a mouse pointer where you want to drag it or do something else, press F2 then start dragging something. To cancel holding down, click a left click.


How to run the code.

1. Download AutoHotkey from https://www.autohotkey.com/



Click a button ‘Download’.



You will see there are 2 versions, I download both of them because some code can not be run with the old/new version.


Open the downloaded files and follow steps to install apps.


From my memories, you don’t have to open the apps because after installation is done, the apps will run in the background.


2. Copy the code above, open new document of Notepad, paste the code. You can change the first line to F2, F3…


Save it then add the extension .ahk.



To run the code, right click at .ahk file, then click the menu ‘Open’ near the icon ‘AutoHotkey’. (see the picture below)



You can see the script by clicking an arrow at the taskbar.



The code below is for holding down a right click button.


F3::Click % "right " (GetKeyState("RButton") ? "Up" : "Down")


Code explanation:

Pressing F3 (FN+F3) will hold down a right mouse button.


Usage: run the code (read how-to above), locate a mouse pointer where you want to drag it or do something else, press F3 then start dragging or something else. To cancel holding down, press F3 again.


You can change F3 to something else, such as F2,F4…


Important note: for 1st code, to cancel holding, just click a left click button.

For 2nd code, to cancel holding, press F3 again.


I tested 2nd code with Gesturefy (Firefox add-on) by setting a right click button as a target button to be held for performing gestures. It works fine.

 

2025/01/17

TinyTask (FREE) – Macro Recorder – Compile to .EXE on Windows 11

There is no virus alert when I open .exe file that is created by TinyTask that is downloaded from the link I provided. https://tinytask.en.uptodown.com/windows/download

The weak point of this app:

I start and stop recording using a shortcut – Control + Shift + Alt + R.

I compile recording to .EXE file.

I open that .EXE file. Everything is fine, my job is done but the recording button is changed to red at the end.


That means this app is recording, I assume a hotkey -- ‘Control + Shift + Alt + R’ is pressed because I use it for starting and stopping recording.

The workaround is close the app before opening .EXE file


And make sure that every open app or other areas that can be affected doesn’t use ‘Control + Shift + Alt + R’ as a shortcut because it will be pressed (I haven’t tested this situation but I’m pretty sure it will happen.).

The funny thing is if I play a recording using a ‘play’ button in the app’s window, there is no issue.



The test steps – TinyTask 1.50

On: Windows 11 Home

Download: https://tinytask.en.uptodown.com/windows/download

 

1. Go to the link above to download it.


There is no need to install it, just open the downloaded file.


Select hotkey for start/stop recording.


2. If your task requires specific size and position, read my previous post to set size and position of an active window with hotkey. https://windowsfreewareguide.blogspot.com/2025/01/autohotkey-free-change-size-and.html


I pressed hotkey to record but the app’s window was not minimized.

You might want to move it to a corner.


While recording, I pressed hotkey to set size and position of the active window. The result was great. Playing the macro can set the size and position of my target window.

After finish recording, you can save it (extension is .rec)


After saving it, name shows in title of the app’s window.

You can play the current macro.

Remember if you press to record while the app’s window has a title, after recoding finishes then you click to play. What you get is the latest recording but don’t worry what you recorded in the name of app’s window doesn’t disappear, you can click a folder icon to open it.


If you want to save the latest recording, you can save it to a new file.

3. Compiling recording to .EXE file (application) is the best way for me because I can place it at task bar and open it from there.


Click an icon to compile recording. You can see the icon of .EXE file in the picture below.

Right click at it and select ‘Show more options’.


Move a mouse pointer over menu ‘Send To’, then click ‘Desktop’ (create shortcut)


You will have a new shortcut file.


You can drag and place it at the taskbar.

Click to run it whenever you want.


To run it with a shortcut, right click at a shortcut file and select ‘Properties’


Click at 'Shortcut key' box, then press a shortcut.


Click ‘Apply’, then click ‘OK’.


Keep in mind that which shortcut you use to start/stop recording.

I haven’t tested clicking a start/stop button.

Even with a weak point but I think it is still a nice app to use.


The test steps – TinyTask 1.50

On: Windows 11 Home

Download: https://tinytask.en.uptodown.com/windows/download

 

2024/08/06

AutoHotkey (FREE) - Send Actions from Double Pressing a Key for Specific Application

Finally, I have found the code that works.

 

 

The test steps – AutoHotkey 2.0.18

OS: Windows 11 Home

Download: https://www.autohotkey.com/

 

1. Download it from a link above and install.

 

2. The code.

 

#IfWinActive ahk_exe Notepad.exe

$a::

KeyWait,a

KeyWait,a,D T0.04

If ErrorLevel

               Send a

else

               Send x

return

#IfWinActive

 

 

Code explanation

 

Line 1: Notepad.exe is an active app. To get name of active app, read my previous post -- https://windowsfreewareguide.blogspot.com/2024/07/autohotkey-free-send-actions-from.html

 

Line 2: I use one key, in this code is a. If you want to use other letters (b,c,d,e...), just change it.

 

Line 3: replace a after , to your letter.

 

Line 4: replace a after , to your letter.

D T0.04 = waits for 0.04 secs for key a to be pressed down.

 

In this code if I press key a one time, it sends a. If I press key a twice while 'Notepad' is active, it sends x. If you type fast and set D T to D T3, what will happen is when you type 'ab' you'll get 'ba' because it waits for 3 secs then key a will be pressed.

 


Time in D T affects double pressing too. If you set D T to D T0.04 but you double press key a too slow, what you get is aa not x.

 


So you might want to do lots of testing in order to make no mistake.

 

Line 6: replace a to your letter.

 

Line 8: replace x to your action.

 

If you want this script to work on every active application, just delete the first and the last line.

 

3. To run script, read step 2 in my post -- https://windowsfreewareguide.blogspot.com/2024/07/send-key-sequences-after-key-is-held.html

 

4. You can send key combination (Ctrl+x,....) as an action. If you don't want to read the offical manual, you can read my post from a link above.

 

To open an application, replace line 8 with Run "wordpad". In this case 'Wordpad' is launched.

 

More details: https://www.autohotkey.com/docs/v2/howto/RunPrograms.htm

 

The manual says Run command can also be used to open documents, folders and URLs.

 

Not bad for 10-line code that will make my flow faster.

 


The test steps – AutoHotkey 2.0.18

OS: Windows 11 Home

Download: https://www.autohotkey.com/