AppleScript NSScreen

[NSScreen]メインスクリーンとサブスクリーン


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
# 要 アクアセシビリティ 許可
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKIt"
use scripting additions
property refMe : a reference to current application

set boolHaveSubScreen to false as boolean

set ocidScreenArray to refMe's NSScreen's screens()

if (count of ocidScreenArray) > 1 then
  log "サブスクリーンがあります"
  set boolHaveSubScreen to true as boolean
  set ocidSubScreen to ocidScreenArray's lastObject()
  set ocidSubRect to ocidSubScreen's frame()
  log ocidSubRect
else if (count of ocidScreenArray) = 1 then
  log "メインスクリーンのみです"
  set boolHaveSubScreen to false as boolean
  set ocidSubRect to {{0, 0}, {0, 0}} as list
end if
###メインスクリーン
set ocidMainScreen to refMe's NSScreen's mainScreen()
set ocidMainRect to ocidMainScreen's frame()
log ocidMainRect
set numMainW to (item 1 of (item 2 of ocidMainRect)) as integer
set numMainH to (item 2 of (item 2 of ocidMainRect)) as integer
###サブスクリーン
set numSubX to (item 1 of (item 1 of ocidSubRect)) as integer
set numSubY to (item 2 of (item 1 of ocidSubRect)) as integer
set numSubW to (item 1 of (item 2 of ocidSubRect)) as integer
set numSubH to (item 2 of (item 2 of ocidSubRect)) as integer




|

[NSScreen] Retinaか?判定する


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application


set ocidScreenArray to refMe's NSScreen's screens()
set appMainScreen to refMe's NSScreen's mainScreen()
set ocidDescription to appMainScreen's deviceDescription()
set recordDeviceResolution to refMe's NSSizeFromCGSize(ocidDescription's valueForKey:"NSDeviceResolution")
set intDeviceResolution to width of recordDeviceResolution as integer
if intDeviceResolution = 144 then
  log "解像度:" & intDeviceResolution
  log "Retinaディスプレイです"
else
  
  log "解像度:" & intDeviceResolution
end if

|

[モニタ]スクリーンサイズと拡張モニタ(考え中)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application


tell application "System Events"
  set numCntDesktop to (count of every desktop) as integer
  set listDesktop to (every desktop) as list
  
  repeat with itemDesktop in listDesktop
    tell itemDesktop
      log display name as text
    end tell
  end repeat
  
end tell

tell application "Finder"
  set listScreenBounds to (bounds of window of desktop) as list
  log listScreenBounds
  
end tell


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKIt"
use framework "Cocoa"
use scripting additions

property refMe : a reference to current application

set ocidScreenArray to refMe's NSScreen's screens()
set numCntScreen to ocidScreenArray's |count|()


repeat with itemScreen in ocidScreenArray
  
  set ocidScreenName to itemScreen's localizedName
  log ocidScreenName as text
  
  set ocidScreenBounds to itemScreen's visibleFrame
  log ocidScreenBounds as list
  
  
  set ocidScreenRect to itemScreen's frame
  log ocidScreenRect as list
  
end repeat

set appMainScreen to refMe's NSScreen's mainScreen()
log appMainScreen's visibleFrame as list
log appMainScreen's frame as list

|

[NSScreen]モニターの情報

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"

use scripting additions

property refMe : a reference to current application

set ocidAllScreens to refMe's NSScreen's screens()
log "モニタ数: " & ocidAllScreens's |count|()

repeat with objScreen in ocidAllScreens
log "--------"
set ocidDescription to objScreen's deviceDescription()
log "NSDeviceResolution:" & refMe's NSStringFromSize(ocidDescription's valueForKey:"NSDeviceResolution")
log "NSDeviceSize:" & refMe's NSStringFromSize(ocidDescription's valueForKey:"NSDeviceSize")
log "NSDeviceIsScreen: " & (ocidDescription's valueForKey:"NSDeviceIsScreen")
log "NSScreenNumber: " & (ocidDescription's valueForKey:"NSScreenNumber")
log "NSDeviceColorSpaceName: " & (ocidDescription's valueForKey:"NSDeviceColorSpaceName")
log "NSDeviceBitsPerSample: " & (ocidDescription's valueForKey:"NSDeviceBitsPerSample")

log objScreen's depth()
log objScreen's frame()
log objScreen's supportedWindowDepths()
log objScreen's colorSpace()
log objScreen's localizedName()
log objScreen's visibleFrame()
log objScreen's safeAreaInsets()
log objScreen's auxiliaryTopLeftArea()
log objScreen's auxiliaryTopRightArea()

end repeat

|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom