Skip to content

Commit

Permalink
Merge pull request #3 from vnniz/feat-transparency
Browse files Browse the repository at this point in the history
[Feat] Add $Transparency parameter, separate base UDFs, translate UDF headers into English, improve README
  • Loading branch information
VNNiz authored Apr 13, 2023
2 parents 753ee39 + 108c2ba commit 516f0fd
Show file tree
Hide file tree
Showing 7 changed files with 2,251 additions and 1,805 deletions.
225 changes: 127 additions & 98 deletions Example.au3 → Example/Example.au3
Original file line number Diff line number Diff line change
@@ -1,98 +1,127 @@
; Author: Lâm Thành Nhân
; Email: [email protected]
; ===============================================================================================================================
; Ảnh để tìm kiếm nên lưu dạng "24-bit Bitmap"
; ===============================================================================================================================
; Ví dụ tìm kiếm theo CLASSNN của Nox
; ===============================================================================================================================


#include <Array.au3>
#include "HandleImgSearch.au3"

Local $WindowHandle = ControlGetHandle("NoxPlayer", "", "[CLASSNN:Qt5QWindowIcon5]")

;Test Global Functions
;~ _TestGlobal(100)
_TestGlobal(100, $WindowHandle)

;Test Handle Functions
;~ _TestHandle(100)
_TestHandle(100, $WindowHandle)

Func _TestGlobal($Count, $Handle = "")
ConsoleWrite("! Test Global Functions" & @CRLF)
; Init
_GlobalImgInit($Handle, 0, 0, -1, -1, False, False, 15 , 1000)

Local $Result
For $i = 1 to $Count
_GlobalImgCapture()

$Result = _GlobalImgSearchRandom(@ScriptDir & "\Images\NoxBrowser.bmp")
If not @error Then
ConsoleWrite("_GlobalImgSearchRandom: " & $Result[0] &" - " & $Result[1] & @CRLF)
Else
ConsoleWrite("_GlobalImgSearchRandom: Fail" & @CRLF)
EndIf

ConsoleWrite("_GlobalGetBitmap: " & _GlobalGetBitmap() & @CRLF)

$Result = _GlobalImgSearch(@ScriptDir & "\Images\NoxBrowser.bmp")
If not @error Then
ConsoleWrite("_GlobalImgSearch: (Total: " & $Result[0][0] & "): " & $Result[1][0] &" - " & $Result[1][1] & @CRLF)
Else
ConsoleWrite("_GlobalImgSearch: Fail" & @CRLF)
EndIf

$Result = _GlobalGetPixel(100, 100)
If not @error Then
ConsoleWrite("_GlobalGetPixel: " & $Result & @CRLF)
Else
ConsoleWrite("_GlobalGetPixel: Fail" & @CRLF)
EndIf

$Result = _GlobalPixelCompare(100, 100, 20)
If not @error Then
ConsoleWrite("_GlobalPixelCompare: " & $Result & @CRLF)
Else
ConsoleWrite("_GlobalPixelCompare: Fail" & @CRLF)
EndIf

Sleep(10)
Next
EndFunc

Func _TestHandle($Count, $Handle = "")
ConsoleWrite("! Test Local Functions" & @CRLF)
; Use for debug mode
$_HandleImgSearch_IsDebug = True
; Test Local Functions

Local $Result
For $i = 1 to $Count
$Result = _HandleImgSearch($Handle, @ScriptDir & "\Images\NoxBrowser.bmp", 0, 0, -1, -1, 15, 1000)

If not @error Then
ConsoleWrite("_HandleImgSearch (Total: " & $Result[0][0] & "): " & $Result[1][0] &" - " & $Result[1][1] & @CRLF)
Else
ConsoleWrite("_HandleImgSearch: Fail" & @CRLF)
EndIf

$Result = _HandleGetPixel($Handle, 100, 100)
If not @error Then
ConsoleWrite("_HandleGetPixel: " & $Result & @CRLF)
Else
ConsoleWrite("_HandleGetPixel: Fail" & @CRLF)
EndIf

$Result = _HandlePixelCompare($Handle, 100, 100, 20)
If not @error Then
ConsoleWrite("_HandlePixelCompare: " & $Result & @CRLF)
Else
ConsoleWrite("_HandlePixelCompare: Fail" & @CRLF)
EndIf

Sleep(10)
Next
EndFunc
; Author: Lâm Thành Nhân
; Email: [email protected]
; ===============================================================================================================================
; Ảnh để tìm kiếm nên lưu dạng "24-bit Bitmap"
; ===============================================================================================================================
; Ví dụ tìm kiếm theo CLASSNN của Nox
; ===============================================================================================================================


#include <Array.au3>
#include "..\HandleImgSearch.au3"

