Jump to content
SalamanderSoup

Capture Screenshot using snipping tool

Recommended Posts

SalamanderSoup

I've created a simple script that opens the Snipping Tool; Selects the "Full Screen Snip" option; then closes the program, prompting a save.  What I can't figure is how to name the file using the system date and time.

Can anyone help?

Run(@WindowsDir & '\system32\SnippingTool.exe')
AutoItSetOption('MouseCoordMode', 0)

Sleep(1)
$hWnd= WinWait("Snipping Tool", "ToolBarWindow32", 1)
WinActive($hWnd)
MouseClick('primary', 84, 48, 1, 0)
MouseClick('primary', 84, 140, 1, 0)
WinClose("[Class:Microsoft-Windows-Tablet-SnipperEditor]")

ControlClick("Snipping Tool", "", "Button1")

 

 

 

 

Share this post


Link to post
Share on other sites
JLogan3o13

@SalamanderSoup moved your topic to General Help and Support, as you seemed to have missed this at the top of the Examples forum:

Do not post general support questions here, instead use the AutoIt Help and Support forums.

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
SalamanderSoup

Thanks, I hope someone will be able to help me.

Share this post


Link to post
Share on other sites
l3ill

Probably because windows wont allow you to save a file with back slashes/forward slashes\ in it.

Try using _NowDate() and StringReplace and replace the " / \ " with "." for instance...

 

p.s. unless you are dead set on using SnippetTool, Autoit has a very cool function called:

_ScreenCapture_Capture that does this job very well ;)

Edited by l3ill
p.s.
  • Like 2

Share this post


Link to post
Share on other sites
SalamanderSoup

Thanks l3ill, could you possibly give me an example of how the NowDate and StringReplace scripts might look together?  I've looked at the AutoScript Help File, and still feel a bit confused at how I should code it.  I'm very new at this.

3 hours ago, l3ill said:

Probably because windows wont allow you to save a file with back slashes/forward slashes\ in it.

Try using _NowDate() and StringReplace and replace the " / \ " with "." for instance...

 

p.s. unless you are dead set on using SnippetTool, Autoit has a very cool function called:

_ScreenCapture_Capture that does this job very well ;)

Share this post


Link to post
Share on other sites
Xandy

Here is your script.

#include <Date.au3>
#include <ScreenCapture.au3>

$filename = _NowDate()
;                         String     Find Replace
$filename = StringReplace($filename, "/", ".")

; I'm guessing fixed location wants the cursor off
;                      Filepath      \    Filename    .Type   x1  y1  x2  y2   Capture Mouse Cursor
_ScreenCapture_Capture(@ScriptDir & "\" & $filename & ".png", 84, 48, 84, 140, False)

It's only programmed to read 1 pixel width, but I hope you know that already.

If you want a BMP or something else you can change the type ".png"

Edited by Xandy
  • Like 1

Share this post


Link to post
Share on other sites
SalamanderSoup

Lol, I'd buy that script for a dollar!

Thank you, both for the input, and thank you Xandy for the working script.

I was able to add the system time to the file name, as well.

  • Like 1

Share this post


Link to post
Share on other sites
Xandy
4 hours ago, l3ill said:

Nice follow up Xandy...

I hope this is not going to be too expensive ;)

I try SO hard!

Your advice gave me a concise path to victory.

2 hours ago, SalamanderSoup said:

I was able to add the system time to the file name, as well.

Then you're learning and all is well.  There's nothing wrong with eating a free fish, unless you're the fish.

Share this post


Link to post
Share on other sites
AutoBert
15 hours ago, SalamanderSoup said:

Lol, I'd buy that script for a dollar!

Just put a one dollar note in your cdtray and run

FileCopy('path to cdtray\one dollar.$$$','https://www.autoitscript.com/donate')

