How could I paste a photo with a hotkey?

Get help with using AutoHotkey and its commands and hotkeys
willzheng7
Posts: 6
Joined: 09 Feb 2017, 14:38

How could I paste a photo with a hotkey?

Post by willzheng7 » 21 Dec 2017, 09:20

Let's say, I have a photo in "D:\photo\test.png"

When I reply an email, I want to paste this photo in my email with a hotkey "Ctrl + ALT + V"

You help is very much appreciated.

BoBo
Posts: 4113
Joined: 13 May 2014, 17:15

Re: How could I paste a photo with a hotkey?

Post by BoBo » 21 Dec 2017, 09:57

Assuming that you've already copied the image to your clipboard ...

Code: Select all

^!v::Send, ^v
Not tested.

AFAIK it's up to your email clients configuration (eg. "txt" vs "HTML") if you paste the image directly into the mgs' body or you'll end up with an attached file!

User avatar
Delta Pythagorean
Posts: 573
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: How could I paste a photo with a hotkey?

Post by Delta Pythagorean » 21 Dec 2017, 10:34

That's a bit tricky, you'd need to push the file into the clipboard, (Not by Clipboard := File) using GDIP, taking it and then pushing it to your email.

- [AHK].......: 1.1.33.02 Unicode 64-bit
- [OS].........: Windows 10.0.19041
- [GITHUB]...: github.com/DeltaPyth
- [PAYPAL]....: paypal.me/DelPyth
- [DISCORD]..: Tophat Cat // Delta#8888

Remember to use [code]CODE[/code] for your multi-line scripts.
Stay safe, stay inside, and remember to wash your hands for 20 seconds!

FanaticGuru
Posts: 1484
Joined: 30 Sep 2013, 22:25

Re: How could I paste a photo with a hotkey?

Post by FanaticGuru » 21 Dec 2017, 12:55

There is a AHK class that you can download and add to your library that makes working with the clipboard very easy.

https://autohotkey.com/board/topic/7467 ... pulations/

Once you have WinClip you can do this:

Code: Select all

#Include <WinClipAPI>
#Include <WinClip>

!^v::
	WinClip.Clear()
	WinClip.SetBitmap(A_Desktop "\Test\TestPic.jpg")
	WinClip.Paste()
return
That will put a picture from a file into the Windows clipboard and paste it.

You can also use WinClip to put HTML into the clipboard and paste which is very useful for pasting into HTML emails. You can basically create nice templates if you want.

Code: Select all

#Include <WinClipAPI>
#Include <WinClip>

f12::
	WinClip.Clear()
	WinClip.SetText("www.ahkscript.org")
	WinClip.SetHTML("<a href=""http://www.ahkscript.org"">Linky to AHK</a>")
	WinClip.Paste()
return
More examples:

Code: Select all

#Include <WinClipAPI>
#Include <WinClip>

#f10::
	Picture := A_Desktop "\Temp\1024x1024.jpg"
	html=
	(
	<font size="2" face="Calibri" color="black">
	<p>Best Regards,<br>Have a nice day!<br>More Greetings and e-mails and that sort of stuff<br><br>
	<b><font size="2">
	Your Name</b><br>
	<a href="mailto:[email protected]">[email protected]</a><br>
	<img src=%Picture% alt="My picture";">
	)
	WinClip.SetHTML(html)
	WinClip.Paste()
return

; hotstring
::OS::
	WinClip.Clear()
	WinClip.SetText("Best Regards,`nHave a nice day!`nMore Greetings and e-mails and that sort of stuff`n`n")
	WinClip.Paste()
	WinClip.Clear()
	WinClip.SetBitmap(A_Desktop "\Temp\1024x1024.jpg")
	WinClip.Paste()
return
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers

BoBo
Posts: 4113
Joined: 13 May 2014, 17:15

Re: How could I paste a photo with a hotkey?

Post by BoBo » 21 Dec 2017, 13:12

FanaticGuru wrote:There is a AHK class that you can download and add to your library that makes working with the clipboard very easy.

https://autohotkey.com/board/topic/7467 ... pulations/

Once you have WinClip you can do this:

[...]
:o :shock: :wtf: :thumbup:
Thx a lot 8-)

willzheng7
Posts: 6
Joined: 09 Feb 2017, 14:38

Re: How could I paste a photo with a hotkey?

Post by willzheng7 » 21 Dec 2017, 14:18

"You can also use WinClip to put HTML into the clipboard and paste which is very useful for pasting into HTML emails. You can basically create nice templates if you want."

Thank you so much. This is exactly the function that I am looking for. I also want to create nice templates because I am dealing with a lot email everyday. Thank you !!! Thank you !!!!!

FanaticGuru wrote:There is a AHK class that you can download and add to your library that makes working with the clipboard very easy.

https://autohotkey.com/board/topic/7467 ... pulations/

Once you have WinClip you can do this:

Code: Select all

#Include <WinClipAPI>
#Include <WinClip>

!^v::
	WinClip.Clear()
	WinClip.SetBitmap(A_Desktop "\Test\TestPic.jpg")
	WinClip.Paste()
return
That will put a picture from a file into the Windows clipboard and paste it.

You can also use WinClip to put HTML into the clipboard and paste which is very useful for pasting into HTML emails. You can basically create nice templates if you want.

Code: Select all

#Include <WinClipAPI>
#Include <WinClip>

f12::
	WinClip.Clear()
	WinClip.SetText("www.ahkscript.org")
	WinClip.SetHTML("<a href=""http://www.ahkscript.org"">Linky to AHK</a>")
	WinClip.Paste()
return
More examples:

Code: Select all

#Include <WinClipAPI>
#Include <WinClip>

#f10::
	Picture := A_Desktop "\Temp\1024x1024.jpg"
	html=
	(
	<font size="2" face="Calibri" color="black">
	<p>Best Regards,<br>Have a nice day!<br>More Greetings and e-mails and that sort of stuff<br><br>
	<b><font size="2">
	Your Name</b><br>
	<a href="mailto:[email protected]">[email protected]</a><br>
	<img src=%Picture% alt="My picture";">
	)
	WinClip.SetHTML(html)
	WinClip.Paste()
return

; hotstring
::OS::
	WinClip.Clear()
	WinClip.SetText("Best Regards,`nHave a nice day!`nMore Greetings and e-mails and that sort of stuff`n`n")
	WinClip.Paste()
	WinClip.Clear()
	WinClip.SetBitmap(A_Desktop "\Temp\1024x1024.jpg")
	WinClip.Paste()
return
FG

Post Reply

Return to “Ask For Help”