Re: Pulover's Macro Creator v5.2.8 - The Complete Automation Tool
Posted: 10 Oct 2020, 19:49
Thanks, WinActivate made the difference
Let's help each other out
https://www.autohotkey.com/boards/
Image search is a really nice function but sometimes it cannot find the searched image.Pulover wrote: ↑10 Oct 2020, 16:06In fact the problems you've described are not bugs in PMC. ImageSearch, PixelSearch and SoundBeep are ahk commands that it executes using the defined parameters, as you can see in the preview panel and you'd probably face the same problems with an exported script. You might have more luck searching the forum as not detecting image is a commonly asked question. Maybe just using WinActivate before ImageSearch might help.
Sometimes the issue is how the person is trying to use ImageSearch. Among the more common problems are:bluefire wrote: ↑12 Oct 2020, 14:12Image search is a really nice function but sometimes it cannot find the searched image.Pulover wrote: ↑10 Oct 2020, 16:06In fact the problems you've described are not bugs in PMC. ImageSearch, PixelSearch and SoundBeep are ahk commands that it executes using the defined parameters, as you can see in the preview panel and you'd probably face the same problems with an exported script. You might have more luck searching the forum as not detecting image is a commonly asked question. Maybe just using WinActivate before ImageSearch might help.
Do you have a tip for image search?
Code: Select all
CoordMode, Pixel, Screen
ImageSearch, FoundX, FoundY, 1049, 109, 1501, 150, *2 C:\Users\tzvi\AppData\Roaming\MacroCreator\Screenshots\Screen_20201013213116.png ; Regen
If (ErrorLevel)
{
MsgBox, 0, , regen not found`, click
}
CoordMode, Pixel, Screen
ImageSearch, FoundX, FoundY, 1049, 109, 1501, 150, *2 C:\Users\tzvi\AppData\Roaming\MacroCreator\Screenshots\Screen_20201013213116.png ; Regen
If (ErrorLevel = 0)
{
MsgBox, 0, , regen found
}
Maybe You Can Use Pixel Search. You are more likely to get success the hard way with Multiple Pixel Search.bluefire wrote: ↑12 Oct 2020, 14:12Image search is a really nice function but sometimes it cannot find the searched image.Pulover wrote: ↑10 Oct 2020, 16:06In fact the problems you've described are not bugs in PMC. ImageSearch, PixelSearch and SoundBeep are ahk commands that it executes using the defined parameters, as you can see in the preview panel and you'd probably face the same problems with an exported script. You might have more luck searching the forum as not detecting image is a commonly asked question. Maybe just using WinActivate before ImageSearch might help.
Do you have a tip for image search?
ImageSearch works on the active window and it's recommended to use WinActivate before each command. The problem in your code is the message box on the first result that steals focus from the target window, so without any sleep or WinActivate the next search fails.
I used the pixel search, but I got the same result as I did in the image search. How to use multiple pixels in PMC?hasantr wrote: ↑14 Oct 2020, 03:34Maybe You Can Use Pixel Search. You are more likely to get success the hard way with Multiple Pixel Search.bluefire wrote: ↑12 Oct 2020, 14:12Image search is a really nice function but sometimes it cannot find the searched image.Pulover wrote: ↑10 Oct 2020, 16:06In fact the problems you've described are not bugs in PMC. ImageSearch, PixelSearch and SoundBeep are ahk commands that it executes using the defined parameters, as you can see in the preview panel and you'd probably face the same problems with an exported script. You might have more luck searching the forum as not detecting image is a commonly asked question. Maybe just using WinActivate before ImageSearch might help.
Do you have a tip for image search?
Can you explain more about variation?SOTE wrote: ↑13 Oct 2020, 04:39Sometimes the issue is how the person is trying to use ImageSearch. Among the more common problems are:bluefire wrote: ↑12 Oct 2020, 14:12Image search is a really nice function but sometimes it cannot find the searched image.Pulover wrote: ↑10 Oct 2020, 16:06In fact the problems you've described are not bugs in PMC. ImageSearch, PixelSearch and SoundBeep are ahk commands that it executes using the defined parameters, as you can see in the preview panel and you'd probably face the same problems with an exported script. You might have more luck searching the forum as not detecting image is a commonly asked question. Maybe just using WinActivate before ImageSearch might help.
Do you have a tip for image search?
1. Not using a wide enough search.
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\My Images\test.bmp
2. Not knowing about using *n (variation) option. This way you are not looking for an exact match, but what is relatively similar by color.
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 C:\My Images\test.bmp
3. As mentioned, not using WinActivate on the Window you want to conduct an image search on or not using the right CoordMode
https://www.autohotkey.com/docs/commands/WinActivate.htm
https://www.autohotkey.com/docs/commands/CoordMode.htm
If the problem is not specific to Pulover's Macro Creator, but how to use AutoHotkey in general, you might want to ask in the Help Forum.
https://www.autohotkey.com/boards/viewforum.php?f=76
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 C:\My Images\test.bmp
Thank you very much for your answer. It was a very revealing answer.SOTE wrote: ↑14 Oct 2020, 20:20ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 C:\My Images\test.bmp
*variation (*50 in the above example or *n in the help file), is a number between 0 and 255 that you can pick. 0 is the default, the most strict, and requires an exact match. 255 would be the most promiscuous, where almost anything could match.
There can be slight color differences between the image file (test.bmp in the above example), type of file format (like JPG or PNG), and the image on the screen. To compensate, you loosen up on how strict ImageSearch will be on matching colors. Instead of *2, you might try *20 or *80. Nobody can say what will be the best number. It's something you play with, if an exact match can't be found, and is part of the troubleshooting process. It's common for AHKers (especially new or less experienced) to overlook this or not be aware the option exists.
https://www.autohotkey.com/docs/commands/ImageSearch.htm
(ImageSearch)
Note- PixelSearch has a similar option that's doing the same (*n in ImageSearch), and it's more obviously called Variation. Some AHKers overlook it too (per Help forum), though probably not so much as with ImageSearch as the name (variation) is more obvious and the help file example uses it.
https://www.autohotkey.com/docs/commands/PixelSearch.htm
(PixelSearch)
Version Update!
Version 5.2.9Download version 5.2.9
- Updated Compare variables in If Statements window to use expressions with symbols operators only.
- Fixed bugs in duplicate and paste in groups.
- Fixed mixed history when adding slots after using undo.
- Fixed escaped percent signs in strings (`%) being wrongly converted to variables during playback.
Code: Select all
InputBox, GearSelector, Chose your gear, Enter "r" for research Clothes`, "t" for Training Gear`, or "p" for Spying. Case sensitive
Sleep, 185
WinActivate, March of Empires: War of Lords
If (GearSelector = r)
{
Text1 := "research speed"
Xs := [395,395,395,395,395,1026,1026,1026,1026,1026]
Ys := [199,289,389,489,562,199,289,389,489,562]
Goto, StartOfLoop
}
If (GearSelector = t)
{
Xs := [395,395,395,395,395,1026,1026,1026,1026,1]
Ys := [199,289,389,489,562,199,289,389,489,562]
Text1 := "training speed"
Goto, StartOfLoop
}
If (GearSelector = p)
{
Xs := [395,395,395,395,395,1026,1026,1026,1026,1026]
Ys := [199,289,389,489,562,199,289,389,489,562]
Text1 := "spy"
}
Else
{
MsgBox, 0, , % GearSelector, 185
Goto, endScript
Code: Select all
InputBox, GearSelector, Chose your gear, Enter "r" for research Clothes`, "t" for Training Gear`, or "p" for Spying. Case sensitive
Sleep, 185
WinActivate, March of Empires: War of Lords
IfInString, GearSelector, r
{
Text1 := "research speed"
Xs := [395,395,395,395,395,1026,1026,1026,1026,1026]
Ys := [199,289,389,489,562,199,289,389,489,562]
Goto, StartOfLoop
}
IfInString, GearSelector, t
{
Xs := [395,395,395,395,395,1026,1026,1026,1026,1]
Ys := [199,289,389,489,562,199,289,389,489,562]
Text1 := "training speed"
Goto, StartOfLoop
}
IfInString, GearSelector, p
{
Xs := [395,395,395,395,395,1026,1026,1026,1026,1026]
Ys := [199,289,389,489,562,199,289,389,489,562]
Text1 := "spy"
}
Else
{
MsgBox, 0, , % GearSelector, 185
Goto, endScript
}
Version Update!
Version 5.3.0Download version 5.3.0
- Fixed bug in Compare variables of If Statements window.
There was indeed a bug with the last update. I didn't test the change as I should I made a mistake... really should have went to bad before releasing that update late at night.