Jump to content
letsCodeMyLife

_ScreenCapture_Capture doesnt saves the image

Recommended Posts

letsCodeMyLife

Hello,

I want to save a screenshot with _ScreenCapture_Capture. My code:

#include <ScreenCapture.au3>

_ScreenCapture_Capture(@ScriptDir & "/test.jpg", 0, 0, 1366, 700)

The problem is not to capture the screen, the problem is to save the image.

Can you help me?

Thanks.

Share this post


Link to post
Share on other sites
Danyfirex

Hello try to add a:

ConsoleWrite(@error & @CRLF)

To check the returned error code.

 

Saludos

Share this post


Link to post
Share on other sites
Melba23

letsCodeMyLife,

Are you using 3.3.14.3? If so then upgrade to 3.3.14.5:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
letsCodeMyLife

I have the latest Version.

Edited by letsCodeMyLife

Share this post


Link to post
Share on other sites
Melba23

letsCodeMyLife,

Add this line to your code above and please post what appears in the SciTE console:

ConsoleWrite($iRet & " - " & @error & @CRLF)

I get:

>"M:\Program\AutoIt3\SciTE\..\AutoIt3.exe" "M:\Program\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "M:\Program\Au3 Scripts\fred1.au3" /UserParams    
+>10:11:55 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0   Keyboard:00000809  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => M:\Program\AutoIt3\SciTE   UserDir => C:\Users\###########\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\#############\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.5)  from:M:\Program\AutoIt3  input:M:\Program\Au3 Scripts\fred1.au3
+>10:11:56 AU3Check ended.rc:0
>Running:(3.3.14.5):M:\Program\AutoIt3\autoit3.exe "M:\Program\Au3 Scripts\fred1.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
True - 0
+>10:11:57 AutoIt3.exe ended.rc:0
+>10:11:57 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 2.923

and the file is correctly created.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
letsCodeMyLife

The $iRet is False and the errror code is 0.

Share this post


Link to post
Share on other sites
Melba23

letsCodeMyLife,

I asked to see the whole SciTE output.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
AndyG

Hi, 

make a screenshot "by hand" and post the picture here please...

 

Share this post


Link to post
Share on other sites
letsCodeMyLife

@Melba23SciTe cant run files in the console.

The requested Screenshot by Hand:

PS: My Laptop is very old.

 

Unbenannt.png

Edited by letsCodeMyLife

Share this post


Link to post
Share on other sites
Melba23

letsCodeMyLife,

Quote

SciTe cant run files in the console

The SciTE console is the lower of the 2 panes in the editor.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
DynamicRookie

Just to let you know, desktop.ini is a virus called Recycler, you should check if it's a positive and if it is, avoid deleting massive amount of files.

About your problem with ScreenCapture, try instead using _ScreenCapture_CaptureWnd

Like this:
 

#include <ScreenCapture.au3>

$0 = @ScriptDir
$a = Random(0,200)
$ab = Random(0,10)
$b = "10.9.8.7.6.5.4.3.2.1"
$c = StringSplit($b, ".")
$b0 = 1
For $d in $c
    If $b0 <> 1 Then
        SplashTextOn('', "Capturing in " & $d& "...", 150, 100, 100, 100, 0, "Tahoma", 16)
        Sleep(1000)
        If $d = "1" Then
            SplashOff()
            ExitLoop
        EndIf
    Else
        $b0 = 0
    EndIf
