Jump to content

Screenshot util


emmanuel
 Share

Recommended Posts

I wrote this so I can put it on my 24/7 user desk, and have them hit one key combo for any errors they get, stamping with username, computername and time/date. I didn't want to go with an existing screenshot app as I want it to be fast and automatic, I don't want to wonder about different settings for different users or any of that. I also didn't want to tread on someone else's licensing, redistributing just one part of their app with mine. Oh, and I'd have really liked to use ImageMagick's import command instead of MSPaint but, unfortunately, it only works with X windows....

It's been tested on XP and 2k, currently only does full screen captures, though next version should do both current window and/or full screen.

Thanks to Doflow and Jdeb and anyone I'm forgetting for the input, I know it's not a huge polished script, but, it does what I want right now.

I am using the current unstable, v3.0.102 6/22/04, though I don't believe I'm using anything that should keep it from compiling properly in stable.

http://www.autoitscript.com/fileman/users/public/emmanuel/screenshot.au3 - from Public folder area.

Thanks for checking it out, let me know what you think.

Edit: just added duplicate script detection, as things get messy if you have two coppies open.

Emmanuel Pleshe

emmanuel.pleshe@gmail.com

Now Listening to:

Spacer - Houston (Secret Agent: The soundtrack for your stylish, mysterious, dangerous life. For Spys and P.I.'s too! [somaFM])

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

if you want it to do that, just comment the winclose and add

WinSetState(" - Paint", @SW_SHOW)
   WinSetState(" - Paint", @SW_RESTORE)
after the winwait.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Got this error

---------------------------
AutoIt Error
---------------------------
Line 51  (File "C:\Documents and Settings\Candles\My Documents\screenshot.au3"):

WinSetState(" - Paint", @SW_SHOW)
^ ERROR

Error: Incorrect number of parameters in function call.
---------------------------
OK   
---------------------------

I did this , maybe I did it wrong I guess .

opt("WinTitleMatchMode", 2)
   WinWait(" - Paint")
   WinSetState(" - Paint", @SW_SHOW)
  WinSetState(" - Paint", @SW_RESTORE)
  ;WinClose(" - Paint")
   AdlibDisable()
   SplashOff()
Link to comment
Share on other sites

sorry, my bad, should have another "", in there...

WinSetState(" - Paint","", @SW_SHOW)
WinSetState(" - Paint","", @SW_RESTORE)

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

I guess... It happens for me, first time, no problems.

so, what does everyone think, should I have the images save in the scriptdir?

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

so, what does everyone think, should I have the images save in the scriptdir?

Well, you can't always count on the C drive even existing, or having write permissions if it does. However, c:\screenshots will probably be accessable (or writable if it's not) for 99.5% of users out there. I suppose this could also be true of the script's directory if someone were to run it from a read-only folder or from a CD. I guess there is no easy solution...

They can always adjust the source if they don't like c:\screenshots.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

They can always adjust the source if they don't like c:\screenshots.

yeah, that's the level I'm leaving the code at for now... I could pretty easily build in INI read/write and popups prompting for locations... but right now, I know what i want.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

For some reasons, it is not printing here.

It freezes on my box and refused to save the screenshot. When I tried to use it, it showed the folder window of "my documents/my pictures" (but not c: screenshots) and then asked me if I want to replace "untitle.bmp", then I say yes, but can't find any "untitile.bmp" afterwards in any folders; The script and the splash screen just stopped at saving until I hit the hotkey combination to quit. But after it quited, I looked at the window task manager, MSpaint.exe was still running and I mannually ended it.

Link to comment
Share on other sites

For some reasons, it is not printing here.

It freezes on my box and refused to save the screenshot.  When I tried to use it, it showed the folder window of "my documents/my pictures" (but not c: screenshots) and then asked me if I want to replace "untitle.bmp", then I say yes, but can't find any "untitile.bmp" afterwards in any folders; The script and the splash screen just stopped at saving until I hit the hotkey combination to quit.  But after it quited, I looked at the window task manager, MSpaint.exe was still running and I mannually ended it.

