screenmouseloc not cutting it
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
screenmouseloc not cutting it
tried to find something in the dictionary but no good. I want set the location of the mouse to a specific location in the program. not to the screen. Will i have to go the long way around and get the screen dimensions, the program dimensions, the location of the program on the screen then use some mathematics to work out where in the screen would equal to the place i need in the program?
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: screenmouseloc not cutting it
The toLocal and toGlobal functions translate points between coordinate systems.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: screenmouseloc not cutting it
hmmm. i dont see them in the dictionary
Re: screenmouseloc not cutting it
@RichardFourthWorld wrote: ↑Fri Oct 13, 2017 5:48 pmThe toLocal and toGlobal functions translate points between coordinate systems.
Maybe you have these functions in your own personal libraries, but these are no build-in LC functions!

@Da_Elf
...
## It ain't THAT much math!
put the mouseloc into tML
add the left of this stack to item 1 of tML
add the top of this stack to item 2 of tML
set the screenmouseloc to tML
...
Best
Klaus
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: screenmouseloc not cutting it
on mouseDown
put the mouseLoc
end mouseDown
will give you the location of your mouse/pointer
on the stack regardless of where your stack
is on screen.
Some people JUST LOVE over-complicating things
put the mouseLoc
end mouseDown
will give you the location of your mouse/pointer
on the stack regardless of where your stack
is on screen.
Some people JUST LOVE over-complicating things

Re: screenmouseloc not cutting it
I am guessing you want to move the mouse (cursor) to a specific location within the borders of the program window, not get the location of the mouse, Klaus's would be the closest.
Code: Select all
on [message]
set the screenMouseLoc to the topLeft of this stack
end [message]
... alternately, whatever formula you want to use, based on one or more of the programs rectangle dimensions, left, right, top, or bottom, see 'rect' or 'rectangle' property.
Last edited by bogs on Fri Oct 13, 2017 7:40 pm, edited 1 time in total.

Re: screenmouseloc not cutting it
lets say the program is 500x500
i want the mouse moved to the middle of the program then i want to set mouse location to 250,250
i want the mouse moved to the middle of the program then i want to set mouse location to 250,250
Re: screenmouseloc not cutting it
Not elegant, but pretty self explanatory, it can be written MUCH shorter, like one line long.
The answer box is in there for you to watch what happens as you move the stack around. Use the return key to OK the answer dialog.
Code: Select all
on mouseUp
answer "This stacks location is " & the rect of this stack
put item 1 of the rect of this stack into tmpX
put item 2 of the rect of this stack into tmpY
set the screenMouseLoc to (tmpX + 250, tmpY + 250)
end mouseUp

Re: screenmouseloc not cutting it
When we say "program", do we mean a LiveCode stack? And not some other, er, program?
That seems to be up in the air, hence Richmond's post.
Craig Newman
That seems to be up in the air, hence Richmond's post.
Craig Newman
Re: screenmouseloc not cutting it
Yet another option is to use
the globalLoc and the localLoc
for the conversion between global and local coordinates.
the globalLoc and the localLoc
for the conversion between global and local coordinates.
shiftLock happens
Re: screenmouseloc not cutting it
That is true, which is why I should clarify that I am posting ONLY in reference to a stack your making yourself in Lc, NOT for centering on some random program running elsewhere.
I see I also forgot to mention that the 'mouseUp' code in my post could be put anywhere, button, card level, stack level, once you create a stack of the 500, 500 dimension you mentioned, you really don't need to put anything on it.
I see -hh clarified Richards post (I think).

Re: screenmouseloc not cutting it
yes. this is indeed trying to use an x,y coordinate based on a stack where 0,0 would be top left of the stack
richards post was to put the mouseloc when i want to set it. looks like bogs put the "unelegant" version i thought might be needed where i need to find the location of the stack in relation to the screen to calculate the position of the mouse on the screen.
richards post was to put the mouseloc when i want to set it. looks like bogs put the "unelegant" version i thought might be needed where i need to find the location of the stack in relation to the screen to calculate the position of the mouse on the screen.
Re: screenmouseloc not cutting it
the unelegant code works but im trying to use it to find the color of a pixel at a location and im using mousecolor. Plus even though im using lock screen i can still see the pointer buz around the screen. should i just hide the pointer then unhide it?
the below is working now. seemed it didnt delete a group fast enough. whee. things are working....
working on an A* pathfinder.. again
it isnt seeming to work though. when run the dots in the blue area should be black and the rest green.
the below is working now. seemed it didnt delete a group fast enough. whee. things are working....
working on an A* pathfinder.. again
it isnt seeming to work though. when run the dots in the blue area should be black and the rest green.
- Attachments
-
- A Star Test3.rar
- (1.69 KiB) Downloaded 239 times
Re: screenmouseloc not cutting it
It is important to know that the "mouseLoc" is read-only. The "screenMouseLoc" can be set. That is why the conversion gadgets exist to find the rect and loc of the card window and adjust.
I have no idea why the mouseLoc cannot be set. It would nice to be able to.
HC had neither. Rinaldi did, though.
Craig
I have no idea why the mouseLoc cannot be set. It would nice to be able to.
HC had neither. Rinaldi did, though.
Craig
Re: screenmouseloc not cutting it
thank you. it would be great to be able to set a local position based on stack or even object but i would never know about it since im still using 6.6.2dunbarx wrote: ↑Fri Oct 13, 2017 10:01 pmIt is important to know that the "mouseLoc" is read-only. The "screenMouseLoc" can be set. That is why the conversion gadgets exist to find the rect and loc of the card window and adjust.
I have no idea why the mouseLoc cannot be set. It would nice to be able to.
HC had neither. Rinaldi did, though.
Craig