最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Using AutoHotKey to paste an image already in the clipboard - Stack Overflow

programmeradmin1浏览0评论

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 badge
Add a comment  | 

1 Answer 1

Reset to default 0

You 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

发布评论

评论列表(0)

  1. 暂无评论