Let's say, I have a JPG in "D:\photo\FREEWIN.JPG"
When I reply an WHATSAPP, I want to paste this photo in WHATSAPP MESSAGE, with a hotkey "F1"
You help is much appreciated.
note: No Copy, Only paste, by pressing only one key i.e. F1
Thanks
Vikas
one key press, paste picture from the drive to WhatsApp
-
- Posts: 34
- Joined: 03 Jul 2021, 20:28
Re: one key press, paste picture from the drive to WhatsApp
Code: Select all
; This script uses a hotkey to paste an image
#Requires AutoHotkey v1.1.33
image := "d:\photo\FREEWIN.jpg"
If !FileExist(image)
MsgBox 48, Error, File not found.`n`n%image%
F1:: ; F1 = Paste image
Clipboard := ""
setClipboardBitmap(image)
ClipWait 0, WaitForAnyData := True
If ErrorLevel
MsgBox 48, Error, An error occurred while waiting for the clipboard.
Else Send ^v
Return
setClipboardBitmap(Filename) { ; By SKAN on D3AG @ tiny.cc/setclipboardbitmap
Local HBM := RES := OCB := 0, CF_BITMAP := 2
If (HBM := LoadPicture(Filename))
If (HBM := DllCall("CopyImage", "Ptr",HBM, "Int", 0, "Int", 0, "Int", 0, "Int", 8, "Ptr"))
If (OCB := DllCall("OpenClipboard", "Ptr", A_ScriptHwnd))
If DllCall("EmptyClipboard")
RES := DllCall("SetClipboardData", "Int", CF_BITMAP, "Ptr", HBM)
OCB := OCB ? DllCall("CloseClipboard")*0 : 0
HBM := HBM ? DllCall("DeleteObject", "Ptr", HBM)*0 : 0
Return !!RES
}
-
- Posts: 34
- Joined: 03 Jul 2021, 20:28
Re: one key press, paste picture from the drive to WhatsApp
sir, please help us, I am trying to merge 3 script into one, but couldn't do
I have try to merge the below 3 mentioned script into one, namely FA
FA SCRIPT
But it shows error, when we compile it :-
Error: The script contains syntax errors.
Specifically:
Z:\Other computers\My
Laptop\SOLD[A]\ARCHIVE\KNOWLEDGE BASE\IVR-MICROSFOT
TELEPHONE ACTIVATION\IVR_24_O3_16_O1_19_02\FA.ahk (72) :
==> Duplicate function definition.
Specificallm setClipboardBitmap[filename]
Thanks
I have try to merge the below 3 mentioned script into one, namely FA
FA SCRIPT
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoTrayIcon
; This script uses a hotkey to paste an image
#Requires AutoHotkey v1.1.33
image := "D:\TEXT_DATA\ivr1.jpg"
If !FileExist(image)
MsgBox 48, Error, File not found.`n`n%image%
+F1:: ; SHIFT+F1 = Paste image
Clipboard := ""
setClipboardBitmap(image)
ClipWait 0, WaitForAnyData := True
If ErrorLevel
MsgBox 48, Error, An error occurred while waiting for the clipboard.
Else Send ^v
Return
setClipboardBitmap(filename) { ; By SKAN on D3AG @ tiny.cc/setclipboardbitmap
Local HBM := RES := OCB := 0, CF_BITMAP := 2
If (HBM := LoadPicture(Filename))
If (HBM := DllCall("CopyImage", "Ptr",HBM, "Int", 0, "Int", 0, "Int", 0, "Int", 8, "Ptr"))
If (OCB := DllCall("OpenClipboard", "Ptr", A_ScriptHwnd))
If DllCall("EmptyClipboard")
RES := DllCall("SetClipboardData", "Int", CF_BITMAP, "Ptr", HBM)
OCB := OCB ? DllCall("CloseClipboard")*0 : 0
HBM := HBM ? DllCall("DeleteObject", "Ptr", HBM)*0 : 0
Return !!RES
}
return
#NoTrayIcon
; This script uses a hotkey to paste an image
#Requires AutoHotkey v1.1.33
image := "D:\TEXT_DATA\ivr2.jpg"
If !FileExist(image)
MsgBox 48, Error, File not found.`n`n%image%
+F2:: ; SHIFT+F2 = Paste image
Clipboard := ""
setClipboardBitmap(image)
ClipWait 0, WaitForAnyData := True
If ErrorLevel
MsgBox 48, Error, An error occurred while waiting for the clipboard.
Else Send ^v
Return
setClipboardBitmap(filename) { ; By SKAN on D3AG @ tiny.cc/setclipboardbitmap
Local HBM := RES := OCB := 0, CF_BITMAP := 2
If (HBM := LoadPicture(Filename))
If (HBM := DllCall("CopyImage", "Ptr",HBM, "Int", 0, "Int", 0, "Int", 0, "Int", 8, "Ptr"))
If (OCB := DllCall("OpenClipboard", "Ptr", A_ScriptHwnd))
If DllCall("EmptyClipboard")
RES := DllCall("SetClipboardData", "Int", CF_BITMAP, "Ptr", HBM)
OCB := OCB ? DllCall("CloseClipboard")*0 : 0
HBM := HBM ? DllCall("DeleteObject", "Ptr", HBM)*0 : 0
Return !!RES
}
return
#NoTrayIcon
; This script uses a hotkey to paste an image
#Requires AutoHotkey v1.1.33
image := "D:\TEXT_DATA\ivr3.jpg"
If !FileExist(image)
MsgBox 48, Error, File not found.`n`n%image%
+F3:: ; SHIFT+F3 = Paste image
Clipboard := ""
setClipboardBitmap(image)
ClipWait 0, WaitForAnyData := True
If ErrorLevel
MsgBox 48, Error, An error occurred while waiting for the clipboard.
Else Send ^v
Return
setClipboardBitmap(filename) { ; By SKAN on D3AG @ tiny.cc/setclipboardbitmap
Local HBM := RES := OCB := 0, CF_BITMAP := 2
If (HBM := LoadPicture(Filename))
If (HBM := DllCall("CopyImage", "Ptr",HBM, "Int", 0, "Int", 0, "Int", 0, "Int", 8, "Ptr"))
If (OCB := DllCall("OpenClipboard", "Ptr", A_ScriptHwnd))
If DllCall("EmptyClipboard")
RES := DllCall("SetClipboardData", "Int", CF_BITMAP, "Ptr", HBM)
OCB := OCB ? DllCall("CloseClipboard")*0 : 0
HBM := HBM ? DllCall("DeleteObject", "Ptr", HBM)*0 : 0
Return !!RES
}
return
Specifically:
Z:\Other computers\My
Laptop\SOLD[A]\ARCHIVE\KNOWLEDGE BASE\IVR-MICROSFOT
TELEPHONE ACTIVATION\IVR_24_O3_16_O1_19_02\FA.ahk (72) :
==> Duplicate function definition.
Specificallm setClipboardBitmap[filename]
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoTrayIcon
; This script uses a hotkey to paste an image
#Requires AutoHotkey v1.1.33
image := "D:\TEXT_DATA\ivr1.jpg"
If !FileExist(image)
MsgBox 48, Error, File not found.`n`n%image%
+F1:: ; SHIFT+F1 = Paste image
Clipboard := ""
setClipboardBitmap(image)
ClipWait 0, WaitForAnyData := True
If ErrorLevel
MsgBox 48, Error, An error occurred while waiting for the clipboard.
Else Send ^v
Return
setClipboardBitmap(filename) { ; By SKAN on D3AG @ tiny.cc/setclipboardbitmap
Local HBM := RES := OCB := 0, CF_BITMAP := 2
If (HBM := LoadPicture(Filename))
If (HBM := DllCall("CopyImage", "Ptr",HBM, "Int", 0, "Int", 0, "Int", 0, "Int", 8, "Ptr"))
If (OCB := DllCall("OpenClipboard", "Ptr", A_ScriptHwnd))
If DllCall("EmptyClipboard")
RES := DllCall("SetClipboardData", "Int", CF_BITMAP, "Ptr", HBM)
OCB := OCB ? DllCall("CloseClipboard")*0 : 0
HBM := HBM ? DllCall("DeleteObject", "Ptr", HBM)*0 : 0
Return !!RES
}
return
Code: Select all
#NoTrayIcon
; This script uses a hotkey to paste an image
#Requires AutoHotkey v1.1.33
image := "D:\TEXT_DATA\ivr2.jpg"
If !FileExist(image)
MsgBox 48, Error, File not found.`n`n%image%
+F2:: ; SHIFT+F2 = Paste image
Clipboard := ""
setClipboardBitmap(image)
ClipWait 0, WaitForAnyData := True
If ErrorLevel
MsgBox 48, Error, An error occurred while waiting for the clipboard.
Else Send ^v
Return
setClipboardBitmap(filename) { ; By SKAN on D3AG @ tiny.cc/setclipboardbitmap
Local HBM := RES := OCB := 0, CF_BITMAP := 2
If (HBM := LoadPicture(Filename))
If (HBM := DllCall("CopyImage", "Ptr",HBM, "Int", 0, "Int", 0, "Int", 0, "Int", 8, "Ptr"))
If (OCB := DllCall("OpenClipboard", "Ptr", A_ScriptHwnd))
If DllCall("EmptyClipboard")
RES := DllCall("SetClipboardData", "Int", CF_BITMAP, "Ptr", HBM)
OCB := OCB ? DllCall("CloseClipboard")*0 : 0
HBM := HBM ? DllCall("DeleteObject", "Ptr", HBM)*0 : 0
Return !!RES
}
return
Code: Select all
#NoTrayIcon
; This script uses a hotkey to paste an image
#Requires AutoHotkey v1.1.33
image := "D:\TEXT_DATA\ivr3.jpg"
If !FileExist(image)
MsgBox 48, Error, File not found.`n`n%image%
+F3:: ; SHIFT+F3 = Paste image
Clipboard := ""
setClipboardBitmap(image)
ClipWait 0, WaitForAnyData := True
If ErrorLevel
MsgBox 48, Error, An error occurred while waiting for the clipboard.
Else Send ^v
Return
setClipboardBitmap(filename) { ; By SKAN on D3AG @ tiny.cc/setclipboardbitmap
Local HBM := RES := OCB := 0, CF_BITMAP := 2
If (HBM := LoadPicture(Filename))
If (HBM := DllCall("CopyImage", "Ptr",HBM, "Int", 0, "Int", 0, "Int", 0, "Int", 8, "Ptr"))
If (OCB := DllCall("OpenClipboard", "Ptr", A_ScriptHwnd))
If DllCall("EmptyClipboard")
RES := DllCall("SetClipboardData", "Int", CF_BITMAP, "Ptr", HBM)
OCB := OCB ? DllCall("CloseClipboard")*0 : 0
HBM := HBM ? DllCall("DeleteObject", "Ptr", HBM)*0 : 0
Return !!RES
}
return
- Attachments
-
- image.png (16.62 KiB) Viewed 37 times
Re: one key press, paste picture from the drive to WhatsApp
Do not repeat the function definition in your script. You need just one instance of your function definition.
To work with different images, you can define your image path in the hotkey subroutine instead of at the top of the script.
To work with different images, you can define your image path in the hotkey subroutine instead of at the top of the script.
Code: Select all
; This script uses hotkeys to paste an image
#Requires AutoHotkey v1.1.33
image := ["p1", "p2", "p3"]
+F1::
+F2::
+F3::
Clipboard := ""
setClipboardBitmap("D:\photo\" image[SubStr(A_ThisHotkey, 0)] ".png")
ClipWait 0, WaitForAnyData := True
If ErrorLevel
MsgBox 48, Error, An error occurred while waiting for the clipboard.
Else Send ^v
Return
setClipboardBitmap(Filename) { ; By SKAN on D3AG @ tiny.cc/setclipboardbitmap
Local HBM := RES := OCB := 0, CF_BITMAP := 2
If (HBM := LoadPicture(Filename))
If (HBM := DllCall("CopyImage", "Ptr",HBM, "Int", 0, "Int", 0, "Int", 0, "Int", 8, "Ptr"))
If (OCB := DllCall("OpenClipboard", "Ptr", A_ScriptHwnd))
If DllCall("EmptyClipboard")
RES := DllCall("SetClipboardData", "Int", CF_BITMAP, "Ptr", HBM)
OCB := OCB ? DllCall("CloseClipboard")*0 : 0
HBM := HBM ? DllCall("DeleteObject", "Ptr", HBM)*0 : 0
Return !!RES
}