Jump to content

Recommended Posts

sharkeye
#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

Share this post


Link to post
Share on other sites
Melba23

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


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
sharkeye

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

Share this post


Link to post
Share on other sites
Melba23

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


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
sharkeye

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

Share this post


Link to post
Share on other sites
Melba23

sharkeye,

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

Anyway, glad you got it working in the end.

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

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

    • UEZ
      By UEZ
      AutoIt Windows Screenshooter
      Key Features:
      takes easily a screenshot from any visible window capture any region of the desktop incl. freehand capturing capture GUI controls and GUI menus separately capture a marked area every x seconds for a duration of y seconds create a GIF animation from saved frames (Vista or higher os required) capture to AVI file (without audio!) takes a screenshot from web sites (available only on Vista+ os and when Aero is enabled) put images to clipboard to paste to other applications easily color picker save image in different formats and also to PDF! add timestamp to saved images simple image editing options: greyscale, b&w, invert, rotate +-90° send image to printer and default email client preview of captured screens incl. zoom option multi monitor support display pixel color under mouse ruler basic image editor (paint, highlight, ellipse, rectangle, text and some graphic FX) watermark captured image no 3rd party tools or DLLs used - pure AutoIt! fully portable - no installation is needed multi language feature (Eng, Ger, Tur, Fra and Rus only) To do:
      capture content of scrollable window/control capture cascaded menus Due to DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "handle", $hMemDC, "int", 0) limitation some windows cannot be captured properly (GDI+, ProgDVB, etc.) but can take screenshots of hidden windows. One workaround is to use full screen capturing (F11/F12) or "Grab Screen" function! Or try double click with rmb on listview items (beta).
      Download source code (5771 downloads previously): AutoIt Windows Screenshooter v1.79 Build 2018-05-08.7z (version 3.3.12.0+ needed!)
      You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name!
      Download compiled Exe only: 4shared / Media Fire / Softpedia (1.54mb)
      Distributing copies of the program in compiled format (exe) must be free of any fee!
      -----> click here to Donate!  
       
      (Current donators: 1. Cuong N.) 
      It is designed for Vista+ operating systems with AERO enabled! E.g. on WinXP machines some functions are not working properly and might crash the application!
      AV scanners may have a negative impact the execution of compiled exe and might report any malware. I guarantee that there is no malicious code in the source code / exe!!! 
      Main GUI:

       
       
      About Intro:

       
       
      Basic Image Editor:

       
       
      Watermark:

       
       
      Click link for an enhanced version of Watermark Image.
      Credits:
      main code by UEZ additional code (alphabetical order) by Authenticity, AutoItObject Team, Eemuli, Eukalyptus, funkey, _Kurt, martin, monoceres, ProgAndy, taietel, trancexx, Ward, wolf9228 and Yashied! mesale0077 for turkish translation wakillon for french translation AZJIO for russian translation Keys:
      Main GUI:
      User your mouse to scroll preview window or
      Numpad 8: Scroll preview window up
      Numpad 2: Scroll preview window down
      Numpad 4: Scroll preview window left
      Numpad 6: Scroll preview window right
      Numpad +: zoom in preview window or mousewheel down
      Numpad -: zoom out preview window or mousewheel up
      F1: capture again on last position
      F5: refresh Windows Name list
      PRINTSCREEN: take screenshot from whole screen
      ALT+PRINTSCR: take a screenshot from active window
      F10: Undo made changes with Image Editing function
      F11: take screenshot from whole screen incl mouse cursor
      F12: take screenshot from whole screen
      Ctrl+Alt+F9 start "Grab Screen" mode
      Ctrl+Alt+F12: take a screenshot from active window using alternative screenshot functionality (beta)!
      Ctrl+r: call ruler
      Ctrl+s: save current displayed image
      Ctrl+x: exit program
      ctrl+w: call web grab input field (availabe only when Aero is enabled)
      Ctrl+i: call image editor
      Ctrl+m: call watermark editor
      Ctrl+z: undo
      Only available on Vista+ os: double click with rmb on list items to use alternative screenshot functionality (beta)!
      When 'Grab Screen' is clicked you can hold down the ctrl key to switch to 'grab controls' mode. Control under mouse will be framed red.
      ctrl + shift will take the screenshot of appropriate control. To capture GUI menues you can press rmb which simulates the lmb. When a menu is opened press shift additionaly to capture it.
      Press and hold only the shift key to capture any region on the desktop using freehand capturing - release it so capture marked regions!
      Or just mark resizeable area which you want to grab. Press CTRL key to grab marked area or right mouse button to capture the marked area every x seconds for a duration of y seconds.
      When saving the image just enter the extension you whish to use (*.jpg;*.png;*.bmp;*.gif;*.tif;*.pdf). Big thanks to taietel for his PDF UDF!
      Image Editor:
      s: save
      c: copy
      n: send
      h: highlighter
      p: pen
      r: rectangle
      e: ellipse
      a: arrow
      o: color
      t: text
      g: text config
      Ctrl+z: undo
      Watermark editor:
      Ctrl+z: undo
       
      To start the app minimized just call it "Windows Screenshooter.exe /min"
      Maybe it is useful for someone...
      Any kind of comment is welcome.
      Br,
      UEZ
      Change log:
       
    • milos83
      By milos83
      If I set the transparency with WinSetTrans, screenshot can't be made.
      This is Windows 7 related.
      Win 10 works fine
      Run the attached file
      #include <ScreenCapture.au3> ;GUI1 $gui1 = GUICreate("gui1", 200, 200, 200, 200) GUICtrlCreateLabel("GUI 1 LABEL", 50, 50 ) GUISetState() ;GUI 2 with transparency is completely ignored by _ScreenCapture_Capture $gui2 = GUICreate("gui1", 200, 200, 200, 200, -1, -1, $gui1) GUICtrlCreateLabel("GUI 2 LABEL", 100, 100 ) GUISetState() WinSetTrans($gui2, "", 150) Sleep(2000) _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image1.jpg", 200, 200, 405, 410) ShellExecute(@MyDocumentsDir & "\GDIPlus_Image1.jpg") As you can see, the semi transparent window will not be visible in the screenshot.
      I noticed that a couple of screen recording tools are acting the same. (But there are those that do work)
      I tried different ways on getting the screenshot and none worked.
      Printscreen does work.
      Is there a way to solve this without using Printscreen?
      ScreenCaptureProblem.au3
    • odaylton
      By odaylton
      I would like to get a region of the screen but avoiding having to save to a file first.
      I believe it is a lack of knowledge on my part but the GUICtrlSetImage function does not allow you to define an image without being a file.
      How to do this:
      ;.... $Pic3 = GUICtrlCreatePic("", 8, 64, 84, 84, -1, _ $WS_EX_STATICEDGE) ;para ter borda em baixo relevo ;.... _ScreenCapture_Capture(@ScriptDir & "\areatemp.jpg", 10, 10, 200, 200) GUICtrlSetImage($Pic3, @ScriptDir & "\areatemp.jpg") ;....  
    • timmalos
      By timmalos
      Hello all.
      I'm trying to do something simple, but I can't manage to find where to start since I can have multiple possibilities and not sure what is the best one :
      Taking screen capture (I can do that) On this capture, I'll look for 10 particular regions that will give me 10 images of 40px * 40px (I can do that) Then what I want is for each of these regions, find on my library of ~140 images which one is the closest one to my region (= the match)  
      What do you think is the best approach ? Ican easily do step 1 and 2, however for the third step :
      I can't use memcmp because they won't be exactly the same (original library can differ a very little bit from what I'll get from my screen capture) There is no text, only drawing Should I do a pixelSum of what I get on screen and do the same via GDIPlus for each of my images in the library?  
      Thanks a lot,
      Tim
       
    • TheNorwegianUser
      By TheNorwegianUser
      I don't get why the images I take turns up like this, but it seems to me like the screenshot doesn't go from the actual positions specified. It's weird, cause what happends is that when I for example move the mouse over the number 25 on SciTE, the image shows that it's over 19... Anyone knows what I'm doing wrong?
      #include <screencapture.au3> #include <WindowsConstants.au3> Hotkeyset("{ESC}", "Terminate") $gui = GUICreate("", 100, 800, 100, 0, $WS_POPUP, $WS_EX_TOPMOST) _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND($gui) GUISetState(@SW_SHOW, $gui) While 1 $scr = _ScreenCapture_Capture("", 0, 0, 100, 800) $bitmap = _GDIPlus_BitmapCreateFromHBITMAP($scr) _WinAPI_DeleteObject($scr) _GDIPlus_GraphicsDrawImage($graphics, $bitmap, 0, 0) WEnd Func Terminate() _GDIPlus_GraphicsDispose($graphics) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_Shutdown() Exit EndFunc  
×