I often copy an image into the clipboard from within an application (using its own method rather than a screenshot) and I want to setup a keyboard shortcut to open IrfanView and paste the image from the clipboard into IrfanView. How to do I do the Paste side of the operation in AutoHotKey?
I often copy an image into the clipboard from within an application (using its own method rather than a screenshot) and I want to setup a keyboard shortcut to open IrfanView and paste the image from the clipboard into IrfanView. How to do I do the Paste side of the operation in AutoHotKey?
Share Improve this question asked Mar 6 at 22:35 EdwardEdward 1031 bronze badge1 Answer
Reset to default 0You can use this script to open IrfanView whenever you copy an image:
#Requires AutoHotkey v2
#SingleInstance
Persistent
; https://www.autohotkey/docs/v2/lib/OnClipboardChange.htm
; check clipboard:
OnClipboardChange FuncOnClipboardChange
FuncOnClipboardChange(type) {
global
; https://www.autohotkey/board/topic/150291-detect-clipboard-contents-as-text-file-etc/#entry735751
If (type = 1) ; the clipboard contains text or files copied
{
If (DllCall("IsClipboardFormatAvailable", "uint", 15))
Tooltip "file(s) copied"
else
Tooltip "Text copied"
}
else If (type = 2) ; the clipboard contains images
{
Tooltip "image(s) copied"
; If WinActive("ahk_exe program.exe")
{
; Result := MsgBox("Would you like to open IrfanView and paste the image?",, "36")
; If Result = "Yes"
{
Run A_ProgramFiles "\IrfanView\i_view64.exe"
if WinWaitActive("ahk_exe i_view64.exe", , 5)
Send "^v" ;Control + v to paste the image
}
}
}
Sleep 1000
Tooltip
}
EDIT:
Try also this:
#Requires AutoHotkey v2
#SingleInstance
; Press Control + F1 to open IrfanView and paste the image into it:
^F1:: {
Run A_ProgramFiles "\IrfanView\i_view64.exe"
if WinWaitActive("ahk_exe i_view64.exe", , 5)
Send "^v" ;Control + v to paste the image
}
For details see https://www.autohotkey/docs/v2/lib/WinWaitActive.htm