HotKeySet("{F1}", "_Test")
HotKeySet("{Esc}", "_Exit")

$_HandleImgSearch_IsDebug = true

Local $Handle = WinGetHandle(@ScriptDir)
While 1
Sleep(10)
WEnd

Func _Test()
_TestHandle(1, $Handle)
EndFunc

Func _Exit()
Exit
EndFunc

Func _TestGlobal($Count, $Handle = "")
ConsoleWrite("! Test Global Functions" & @CRLF)
; Init
_GlobalImgInit($Handle, 0, 0, -1, -1, False, true, 0, 0, 1)

Local $Result
For $i = 1 to $Count
_GlobalImgCapture()

$Result = _GlobalImgSearchRandom(@ScriptDir & "\Images\test.bmp")
If not @error Then
ConsoleWrite("_GlobalImgSearchRandom: " & $Result[0] &" - " & $Result[1] & @CRLF)
Else
ConsoleWrite("_GlobalImgSearchRandom: Fail" & @CRLF)
EndIf

ConsoleWrite("_GlobalGetBitmap: " & _GlobalGetBitmap() & @CRLF)

$Result = _GlobalImgSearch(@ScriptDir & "\Images\NoxBrowser.bmp")
If not @error Then
_ArrayDisplay($Result)
ConsoleWrite("_GlobalImgSearch: (Total: " & $Result[0][0] & "): " & $Result[1][0] &" - " & $Result[1][1] & @CRLF)
Else
ConsoleWrite("_GlobalImgSearch: Fail" & @CRLF)
EndIf

$Result = _GlobalGetPixel(100, 100)
If not @error Then
ConsoleWrite("_GlobalGetPixel1: " & $Result & @CRLF)
Else
ConsoleWrite("_GlobalGetPixel1: Fail" & @CRLF)
EndIf
$Result = _GlobalGetPixel(101, 101)
If not @error Then
ConsoleWrite("_GlobalGetPixel2: " & $Result & @CRLF)
Else
ConsoleWrite("_GlobalGetPixel2: Fail" & @CRLF)
EndIf
$Result = _GlobalGetPixel(102, 102)
If not @error Then
ConsoleWrite("_GlobalGetPixel3: " & $Result & @CRLF)
Else
ConsoleWrite("_GlobalGetPixel3: Fail" & @CRLF)
EndIf

$Result = _GlobalPixelCompare(100, 100, 20)
If not @error Then
ConsoleWrite("_GlobalPixelCompare: " & $Result & @CRLF)
Else
ConsoleWrite("_GlobalPixelCompare: Fail" & @CRLF)
EndIf

Sleep(10)
Next
EndFunc

Func _TestHandle($Count, $Handle = "")
ConsoleWrite("! Test Local Functions" & @CRLF)
; Use for debug mode
$_HandleImgSearch_IsDebug = True
; Test Local Functions

Local $Result
For $i = 1 to $Count
$Result = _HandleImgSearch($Handle, @ScriptDir & "\Images\test.bmp", 0, 0, -1, -1, 50, "000000", 10)
If not @error Then
_ArrayDisplay($Result, "_HandleImgSearch")
ConsoleWrite("_HandleImgSearch (Total: " & $Result[0][0] & "): " & $Result[1][0] &" - " & $Result[1][1] & @CRLF)
Else
ConsoleWrite("_HandleImgSearch: Fail" & @CRLF)
EndIf

;~ $Result = _HandleImgWaitExist($Handle, @ScriptDir & "\Images\testWindowFolderTitle.png", 3, 0, 0, -1, -1, 15, 0xFFFFFF, 1000)
;~ If not @error Then
;~ _ArrayDisplay($Result, "_HandleImgWaitExist")
;~ ConsoleWrite("_HandleImgWaitExist (Total: " & $Result[0][0] & "): " & $Result[1][0] &" - " & $Result[1][1] & @CRLF)
;~ Else
;~ ConsoleWrite("_HandleImgWaitExist: Fail" & @CRLF)
;~ EndIf

$Result = _HandleGetPixel($Handle, 100, 100)
If not @error Then
ConsoleWrite("_HandleGetPixel: " & $Result & @CRLF)
Else
ConsoleWrite("_HandleGetPixel: Fail" & @CRLF)
EndIf

$Result = _HandlePixelCompare($Handle, 100, 100, 20)
If not @error Then
ConsoleWrite("_HandlePixelCompare: " & $Result & @CRLF)
Else
ConsoleWrite("_HandlePixelCompare: Fail" & @CRLF)
EndIf

Sleep(10)
Next
EndFunc
Binary file added Example/Images/test.bmp
Binary file not shown.
Loading

0 comments on commit 516f0fd

Please sign in to comment.