AutoHotkey Community

It is currently May 27th, 2012, 3:19 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: ImageSearch not working
PostPosted: October 19th, 2005, 10:47 pm 
Offline

Joined: April 16th, 2005, 1:05 am
Posts: 28
I have been looking though the fourm and have seen some other people with the same problem as me. they seem to get it to work but nothing they changed helped me.

my code is just a test for something else and it comes right from the help file.

Code:
ImageSearch, xcord, ycord, 0, 0, A_ScreenWidth, A_ScreenHeight, *150 Explorer.exe
if ErrorLevel = 2
   MsgBox Could not conduct the search.
else if ErrorLevel = 1
   MsgBox Icon could not be found on the screen.
else
   MsgBox The icon was found at %xcord%,%ycord%


all i am trying to do is find an image on my desktop. to does not seem to mater what file path/name i put in it the error level is always 1.

i tried C:\WINNT\Explorer.exe, %A_ScriptDir%\Explorer.exe, i put a .bmp on the desktop and looked for that using %A_ScriptDir%\test.bmp and C:\Documents and Settings\user\desktop\test.bmp and the error level is always set to 1.

is my code wrong?

_________________
cstone


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2005, 11:23 pm 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
Sorry, found only 18 Icons in Explorer.exe, what icon did you search for?
Image
You can use the Icon Browser from the script section
http://www.autohotkey.com/forum/viewtopic.php?t=5587

*150 is the shade option, I think, you need to define the icon-number, too.
e.g. *icon3 for the printer


Last edited by garath on October 20th, 2005, 12:06 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2005, 11:50 pm 
Offline

Joined: April 16th, 2005, 1:05 am
Posts: 28
I used the *Icon1 (this being the my computer icon) but the error level is still at 1 unless i have notepad open then it says it is at 237,198 (the cords of the window, and it only works with notepad). if i have just he desktop showing then the error level is 1. using window spy the cords that should be returned are 21,78.

i tried putting in A_ScriptDir but then the error level is 2.

if i just have test.bmp on the desktop would i use just C:\Documents and Settings\user\Desktop\test.bmp to the the cords of the icon or do i need to have *IconN in it also?

_________________
cstone


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2005, 12:11 am 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
hmm, could you post the icon, you are looking for?
And a sample of your aplication window?
If you have the icon as bitmap, you don“t need *iconN
You need the bmp in the same dimension as the icon in the application-window


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2005, 12:20 am 
Offline

Joined: April 16th, 2005, 1:05 am
Posts: 28
the code that i am useing is:
Code:
ImageSearch, xcord, ycord, 0, 0, A_ScreenWidth, A_ScreenHeight, *150 C:\Documents and Settings\user\Desktop\test.bmp
if ErrorLevel = 2
   MsgBox Could not conduct the search.
else if ErrorLevel = 1
   MsgBox Icon could not be found on the screen.
else
   MsgBox The icon was found at %xcord%,%ycord%


i am not sure how to post the icon. all it is is a .bmp file that i created on my desktop.

by aplication window do you mean my desktop? both the script and the .bmp file are on my desktop.
do i need to be looking for the picture that the icon is? i did try to do that by using %SystemRoot%\System32\mspaint.exe but that doesn't work either. but regardless of how i change the code if notpad is open it returns the coords for that.



if you where to (on your desktop) go right click -> New -> BMP file and name it test, using ImageSearch how would you find the coords to that icon?

_________________
cstone


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2005, 1:18 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
This could be a problem caused by an icon resource having multiple icons in it that are the same except for their varying color depth. Try extracting the candidate icon(s) with a tool such as LiquidIcon. Save the file as a ico file and use that with ImageSearch.

Here's a related topic you've probably already read: Recognize SysTray Icon


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2005, 2:03 am 
Offline

Joined: April 16th, 2005, 1:05 am
Posts: 28
do you know of any other way to find the placement of icons on the desktop that doesn't enovle ImageSearch?

the program i am thinking about will be used on more then one computer and i won't be able to extract the icon files on them.

_________________
cstone


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2005, 7:15 am 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
Which program do you want to use, could you use shortcuts?
Maybe you can select certain controls, check it with "Window Spy" which is part of the Autohotkey installation.
Why do you want to look for the placement of the icon, do you really need to know, if there is that icon?
Couldnt you read the file-content of the Folder "Desktop"?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2005, 9:41 pm 
Offline

Joined: April 16th, 2005, 1:05 am
Posts: 28
the program i am looking into has to do with moving icons around the desktop and most of the icons can't be shortcuts. i have numerous computers that i would like to look the same (and i change the looks on occasion) so i would prefer to have a program that automaticly moves the icons for me instead of haveing to do it all myself.

i am not even sure if this is possable with autohotkey, but i am just looking into it. either way i still get to know the program better.

_________________
cstone


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2005, 9:54 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Since the desktop is a ListView, you could try using "ControlGet List" on it. However, I'm not sure if this will give you the position info you need.

Another approach is PixelSearch or PixelGetColor, which might be a more lenient approach than ImageSearch if the icons in question have a unique colors or patterns of colors in them.

Finally, there are some messages you can send to a ListView to find out the positions of its icons, such as LVM_GETITEMPOSITION. However, they might all require sending a structure via message. Worse yet, I think the structure must be allocated in the remote process's address space with VirtualAllocEx(), which if true would make this approach pretty difficult.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2005, 11:04 pm 
Offline

Joined: April 16th, 2005, 1:05 am
Posts: 28
i am horrable at figuring out how to use Send/PostMessage. the LVM_GETITEMPOSITION may work if i knew how to set it up.

is there any way to get only a portion of a control?
since the desktop is a control called SysListView321 inside of the window Program Manager, would it be possable to say make another control inside that window, or get only a portion of the original control?

_________________
cstone


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2005, 1:52 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
cstone wrote:
is there any way to get only a portion of a control?
"ControlGet List" can retrieve only the selected or focused icons if you specify that option. Other than that, the only way to get part of the control is to retrieve all of its rows (icons) and then have the script examine the list and filter out the ones you don't want.

Quote:
would it be possable to say make another control inside [Program Manager]
I don't think so.

Quote:
i am horrable at figuring out how to use Send/PostMessage. the LVM_GETITEMPOSITION may work if i knew how to set it up.
This should be a last resort, after you've exhausted other approaches such as creative use of PixelSearch or PixelGetColor. This is because it would take even a programming expert at least a half hour to write such a script. Even then, it is uncertain it would do what you need it to do, so it might turn out ot be a waste of time (some further discussion beforehand could reduce this uncertainty).


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, rbrtryn and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group