I am trying to create a batch script which puts a screenshot on the clipboard for me to save in another application.
I am using the "^{PRTSC}" and have copied code from another posting here (I would ask/comment there but the listing is closed and I do not have enough points to post there.)
When I run the following line line I get no errors:
powershell -c "$wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys("%{PRTSC}")
But when I create a new document in Photoshop and select Paste ctrl+v, nothing is pasted from the clipboard.
Clearly the code is not putting a screenshot in the clipboard.
( I do not want to use Navcmd )
2
Answers
Here is an old batch script that use a module in
VB.net
and save a screenshot asjpeg
image with system date:As far as I know, windows keyboard supports two shortcuts to capture the screen:
Per the title and your description,
^{PRTSC}
should act as if it’s pressing Ctrl+PrtScn, which will perform the same action as PrtScn.Assuming you just want to capture the active window, running the following command from a batch file will work:
There are a few differences:
SendWait
implementation from .NET. The COMSendKeys
implementation has some issues, notably around how it reacts to console windows and special keys.%
to simulate the Alt key, and more, since it’s in a batch file, escaping the%
with%%
.