Next
$HWnd = WinActive('', '')
Sleep(500)
_ScreenCapture_CaptureWnd($0 & "\Screenshots\" & "Screenshot" & $a +$ab & ".jpg", $HWnd, 0, 0, -1, -1, False)
MsgBox(0, '', "Screenshot saved on " & $0 & "\Screenshots\" & "Screenshot" & $a +$ab & ".jpg")
exit 0

 

  • Variable $0 stores current script working directory
  • Variable $a stores a random number between 0 and 200
  • Variable $ab stores a random number between 0 and 10
  • Variable $b stores a countdown
  • Variable $c splits the variable $b into an array countdown
  • Variable $b0 debugs For loop to skip the first subscript [0] that contains amount of subscripts
  • For loop does a countdown and splashs it on screen.
  • Variable $d stores the countdown
  • Between each $d round, it sleeps a second.
  • After countdown end, variable $HWnd stores the handle of the actual active window
  • _ScreenCapture_CaptureWnd searchs for a folder called "Screenshots" on @ScriptDir and stores screen capture there.
  • Then a MsgBox saying the location of screenshot saved pops up
  • Exit script.
Edited by DynamicRookie
Explanation

Share this post


Link to post
Share on other sites
kaisies

Desktop.ini happens in normal windows operation. It's presence does not mean he has a virus. 

Share this post


Link to post
Share on other sites
letsCodeMyLife

nope my Desktop.ini isn't  a Virus.

And the _Screencapture_CaptureWnd also doesnt work.

And when i try to execute it on the SciTe Shell it Displays this error: (its german)

>"E:\AutoItEdit\..\AutoIt3.exe" "E:\AutoItEdit\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Sybille\Desktop\test.au3" /UserParams   
>Das System kann die angegebene Datei nicht finden.
 

"Das System kann die angegebene Datei nicht finden." is translated to english: "The System cant find the file."

Edited by letsCodeMyLife

Share this post


Link to post
Share on other sites
DynamicRookie

About desktop ini, theres a virus called Recycler that tries to impersonate common recycle bin files to fill the hard disk of trash and let other viruses in.

 

There shouldn't be 2 of them, and if they also appear on other folders non related to desktop (Maybe along with links) then is a virus.

Edited by DynamicRookie

Share this post


Link to post
Share on other sites
DynamicRookie

About ScreenCapture its cause you need a folder called Screenshots placed on the same directory as script, in example: C:/Test/Script/Screenshots

 

Where Script folder contains the script and Screenshots saves the screen captures.

 

You can, however, edit the script to change the directory to save screenshots at.

Edited by DynamicRookie

Share this post


Link to post
Share on other sites
DynamicRookie

I feel like you trying to do a spyware, aren't you?:naughty:

Edited by DynamicRookie

Share this post


Link to post
Share on other sites
Jos
2 hours ago, DynamicRookie said:

I feel like you trying to do a spyware, aren't you?:naughty:

What about you stop these accusations and simply follow the rules of reporting posts?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Melba23

letsCodeMyLife,

The _ScreenCapture_CaptureWnd function definitely does exist! Please run the following code and tell us what appears in the MsgBox:

MsgBox(0, "Version", @AutoItVersion)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
letsCodeMyLife

@Melba23: The MsgBox Displays: 3.3.14.3

@DynamicRookie: I won't program Spyware and i already have created the Screenshots Folder and it also doesnt work.

But i find my own solve:

I use _WinAPI_SaveHBITMAPToFile. This works on my Computer, but  on my Laptop it Ends with error code 30.

Share this post


Link to post
Share on other sites
Melba23

letsCodeMyLife,

So, as explained here:

to which thread I linked you earlier, you are NOT using the latest version (despite your earlier comment) and, because of a known bug, the _ScreenCapture functions will not save a file. Update to 3.3.14.5 where the bug has been fixed (along with some others) and all will be well.

Might I suggest that in future you actually take the time to read the responses you get - then we would not have all wasted our time over the past few days.

M23

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

    • bowker
      By bowker
      Hi! Is there a way for me to set the value for my slider? I am getting the value for my slider with
       
      Local $strText = _UIA_getPropertyValue($oUIElement, $UIA_LegacyIAccessibleValuePropertyId) MsgBox(0,"",$strText)  
    • nacerbaaziz
      By nacerbaaziz
      Hello
      Can we pause and resume the download in the InetGet function?
      If is possible, what is the solution please?
      I used this code To manage the download

      #include <INet.au3> func _downloader($name, $linc, $filepath, $RTLF = false, $link = false) global $downloader = GUICreate("downloader", 400, 200, -1, -1, $WS_CLIPCHILDREn, $RTLF, $link) global $path = $filePath $labelTxt = GUICtrlCreateLabel("downloading " & $name, 50, 10, 200, 20) global $labelTxt0 = GUICtrlCreateLabel("downloaded size 0 MB " & "OF 0 MB", 50, 60, 300, 20) global $Progress = "" global $sText = ""     For $i = 1 To Random(5, 20, 1) ; Return an integer between 5 and 20 to determine the length of the string.         $sText &= Chr(Random(65, 122, 1)) ; Return an integer between 65 and 122 which represent the ASCII characters between a (lower-case) to Z (upper-case). next global $labelTxt2 = GUICtrlCreateInput("0%", 50, 80, 50, 20) _GUICtrlEdit_SetReadOnly(-1, true) GUIStartGroup("") global $beep = GUICtrlCreateCheckBox("use the progress beep notification", 150, 120, 200, 20) GUIStartGroup("") $button = GUICtrlCreateButton("Cancel', 130, 150, 180, 25, 0x01) $iIndex = 0 global $Target global $url GUIStartGroup("") global $Progress = GUICtrlCreateProgress(50, 90, 150, 20) global $Target = $filepath global $url = $linc global $path = $filepath global $hDownloadNo = _RSMWare_GetData($url, $Target) global $status = false AdlibRegister("SetProgress") global $onprogress = false, $curent = false GUISetState(@sw_Show) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $button $asc = MsgBox(4132,"exit download?","if you click yes the downloading will be cancel, do you want to cancel it ?") if $asc = 6 then AdlibUnRegister("SetProgress") GUIDelete() If $hDownloadNo <> 0 Then InetClose($hDownloadNo) exitLoop endIf EndSwitch if $status = -1 then $status = 0 $hDownloadNo = _RSMWare_GetData($url, $Target) $onprogress = false $curent = false elseIf $Status = 1 then $status = $path GUIDelete() AdlibUnRegister("SetProgress") exitLoop endIf WEnd return $status endFunc Func _RSMWare_GetData($url, $Target) Local $hDownload = InetGet($url, $Target, 1, 1) Return $hDownload EndFunc ;==>_RSMWare_GetData Func SetProgress() Local $state If $hDownloadNo <> 0 Then $state = InetGetInfo($hDownloadNo) If @error = 0 Then $infor = "downloaded size " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADREAD) / 1048576), 2) & " MB of " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) / 1048576), 2) & " MB " $onprogress = Round(Ceiling(($state[0] / $state[1]) * 100)) if not (InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) = 0) then if $onProgress <= 0 then $onProgress = 0 GUICtrlSetData($Progress, $onProgress) GUICtrlSetData($labelTxt0, $infor) GUICtrlSetData($labelTxt2, $onProgress & "%") if _isChecked($beep) then if $onprogress > $curent then beep((100 + $onprogress * 20), 100) $curent = $onprogress endIf endIf endIf If $state[2] Then If $state[3] Then InetClose($hDownloadNo) $status = 1 else InetClose($hDownloadNo) $status = -1 endIf endIf EndIf endIf EndFunc ;==>SetProgress
    • VollachR
      By VollachR
      Hi,
      I'm looking for a way to take a number value from a Row2 of a 2D array and according to this check if files that appear in rows 3-11 in the array exists.
      For example, if the number in Row2 is 5 I need to check for the files in Row 3-6 only, if it is 6 than rows 3-7 and so on.
      I thought on using a FOR loop but I have very little experience with those.
      Can you suggest the best way to do what I need?
      BTW, the files in Rows 3-11 will usually have blank value for any row above the number in Row2 (e.g. Row2 = 5 so Rows3-6 will have values but 8-11 be empty), The values I need are in Column 1 of the array, the name of the key from the INI file that the array was created from is in Column 0.
      Full Example:
      Row2 of Array:
      Col0 = Games# - Col1 = 5
      Rows3-6
      Col0 = Exe2 - Col1 = Path To File
      Col0 = Exe3 - Col1 = Path To File
      Col0 = Exe4 - Col1 = Path To File
      Col0 = Exe5 - Col1 = Path To File
      I need that if Row2 is 5 to check these above for rows if the file exists, if it was 6 then the next row as well and so on up until number 10 in Row2 as it can't go above 10.
      So basically for whatever number in Row2 from 2-10 need to check 1-9 rows from 3-11 to see if the files in Col1 exists and if any of them don't exist it should call a function that shows an error message.
      I'm pretty sure I have the first line of the for look correct:
      For $i = 1 To $aAIO[2][1] Just not sure how to continue from there, also not sure if $i should be equal 1 or 2.
      Help will be appreciated.
    • VollachR
      By VollachR
      Hi,
      I've written a specialty INI file editor for a specific set of INI files related to a bigger script I'm working on.
      I'm trying to create a verification script that checks the ini files structure and format and gives an error if they are not in expected format.
      What I did so far is create a couple of custom arrays, each with the list of Sections expected in the files and I use IniReadSectionNames in order to read the sections from the selected INI file and compare it to the array.
      It works fine, excepts it only gives an error if one or more of the sections in the custom array is missing, if they all exist but there are other additional sections that shouldn't be there it doesn't give an error and continue to open the editor screen.
      Here are the relevant part of my script:
      The Custom Verification Arrays:
      ;Creating Arrays for INI Verification Global $aSettingsVerify[7] $aSettingsVerify[1] = "Conversion" $aSettingsVerify[2] = "AIO" $aSettingsVerify[3] = "Data" $aSettingsVerify[4] = "Redist" $aSettingsVerify[5] = "Split" $aSettingsVerify[6] = "Autorun" Global $aDataVerify[6] $aDataVerify[1] = "Compression" $aDataVerify[2] = "Exclude" $aDataVerify[3] = "LangExclude" $aDataVerify[4] = "PreCommands" $aDataVerify[5] = "PostCommands" The IniReadSectionNames verification part:
      Case $OK If StringInStr($ActiveConfig, "Settings.ini") Then $CheckArray1 = IniReadSectionNames($ActiveConfig) $CheckArray2 = _ArrayCompare($aSettingsVerify, $CheckArray1) $CheckArray3 = UBound($CheckArray2, 1) If $CheckArray3 = 1 Then GUIDelete($ConfigStart) SettingsGUI() EndIf If $CheckArray3 > 1 Then WrongIni() EndIf EndIf If StringInStr($ActiveConfig, "Data") Then $CheckArray1 = IniReadSectionNames($ActiveConfig) $CheckArray2 = _ArrayCompare($aDataVerify, $CheckArray1) $CheckArray3 = UBound($CheckArray2, 1) If $CheckArray3 = 1 Then GUIDelete($ConfigStart) DataGUI() EndIf If $CheckArray3 > 1 Then WrongIni() EndIf EndIf The Function that performs the compare: (Found it in another thread on this forums somewhere by using Google Search)
      ;Compares Imported INI file with the Verification array Func _ArrayCompare(ByRef $a1, ByRef $a2) Local $nOldSize = UBound($a2) Local $a3[$nOldSize], $nNewSize = $nOldSize For $i = 0 To UBound($a1) - 1 For $j = 0 To $nOldSize - 1 If Not $a3[$j] And ($a1[$i] = $a2[$j]) Then $a3[$j] = 1 $nNewSize -= 1 EndIf Next Next Local $a4[$nNewSize], $j = 0 For $i = 0 To $nOldSize - 1 If Not $a3[$i] Then $a4[$j] = $a2[$i] $j += 1 EndIf Next Return $a4 EndFunc ;==>_ArrayCompare  
      Any way to make a check if there are sections other than the ones in the Verification Array and produce an error?
      Thanks
    • Valnurat
      By Valnurat
      Can you explain why my mouseclick don't work in my shockwave fullscreen.
       
      I know my syntax is ok, because it moves to coordinates, but this will only press 1 time, even that I want to press 5 times.
      How can that be?
×