TSz19 Posted November 3, 2020 Share Posted November 3, 2020 How can I write? Give me the pictures I have captured find in WingetHandel Link to comment Share on other sites More sharing options...
caramen Posted November 3, 2020 Share Posted November 3, 2020 (edited) We won't be able to help you until you provide something you tried. OR at least explain the complete task of what you're trying to accomplish. The only thing I can say actually is WinGetHandle, retrieves the internal handle of a window. It does not capture any screenshot at any moment. You could check my signature. "How to ask help". Regards. Edited November 3, 2020 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
TSz19 Posted November 4, 2020 Author Share Posted November 4, 2020 @caramen Can you help me solve the problem so it can be found in the pictures in Wingethandel? i know I went to fix my fever at this point. expandcollapse popupFunc _MatchPicture($Handle,$Match_Pic, $Threshold = 2, $CustomCords = False, $LoopCount = 2, $LoopWait = 2000) Local $rect_window = WinGetPos($Handle) Local $hDC = _WinAPI_GetWindowDC($Handle) Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC) Local $Match_Pic = _WinAPI_CreateCompatibleBitmap($hDC, $LoopCount,$LoopWait) Local $hDestSv = _WinAPI_SelectObject($hDestDC, $Match_Pic) Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC,$LoopCount,$LoopWait) Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp) _WinAPI_PrintWindow($Handle, $hSrcDC, True) If Not FileExists($Match_Pic) Then _Internal_ErrorLogger("Match Image not found: " & $Match_Pic) Return SetError(1) EndIf If $LoopCount <= 0 Then ConsoleWrite("Error: $LoopCount Variable set to 0. At least 1 is required.") Return SetError(1) EndIf Local $hBitmap ;Performance Counters Local $Perf = TimerInit() ;Load Match Image Local $hMatch_Pic = _cvLoadImage($Match_Pic) Local $hMatch_Size = _cvGetSize($hMatch_Pic) Local $width2 = DllStructGetData($hMatch_Size, "width") Local $height2 = DllStructGetData($hMatch_Size, "height") Local $ScreenSize = _ScreenSize() For $iTries = 1 To $LoopCount Step +1 ;Capature Screen / Load as Main image If Not IsArray($CustomCords) Then $hBitmap = _ScreenCapture_Capture("", 0, 0, $ScreenSize[0], $ScreenSize[1], False) Else $hBitmap = _ScreenCapture_Capture("", $CustomCords[0], $CustomCords[1], $CustomCords[2], $CustomCords[3], False) EndIf Local $Bitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) Local $hMain_Pic = _Opencv_BMP2IPL($Bitmap) Local $hMain_Size = _cvGetSize($hMain_Pic) Local $width = DllStructGetData($hMain_Size, "width") Local $height = DllStructGetData($hMain_Size, "height") Local $rw = $width - $width2 + 1 Local $rh = $height - $height2 + 1 Local $tmaxloc = DllStructCreate( "int x;" & "int y;") Local $tminloc = DllStructCreate( "int x;" & "int y;") Local $tmaxval = DllStructCreate("double max;") Local $tminval = DllStructCreate("double min;") Local $pmaxloc = DllStructGetPtr($tmaxloc) Local $pminloc = DllStructGetPtr($tminloc) Local $pmaxval = DllStructGetPtr($tmaxval) Local $pminval = DllStructGetPtr($tminval) ;Search for Match Local $presult = _cvCreateMat($rh, $rw, 5) _cvMatchTemplate($hMain_Pic, $hMatch_Pic, $presult, 5) _cvThreshold($presult, $presult, $Threshold, 1, 0) _cvMinMaxLoc($presult, $pminval, $pmaxval, $pminloc, $pmaxloc, Null) ;Set coordinates Local $Coordinates[4] If IsArray($CustomCords) Then $Coordinates[0] = DllStructGetData($tmaxloc, "x") +2+ $CustomCords[0] ; x $Coordinates[1] = DllStructGetData($tmaxloc, "y") +2+ $CustomCords[1] ; y $Coordinates[2] = DllStructGetData($tmaxloc, "x") +2+ $width2 + $CustomCords[0] ;x2 $Coordinates[3] = DllStructGetData($tmaxloc, "y") +2+ $height2 + $CustomCords[1] ;y2 Else $Coordinates[0] = DllStructGetData($tmaxloc, "x") ; x $Coordinates[1] = DllStructGetData($tmaxloc, "y") ; y $Coordinates[2] = DllStructGetData($tmaxloc, "x") + $width2 ;x2 $Coordinates[3] = DllStructGetData($tmaxloc, "y") + $height2 ;y2 EndIf ;Release Resources _cvReleaseMat($presult) _cvReleaseImage($hMain_Pic) _GDIPlus_BitmapDispose($Bitmap) _WinAPI_DeleteObject($hBitmap) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_ReleaseDC($Handle, $hDC) _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hBmp) ;Check if found If Not (DllStructGetData($tmaxloc, "x") = 0 And DllStructGetData($tmaxloc, "y") = 0 And $width2 = DllStructGetData($tmaxloc, "x") + $width2 And $height2 = DllStructGetData($tmaxloc, "y") + $height2) Then _cvReleaseImage($hMatch_Pic) _Internal_MatchLogger("Match found at: " & $Coordinates[0] & "|" & $Coordinates[1] & "|" & $Coordinates[2] & "|" & $Coordinates[3] & " // Loop counter: " & $iTries & " // Threshold: " & $Threshold & " // Total check time: " & Round(TimerDiff($Perf), 0) & " ms") Return $Coordinates EndIf Sleep($LoopWait) Next _cvReleaseImage($hMatch_Pic) _Internal_ErrorLogger("No match found. Loop counter: " & $LoopCount & ". // Total check time: " & Round(TimerDiff($Perf), 0) & " ms // Wait-Time per loop: " & $LoopWait & " ms. // Threshold: " & $Threshold & " // Match Image: " & $Match_Pic) Return SetError(2) EndFunc ;==>_MatchPicture you can find this code in the file named OpenCV-Match_UDF.au3. in the post below. Link to comment Share on other sites More sharing options...
caramen Posted November 4, 2020 Share Posted November 4, 2020 (edited) What are you trying to do and what is the error ? I don't understand the request sir I'm sorry. Edited November 4, 2020 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
JuanFelipe Posted November 4, 2020 Share Posted November 4, 2020 I don't understand you, what exactly do you want to do? Link to comment Share on other sites More sharing options...
TSz19 Posted November 5, 2020 Author Share Posted November 5, 2020 @caramen @JuanFelipe Sorry i am not good at english i want OpenCv to find the image in Wingethandel. you can find this code in the file named OpenCV-Match_UDF.au3. in the post below you see code Func _MatchPicture($Handle,$Match_Pic, $Threshold = 2, $CustomCords = False, $LoopCount = 2, $LoopWait = 2000) Local $rect_window = WinGetPos($Handle) Local $hDC = _WinAPI_GetWindowDC($Handle) Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC) Local $Match_Pic = _WinAPI_CreateCompatibleBitmap($hDC, $LoopCount,$LoopWait) Local $hDestSv = _WinAPI_SelectObject($hDestDC, $Match_Pic) Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC,$LoopCount,$LoopWait) Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp) _WinAPI_PrintWindow($Handle, $hSrcDC, True) If Not FileExists($Match_Pic) Then _Internal_ErrorLogger("Match Image not found: " & $Match_Pic) Return SetError(1) EndIf If $LoopCount <= 0 Then ConsoleWrite("Error: $LoopCount Variable set to 0. At least 1 is required.") Return SetError(1) EndIf Local $hBitmap ;Performance Counters Local $Perf = TimerInit() ;Load Match Image Local $hMatch_Pic = _cvLoadImage($Match_Pic) Local $hMatch_Size = _cvGetSize($hMatch_Pic) Local $width2 = DllStructGetData($hMatch_Size, "width") Local $height2 = DllStructGetData($hMatch_Size, "height") Local $ScreenSize = _ScreenSize() For $iTries = 1 To $LoopCount Step +1 ;Capature Screen / Load as Main image If Not IsArray($CustomCords) Then $hBitmap = _ScreenCapture_Capture("", 0, 0, $ScreenSize[0], $ScreenSize[1], False) Else $hBitmap = _ScreenCapture_Capture("", $CustomCords[0], $CustomCords[1], $CustomCords[2], $CustomCords[3], False) EndIf Local $Bitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) Local $hMain_Pic = _Opencv_BMP2IPL($Bitmap) Local $hMain_Size = _cvGetSize($hMain_Pic) Local $width = DllStructGetData($hMain_Size, "width") Local $height = DllStructGetData($hMain_Size, "height") Local $rw = $width - $width2 + 1 Local $rh = $height - $height2 + 1 Local $tmaxloc = DllStructCreate( "int x;" & "int y;") Local $tminloc = DllStructCreate( "int x;" & "int y;") Local $tmaxval = DllStructCreate("double max;") Local $tminval = DllStructCreate("double min;") Local $pmaxloc = DllStructGetPtr($tmaxloc) Local $pminloc = DllStructGetPtr($tminloc) Local $pmaxval = DllStructGetPtr($tmaxval) Local $pminval = DllStructGetPtr($tminval) ;Search for Match Local $presult = _cvCreateMat($rh, $rw, 5) _cvMatchTemplate($hMain_Pic, $hMatch_Pic, $presult, 5) _cvThreshold($presult, $presult, $Threshold, 1, 0) _cvMinMaxLoc($presult, $pminval, $pmaxval, $pminloc, $pmaxloc, Null) ;Set coordinates Local $Coordinates[4] If IsArray($CustomCords) Then $Coordinates[0] = DllStructGetData($tmaxloc, "x") +2+ $CustomCords[0] ; x $Coordinates[1] = DllStructGetData($tmaxloc, "y") +2+ $CustomCords[1] ; y $Coordinates[2] = DllStructGetData($tmaxloc, "x") +2+ $width2 + $CustomCords[0] ;x2 $Coordinates[3] = DllStructGetData($tmaxloc, "y") +2+ $height2 + $CustomCords[1] ;y2 Else $Coordinates[0] = DllStructGetData($tmaxloc, "x") ; x $Coordinates[1] = DllStructGetData($tmaxloc, "y") ; y $Coordinates[2] = DllStructGetData($tmaxloc, "x") + $width2 ;x2 $Coordinates[3] = DllStructGetData($tmaxloc, "y") + $height2 ;y2 EndIf ;Release Resources _cvReleaseMat($presult) _cvReleaseImage($hMain_Pic) _GDIPlus_BitmapDispose($Bitmap) _WinAPI_DeleteObject($hBitmap) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_ReleaseDC($Handle, $hDC) _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hBmp) ;Check if found If Not (DllStructGetData($tmaxloc, "x") = 0 And DllStructGetData($tmaxloc, "y") = 0 And $width2 = DllStructGetData($tmaxloc, "x") + $width2 And $height2 = DllStructGetData($tmaxloc, "y") + $height2) Then _cvReleaseImage($hMatch_Pic) _Internal_MatchLogger("Match found at: " & $Coordinates[0] & "|" & $Coordinates[1] & "|" & $Coordinates[2] & "|" & $Coordinates[3] & " // Loop counter: " & $iTries & " // Threshold: " & $Threshold & " // Total check time: " & Round(TimerDiff($Perf), 0) & " ms") Return $Coordinates EndIf Sleep($LoopWait) Next _cvReleaseImage($hMatch_Pic) _Internal_ErrorLogger("No match found. Loop counter: " & $LoopCount & ". // Total check time: " & Round(TimerDiff($Perf), 0) & " ms // Wait-Time per loop: " & $LoopWait & " ms. // Threshold: " & $Threshold & " // Match Image: " & $Match_Pic) Return SetError(2) EndFunc ;==>_MatchPicture OpenCV_Match.zip Link to comment Share on other sites More sharing options...
TSz19 Posted November 5, 2020 Author Share Posted November 5, 2020 What I want is for it to find the image in the wingetHendel. Link to comment Share on other sites More sharing options...
caramen Posted November 5, 2020 Share Posted November 5, 2020 Open the help file and read WinGetHandle. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki 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