Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 16:20

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



ImageSearch2015 and transparency

Discussion on ImageSearch2015 and transparency within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Oct 2007
Posts: 2
Received Thanks: 0
ImageSearch2015 and transparency

Does anyone here have used transparency with ImageSearch dll successfully? Every test I'm making are not working. I edited an image and colored a section in black for those pixels to be ignored but the rest should be found and it's not the case.

Here is the code I'm trying to make work:

Code:
#include <ImageSearch2015.au3>

HotKeySet("^q", "Quit")

Global $i = 0
Global $X = ""
Global $y = ""
Global $Result = 0


$Result = _ImageSearch(@ScriptDir & "\test.png",1,$x,$y,50,0x000000)
If $Result = 1 Then
   MouseMove($x,$y,1)
EndIf


Func Quit()
    Exit
EndFunc
Here is my test image:


Here is the ImageSearch2015.au3:

Code:
#AutoIt3Wrapper_UseX64=y ; Set to Y or N depending on your situation/preference!!
#include-once
#include <WinAPIFiles.au3> ; for _WinAPI_Wow64EnableWow64FsRedirection
#include <ScreenCapture.au3> ;_ScreenCapture_CaptureWnd etc. ;using this in the example to create a test image, otherwise not neccessary here

#Region When running compiled script, Install needed DLLs if they don't exist yet
If Not FileExists("ImageSearchDLLx32.dll") Then FileInstall("ImageSearchDLLx32.dll", "ImageSearchDLLx32.dll", 1);FileInstall ( "source", "dest" [, flag = 0] )
If Not FileExists("ImageSearchDLLx64.dll") Then FileInstall("ImageSearchDLLx64.dll", "ImageSearchDLLx64.dll", 1)
If Not FileExists("msvcr110d.dll") Then FileInstall("msvcr110d.dll", "msvcr110d.dll", 1);Microsoft Visual C++ Redistributable dll x64
If Not FileExists("msvcr110.dll") Then FileInstall("msvcr110.dll", "msvcr110.dll", 1);Microsoft Visual C++ Redistributable dll x32
#EndRegion

Local $h_ImageSearchDLL = -1; Will become Handle returned by DllOpen() that will be referenced in the _ImageSearchRegion() function

#Region ImageSearch Startup/Shutdown
Func _ImageSearchStartup()
	_WinAPI_Wow64EnableWow64FsRedirection(True)
	$sOSArch = @OSArch ;Check if running on x64 or x32 Windows ;@OSArch Returns one of the following: "X86", "IA64", "X64" - this is the architecture type of the currently running operating system.
	$sAutoItX64 = @AutoItX64 ;Check if using x64 AutoIt ;@AutoItX64 Returns 1 if the script is running under the native x64 version of AutoIt.
	If $sOSArch = "X86" Or $sAutoItX64 = 0 Then
		$h_ImageSearchDLL = DllOpen("ImageSearchDLLx32.dll")
		If $h_ImageSearchDLL = -1 Then Return "DllOpen failure"
	ElseIf $sOSArch = "X64" And $sAutoItX64 = 1 Then
		$h_ImageSearchDLL = DllOpen("ImageSearchDLLx64.dll")
		If $h_ImageSearchDLL = -1 Then Return "DllOpen failure"
	Else
		Return "Inconsistent or incompatible Script/Windows/CPU Architecture"
	EndIf
	Return True
EndFunc   ;==>_ImageSearchStartup

Func _ImageSearchShutdown()
	DllClose($h_ImageSearchDLL)
	_WinAPI_Wow64EnableWow64FsRedirection(False)
	Return True
EndFunc   ;==>_ImageSearchShutdown
#EndRegion ImageSearch Startup/Shutdown

