Jump to content

Screen capture


MRAJ
 Share

Recommended Posts

Hi ,

I tried to capture the command prompt screen text (cd NewFolder only) using _ScreenCapture_Capture command but it is taking the full screen , how to capture only the particular screen text and based on that if particular text not found alert should be generated. Please help.

image.png.18da5e2a97268d58b20ae69b830383c5.png 

 Below is my script if $Screen will not match with the screenshot of the cd NewFolder which i have taken and saved then generate alert.

Here in Script Untitled1.jpg is the screenshot of the cd NewFolder

#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <FileConstants.au3>
#include <File.au3>
#include <AutoItConstants.au3>
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPIFiles.au3>


Run("cmd.exe")

Send('c:' & "{ENTER}")
Send('cd NewFolder' & "{ENTER}")

Local $Screen = _ScreenCapture_Capture('C:\Users\Pictures' & "\GDIPlus_Image2.jpg", 0, 0, 796, 596)

If ($Screen == 'C:\Users\Pictures\Untitled1.jpg') Then
LogError(" Success ")
 WinClose("C:\Windows\SYSTEM32\cmd.exe")

Else

LogError("Cannot connect to New Folder ")
  

EndIf

  


 

 

image.png

Link to comment
Share on other sites

Not sure what you are trying to accomplish but here is a couple of ways to capture a window:

#include <ScreenCapture.au3>

;~ Example 1
Run(@ComSpec & ' /k C: && CD\ && CD "Program Files"')
WinWait(@ComSpec)
Local $aCmdPos = WinGetPos(@ComSpec)
Local $sScreenShot = "C:\Temp\CmdScreenShot1.jpg"
_ScreenCapture_Capture($sScreenShot, $aCmdPos[0], $aCmdPos[1], $aCmdPos[2], $aCmdPos[3])
WinClose(@ComSpec, "")
If FileExists($sScreenShot) Then ShellExecute($sScreenShot)

;~ Example 2
Run(@ComSpec & ' /k C: && CD\ && CD "Program Files (x86)"')
WinWait(@ComSpec)
Local $hCmdWnd = WinGetHandle(@ComSpec)
Local $sScreenShot = "C:\Temp\CmdScreenShot2.jpg"
_ScreenCapture_CaptureWnd($sScreenShot, $hCmdWnd)
WinClose(@ComSpec)
If FileExists($sScreenShot) Then ShellExecute($sScreenShot)

 

Link to comment
Share on other sites

Hi Subz,

Thanks, but i dont want whole window or command prompt..i just want to capture the screenshot like below. if that screenshot doesn't match the what i saved screenshot, then generate alert.

image.png.effc92c308a598d27d47e2b00822cda7.png

One more example like if we give the URL www.google.com , so to check if google logo is there or not, i just want to take screenshot of only google logo using screesncapture command not entire screen and match with screenshot which i saved, if that doesn't match  then generate the alert:

I just want particular image or text to capture.

image.png.60ac23abd8927a091e7bd0680b1caa01.png

Link to comment
Share on other sites

That seems like a silly way to verify you're on the right page. Just look at the page's HTML and see if it's there.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

@MRAJ The approach, you want to take, to verify if the "cd newfolder" is successful will be extremely hard to make it to work. First the line :

2 hours ago, MRAJ said:

If ($Screen == 'C:\Users\Pictures\Untitled1.jpg') Then

is not comparing 2 different .jpg.  You are comparing $Screen (= True) with a String !

 

Edited by Nine
Link to comment
Share on other sites

20 minutes ago, MRAJ said:

but i need to capture only particular region using screencapture

How are you to determine where on the screen it is you need to capture? How are you going to compare the pictures to each other? What happens when Google changes their logo, which they do almost daily? 

Have you read the help file for _ScreenCapture_Capture? What you are comparing its return value to isn't correct, it doesn't ever return a file name, so comparing that to a string of the file name makes no sense.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

So any other AutoIT command by which i can capture the particular string ,text or image ? Please let me know as i have some Application websites where i have to match the string,text and image of the websites, if that websites not found these ,then it should alert..as i am not finding HTML code for these because these Application websites are customized like Oracle Application.

Link to comment
Share on other sites

Oracle applications ?  Like financials, or human ressources ?  Can you give us an example of screen where you want to capture stuff. Bring also the autoit info tool with cursor over the control you want to get info of.  What the relation with Dos command like cd you started with ?  And what's Google doing in all that ?  Please try the explain a bit more...

Link to comment
Share on other sites

49 minutes ago, MRAJ said:

So any other AutoIT command by which i can capture the particular string ,text or image ?

Yes, there are literally dozens. You just need to define what you're trying to capture, and from what type of application. What you're doing now isn't the way to do it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi Brew,

There are an oracle application and BO application where i need to alert if the page image not found:

Below is the for SAP BO Application:

Where i have to click on Public Folders and click on OpenDocument if that document opens within 60 seconds then it is fine or else it should alert: I tried to use AutoIT Info Tool but it is not giving the exact info to alert.

image.png.9e7701d40227814e470df29654de7741.png

 

For Oracle Application we have to give order number and after giving order number it will give the Order number and customer name, if that matches then Fine or else it should alert.

image.png.f24dda5bb512e072c51be7a42d272d00.png

image.png.f6eae409f84ccebde6f2957dc23efcd5.png

 

and one more for oracle Application where i have to run the oracle command in the command prompt, if the output shows valid screen then fine or else Alert.

I tried to find any HTML element related to that and also Info tool but there is no match, as they are Java UDF codes...

Let me know if you need more info on this.

 

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