Jump to content

Recommended Posts

Posted (edited)
#include <ScreenCapture.au3>
Local $hBmp
; Capture full screen
$hBmp = _ScreenCapture_Capture("")
_ScreenCapture_SaveImage("C:\Software\autoitscripts\scripts\images\prp\ocr\"&"ocr_01.PNG",$hBmp)
Sleep(1000)
_ScreenCapture_Capture("C:\Software\autoitscripts\scripts\images\prp\ocr\"&"ocr_02.PNG")
Sleep(1000)
ShellExecute("C:\Software\autoitscripts\scripts\images\prp\ocr\"&"ocr_01.PNG")
Sleep(1000)
ShellExecute("C:\Software\autoitscripts\scripts\images\prp\ocr\"&"ocr_02.PNG")

Hi All,

This is my first post and I have checked the forum.  If this question has been asked and answered I apologise.

The code above is intended to save the whole screen to a directory; it doesn't work.

I have downloaded and copied and renamed the files referenced in https://www.autoitscript.com/forum/topic/192254-33143-fixes/ to my includes directory.

Clearly there is some step that I am missing; do I need to download and register a dll?

 

I know that I am using two different methods above but neither works for me.

Edited by sharkeye
  • Moderators
Posted

sharkeye,

Welcome to the AutoIt forum.

This works perfectly for me:

#include <ScreenCapture.au3>
Local $hBmp
; Capture full screen
$hBmp = _ScreenCapture_Capture("")
_ScreenCapture_SaveImage(@ScriptDir & "\test1.PNG", $hBmp)
Sleep(1000)
$hBmp = _ScreenCapture_Capture(@ScriptDir & "\test2.PNG")
Sleep(1000)
ShellExecute(@ScriptDir & "\test1.PNG")
Sleep(1000)
ShellExecute(@ScriptDir & "\test2.PNG")

Are you sure you have permission to write the files to that folder - do they actually get saved?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Posted (edited)

How odd ,

I changed the code to reference the Script Directory as below and ran it as an administrator:

I can create files in both the directory in the first post and the script directory without using admin rights etc.

#include <ScreenCapture.au3>
Local $hBmp
; Capture full screen
$hBmp = _ScreenCapture_Capture("")
_ScreenCapture_SaveImage(@ScriptDir & "\ocr_01.PNG",$hBmp)
Sleep(1000)
_ScreenCapture_Capture(@ScriptDir & "\ocr_02.PNG")
Sleep(1000)
ShellExecute(@ScriptDir & "\ocr_01.PNG")
Sleep(1000)
ShellExecute(@ScriptDir & "\ocr_02.PNG")

But it still doesn't create the file.

By the way on screen my code looks like what you pasted except that _ScreenCapture_Capture and _ScreenCapture_SaveImage are black rather than blue.

Is that a clue by any chance?

Thank you for your help.

screen_sample.au3

Edited by sharkeye
  • Moderators
Posted

sharkeye,

Unless you have changed the defaults in SciTE, the colours should match. You said:

Quote

I have downloaded and copied and renamed the files referenced in https://www.autoitscript.com/forum/topic/192254-33143-fixes/ to my includes directory.

Is this a personal includes directory - or the one inside your AutoIt installation? You need to replace the include files that come with AutoIt - and the black colour makes me think that you have not done this as that is the colour for non-standard functions.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Posted (edited)

Hi Melba23,

Thanks for your input.  ScreenCapture is now working for me.

I had placed the files into the Autoit Includes installation directory and renamed them by removing _fixed from the end of the filename.

However before doing this I had renamed the original .au3 files to have _old at the end of the file and I had left these files in the AutoIt includes directory.

I moved the old files to another directory and 'it just worked'.   

Again thanks for your help and of course I had not followed the instructions (which say to delete the old files) so this was completely my own fault.

Edited by Melba23
Removed quote
  • Moderators
Posted

sharkeye,

Interesting - it should have worked even with the old renamed files.

Anyway, glad you got it working in the end.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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
×
×
  • Create New...