#Region ImageSearch UDF;slightly modified
; ------------------------------------------------------------------------------
;
; AutoIt Version: 3.0
; Language:       English
; Description:    Functions that assist with Image Search
;                 Require that the ImageSearchDLL.dll be loadable
;
; ------------------------------------------------------------------------------
;===============================================================================
;
; Description:      Find the position of an image on the desktop
; Syntax:           _ImageSearchArea, _ImageSearch
; Parameter(s):
;                   $findImage - the image to locate on the desktop
;                   $tolerance - 0 for no tolerance (0-255). Needed when colors of
;                                image differ from desktop. e.g GIF
;                   $resultPosition - Set where the returned x,y location of the image is.
;                                     1 for centre of image, 0 for top left of image
;                   $x $y - Return the x and y location of the image
;                   $transparency - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of
;                                  the color to be used as transparency; can be omitted if
;                                  not needed
;
; Return Value(s):  On Success - Returns True
;                   On Failure - Returns False
;
; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify
;       a desktop region to search
;
;===============================================================================
Func _ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)
	Return _ImageSearchArea($findImage, $resultPosition, 0, 0, @DesktopWidth, @DesktopHeight, $x, $y, $tolerance, $transparency)
EndFunc   ;==>_ImageSearch

Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance = 0, $transparency = 0);Credits to Sven for the Transparency addition
	If Not FileExists($findImage) Then Return "Image File not found"
	If $tolerance < 0 Or $tolerance > 255 Then $tolerance = 0
	If $h_ImageSearchDLL = -1 Then _ImageSearchStartup()

	If $transparency <> 0 Then $findImage = "*" & $transparency & " " & $findImage
	If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
	$result = DllCall($h_ImageSearchDLL, "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)

	If @error Then
	ConsoleWrite("DllCall Error=" & @error)
		Return 0
	EndIf

	If Not IsArray($result) Or $result = 0 Then Return 0
	If $result[0] = "0" Then Return 0

	$array = StringSplit($result[0], "|")
	If (UBound($array) >= 4) Then
		$x = Int(Number($array[2])); Get the x,y location of the match
		$y = Int(Number($array[3]))
		If $resultPosition = 1 Then
			$x = $x + Int(Number($array[4]) / 2); Account for the size of the image to compute the centre of search
			$y = $y + Int(Number($array[5]) / 2)
		EndIf
		Return 1
	EndIf
EndFunc   ;==>_ImageSearchArea

;===============================================================================
;
; Description:      Wait for a specified number of seconds for an image to appear
;
; Syntax:           _WaitForImageSearch, _WaitForImagesSearch
; Parameter(s):
;                   $waitSecs  - seconds to try and find the image
;                   $findImage - the image to locate on the desktop
;                   $tolerance - 0 for no tolerance (0-255). Needed when colors of
;                                image differ from desktop. e.g GIF
;                   $resultPosition - Set where the returned x,y location of the image is.
;                                     1 for centre of image, 0 for top left of image
;                   $x $y - Return the x and y location of the image
;                   $transparency - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of
;                                  the color to be used as transparency can be omitted if
;                                  not needed
;
; Return Value(s):  On Success - Returns 1
;                   On Failure - Returns 0
;
;
;===============================================================================
Func _WaitForImageSearch($findImage, $waitSecs, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)
	$waitSecs = $waitSecs * 1000
	$startTime = TimerInit()
	While TimerDiff($startTime) < $waitSecs
		Sleep(100)
		If _ImageSearch($findImage, $resultPosition, $x, $y, $tolerance, $transparency) Then
			Return True
		EndIf
	WEnd
	Return False
EndFunc   ;==>_WaitForImageSearch

;===============================================================================
;
; Description:      Wait for a specified number of seconds for any of a set of
;                   images to appear
;
; Syntax:           _WaitForImagesSearch
; Parameter(s):
;                   $waitSecs  - seconds to try and find the image
;                   $findImage - the ARRAY of images to locate on the desktop
;                              - ARRAY[0] is set to the number of images to loop through
;                                ARRAY[1] is the first image
;                   $tolerance - 0 for no tolerance (0-255). Needed when colors of
;                                image differ from desktop. e.g GIF
;                   $resultPosition - Set where the returned x,y location of the image is.
;                                     1 for centre of image, 0 for top left of image
;                   $x $y - Return the x and y location of the image
;                   $transparent - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of
;                                  the color to be used as transparent; can be omitted if
;                                  not needed
;
; Return Value(s):  On Success - Returns the index of the successful find
;                   On Failure - Returns 0
;
;
;===============================================================================
Func _WaitForImagesSearch($findImage, $waitSecs, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)
	$waitSecs = $waitSecs * 1000
	$startTime = TimerInit()
	While TimerDiff($startTime) < $waitSecs
		For $i = 1 To $findImage[0]
			Sleep(100)
			If _ImageSearch($findImage[$i], $resultPosition, $x, $y, $tolerance, $transparency) Then
				Return $i
			EndIf
		Next
	WEnd
	Return False
EndFunc   ;==>_WaitForImagesSearch
#EndRegion ImageSearch UDF;slightly modified
kornb is offline  
Old 05/25/2018, 07:38   #2
 
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
If $transparency <> 0 Then $findImage = "*" & $transparency & " " & $findImage

Transparency don't match imagesearch lib params
Should be "Trans", also $findimage is overwritten, params should be splited with blanks



Hint: view attachment image
elmarcia is offline  
Thanks
1 User
Old 06/03/2018, 15:56   #3
 
elite*gold: 0
Join Date: Oct 2007
Posts: 2
Received Thanks: 0
So basically, ImageSearch2015 should be corrected by using the correct param and spaces? I will try to find what needs to be cleaned. Thank you for pointing this out.
kornb is offline  
Reply


Similar Threads Similar Threads
ImageSearch2015 Problem
03/15/2016 - AutoIt - 8 Replies
Hello, I try to script a bot that press buttons if a picture is shown. The current problem is that the bot do nothing when i start it. If I let the #include <ImageSearch2015.au3> out the debugger says that the function _ImageSearch is unknown, thats normal I know, but at least it says something. Can anyone help me please?
[RELEASE] Wallhack transparency modifier
10/07/2012 - Counter-Strike Hacks, Bots, Cheats & Exploits - 6 Replies
What it does: It lets you change the opacity of wallhacks for games like css and tf2. So if you can't see through walls well enough or want walls to become more solid, you can change it in seconds using this program. Your wallhack change takes effect when you restart CSS or you can change your materials without restarting css by turning on sv_cheats 1 and do mat_reloadallmaterials. Only existing transparent materials will be changed to prevent making player models or the floor transparent. ...
Working with Alpha Channels (Transparency in DDS)
03/20/2010 - Dekaron Private Server - 10 Replies
Ok so the tutorial before showed you the basics of DDS editing, and how to open it, edit it, and save it. Now in this tutorial, i'm going to be going over the more advanced editing of DDS. I'm going to show you how to use Alpha Channels, or transparency in DDS. I'm pretty sure a lot of people wondered how to do this, its not that hard after you get the hang of it. Ok so i'm not going to edit anything, but i'm going to start a new dds project from scratch. 1. Make a new project, use this...
transparency
07/04/2007 - Conquer Online 2 - 1 Replies
hey guys, im not askign for the link to where i can find what i'm looking for but i'm just asking what its called i remeber reading a few months ago about a patch or tool that allows you to make the monsters transparent or somehting liek that to allow you to click through them so you can hop or run correctly. i was wondering what that tool or patch is called. thanks ahead of time and i was curious on what a nproxy or pro proxy was. thanks
transparency help
11/28/2005 - Conquer Online 2 - 6 Replies
*Edit* k, nm, after spending iunno how long reading through every single post on the topic -.- I figured out what I was doing wrong. Well anyhow here are some SS's of what I've done, a black/gold/red archer coat, a pink tao armour(I didn't like the pink version provided here, seemed to purple :/) and a sketchy attempt at trojan full super(which needs work, but hey I'm new at this)



All times are GMT +1. The time now is 16:22.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.