I often use #206 paste image from clipboard to new png file for documentation
I want to make this more efficient in two respects if anyone can advise
a) I don't want to keep renaming the new created file. Most commonly I would want to name it the same as the currently selected file but with an appended serial number or a date/time. For example I might have a starting file
How to clean a cat.png
If I have that selected I would want the newly created file to be How to clean a cat -01.png or perhaps "how to clean a cat 20230714 1522.png"
Problem is I can't fine any scripted route to using the #206 that will take any optional filename
b) Sometimes pasting to jpg is more efficient for the type of material. I'm aware there is a tweak to change png to jpg pastes. However I don't want a permanent change - rather on the fly.
Many thanks for any helpful pointers or code.
Scripted paste of image from clipboard
-
- Site Admin
- Posts: 60618
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripted paste of image from clipboard
Well, I don't think that's possible at the moment. To make this scriptable I would have to add a new scripting command. I'm not sure if this is justifiable. (I know what you are thinking. )
FAQ | XY News RSS | XY Twitter
Re: Scripted paste of image from clipboard
Get e.g. nircmd (http://www.nirsoft.net/utils/nircmd.html) and use a script...
Switching on the fly between jpg and png in XY isn't possible and if you want jpg instead of png from nircmd, look for a cli tool to convert it and add it to the script (e.g. imagemagick).
Code: Select all
$nircmd = "D:\Users\highend\Downloads\nircmd-x64\nircmdc.exe";
$new = <curpath> . "\" . gpc(<curitem>, "base") . " " . now("yyyymmdd hhnn") . ".png";
runret(lax("$nircmd" clipboard saveimage "$new"));
One of my scripts helped you out? Please donate via Paypal
Re: Scripted paste of image from clipboard
Hello, Dear XYplorer Community!
Hello, aubrey97!
I was interested, if I can find a solution to the problem previously mentioned here on "20 Jul 2023 13:34" under a) by using XY-Scripting.
Therefore I composed a following simple script running under XY v. 24.60.0104:
(it is assumed, that
1. the user has a screenshot in the clipboard,
2. there may be only one file Clipboard-*.png - that one created by #206; - in the current path,
3. before starting the script, the user selects a file the name of which will be used to rename after):
Code: Select all
$s_i = <selitem>;
if($s_i == ""){
echo "No file selected";
end 1==1;
}
$c_p = <curpath>;
#206;
$qs1 = quicksearch("Clipboard-*.png /fn",$c_p);
if($qs1 == ""){
echo "No file found";
end 1==1;
}
$n_b = gpc($s_i,"base");
$n_n = $n_b."-"."<date yyyy.mm.dd-hh.MM.ss>".".png";
renameitem($n_n,$qs1);
- XY stops on a ready for manual renaming Clipboard-file name and the status bar shows the expected new file name
see attached screenshot. Then I press "Esc" and XY releses the renamed file with the expected file name.
Expected behavior were only "XY releses the renamed file with the expected file name".
(The information provided above is experimental. I catch screenshots by using other software.)
Edit: grammar.
Last edited by zakhar on 21 Jul 2023 15:31, edited 2 times in total.
Re: Scripted paste of image from clipboard
@aubrey97: With Irfanview you can on the fly switch between png jpg too, eg
@zakhar: #206 waits for input, so you need to skip that somehow, maybe something like this:
i_view64.exe /clippaste /convert=filename.jpg
@zakhar: #206 waits for input, so you need to skip that somehow, maybe something like this:
Code: Select all
$base = <curbase>;
#206; #485;
if ($base && $base != <curbase>) { renameitem($base,, 17); }
-
- Site Admin
- Posts: 60618
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripted paste of image from clipboard
I enhanced SC savethumb to support the clipboard as source. Next beta.
FAQ | XY News RSS | XY Twitter
Re: Scripted paste of image from clipboard
Many thanks for all responses --I will do some experimenting...
Re: Scripted paste of image from clipboard
@jupe:
Thank you!
@aubrey97:
Now with the new beta "v. 24.60.0109 - 2023-07-21 17:26"
- see here viewtopic.php?p=212802#p212802 -
and "savethumb(<clipimg>, "clipboardimage", "100%", , "jpg")"
we have a complete solution of your query of "20 Jul 2023 13:34" and a complete solution for catching screenshots with XY!
@admin:
Thank you! Perfect application and perfect support!
Thank you!
@aubrey97:
Now with the new beta "v. 24.60.0109 - 2023-07-21 17:26"
- see here viewtopic.php?p=212802#p212802 -
and "savethumb(<clipimg>, "clipboardimage", "100%", , "jpg")"
we have a complete solution of your query of "20 Jul 2023 13:34" and a complete solution for catching screenshots with XY!
@admin:
Thank you! Perfect application and perfect support!