September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
30
Task/Mouse-position/AppleScript/mouse-position-1.applescript
Normal file
30
Task/Mouse-position/AppleScript/mouse-position-1.applescript
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use application "System Events"
|
||||
|
||||
property process : a reference to (first process whose frontmost = true)
|
||||
property window : a reference to front window of my process
|
||||
|
||||
|
||||
set [Wx, Wy] to my window's position
|
||||
set [Cx, Cy] to {x, y} of the mouse's coordinates()
|
||||
|
||||
|
||||
script mouse
|
||||
use framework "Foundation"
|
||||
|
||||
property this : a reference to current application
|
||||
property NSEvent : a reference to NSEvent of this
|
||||
property NSScreen : a reference to NSScreen of this
|
||||
|
||||
on coordinates()
|
||||
-- Screen dimensions
|
||||
set display to NSDeviceSize of deviceDescription() ¬
|
||||
of item 1 of NSScreen's screens() as record
|
||||
|
||||
-- Mouse position relative to bottom-left of screen
|
||||
set mouseLoc to (NSEvent's mouseLocation as record)
|
||||
-- Flip mouse y-coordinate so it's relative to top of screen
|
||||
set mouseLoc's y to (display's height) - (mouseLoc's y)
|
||||
|
||||
mouseLoc
|
||||
end coordinates
|
||||
end script
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
-- Cursor position relative to active window
|
||||
[Cx - Wx as integer, Cy - Wy as integer]
|
||||
Loading…
Add table
Add a link
Reference in a new issue