Jump to content

Basic screencapture script wont save file


nowayn
 Share

Recommended Posts

So im trying to do some screenshots with autoit but I can't even get the most basic script to actually save the file anywhere.

 

#include <ScreenCapture.au3>

_ScreenCapture_Capture(@ScriptDir & '\1.jpg')

This code won't save the image in the script directory even though I'm running AutoIt as admin and have full control on all users and groups in that folder. I'm guessing its something to do with not being allowed to save but why?

Link to comment
Share on other sites

Hi @nowayn, and welcome to the AutoIt Forum :)
What @error is returned from the function?

#include <ScreenCapture.au3>

_ScreenCapture_Capture(@ScriptDir & '\1.jpg')
If @error Then  ; Error Checking
    ConsoleWrite("Error taking the Screenshot. Error: " & @error & @CRLF)
EndIf

 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Try using #RequiresAdmin.  My guess would be your trying to save inside a folder that you don't have permission.   A way to tell if it was actually captured you should be able to paste to paint manually.  

 

I think I had to always do something like

$hBitmap=screencapture_capture()

Screencapture_saveimage("path\", $hBitmap)

 

Edited by markyrocks
Link to comment
Share on other sites

6 minutes ago, markyrocks said:

Try using #RequiresAdmin.  My guess would be your trying to save inside a folder that you don't have permission.   A way to tell if it was actually captured you should be able to paste to paint manually.  

 #RequireAdmin doesn't help either and nothing happens if I try to paste it into paint 

Link to comment
Share on other sites

Try making a file the name you want and put a random image in and see if it saves over it or if it just snaps a shot of the image in the file.  Unless you're deleting the screenshot in a part of your script we cant see then you should be able to open paint and paste the screenshot in. Its either trying to take a screenshot of a file that doesn't exist or its @error and you have some other issue beyond my comprehension.

Edited by markyrocks
Link to comment
Share on other sites

32 minutes ago, nowayn said:

nothing changes by putting a file with the same output name in the folder and 

 

#include <ScreenCapture.au3>
Local $hBmp

$hBmp = _ScreenCapture_Capture("")

_Screencapture_saveimage(@ScriptDir & "\1.jpg", $hBmp)

Take a look here, https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_BitmapCreateHBITMAPFromBitmap.htm.  I think this was how I fixed it when I was using screen capture... 

 

That GDI plus is pretty neat, lot of different tools in there to manipulate images while they're in temp memory.   Edit...nm. maybe try saving the file as a .bmp.  an hbitmap is a handle to a bitmap and there might be some issue with the conversion. 

 

Edited by markyrocks
Link to comment
Share on other sites

3 hours ago, ViciousXUSMC said:

Are you compliant with the version number?

It specifically states "screencapture" being a problem in 3.3.14.3/4

 

1

sry, fell asleep. it said i was running 3.5.4 but it appears that it doesn't exist. decided to update anyway and now it works soo i guess it must have been that. THANKS SO MUCH

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...