How to hide mouse cursor with AppleScript

Hi,

How to hide mouse cursor with AppleScript?

How about this?

http://piyocast.com/as/archives/6030

1 Like

It does not work.


use AppleScript version "2.4" — Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

set curCursor to current application’s NSCursor’s currentCursor()

current application’s NSCursor’s hide()

delay 5

current application’s NSCursor’s unhide()

Error: Expected end of line, etc. but found unknown token.

The code you’ve posted contains “smart” apostrophes (character id 8217) instead of the ordinary ones (character id 39) used in AppleScript.

This works:

use framework "AppKit"

-- Get the current cursor
set curCursor to current application's NSCursor's currentCursor

-- Hide the cursor
tell current application's NSCursor
	hide()
end tell

-- Delay for 5 seconds
delay 5

-- Show the cursor again
tell current application's NSCursor
	unhide()
end tell

My blog’s each program list has URL event copy link in each end.
Don’t copy & paste program list directly.