I had that one show up at a few odd times as well, though it was mostly when there was two copies of the script running. if the file on the server's newer than the one you have(or newer than the last edit on that post...), get the newer one...

What OS are you running? Can you uncomment the opt... line and see which line of code it's hanging on?

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

I had that one show up at a few odd times as well, though it was mostly when there was two copies of the script running.  if the file on the server's newer than the one you have(or newer than the last edit on that post...), get the newer one...

What OS are you running?  Can you uncomment the opt... line and see which line of code it's hanging on?

Hey, yes, it stop at line 55. And I can make it work when I add some time before it started to write the file name and path to the directory control:

$filename = @UserName & " on " & @ComputerName & " at " & @HOUR & "." & @MIN & "." & @SEC & " on " & @MON & "-" & @MDAY & "-" & @YEAR & ".jpg"
   sleep (1000)  
   ControlSetText("Save As", "", "Edit1", '"' & $filepath1 & "\" & $filename & '"')

I put 1 seconds and it works, I think it is that AutoIt needs more time to detect the control.

Then, also, after it successfully saved, both before and after I quit the script, Mspaint still is running. So I think to add a line to close the process could be useful:

SplashTextOn("", "ScreenShot by Emmanuel" & @LF & "Alt-Ctrl-PrintScreen to take a screenshot" & @LF & "  Alt-Ctrl-Q to quit" & @LF & "Screenshots stored in C:\Screenshots" & @LF & "Screenshot Saved", 400, 100, -1, 0, 1)
   ProcessClose("mspaint.exe")

And btw, how did you make the icon menu not showing even when I click on it? You know, if you click on the icon it will pause the script, I always want to disable that but still have the icon there. I always want to be able to do that so the user won't be able to disable the script. I see that you did it with this script, which line was it?

Link to comment
Share on other sites

Hey, yes, it stop at line 55.  And I can make it work when I add some time before it started to write the file name and path to the directory control:

$filename = @UserName & " on " & @ComputerName & " at " & @HOUR & "." & @MIN & "." & @SEC & " on " & @MON & "-" & @MDAY & "-" & @YEAR & ".jpg"
   sleep (1000)  
   ControlSetText("Save As", "", "Edit1", '"' & $filepath1 & "\" & $filename & '"')

I put 1 seconds and it works, I think it is that AutoIt needs more time to detect the control.

I think a full second might be excessive, I'm more likely to try 250 or 500, since that window isn't hidden, and I don't want users to see it more than needed... maybe hidding the save window then waiting... what I'd really prefer is some sort of controlwait function that waits for a control to exist...

Then, also, after it successfully saved, both before and after I quit the script, Mspaint still is running.  So I think to add a line to close the process could be useful:

SplashTextOn("", "ScreenShot by Emmanuel" & @LF & "Alt-Ctrl-PrintScreen to take a screenshot" & @LF & "  Alt-Ctrl-Q to quit" & @LF & "Screenshots stored in C:\Screenshots" & @LF & "Screenshot Saved", 400, 100, -1, 0, 1)
   ProcessClose("mspaint.exe")
my guess is that it's getting the winclose before it's done saving... maybe this would help:
WinWait(" - Paint")
   sleep(250)
   WinClose(" - Paint")

And btw, how did you make the icon menu not showing even when I click on it? You know, if you click on the icon it will pause the script, I always want to disable that but still have the icon there.  I always want to be able to do that so the user won't be able to disable the script. I see that you did it with this script, which line was it?

break(0) does that.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

emmanuel, you might try a loop like this:

Do
    ControlCommand("title", "text", "Control", "IsEnabled", "")
Until Not @error

ControlCommand sets @error if the window or control doesn't exist.

Link to comment
Share on other sites

emmanuel, you might try a loop like this:

Do
    ControlCommand("title", "text", "Control", "IsEnabled", "")
Until Not @error

ControlCommand sets @error if the window or control doesn't exist.

I put that in, will upload an update and we'll see if that fixes it... If you'll do that R.L.?

Edit: and thanks Valik

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...