Macro hotkey for "Save Image As..." in Firefox?

6,140

You will have to use The Key History in AutoHotKey to find out the ScanCode or keyname of your G4 key to launch this. Alternatively, you could map the G4 key internally to e.g. CtrlAltWinF12 and use the 2nd hotkey option.
The script will only execute when Firefox is active. It will Launch the rightClick menu, then send v, wait for the save as window and click Enter.

#SingleInstance Force
#installKeybdHook
#Persistent

#IfWinActive, ahk_class MozillaWindowClass
SC123::  ; or ^!#F12:: , select one of the two options
    Send,{RButton}
    Sleep, 30
    Send, v
    WinWaitActive, Save Image
    ControlSend, Button1, {Space} , Save Image
Return
#IfWinActive

Find the scancode:

Right Click on AutoHotKey Icon. Select Open, Type Ctrlk, hit G4, then F5 to refresh the page and see the scancode for G4 towards the bottom.


In AutoHotKey you can define hotkeys in multiple ways. Examples:

a::Send, Hello World!

When you press a it will send "Hello World" to whatever is active on your screen right then.

F12::Send, Hello World! 

Same but now for the F12 key

^!#F12::Send, Hello World! 

Same but now for the Ctrl+Alt+Win+F12 key combination

F1::Send, {F12}

Would remap your F1 key into the behaviour of the F12 key

SC058::Send, Test 

Uses ScanCode 058 (is the F12 key) to send "Test".

:*:ahk::AutoHotKey 

Expands abc into the word AutoHotKey.

In your situation, you will have to decide which hotkey combination will trigger the script.

Here is some documentation:
http://www.autohotkey.com/docs/KeyList.htm
http://www.autohotkey.com/docs/Hotkeys.htm

Oh, übrigens, the double :: separates the hotkey from the action and the ; is the comment separator. Grüsse.

Share:
6,140

Related videos on Youtube

Wuschelbeutel Kartoffelhuhn
Author by

Wuschelbeutel Kartoffelhuhn

Updated on November 23, 2022

Comments

  • Wuschelbeutel Kartoffelhuhn
    Wuschelbeutel Kartoffelhuhn over 1 year

    Relevant PC info:

    • Windows 7 64bit
    • Firefox (latest)
    • Logitech g710+ Keyboard with Logitech Gaming software

    Right now, I have to:

    1. Hover over an image
    2. right-click
    3. Click "Save Image As.."
    4. Click "Save" on the explorer save window (and potentially go to desktop)

    I instead want to be able to:

    1. Hover over an image
    2. Press the G4 button on my g710+ keyboard

    My first choice would be a Firefox extension, followed by a Lua script (that's what Logitech Gaming Software allows you to use), followed by AutoIt (I can code up simple things), followed by Autohotkey (never used it before and not installed).

    In the latter three cases I obviously don't expect code. My intention is only to find out if there is a Firefox extension out there, or a simpler solution that I haven't thought of.

  • Wuschelbeutel Kartoffelhuhn
    Wuschelbeutel Kartoffelhuhn about 11 years
    Thanks for your answer. What does the line: "SC123:: ; or ^!#F12:: , select one of the two options" do? I have never seen autohotkey code before so I'm just curious what double colon means and the semicolon