Page 1 of 1

IF THEN ELSE? of JUMP IF?

Posted: Sun Oct 09, 2016 11:54 pm
by blingblangblong
Hello I hope some one can help me with this problem.
I'm trying to achieve a hot corner of sorts but I am unable to create the code i need.
This is what i have come up with but it doesn't work

Code: Select all

from eg.WinApi.Dynamic import mouse_event, GetCursorPos, SetCursorPos, POINT

point = POINT()
GetCursorPos(point)

print point.x
print point.y

if point.x:0
    eg.TriggerEvent("CEC2.pause")
Thanks for your time
Richard

Re: IF THEN ELSE? of JUMP IF?

Posted: Mon Oct 10, 2016 1:46 am
by kgschlosser
i am not sure exactly what you are trying to accomplish with this script. but all you have to do is remove the 0 after the colon


the colon is there for an indicator that you have finished asking your question and if your question have been answered correctly then to do the statements that are tabbed under the question.


but with your question of:

Code: Select all

if point.x:
will always be answered as a yes unless your mouse is at position 0 on the horizontal axis.

so if you are looking for a specific point on the screen. then you would have to do

Code: Select all

if point.x == 510:
the == indicates that the 2 values must be identical. but in the world of mouse movements chances of that happening are very slim. so you would want to do a range

Code: Select all

if 500 < point.x < 520:
so this would be if point.x is larger than 500 and point.x is also less than 520 giving you a range of 20

if ya have any more questions feel free to ask

Re: IF THEN ELSE? of JUMP IF?

Posted: Mon Oct 10, 2016 2:30 pm
by blingblangblong
kgschlosser wrote:i am not sure exactly what you are trying to accomplish with this script. but all you have to do is remove the 0 after the colon
Hello and thank you for your help. I want to make a script that runs in a loop that can monitor mouse and activate something at that point of being there after a delay.
the colon is there for an indicator that you have finished asking your question and if your question have been answered correctly then to do the statements that are tabbed under the question.


but with your question of:

Code: Select all

if point.x:
will always be answered as a yes unless your mouse is at position 0 on the horizontal axis.
yes that is exactly what i want.
I want X and Y to be at 0 for x seconds before activating whatever command i want.
so if you are looking for a specific point on the screen. then you would have to do

Code: Select all

if point.x == 510:
the == indicates that the 2 values must be identical. but in the world of mouse movements chances of that happening are very slim. so you would want to do a range
Thanks i got it working of sorts with

Code: Select all

if point.x == 0:
eg.TriggerEvent("CEC2.pause")

Code: Select all

if 500 < point.x < 520:
The code above sounds better but i couldn't get it to work.
so this would be if point.x is larger than 500 and point.x is also less than 520 giving you a range of 20

if ya have any more questions feel free to ask
Thanks again for your help

Re: IF THEN ELSE? of JUMP IF?

Posted: Mon Oct 10, 2016 2:56 pm
by blingblangblong
Ok ive tried a few other variations and i'm now stuck with the loop in the wrong place

Code: Select all

from eg.WinApi.Dynamic import mouse_event, GetCursorPos, SetCursorPos, POINT
import time

for x in range(0, 5):
    point = POINT()
    GetCursorPos(point)
    print point.x
    print point.y
    if -1 < point.x < 20:
        eg.TriggerEvent("CEC2.pause")
    time.sleep(5)
but it loops 5 times for 5 times then triggers the event 5 times
i want to be able to get my mouse up there and then act on it once not 5 times

Re: IF THEN ELSE? of JUMP IF?

Posted: Mon Oct 10, 2016 3:48 pm
by blingblangblong
I also tried this and broke it into an endless loop lol

Code: Select all

from eg.WinApi.Dynamic import mouse_event, GetCursorPos, SetCursorPos, POINT
import time

def goto(linenum):
    global line
    line = linenum

line = 1
while True:
    if line == 1:
        point = POINT()
        GetCursorPos(point)
        print point.x
        print point.y
        if -1 < point.x < 20:
            goto (2)
        elif line == 2:
            eg.TriggerEvent("CEC2.pause")
            goto(20)
        else:
			time.sleep(5)
            goto(1)
    elif line == 20:
        break
any help would be great thanks

Re: IF THEN ELSE? of JUMP IF?

Posted: Tue Oct 11, 2016 6:36 am
by kgschlosser
it might be easier if you explain what you are trying to accomplish and then we can work from there and give you the best possible way to achieve what you want to do.

Re: IF THEN ELSE? of JUMP IF?

Posted: Tue Oct 11, 2016 4:31 pm
by blingblangblong
kgschlosser wrote:it might be easier if you explain what you are trying to accomplish and then we can work from there and give you the best possible way to achieve what you want to do.
OK I would like to make a python script that monitors my mouse at a given coordinates (x,y) (maybe 0, 0 or maybe 0, 1079 I'm not sure yet) wait then do something maybe stop music and put pc to sleep.
I'm sure I made that clear in one of my previous posts, no biggy hope you now understand what it is I'm trying to do, thank you again.

Re: IF THEN ELSE? of JUMP IF?

Posted: Thu Oct 13, 2016 11:02 am
by kgschlosser
ok so you want it to monitor all mouse movements all the time????. if so that is going to be a couple percent hit to your cpu.

and you would have to use threading for something like that. it's a pretty involved script. I don't have a problem coding it up for ya i just want to get all the info on exactly what ya want

Re: IF THEN ELSE? of JUMP IF?

Posted: Thu Oct 20, 2016 9:11 pm
by blingblangblong
kgschlosser wrote:ok so you want it to monitor all mouse movements all the time????. if so that is going to be a couple percent hit to your cpu.

and you would have to use threading for something like that. it's a pretty involved script. I don't have a problem coding it up for ya i just want to get all the info on exactly what ya want
Hello
Yes that would be great. do you mean threading inside the script? Or not sure what you mean by that. but i suppose i will see when you have done it :-)
Thanks


I have found another thing i want to do but not sure if it is possible.
My EG is set to send a cec command to mt TV to turn off when windows turns the monitor off. And it works great.
But i need it to some how check if the source is actually active on the TV as it turns off the TV when im on a different source.
I am unable to figure our how to get a dump of all commands the tv will accept if that is even possible?????

Re: IF THEN ELSE? of JUMP IF?

Posted: Fri Oct 21, 2016 9:53 am
by kgschlosser
Ok. My last post was more of a question. I need to know what is supposed to trigger the start of looking for a specific mouse location. And 2nd how often to check the position. Making it real-time will chew up to much CPU. And we also need to know the x, y coordinates for each of the 4 corners for s square of pixels. And what to do when you are in that square. Can't use a single point would be to hard to get the mouse to sit there. And also how long would the mouse have to sit there? And if it sat there should it continue to whatever it is over and over again?

And i do not know to much about CEC but what I do know is that the command set is dictated by the TV . So I would do some research on the TV and see what it supports