How to paste image?
How to paste image?
Hi, I have an image on disk which I would frequently like to paste to my documents using a hotkey. How is this possible? Thanks.
Re: How to paste image?
1. copy the image to the clipboard
2. paste the image from clipboard to application using ^v (from keyboard)
there is a script that does step 1, here
http://www.autohotkey.com/board/topic/5 ... clipboard/
2. paste the image from clipboard to application using ^v (from keyboard)
there is a script that does step 1, here
http://www.autohotkey.com/board/topic/5 ... clipboard/
Re: How to paste image?
Thank you! I see it is very complicated, it requires gdi library. No simpler solutions?
Re: How to paste image?
If I understand your question correctly, you have image file somewhere on your hdd and you want that file to be coped to your documents folder. In that case you dont need to use paste, you can use FileCopy command ( http://ahkscript.org/docs/commands/FileCopy.htm ) to copy file from one location to another.
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
Re: How to paste image?
>>No simpler solutions?
open the image in a paint program and copy it (so it goes to the clipboard)
Run the following script and press F1, to store the image to a file (in AHk's clipboard format)
Later, run the script and press F2, to copy the image from the stored file back to the clipboard.
Then press ^v to paste the contents of the clipboard whereever you want.
; store an image from the clipboard to a file
f1::
FileAppend, %ClipboardAll%, my_clip_image.img ; The file extension does not matter.
return
; read an image from a file into the clipboard
f2::
FileRead, Clipboard, *c my_clip_image.img ; Note the use of *c, which must precede the filename.
return
open the image in a paint program and copy it (so it goes to the clipboard)
Run the following script and press F1, to store the image to a file (in AHk's clipboard format)
Later, run the script and press F2, to copy the image from the stored file back to the clipboard.
Then press ^v to paste the contents of the clipboard whereever you want.
; store an image from the clipboard to a file
f1::
FileAppend, %ClipboardAll%, my_clip_image.img ; The file extension does not matter.
return
; read an image from a file into the clipboard
f2::
FileRead, Clipboard, *c my_clip_image.img ; Note the use of *c, which must precede the filename.
return
Re: How to paste image?
Thank you Leefme, I learned something new.
Vasili, My wish was to create a signature (which would include an image) that could be pasted to Word (or other application) using a hotkey.
I understand the main problem is how to directly copy any image from disk to clipboard and that there are no simple functions for doing this.
Vasili, My wish was to create a signature (which would include an image) that could be pasted to Word (or other application) using a hotkey.
I understand the main problem is how to directly copy any image from disk to clipboard and that there are no simple functions for doing this.
- FanaticGuru
- Posts: 1907
- Joined: 30 Sep 2013, 22:25
Re: How to paste image?
This is a good technique to know for easy Microsoft Office automation.m3user wrote:Thank you Leefme, I learned something new.
There are lot of fancy ways to interact with Office but it is sometimes just simpler to get what you want on the clipboard once, then save the clipboard to a file. And from then on, have AHK retrieve the correct file and paste if for you. It could be an email template, signature, Excel table, etc.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: How to paste image?
Some solutions:
- You can record macros in Microsoft Word, it also allows you to assign a hotkey.
- The GDI method mentioned by Leefme. The usage is very simple.
Code: Select all
#Include <Gdip_All> ; http://www.autohotkey.net/~Rseding91/Gdip%20All/Gdip_All.ahk CopyImage("test.jpg") CopyImage(ImageFile) { pToken := Gdip_Startup() Gdip_SetBitmapToClipboard(pBitmap := Gdip_CreateBitmapFromFile(ImageFile)) Gdip_DisposeImage(pBitmap) Gdip_Shutdown(pToken) }
- Set "HTML clipboard"
Code: Select all
; WinClip by Deo: ; -> http://www.autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/ #Include <WinClipAPI> #Include <WinClip> CopyImage("test.jpg") CopyImage(ImageFile) { WinClip.Clear() ; Make sure ImageFile is full path Loop, %ImageFile% ImageFile := A_LoopFileLongPath WinClip.SetHTML( "<IMG src=""" ImageFile """>" ) ; Below two lines might not needed. WinClip.SetFiles( ImageFile ) WinClip.SetBitmap( ImageFile ) }
- Use a command line tool, such as irfanview.
Code: Select all
RunWait, i_view32.exe "c:\test.jpg" /clipcopy /cmdexit
Re: How to paste image?
Thank you tmplinshi, I'll test it and decide between Gdip and WinClip.
Who is online
Users browsing this forum: Bing [Bot], Starker and 284 guests