0
votes


I am trying to make a script to allow me to right click on an image and use the context menu to save it as an image at the default location and with the default image name that Word selects. I am trying to reduce a (Right Click -> Button press -> Enter) sequence to just a Ctrl + RClick combo.
Context menu screenshot
Default location and image name

This is what I have right now, which does not work:

^RButton::
MouseClick, right
Sleep, 500
Send, s
Sleep, 500
Send, {Enter}
return

Apologies if I am doing something stupid, I just started using ahk today.

1

1 Answers

1
votes

Try

#IfWinActive ahk_exe WINWORD.EXE ; only if MS Word is the active window

    ^RButton::
        KeyWait, Ctrl, L ; wait for the Control key to be released
        Click right
        WinWait, ahk_class Net UI Tool Window ; Word's context menu
        WinActivate, ahk_class Net UI Tool Window
        WinWaitActive, ahk_class Net UI Tool Window
        Send, s
        WinWait, Save As Picture
        WinActivate, Save As Picture
        WinWaitActive, Save As Picture
        Send, {Enter}
    return

#IfWinActive

https://www.autohotkey.com/docs/commands/_IfWinActive.htm