The dollar will transfered asap.  :lol:

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Jury
      By Jury
      So I get:
      $aMatch[0] Date(1499295600000)   this is supposed to be 06 Jul 2017
      $aMatch[0] Date(1483574400000)  this is supposed to be 05 Jan 2017
      does anybody know the formula to calculate the date from the large number?  It doesn't seem to be anything to do with DateToDayValue.
      thanks in advance.
    • litlmike
      By litlmike
      I am taking a Date & Time and splitting them using _DateTimeSplit, so that I can create a filename in the format: YYYYMMDD_HHMMSS.jpg.  The only issue is that if the month, or day, is a two-digit number that begins with a zero (so less than 10), then the month, or day, is formatted as a single-digit number.  Suggestions on how to accomplish this?
      Example:
      20180101 becomes 2018, 1, 1
      20180303 becomes 2018, 3, 3
      20180505 becomes 2018, 5, 5
      20180606 becomes 2018, 6, 6
      20180909 becomes 2018, 9, 9
      What I want:
      20180101 becomes 2018, 01, 01
      20180303 becomes 2018, 03, 03
      20180505 becomes 2018, 05, 05
      20180606 becomes 2018, 06, 06
      20180909 becomes 2018, 09, 09
      Func _CreateFileNameFromDateTimeFormat($sDateThatWasChangedIntoDateTimeFormat = "2018/01/02 10:29:39") Local $aMyDate, $aMyTime, $sNewImageFileName _DateTimeSplit($sDateThatWasChangedIntoDateTimeFormat, $aMyDate, $aMyTime) _ArrayDisplay($aMyDate) _ArrayDisplay($aMyTime) ;This will become file name $sNewImageFileName = $aMyDate[1] & $aMyDate[2] & $aMyDate[3] & "_" & $aMyTime[1] & $aMyTime[2] & $aMyTime[3] & ".jpg" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sNewImageFileName = ' & $sNewImageFileName & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console EndFunc ;==>_CreateFileNameFromDateTimeFormat  
       
    • Jefrey
      By Jefrey
      Needed a way to store global temporary & permanent information and came up with this.
      This is inspired by NodeJS's store and store2 packages, as well as W3 specs' localStorage and sessionStorage, offering multiple ways of usage.
      This is not related to any browser's storage, nor will allow you to access or modify browsers storage - although this is possible and not a hard task, this is not what this UDF is intended to do.
      This UDF offers functions for temporary storage (that gets cleaned up once the application is shutdown) that is kept on memory using ScriptingDictionary, as well as for permanent storage, that is saved on the harddisk as an encrypted file.
      sessionStorage (temporary storage)
      It's useful to keep application state and temporary settings accessible by any part of your script (although it could also be done with a global variable, I still prefer this method).
      You have multiple ways, at your choice, to:
      ; add or modify a key sessionStorage("foo", "bar") store("foo", "bar") sessionStorage_set("foo", "bar") sessionStorage_setItem("foo", "bar") ; read a key (returns false if key does not exist) $read = sessionStorage("foo") $read = store("foo") $read = sessionStorage_get("foo") $read = sessionStorage_getItem("foo") ; delete a key sessionStorage_remove("foo") ; delete all keys sessionStorage_clear() sessionStorage_clearAll() localStorage (permanent storage)
      It's useful to store user-defined settings.
      ; initialize ; this is optional, but allows you to control ; how things are going to be saved localStorage_startup([file where you want the settings to be saved], [crypt password]) ; by default, if not supplied, if supplied the "Default" keyword (or if you dont initialize), ; the file will be a random-named file (based on @ScriptFullPath) at user's %APPDATA% ; and the password will also be based on @ScriptFullPath ; you can set only the crypt password if you want: ; localStorage_startup(Default, "mypassword") ; the usage is the same as sessionStorage ; add or modify a key localStorage("foo", "bar") store2("foo", "bar") ; notice the '2' localStorage_set("foo", "bar") localStorage_setItem("foo", "bar") ; read a key (returns false if key does not exist) $read = localStorage("foo") $read = store2("foo") $read = localStorage_get("foo") $read = localStorage_getItem("foo") ; delete a key localStorage_remove("foo") ; delete all keys localStorage_clear() localStorage_clearAll() Download
    • Shedunn
      By Shedunn
      I've been looking through some different functions(not sure if that's the right word) to get the Date and time and I can't find one that doesn't include "/ " or ":" in what is returned.

      I'm trying to create a file name with this format "QuickConfig_MMDDYYYY_HHMM"  (doesn't matter if 24 or 12hr format)
      #include <Date.au3> Func _SaveConfig MouseClick('primary',155, 46, 1, 0) ;clicks save as WinWait('Save bluePRINT Configuration As...','', 4) MouseClick('primary',632, 47, 1, 0) ;clicks the file path bar $Documents = @MyDocumentsDir $FilePath = $Documents & '\BP3 Configs' Send($FilePath) Send('{ENTER}') MouseClick('primary',166, 580, 1, 0) ;clicks file name bar $FileName = 'QuickConfig_' & _NowDate & '_' & _NowTime Send($FileName) Send('{ENTER}') EndFunc  
       
      I'm wondering if there is a function somewhere to do this?
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.