Jump to content

Check every 10sec _ImageSearch()


Recommended Posts

Your imagesearch needs to be inside the loop, it only checks it once before going into the loop as written.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

12 hours ago, BrewManNH said:

Your imagesearch needs to be inside the loop, it only checks it once before going into the loop as written.

Now it works! But the while loop will not end also if the image is found...

Link to comment
Share on other sites

You know that every functions returns some indication telling you that the function endet successfully or that an error occurred? Depending on this indication you have to check for the image again or leave the loop.
The rest is pure AutoIt ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Developers
3 hours ago, Zag8888 said:

Can you please explain how can I do this? Thanks

Only if you are willing to share what you are doing exactly or else it is guess work.

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.
  :)

Link to comment
Share on other sites

  • Developers

Sure...but WHAT do you want to use this for so WE can try to help you... Else please don't waste our time and forum space. Clear enough for you this time?

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.
  :)

Link to comment
Share on other sites

21 minutes ago, Jos said:

Sure...but WHAT do you want to use this for so WE can try to help you... Else please don't waste our time and forum space. Clear enough for you this time?

Jos

I made a photo, I just want the script click on this photo when its found, that's all. I just want to learn Autoit, I'm liking it a lot!

Link to comment
Share on other sites

 You are lucky that I have seen your topic !

=======

First of all, you shouldn't use the ordinary image search function...as it is not good because it requires that the image appears on the screen, so you can't do any other thing while the script is running

,so you need  the ~:{:}{ImageSearchEX}{:}:~ function

by it,you can search for the image in a specific window...and the function don't require that the image appears on the screen >> only it should appear on the window

,so this function run in the background

=======

Image Search EX Topic  : https://www.autoitscript.com/forum/topic/196542-image-search-inactive-window-but-not-minimized/

=======

note that :

1 : This function doesn't run on X64 bit ,so you have to make the script run on 32 bit by using :

#AutoIt3Wrapper_UseX64=NO

2 : This function requires the window to be shown ,not minimized or hidden.

,so if you want to hide the window  : just move it to (-X , -Y) Position that is out of the screen

======

Eventually : Here is the code you need :

#NoTrayIcon
#AutoIt3Wrapper_UseX64=NO
#include <imageSearchEX.au3>

Global $imageSearchEX = imageSearchEX
Global $_Check_Image  = _Check_Image

$Your_Window = "";your window
$Your_Control = "";your Control
$Your_Image = "";your Image

While 1
$Coords = $_Check_Image($Your_Window,$Your_Control,$Your_Image)
If $Coords <> 0 Then
    ;Do Something
    ExitLoop
EndIf
Sleep(10000) ;Sleep 10 Seconds
WEnd


Func _Check_Image($Window, $Control, $Image)
$Hwnd = WinGetHandle($Window)
$Control_Pos = ControlGetPos($Hwnd,$Control)
$Coords = $imageSearchEX($Hwnd,$Image)
Return $Coords
EndFunc

 

 

 

Link to comment
Share on other sites

Sorry,the code is not complete ..i didn't revise it 🤒

Also, there is no (Edit) Button 🙄

Here it is :

#NoTrayIcon
#AutoIt3Wrapper_UseX64=NO
#include <imageSearchEX.au3>

Global $imageSearchEX = imageSearchEX
Global $_Check_Image  = _Check_Image

$Your_Window = "";your window
$Your_Control = "";your Control
$Your_Image = "";your Image

While 1
$Coords = $_Check_Image($Your_Window,$Your_Control,$Your_Image)
If $Coords <> 0 Then
    ;Do Something
    ExitLoop
EndIf
Sleep(10000) ;Sleep 10 Seconds
WEnd


Func _Check_Image($Window, $Control, $Image)
$Hwnd = WinGetHandle($Window)
$Control_Pos = ControlGetPos($Hwnd,$Control)
$Coords = $imageSearchEX($Hwnd,$Image)
$Result = $Coords
If $Coords <> 0 Then
    Local $Image_Pos[] = [ $Coords[0] - $Control_Pos[0], $Coords[1] - $Control_Pos[1] ]
    $Result = $Image_Pos
EndIf
Return $Result
EndFunc

 

Link to comment
Share on other sites

  • Developers

Hey @El-Masry, or should I say @ibrahem...  and what an entrance 😟

10 hours ago, El-Masry said:

You are lucky that I have seen your topic !

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.
  :)

Link to comment
Share on other sites

  • Developers

Ah ... the victim role.  I am not shedding any tears as you know that you were not banned because nobody helped you.
You will be on a very short leece so 1 single "mistake" will get you banned. 

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.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...