Posts: 51
Threads: 6
Joined: Jan 2005
EDIT:
Okay id like to add something in my code, that if this color: 0xFB00 is NOT at this location: 95 132, for the script to: key 4
I want the script to look for this color throughout the whole thing. At any time that color is not at that location, for it to key 4.
Ive tried a few things, but nothing seems to be working, and i dont really understand why
Thanks for the help
Posts: 1,271
Threads: 399
Joined: Mar 2003
do you mean:
if not color at xm ym in window x then make key 4 ?
Posts: 51
Threads: 6
Joined: Jan 2005
Yeah. If the color Z is not at location X Y, at any time throughout the whole of the script, key 4
z= 0xFB00
X,Y= 95 132
Posts: 1,271
Threads: 399
Joined: Mar 2003
Posts: 51
Threads: 6
Joined: Jan 2005
With that however, it waits for a specific color, then when that color is visable at that location, the macro starts. Thats not what i am looking for, i know how to do that.
I allready have my macro running, and at ANY time throughout the macro, if the color disappears from the location, to press key 4, while the rest of the macro continues to run (or it pasues for a second while key 4 is pressed, then continues where the macro left off), and lets say 10sec later, if the color disapeaers, to again, press key 4. So while the macro is running, i want this other independent part of it, looking all the time at the location. for that color to disapear, and to press key 4. I guess it would be easier to do it in a different macro, and have 2 macro's running at once, however, id like to keep it all in the same macro.
thanks,
Posts: 1,271
Threads: 399
Joined: Mar 2003
please be patient be me.
so which part is now missing in your function ?
Posts: 51
Threads: 6
Joined: Jan 2005
Well i have my macro set up and running.
While the macro is running, i would like it allways watching the location of: 95 132,for the color: 0xFB00. if at any time throughout the macro, that the color 0xFB00, is not there, i want the macro to press key 4.
I hope im being clear, as i see no other way to put it :?
thanks,
Posts: 1,271
Threads: 399
Joined: Mar 2003
so you ask for a global watcher ?
you can add something like this to your init2 macro:
tim 1 your_color_checker_macro
Posts: 51
Threads: 6
Joined: Jan 2005
Not exactly sure how to do that. Could you maybe explain it alittle further? possibly using the location and colors mentioned above?
Thanks again
Posts: 51
Threads: 6
Joined: Jan 2005
Heres a different way it can work:
i want while the macro is running, if at anytime throughout the macro if this pixel color appears: 0x238, at this location: 88 133, for it to: Key 4
Posts: 1,271
Threads: 399
Joined: Mar 2003
when you want to have a macro running independent, then the macro
has to be declared as function.
-> your macro -> properties -> type -> change macro to function
two macros can't run at the same time.
but 1(n) function and a macro can ...
Posts: 51
Threads: 6
Joined: Jan 2005
Okay i created a new function, have it filled with that i want. Now how do i add it to my main macro, that when the macro starts up, it activates this function aswell?
also can a function be something like this:
rep 999999999999999
WaitPixelColor(0 0x238 88 133)
key 4
???
Posts: 1,271
Threads: 399
Joined: Mar 2003
let me put it straight:
add your function to the init2 macro:
tim 1 your_color_checker_function
on qm start your_color_checker_function will be executed once per second.
better wait for gintaras to clean up my answers
Posts: 51
Threads: 6
Joined: Jan 2005
dosnt seem to be working. I have this in my function:
int c=pixel(88 133)
if (c=0x238)
,key 4
and i have
at the top of my macro. And the function dosnt seem to be working. I read up alittle on functions, and i think what im trying to make the function do, is not possible for a fucntion. Any ideas?
Posts: 12,092
Threads: 142
Joined: Dec 2002
Put this at the beginning of the main macro:
mac "your_color_checker_function"
This starts the function to run asynchronously, simultaneously with the main macro.
Now, how to stop the function when the main macro ends? For example, you can use a global variable. But it is easier to use shutdown -6, unless your QM version is quite old. Place this at the end of the main macro:
err+
shutdown -6 0 "your_color_checker_function"
Posts: 51
Threads: 6
Joined: Jan 2005
Hmm still dosnt seem to work. Ive tried to have a few things in function, but nothing seems to come up good. This is what i have right now:
WaitPixelColor(0 0x4053B 95 135)
key 4
As simple as it could get, but it dosnt seem to work, i also have the mac "name" In my macro. Any ideas what the problem could be?
Posts: 12,092
Threads: 142
Joined: Dec 2002
The function could be:
rep
,if(pixel(95 135)=0x4053B)
,,key 4
,0.1
Posts: 51
Threads: 6
Joined: Jan 2005
lol, well i figured out what the problem was, the pixel was set to something like 3% opacity, something i couldnt reconize by looking at it, and the pixel itself would change depending on whats in the foreground, bot is my face red :oops:
Posts: 51
Threads: 6
Joined: Jan 2005
Gintaras Wrote:Put this at the beginning of the main macro:
mac "your_color_checker_function"
This starts the function to run asynchronously, simultaneously with the main macro.
Now, how to stop the function when the main macro ends? For example, you can use a global variable. But it is easier to use shutdown -6, unless your QM version is quite old. Place this at the end of the main macro:
err+
shutdown -6 0 "your_color_checker_function"
I tried the shutdown thing, however it dosnt seem to be working. Unless its something else that im thinking off, how do i make it that when i click end macro, it ends the function aswell? Because many times ill end macro for a second, and start it back up. Then later ill look and ill have like 4 functions up when i go to end function...so how do i do it, that when i end macro(right click on tray and end macro) that the function ends aswell?
Posts: 12,092
Threads: 142
Joined: Dec 2002
Here is another way. Remove all previously added code from the beginning and end of the macro, and add this to the beginning:
atend your_color_checker_function 1
mac "your_color_checker_function"
Function your_color_checker_function:
function [onmacroexit]
if(getopt(nthreads)>1) ret ;;allow only single instance
int+ g_stop=onmacroexit; if(g_stop) ret
rep
,if(pixel(95 135)=0x4053B)
,,key 4
,0.1
,if(g_stop) ret
Posts: 331
Threads: 60
Joined: May 2006
not sure if this can be done and if it can be done how slow it would be but im wanting to konw if a color exists in a window i dont want to look at just one pixel in the window i want to look for the color on the whole window every pixel, lets say my window im looking at is 300 by 300 pixels i want to do an if the color blue is on that window at all it runs the code thats indented, here is an EX of what im trying to do
if(pixel(window name)=0x4053B)
,clo "window name"
Posts: 12,092
Threads: 142
Joined: Dec 2002
Getting all pixels with pixel is very slow. Use scan to find image.
|