MRAJ Posted November 9, 2018 Share Posted November 9, 2018 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. 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 Link to comment Share on other sites More sharing options...
dmob Posted November 9, 2018 Share Posted November 9, 2018 You could try StdoutRead instead. See the helpfile for Run and StdoutRead commands. Link to comment Share on other sites More sharing options...
Subz Posted November 9, 2018 Share Posted November 9, 2018 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 More sharing options...
MRAJ Posted November 9, 2018 Author Share Posted November 9, 2018 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. 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. Link to comment Share on other sites More sharing options...
BrewManNH Posted November 9, 2018 Share Posted November 9, 2018 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. 66Gramms 1 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 GudeHow 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 More sharing options...
MRAJ Posted November 9, 2018 Author Share Posted November 9, 2018 Yes correct..but i need to capture only particular region using screencapture instead of whole window or screen. Link to comment Share on other sites More sharing options...
Nine Posted November 9, 2018 Share Posted November 9, 2018 (edited) @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 November 9, 2018 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
BrewManNH Posted November 9, 2018 Share Posted November 9, 2018 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 GudeHow 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 More sharing options...
MRAJ Posted November 9, 2018 Author Share Posted November 9, 2018 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 More sharing options...
Nine Posted November 9, 2018 Share Posted November 9, 2018 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... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
BrewManNH Posted November 9, 2018 Share Posted November 9, 2018 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 GudeHow 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 More sharing options...
MRAJ Posted November 13, 2018 Author Share Posted November 13, 2018 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. 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. 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 More sharing options...
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