Jump to content
kevilex

Image search, fonts, etc.

Recommended Posts

kevilex

Hey, I have an interesting issue where I have tried to make a script where it takes a picture of a part of my monitor in which I have saved to $test, and after doing so, it would image search another part of the monitor for the same image. After checking if it is on the other part of the monitor, it would call my function Yes or the function No, based on the . After some trial and error I ended up with this code (sorry for the delays). I put this in the scenario that it was intended for and I quickly realized that the $test image was slightly bigger at one side of the monitor. 

This got me wondering if I could make it in any other ways, the picture is based on numbers and text, so therefore I am wondering there's an easy way of adding a font to an image search where it would recognize the numbers and values for then to compare to each other.

 

I'm sorry if I am missing some key points, this is one of my first scripts (, absolute first with image search) and I am really excited to get this working! :)

While $loop <> 5
   FFSnapShot (655, 576, 697, 604, 1, "test" )
   Sleep(1000)
   FFApplyFilterOnSnapshot( 0, 0, 0, 1)
   Sleep(1000)
   FFSaveBMP ("test")
   Sleep(1000)
   $search = _ImageSearchArea("test.bmp",1,553, 224, 794, 462, $x, $y, 10,$HBMP=0)
   Sleep(1000)
   If $search = 1 Then
   Sleep(1000)
   Call(Yes)
Else
      Sleep(1000)
      Call(No)
   EndIf
   Sleep(1000)
FileDelete ( @DesktopDir test.bmp" )

   WEnd

Share this post


Link to post
Share on other sites
kevilex
#include <ImageSearch.au3>
#include "FastFind.au3"
#include <GDIPlus.au3>
HotKeySet("q", "MyExit")
$x = 0
$y = 0
$loop = 1
$yesx = 795
$yesy = 577
$nox = 553
$noy = 566
$Number = @ScriptDir & "test.bmp"
$HBMP = 0
WinActivate ("test")
While $loop <> 5
   FFSnapShot (655, 576, 697, 604, 1, "test" )
   Sleep(1000)
   FFApplyFilterOnSnapshot( 0, 0, 0, 1)
   Sleep(1000)
   FFSaveBMP ("Number")
   Sleep(1000)
   $search = _ImageSearchArea("Number.bmp",1,553, 224, 794, 462, $x, $y, 10,$HBMP=0)
   Sleep(1000)
   If $search = 1 Then
   Sleep(1000)
   Call(Yes)
Else
      Sleep(1000)
      Call(No)
   EndIf
   Sleep(1000)
FileDelete ( @ScriptDir number.bmp" )

   WEnd
Func yes()
   MouseClick("left", $yesx, $yesy)
EndFunc
func No()
   MouseClick("left", $nox, $noy)
EndFunc
Func MyExit ()
   Exit
EndFunc

Here you have the full code, couldn't edit the post for some reason, sorry!

Share this post


Link to post
Share on other sites
Jos

@kevilex,
Moved to the appropriate forum, as the DEV forum very clearly states:

{Do not create AutoIt-related topics here, use AutoIt General Help and Support}

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
kevilex
2 minutes ago, Jos said:

@kevilex,
Moved to the appropriate forum

Don't know the difference, but thanks!

Share this post


Link to post
Share on other sites
Jos
Posted (edited)
6 minutes ago, kevilex said:

Don't know the difference, but thanks!

Which part  of that quoted line is unclear to you as I would think it is pretty strait forward.... no?

Your script has several syntax errors and logic errors, so aren't you getting errors when running it?

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
kevilex
1 minute ago, Jos said:

Your script has several syntax errors and logic errors, so aren't you getting errors when running it?

Yeah, it runs

Share this post


Link to post
Share on other sites
kevilex

I have tested both when it should call the yes and no function, it works perfectly. The problem is just that the thing it was supposed to find was another size, and I need a fix for that ^^ 

Share this post


Link to post
Share on other sites
JLogan3o13

How about some explanation as to what you're actually trying to accomplish. You are finding one of the many reasons not to use image/pixel search unless there are no alternatives. I guarantee there is a better way to accomplish what you are after.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
kevilex

I am new to coding, therefore just chosing a task and trying to complete it in the easiest way possible. In my case, I like to practice this in flashgames, I've done several games where pixelsearch have done me plenty, but at this game I can't seem to do the same thing because the dimensions is off and it's based off of numbers in which has to be read. The game is hard to do a DOM explore search for the elements because it is all like a giant picture, therefore making me go into the sourcecode, where I have next to no clue what's going on.

So what I am trying to do is to get some practice in coding thoughtprocess and general syntaxes. I would highly appreciate some help with this as I want to learn more about more advanced stuff. I know that games are not allowed to be cheated on this website, but since it is a flashgame and I am not going to embarrase myself by publicly posting it, why not learn with it now that I am done making calculators, etc.

The game is Bingo on facebook if you want to help me, either I need some way of getting the numbers to match up with each other, or I am going to need the element.

Share this post


Link to post
Share on other sites
Melba23

kevilex,

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked.

See you soon with a legitimate question I hope.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×