tonycst Posted December 17, 2016 Posted December 17, 2016 Simple code: _ScreenCapture_Capture(@DesktopDir & "\Shapshot.jpg") Sometimes full screen is captured sometimes not. Why is that ? Is this a BUG ? Must be because i dont see anything wrong with the code.
junkew Posted December 17, 2016 Posted December 17, 2016 What is not definition? Partial screenshot or nothing at all. Whats your screensize videocard number of monitors which windows version etc FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
tonycst Posted December 22, 2016 Author Posted December 22, 2016 Partial screen shot is taken. Sometimes its full screen, sometimes its partial. So regardless of # of monitors or screen size or video cards, problem is random. 3 different computers used. One laptop with 2 video Intel and ATI Desktop computer with Intel video card only. 2nd Desktop computer with ATI video card higher end. All same result. Hid and miss situation.
junkew Posted December 22, 2016 Posted December 22, 2016 #include <ScreenCapture.au3> consolewrite(@AutoItExe & @CRLF) consolewrite(@AutoItVersion & @CRLF) consolewrite(@AutoItX64 & @CRLF) consolewrite(@CPUArch & @CRLF) consolewrite(@OSArch & @CRLF) consolewrite(@OSBuild & @CRLF) consolewrite(@OSServicePack & @CRLF) consolewrite(@OSType & @CRLF) consolewrite(@OSVersion & @CRLF) consolewrite(@WindowsDir & @CRLF) consolewrite(@TempDir & @CRLF) for $i=1 to 100 $scrFile=@TEmpDir & "\screenshot" & $i & ".jpg" _ScreenCapture_Capture($scrFile) ;~ consolewrite($scrfile & @CRLF) Next No problem on my system for above 100 screenshots. Maybe your screenshot file is still in use by OS if you do it to quickly after each other to same file? C:\Program Files (x86)\AutoIt3\autoit3_x64.exe 3.3.14.2 1 X64 X64 14393 WIN32_NT WIN_10 C:\WINDOWS FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
tonycst Posted December 26, 2016 Author Posted December 26, 2016 Did 100 shots test all were good on one of my computers. But my laptop and other computer i use it on at work produces partial screenshot each time.
junkew Posted December 26, 2016 Posted December 26, 2016 Alternative https://www.autoitscript.com/autoit3/docs/libfunctions/_ScreenCapture_SaveImage.htm FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
tonycst Posted December 26, 2016 Author Posted December 26, 2016 #include <ScreenCapture.au3> $JPEG = _ScreenCapture_Capture("") _ScreenCapture_SaveImage (@DesktopDir & "\Shapshot.jpg",$JPEG) _WinAPI_DeleteObject ($JPEG) How is that any different ? Its still using _ScreenCapture_Capture which is the root of the problem. Worked fine on desktop but not on laptop, so i am assuming it will fail at work desktop as well.
junkew Posted December 27, 2016 Posted December 27, 2016 you conclude something i cant. Issue can be in capture or in save. The hbmp reference you get you can analyse on height and width. Which part of screen is captured. What dimension is captured if you get a partial screenshot. Allways same partial or random. Maybe you can try with printscreen putting on clipboard and paste clipboard to file. Maybe update the videodriver if possible. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
junkew Posted December 27, 2016 Posted December 27, 2016 Explicit parameters maybe? @DeskTopHeight @DeskTopWidth FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
tonycst Posted December 29, 2016 Author Posted December 29, 2016 (edited) Ok solved the problem by specifying dimensions of the screen. (thanks junkew) $JPEG = _ScreenCapture_Capture("",0,0,@DesktopWidth,@DesktopHeight) shoots 1920x1080 instead of 1536x864 (weird number if you as me) What does that mean, what function does not work properly, saving or capturing ? Edited December 29, 2016 by tonycst
junkew Posted December 29, 2016 Posted December 29, 2016 DPI settings / fontsize 15 inch zooming to 125% not the latest video drivers depending on what you take a screenshot of (Direct3D/GDI+) It has nothing to do with AutoIt. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
tonycst Posted December 30, 2016 Author Posted December 30, 2016 Take that back. Only works is specifying desktop dimensions but not when using variable. #include <ScreenCapture.au3> $Coordinates = WinGetpos ("0.jpg") $JPEG = _ScreenCapture_Capture("",$Coordinates[0],$Coordinates[1],$Coordinates[2],$Coordinates[3]) _ScreenCapture_SaveImage (@DesktopDir & "\Shapshot.jpg",$JPEG) _WinAPI_DeleteObject ($JPEG) Console says: 43x82x458x370 which is exactly what it is Resulted image 416x289 which is not 458x370 Coordinates are also wrong. Both console and AU3Info say: 43x82 which is correct but the resulting image is way off where it suppose to be. Look for your self. The snapshot.jpg is the generated by autoit. Normal screenshot.jpg is the one i created with PRINTSCREEN button and pasted into picture. So what gives ? My DPI settings are default, i did not change that ever. Drivers are latest (in any case later then autoit version i have) I only get this problem on some computers, not all of them.
junkew Posted December 30, 2016 Posted December 30, 2016 (edited) a. Workaround is working. Isn't that good enough? b. Your details are far from clear b1. If it works does it work consistently on the same computer? b2. If it DOES NOT work is it then consistently not working on that computer? b3. You use winGetPos to get coordinates that you use for _screencapture_capture whereas these coordinates are not interchangable. c. yes, _screencapture_capture can go wrong if Windows OS or Videodriver gives back internally incorrect screensize which can be caused by some examples I gave earlier I assume AutoIt uses the same values as are given by below 2 lines of code. You could try to see what happens on the faulty systems consolewrite(@desktopheight & @CRLF) consolewrite(@desktopwidth & @CRLF) d. I have no insight in source of autoit but my logic would be that it uses the normal systemmetrics of the system. So on the incorrect working computers maybe run #include <WinAPI.au3> consolewrite(_WinAPI_GetSystemMetrics(76) & @CRLF) consolewrite(_WinAPI_GetSystemMetrics(77) & @CRLF) consolewrite(_WinAPI_GetSystemMetrics(78) & @CRLF) consolewrite(_WinAPI_GetSystemMetrics(79) & @CRLF) https://msdn.microsoft.com/en-us/library/windows/desktop/ms724385(v=vs.85).aspx Edited December 30, 2016 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
tonycst Posted January 6, 2017 Author Posted January 6, 2017 a) work around did not work. b ) i provided script exactly as i run it. It works on one computer but not the other. Cant be any more clear. c) It works on one computer but does not work on the other constantly consolewrite(@desktopheight & @CRLF) consolewrite(@desktopwidth & @CRLF) and $Coordinates = WinGetpos ("0.jpg") return correct values (different obviously because i am trying to get the size of the windows that i want to take screen shot from) so getting the correct values is not the issue at all because they all return correct. Sometimes screenshot will not even be taken at all. Everything works find in my bedroom desktop but not on my laptop. Both run same windows 10 both 64bit both have same things installed and same autoit version.
junkew Posted January 6, 2017 Posted January 6, 2017 wingetpos from a picture is completely new to me and do not understand it from help file. So whats your expected result from wingetpos("0.jpg") https://www.autoitscript.com/autoit3/docs/functions/WinGetPos.htm FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
junkew Posted January 6, 2017 Posted January 6, 2017 #include <ScreenCapture.au3> $Coordinates = WinGetpos ("0.jpg") consolewrite($Coordinates[0] & @CRLF) consolewrite($Coordinates[1] & @CRLF) consolewrite($Coordinates[2] & @CRLF) consolewrite($Coordinates[3] & @CRLF) $JPEG = _ScreenCapture_Capture("",$Coordinates[0],$Coordinates[1],$Coordinates[2],$Coordinates[3]) _ScreenCapture_SaveImage (@DesktopDir & "\Shapshot.jpg",$JPEG) _WinAPI_DeleteObject ($JPEG) what are the input parameter values. as its undefined in the help file what wingetpos does on a picture it can be that your coordinates from 0.jpg are different or that as 0.jpg does not have a path its finding a different jpg on your different system in a different folder and as such giving inconclusive behavior. Try a path in front of 0.jpg. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now