screenshot to mspaint

Discuss and share scripts and script files...
Post Reply
eurytos
Posts: 200
Joined: 29 Jan 2008 15:53

screenshot to mspaint

Post by eurytos »

I can not guarantee this is even close to the best way to do this but here is what I have done. If it isn't be nice, this is my first script!

I created a new folder under my xyplorer installation and I am pasting the screenshot into this folder so I can use it in my UDC.

I had to set 'selpos 2' because I am modifying this to copy the current screenshot to an archive folder below the current folder. If you do not have any subfolders it should be selpos 1.

Code: Select all

"Screenshot"
 // Get current location
 set $path, <curpath>;
 // Go to temporary folder
 goto "C:\Program Files\XYplorer\appdata\TempImages\";
 // Select all files
 #255; 
 // Delete the last screenshot(s)
 #169;
 // paste the clipboard to temporary folder
 #206;
 // sort list by modified date descending just in case
 sortby mod, d;
 // select the second item because of a folder taking pos 1
 selpos 2;
 // make sure List has focus
 focus l;
 // copy file path to clipboard
 #101;
 // go back to that original location
 goto $path;
 // load path to mspaint using pre-defined UDC
 // "c:\windows\system32\mspaint.exe" "<clipboard>"
 #1405;

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

Looks like a nice script :) Well done.

Just a quick question : why do you go through all the trouble of sorting the List and selecting back the file ? Is it just to close the Rename mode, or something else I'm missing ?

If the former, I think doing a simple "focus l" should be enough. That way, you don't even have to use selpos (or worry about folders, etc)

(Also, you might be interrested in the command "setting" for such cases : by using "setting HideFoldersInList, 1" you can ensure that, during the execution of the script, no folders will be shown on List. That way, no matter what, your script will always work as expected.)
Proud XYplorer Fanatic

eurytos
Posts: 200
Joined: 29 Jan 2008 15:53

Post by eurytos »

Thanks for the tips! I have modified it to this now.

Code: Select all

 "ArchiveScreenshot"
 // Get current location
 set $path, <curpath>;
 // Go to temporary folder
 goto "C:\Program Files\XYplorer\appdata\TempImages\";
 // Select all files
 #255; 
  // Delete the last screenshot(s)
 #169;
  // paste the clipboard to temporary folder
 #206;
 setting HideFoldersInList, 1;
 selpos 1;
 //rename the file
 rename , Screenshot<dmmddyy><mhhnnss>, "<curitem>"; 
 // Copy the screenshot to Archive folder
 copyto "C:\Program Files\XYplorer\appdata\TempImages\Archive\<curext>\<dmmddyy>";
 // copy file path to clipboard
 #101;
 // go back to that original location
 goto $path;
 // load path to mspaint using custom file association 
 open <clipboard>;
Now I also rename the file to: Screenshot<date-timestamp> and file it away in subfolders based first on file extension and then broken down by day.

quick question, do I need to reset ' setting HideFoldersInList, 1;' to anything when done?

Thanks!

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

No, you don't have to do anything. When the script execution is over, XY will restore that setting to whatever it was set before the script started, that's the beauty of it ;)

Quick thing : your command call for rename seems wrong : as third parameter you put "<curitem>", but :
- first, the 3rd param is for preview or not, not the item(s) to be renamed, you're missing a coma here!
- second, you don't need to specify it, by default rename applies to selected items and with "selpos 1" you've already selected it ;)
Proud XYplorer Fanatic

eurytos
Posts: 200
Joined: 29 Jan 2008 15:53

Post by eurytos »

Thanks again!

I missed the comma because I was using preview to test the path and naming while I was messing with it and I guess I accidentally deleted it when i removed the preview.

Post Reply