Page 1 of 1
how to store screenshot in a variable, then paste it later?
Posted: 11 May 2024, 09:14
by alawsareps
Something like this:
Code: Select all
f1:: {
send("{printscreen}")
screenshot := A_Screenshot
}
f3:: {
;----- PASTE SCREENSHOT
send(screenshot)
}
Re: how to store screenshot in a variable, then paste it later?
Posted: 11 May 2024, 09:50
by WarlordAkamu67
Depending on what you really want, you may be able to send printscreen. Another option is to use a library such as
ImagePut by iseahound.
Here is GitHub documentation that shows how to use it.
Re: how to store screenshot in a variable, then paste it later?
Posted: 11 May 2024, 10:02
by xMaxrayx
idk if autohotkey support binary data as variable like python, as I know it's just straight string type variables
if you want use python you can do this (if the screenshot saved in clipboard)
Code: Select all
clipboard_image = ImageGrab.grabclipboard()
you need to import PIL, then you can have some libraries if you want edit it.
then if you want send the image isn't that easy with just line you need to write which format-type for win clipboard
https://learn.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats
you can also, register a new type like 'PNG' but it wont be accepted to all software
I think you can use more than one (clipboard format-type)
notice win clipboard history future =/= normal windows clipboard, the first one seems like external software but maybe i'm wrong.
Re: how to store screenshot in a variable, then paste it later?
Posted: 11 May 2024, 10:16
by Noitalommi_2
Hi.
You could use
ClipboardAll for that task.
Code: Select all
#Requires AutoHotkey 2.0
#SingleInstance
F1:: ; takes a screenshot
F2:: { ; restores the screenshot
static ClipSaved := ""
if ThisHotkey = "F1" {
A_Clipboard := ""
Send "{LWin down}{F24}{LWin up}"
ClipWait , 1
ClipSaved := ClipboardAll()
SoundBeep
}
else A_Clipboard := ClipSaved, SoundBeep(600)
}
Re: how to store screenshot in a variable, then paste it later?
Posted: 11 May 2024, 10:42
by mikeyww
More:
viewtopic.php?f=83&t=115622#p515378
Or:
Code: Select all
#Requires AutoHotkey v2.0
; https://github.com/buliasz/AHKv2-Gdip
#Include d:\Q\vis2\lib\Gdip_AllV2.ahk
pToken := Gdip_Startup()
pos := '0|0|' A_ScreenWidth '|' A_ScreenHeight
OnExit done
F2:: {
Global pBitmap := Gdip_BitmapFromScreen(pos)
SoundBeep 1500
}
F3:: {
A_Clipboard := ''
Try Gdip_SetBitmapToClipboard(pBitmap)
Catch
Return MsgBox('Nothing has been copied.', 'Error', 'Icon!')
If ClipWait(1, ANY := True) {
Send '^v'
SoundBeep 1000
} Else MsgBox 'An error occurred while waiting for the clipboard.', 'Error', 'Icon!'
}
done(exitReason, exitCode) {
Try Gdip_DisposeImage(pBitmap), Gdip_Shutdown(pToken)
SoundBeep 2500
}