Jump to content
Sign in to follow this  
Archetype90

Image Search Problems

Recommended Posts

Archetype90

Hello,

I recently followed the following Image Search tutorial;

I followed it to the letter, using the iTunes logo on my desktop as the picture. But, after finishing and pressing the hotkey, the macro does nothing. I have the ImageSearch.au3 in the folder as well as the DLL and picture of the icon. Here is my code;

#include 

HotKeySet("{F4}", "Start")

$X = 0
$Y = 0

Func Start()
$Search = _ImageSearch('Rare.bmp',0,$X,$Y,0)
If $Search = 1 Then
MouseMove($X, $Y, 10)
EndIf
EndFunc

while 1
sleep(100)
WEnd

Any help as to why this is not working would be greatly appreciated. I have tried turning the transparency up, but had no luck. Thanks!

Share this post


Link to post
Share on other sites
abberration

That's actually an awkward and unreliable way of doing things. In the help file, look up FileExists and FileGetShortcut. You could say something like:

$shortCutExists = 0 ; no shortcut yet
If FileExists(@DesktopCommonDir & "\iTunes.lnk") Then
    $sName = FileGetShortcut(@DesktopCommonDir & "\iTunes.lnk")
    $shortCutExists = 1 ; does exist
EndIf

If $shortCutExists = 1 Then
    Run($sName[0])
EndIf

^ Untested code. I just wanted to give you a general example of what I was talking about.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites
Archetype90

That's actually an awkward and unreliable way of doing things. In the help file, look up FileExists and FileGetShortcut. You could say something like:

$shortCutExists = 0 ; no shortcut yet
If FileExists(@DesktopCommonDir & "\iTunes.lnk") Then
$sName = FileGetShortcut(@DesktopCommonDir & "\iTunes.lnk")
$shortCutExists = 1 ; does exist
EndIf

If $shortCutExists = 1 Then
Run($sName[0])
EndIf

^ Untested code. I just wanted to give you a general example of what I was talking about.

Thanks for the reply!

I've been wanting to fiddle around with ImageSearch for a while now and I thought that tutorial would be a good place to start. Since I couldn't get that working I figured I was doing something fundamentally wrong with it and was hoping to get solutions about how to fix it. Thanks for the alternative for finding an icon, but my overall goals are not to find the icon, but to fiddle around with ImageSearch and get it working.

Share this post


Link to post
Share on other sites
ileandros

This should work for you.

#include <ImageSearch.au3>
$x1=0
$y1=0
HotKeySet( "S", "Start" )
HotKeySet( "E", "End" )
While 1
   Sleep (100)
WEnd
Func Start()
   While 1
   $result = _ImageSearch("Rare.bmp",1,$x1,$y1,0)
   if $result=1 Then
   MouseMove($x1,$y1,3)
  Else
   MsgBox(0,"", "Can't find image")
   EndIf
   WEnd
EndFunc
Func End()
   Exit
EndFunc

Make sure to include your library. If the script doesnt finds your icon then it could be your picture.

Check if you have the right imagesearch library.

Try to save your picture in .png and change it in Rare.png to test it


I feel nothing.It feels great.

Share this post


Link to post
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
Sign in to follow this  

×