ftscoding Posted January 9, 2013 Posted January 9, 2013 Like the title says. I made a script, and it relies on ImageSearch and .bmp's. I need it to search for a word in a certain context, and this word has backgrounds that change constantly. For this reason, I made a bmp file of the word, and removed the background for nothing, basically (on Photoshop, I deleted the areas that did not belong to the word, leaving only the word and a transparent background behind it). However, I wasn't able to test this yet, since it is a rare occurance, and I have no idea on what else to test it on. So, anyone has any experience on this? Does AutoIt/Imagesearch take the transparent area as white, or does it actually recognize the transparency? Thank you for your help and time.
Xandy Posted January 9, 2013 Posted January 9, 2013 (edited) Yes make a mask. Only check flagged pixels in the mask, like anything not bkcolor. So two images. Sample actual data, then use a mask to decide what to check. EDIT: A bmp does not have transparency by it'self. You will detect the color that represents transparent, use your mask to negate that. Edited January 9, 2013 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker)
Xandy Posted January 9, 2013 Posted January 9, 2013 (edited) Actually I didn't use ImageSearch. Here is a snip example, it's to complex for me to bother adapting it to run stand alone. Maybe you can figure out what you need from it though. expandcollapse popupif $mask= 1 then for $y= 0 to $rh-1 for $x= 0 to $rw-1 if _GDIPlus_BitmapGetPixel($hbmpmask, $x, $y)<> 4278190080 then;if not mask ignore if _GDIPlus_BitmapGetPixel($hbmpscreen, $x, $y)= _GDIPlus_BitmapGetPixel($hbmprect, $x, $y) then $pixelmatch+=1 endif endif next if $pixelmatch> $pixelmatchmax then $docondition= 1 exitloop endif next else;no mask for $ii= $ay to $ay+$ah;check a programmable area of any rect size $pixelmatch= 0 for $i= $ax to $ax+$aw $pixelmatch= 0 for $y= 0 to $rh-1 for $x= 0 to $rw-1 if _GDIPlus_BitmapGetPixel($hbmpscreen, ($i+$x)-$ax, ($ii+$y)-$ay)= _GDIPlus_BitmapGetPixel($hbmprect, $x, $y) then $pixelmatch+= 1 endif if $pixelmatch= 0 then $x= $rw next if $pixelmatch> $pixelmatchmax then $docondition= 1 ;store point found $udvariable[$macro[$macroid][$macrocommand[$macroid][0]][35]]= $i $udvariable[$macro[$macroid][$macrocommand[$macroid][0]][36]]= $ii $i= $ax+$aw;this will exit loop $ii= $ay+$ah;this will exit loop exitloop;this will exit loop endif if $pixelmatch= 0 then $y= $rh next;next y next;next i next;next ii endif;end if mask Edited January 9, 2013 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker)
ftscoding Posted January 10, 2013 Author Posted January 10, 2013 Thanks for the answers, they surely are helpful. I'll try to look it up and see what I can do with it, thanks
Developers Jos Posted July 21, 2017 Developers Posted July 21, 2017 In how many threads were you planning to ask the same questions in different ways? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
ZxPwd Posted July 21, 2017 Posted July 21, 2017 Which ever one it would take to get an answer faster.
Developers Jos Posted July 21, 2017 Developers Posted July 21, 2017 Wrong answer! SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
ZxPwd Posted July 21, 2017 Posted July 21, 2017 13 hours ago, Jos said: Wrong answer! I know it's the wrong answer but you came off as mostly rude so I had too.
KickStarter15 Posted July 22, 2017 Posted July 22, 2017 (edited) @ZxPwd Never get back your reason on how people responded you in your post especially to our developers. Learn to be more cooperative like others, lets say you open up an old thread about 4 years old but have you tried it by yourself if that code works? as what your posted comment, I think you need to check it first before posting so many related thread in this forum with the same question. KS15 Edited July 22, 2017 by KickStarter15 Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.
Developers Jos Posted July 22, 2017 Developers Posted July 22, 2017 7 hours ago, ZxPwd said: you came off as mostly rude so I had too. You were rude already by cross posting the same question at multiple places, hence my comment. Don't particularly have patience for people that do that and still don't see you care much about it do you? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now