Jump to content
Sign in to follow this  
Asdafa

Almost working 1 little thing. (closing the program)

Recommended Posts

Asdafa

hi

i made this code that checks a image. I did not made that code but the code that i need wich 1 u can see here under.

What the code does is checking for a image. when it is found it will give the image 5 star.

But if the image is not found in 1500 sec it needs to close. Only thing is. It does not close. i don't know whats wrong, tryed other functions but i don't know whats wrong.

Like u can see i'm useing a timer. I tested the timer before and it works well.

A bit help with a explanation would be real nice.

HotkeySet ("{delete}", "STD")

#include <ImageSearch.au3>

a() 

Func a()
$Timedif = 1500
$Timer = TimerInit()
While 1
    If (TimerDiff($Timer)/1000) < $Timedif Then
        sleep (10)
        a0()
    Else
        STD()
        $Timer = TimerInit()
    EndIf
WEnd
EndFunc

Func STD()
ProcessClose("check.exe")
$PID = ProcessExists("check.exe")
If $PID Then ProcessClose($PID)
EndFunc

func a0()
dim $res
$x = 0
$y = 0

$res = _imagesearcharea('check.bmp',1,0,0,0,0,$x,$y,100)
If $res = 1 Then
sleep (10)
Kees()
Else
    mouseclick ("left", 180,180,2,1)
EndIf
EndFunc

Share this post


Link to post
Share on other sites
Melba23

Asdafa,

It does not close

Because you never ask it to close! :blink:

Look at this section of your code and my comments:

$Timedif = 1500
$Timer = TimerInit()
While 1
    If (TimerDiff($Timer) / 1000) < $Timedif Then
        ; Here is the code that will run if we are at less than 1500 secs   
        Sleep(10)
        a0()
    Else
        STD()
        ; If we get past 1500 secs we end up here
        ; You now reset the timestamp so that when we get to the top of the loop again we run the code above for another 1500 secs!!!!
        $Timer = TimerInit()
    EndIf
WEnd

You need to rethink the logic of this bit if you want to Exit at some point! ;)

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

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.