UI

WEBページのGUIでペーストを使ってファイルをアップロード


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

WEBページのGUIでペーストを使ってファイルをアップロード.scpt
ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(* 
004
005WEBページのGUIでペーストを使ってファイルをアップロード
006サンプルはopenAI
007
008『たぶん』サイト側がペーストに対応している必要があります
009
010com.cocolog-nifty.quicktimer.icefloe *)
011----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
012use AppleScript version "2.8"
013use scripting additions
014
015#選択中のファイルをコピーして
016tell application "Finder"
017   activate
018   tell application "System Events"
019      keystroke "c" using {command down}
020   end tell
021end tell
022
023
024set strURL to ("https://chatgpt.com/") as text
025
026tell application "Microsoft Edge"
027   tell front window
028      make new tab with properties {URL:strURL}
029      repeat 30 times
030         tell active tab
031            set boolLoading to loading as boolean
032         end tell
033         if boolLoading is true then
034            delay 0.5
035         else
036            #魔法の0.5
037            delay 0.5
038            exit repeat
039         end if
040      end repeat
041   end tell
042end tell
043
044#入力部分へカーソルを移動させて
045tell application "Microsoft Edge"
046   activate
047   tell application "System Events"
048      tell application process "Microsoft Edge"
049         tell front window
050            key code 53 using {shift down}
051         end tell
052      end tell
053   end tell
054end tell
055#ペーストでアップロード
056tell application "Microsoft Edge"
057   activate
058   tell application "System Events"
059      tell application process "Microsoft Edge"
060         tell front window
061            keystroke "v" using {command down}
062         end tell
063      end tell
064   end tell
065end tell
AppleScriptで生成しました

| | コメント (0)

[UI] 『フォルダへ移動』のUI上でのクリック

macscripterに投稿したのと同じ内容だけど

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

『フォルダへ移動』のUI上でのクリック.scpt
ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(* 
004『フォルダへ移動』のUI上でのクリック
005com.cocolog-nifty.quicktimer.icefloe *)
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use scripting additions
009
010tell application "Microsoft Edge"
011   activate
012   tell application "System Events"
013      tell application process "Microsoft Edge"
014         tell front window
015            #フォルダへ移動画面を出して
016            keystroke "g" using {command down, shift down}
017            #フォルダへ移動画面が出る待ち時間魔法の1秒
018            delay 1
019            #入力可能エリアのXボタンを
020            tell button 1 of sheet 1 of sheet 1
021               #クリックして 内容を消して
022               click
023               #内容を入れて
024               keystroke "/tmp\n\n"
025               #リターンで
026               keystroke return
027            end tell
028         end tell
029      end tell
030   end tell
031end tell
AppleScriptで生成しました

| | コメント (0)

前回Openパネルが使用したフォルダパスのリセット(失敗作)

これは、設定した値が
反映されたり、されなかったりで
どうも、安定に欠くが
基本は
アプリケーションの設定ファイルの
NSOSPLastRootDirectory

com.apple.appkit.xpc.openAndSavePanelService.plist
NSOSPRecentPlaces
の0番を変更すればいいのだろうけど
上手くいかなかった
失敗ではないけど、安定しないので不採用



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

OPENダイアログのdefault locationのセット.applescript
ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(* 
004
005OPEN/SAVEパネルのdefault location
006実行時に表示されるパスの値の変更
007
008
009com.cocolog-nifty.quicktimer.icefloe *)
010----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
011use AppleScript version "2.8"
012use framework "Foundation"
013use framework "AppKit"
014use framework "UniformTypeIdentifiers"
015use scripting additions
016
017property refMe : a reference to current application
018
019#設定項目
020#このパスをデフォルトとケーションとして設定する
021set strDirPath to ("/tmp") as text
022
023#設定項目
024#設定するアプリケーションのplistのパス
025set strFilePath to "~/Library/Preferences/com.microsoft.edgemac.plist" as text
026
027
028
029set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
030set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
031set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:(false)
032
033#NSDATA
034set ocidOption to (refMe's NSDataReadingMappedIfSafe)
035set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(ocidOption) |error|:(reference)
036if (item 2 of listResponse) = (missing value) then
037   log "initWithContentsOfURL 正常処理"
038   set ocidReadData to (item 1 of listResponse)
039else if (item 2 of listResponse) ≠ (missing value) then
040   set strErrorNO to (item 2 of listResponse)'s code() as text
041   set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
042   refMe's NSLog("■" & strErrorNO & strErrorMes)
043   return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes
044end if
045#NSPropertyListSerializationにする
046set appPlistSerial to (refMe's NSPropertyListSerialization)
047set ocidOption to (refMe's NSPropertyListMutableContainersAndLeaves)
048set listResponse to appPlistSerial's propertyListWithData:(ocidReadData) options:(ocidOption) format:(reference) |error|:(reference)
049log (count of listResponse)
050if (item 3 of listResponse) = (missing value) then
051   set ocidPlistDict to (item 1 of listResponse)
052   set ocidFormat to (item 2 of listResponse)
053else if (item 3 of listResponse) ≠ (missing value) then
054   set strErrorNO to (item 2 of listResponse)'s code() as text
055   set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
056   current application's NSLog("■" & strErrorNO & strErrorMes)
057   return "エラーしましたpropertyListWithData:" & strErrorNO & strErrorMes
058end if
059
060#NSURLBookmark
061set ocidBookMarkData to ocidPlistDict's objectForKey:("NSOSPLastRootDirectory")
062
063#BOOKMARKを変換パス
064set ocidKeyArray to refMe's NSMutableArray's alloc()'s init()
065ocidKeyArray's addObject:(refMe's NSURLPathKey)
066ocidKeyArray's addObject:(refMe's NSURLNameKey)
067set ocidResourceValues to refMe's NSURL's resourceValuesForKeys:(ocidKeyArray) fromBookmarkData:(ocidBookMarkData)
068set ocidFilePath to (ocidResourceValues's objectForKey:(refMe's NSURLPathKey))
069log ocidFilePath as text
070
071#BOOKMARKを変換ファイルURL
072set ocidOption to (refMe's NSURLBookmarkResolutionWithoutUI)
073set listResponse to refMe's NSURL's URLByResolvingBookmarkData:(ocidBookMarkData) options:(ocidOption) relativeToURL:(missing value) bookmarkDataIsStale:(false) |error|:(reference)
074set ocidFileURL to (item 1 of listResponse)
075log ocidFileURL's absoluteString() as text
076
077#この値をセットしていく
078
079set ocidDirPathStr to refMe's NSString's stringWithString:(strDirPath)
080set ocidDirPath to ocidDirPathStr's stringByStandardizingPath()
081set ocidDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidDirPath) isDirectory:true)
082
083#BOOKマークデータを作成して
084set ocidOption to (refMe's NSURLBookmarkResolutionWithoutUI)
085set listResponse to ocidDirPathURL's bookmarkDataWithOptions:(ocidOption) includingResourceValuesForKeys:(missing value) relativeToURL:(missing value) |error|:(reference)
086set ocidSetBookmarkData to (item 1 of listResponse)
087
088
089#セットして
090ocidPlistDict's setObject:(ocidSetBookmarkData) forKey:("NSOSPLastRootDirectory")
091
092#NSPropertyListSerialization
093set listResponse to (refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidPlistDict) format:(ocidFormat) options:(0) |error|:(reference))
094if (item 2 of listResponse) = (missing value) then
095   set ocidSaveData to (item 1 of listResponse)
096else if (item 2 of listResponse) ≠ (missing value) then
097   set strErrorNO to (item 2 of listResponse)'s code() as text
098   set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
099   refMe's NSLog("■" & strErrorNO & strErrorMes)
100   return "エラーしましたdataWithPropertyList:" & strErrorNO & strErrorMes
101end if
102
103#NSDATAで保存
104set ocidOption to (refMe's NSDataWritingAtomic)
105set listDone to (ocidSaveData's writeToURL:(ocidFilePathURL) options:(ocidOption) |error|:(reference))
106if (item 2 of listResponse) ≠ (missing value) then
107   set strErrorNO to (item 2 of listResponse)'s code() as text
108   set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
109   refMe's NSLog("■" & strErrorNO & strErrorMes)
110   return "エラーしましたwriteToURL: " & strErrorNO & strErrorMes
111end if
112
113
114
115
116set strFilePath to ("~/Library/Preferences/com.apple.appkit.xpc.openAndSavePanelService.plist") as text
117set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
118set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
119set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:(false)
120
121
122set listResponse to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidFilePathURL) |error|:(reference)
123if (item 2 of listResponse) = (missing value) then
124   set ocidXPCDict to (item 1 of listResponse)
125else if (item 2 of listResponse) ≠ (missing value) then
126   set strErrorNO to (item 2 of listResponse)'s code() as text
127   set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
128   refMe's NSLog("■" & strErrorNO & strErrorMes)
129   return "エラーしました" & strErrorNO & strErrorMes
130end if
131
132set ocidRecentArray to ocidXPCDict's objectForKey:("NSOSPRecentPlaces")
133ocidRecentArray's replaceObjectAtIndex:(0) withObject:(ocidSetBookmarkData)
134
135
136
137set listDone to ocidXPCDict's writeToURL:(ocidFilePathURL) |error|:(reference)
138if (item 1 of listDone) is true then
139   log "writeToURL 正常処理"
140else if (item 2 of listDone) ≠ (missing value) then
141   set strErrorNO to (item 2 of listDone)'s code() as text
142   set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
143   refMe's NSLog("■" & strErrorNO & strErrorMes)
144   return "writeToURL エラーしました" & strErrorNO & strErrorMes
145end if
AppleScriptで生成しました

| | コメント (0)

[redesigned_text_cursor]入力支援のUIを停止・再開する

停止
サンプルコード

サンプルソース(参考)
行番号ソース
001#!/bin/bash
002#com.cocolog-nifty.quicktimer.icefloe
003#
004# /System/Library/FeatureFlags/Domain
005# に
006# 各種フラッグのキー名が格納されている
007#################################################
008###
009USER_WHOAMI=$(/usr/bin/whoami)
010/bin/echo "実行ユーザー(whoami): $USER_WHOAMI"
011###実行しているユーザー名
012CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
013/bin/echo "コンソールユーザー(scutil): $CONSOLE_USER"
014###実行しているユーザー名
015CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
016/bin/echo "コンソールユーザー(scutil): $CONSOLE_USER"
017###実行しているユーザー名
018HOME_USER=$(/bin/echo "$HOME" | /usr/bin/awk -F'/' '{print $NF}')
019/bin/echo "実行ユーザー(HOME): $HOME_USER"
020###logname
021LOGIN_NAME=$(/usr/bin/logname)
022/bin/echo "ログイン名(logname): $LOGIN_NAME"
023###UID
024USER_NAME=$(/usr/bin/id -un)
025/bin/echo "ユーザー名(id): $USER_NAME"
026###STAT
027STAT_USR=$(/usr/bin/stat -f%Su /dev/console)
028/bin/echo "STAT_USR(console): $STAT_USR"
029
030########################################
031#サブフォルダのアクセス権チェック(定型)
032/bin/echo "USER DIRチェック開始"
033STR_CHK_PATH="/Users/$CONSOLE_USER/"
034/bin/chmod 755  "$STR_CHK_PATH"
035
036LIST_SUB_DIR_NAME=("Desktop" "Documents" "Downloads" "Movies" "Music" "Pictures" "Groups" "Developer" "Applications" "bin")
037for ITEM_DIR_NAME in "${LIST_SUB_DIR_NAME[@]}"; do
038  STR_CHK_PATH="/Users/$CONSOLE_USER/${ITEM_DIR_NAME}"
039  /bin/chmod 700 "$STR_CHK_PATH"
040  /bin/chmod +a "group:everyone deny delete" "$STR_CHK_PATH"
041done
042
043STR_CHK_PATH="/Users/$CONSOLE_USER/Sites"
044/bin/chmod 755  "$STR_CHK_PATH"
045
046
047########################################
048#ユーザー環境
049PATH_PREF_DIR="/Users/${STAT_USR}/Library/Preferences/FeatureFlags/Domain"
050/bin/mkdir -p "$PATH_PREF_DIR"
051##
052PATH_PLIST_FILE="${PATH_PREF_DIR}/UIKit.plist"
053#空のPLIST
054/usr/libexec/PlistBuddy -c "Save" "$PATH_PLIST_FILE"
055#DICTを作って
056/usr/libexec/PlistBuddy -c "Add :redesigned_text_cursor dict" "$PATH_PLIST_FILE"
057#KEY VALUE
058/usr/libexec/PlistBuddy -c "Add :redesigned_text_cursor:Enabled bool false" "$PATH_PLIST_FILE"
059#保存
060/usr/libexec/PlistBuddy -c "Save" "$PATH_PLIST_FILE"
061#確認
062/usr/bin/defaults read "$PATH_PLIST_FILE" redesigned_text_cursor
063#
064#/usr/bin/defaults write "$PATH_PLIST_FILE" redesigned_text_cursor -dict-add Enabled -false
065
066########################################
067#ローカル環境
068PATH_PREF_DIR="/Library/Preferences/FeatureFlags/Domain"
069/usr/bin/sudo /bin/mkdir -p "$PATH_PREF_DIR"
070##
071PATH_PLIST_FILE="${PATH_PREF_DIR}/UIKit.plist"
072#空のPLIST
073/usr/bin/sudo /usr/libexec/PlistBuddy -c "Save" "$PATH_PLIST_FILE"
074#DICTを作って
075/usr/bin/sudo /usr/libexec/PlistBuddy -c "Add :redesigned_text_cursor dict" "$PATH_PLIST_FILE"
076#KEY VALUE
077/usr/bin/sudo /usr/libexec/PlistBuddy -c "Add :redesigned_text_cursor:Enabled bool false" "$PATH_PLIST_FILE"
078#保存
079/usr/bin/sudo /usr/libexec/PlistBuddy -c "Save" "$PATH_PLIST_FILE"
080#確認
081/usr/bin/defaults read "$PATH_PLIST_FILE" redesigned_text_cursor
082#
083#/usr/bin/sudo /usr/bin/defaults write "$PATH_PLIST_FILE" redesigned_text_cursor -dict-add Enabled -false
084exit 0
AppleScriptで生成しました

再開
サンプルコード

サンプルソース(参考)
行番号ソース
001#!/bin/bash
002#com.cocolog-nifty.quicktimer.icefloe
003#
004# /System/Library/FeatureFlags/Domain
005# に
006# 各種フラッグのキー名が格納されている
007#################################################
008###
009USER_WHOAMI=$(/usr/bin/whoami)
010/bin/echo "実行ユーザー(whoami): $USER_WHOAMI"
011###実行しているユーザー名
012CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
013/bin/echo "コンソールユーザー(scutil): $CONSOLE_USER"
014###実行しているユーザー名
015CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
016/bin/echo "コンソールユーザー(scutil): $CONSOLE_USER"
017###実行しているユーザー名
018HOME_USER=$(/bin/echo "$HOME" | /usr/bin/awk -F'/' '{print $NF}')
019/bin/echo "実行ユーザー(HOME): $HOME_USER"
020###logname
021LOGIN_NAME=$(/usr/bin/logname)
022/bin/echo "ログイン名(logname): $LOGIN_NAME"
023###UID
024USER_NAME=$(/usr/bin/id -un)
025/bin/echo "ユーザー名(id): $USER_NAME"
026###STAT
027STAT_USR=$(/usr/bin/stat -f%Su /dev/console)
028/bin/echo "STAT_USR(console): $STAT_USR"
029
030########################################
031#サブフォルダのアクセス権チェック(定型)
032/bin/echo "USER DIRチェック開始"
033STR_CHK_PATH="/Users/$CONSOLE_USER/"
034/bin/chmod 755  "$STR_CHK_PATH"
035
036LIST_SUB_DIR_NAME=("Desktop" "Documents" "Downloads" "Movies" "Music" "Pictures" "Groups" "Developer" "Applications" "bin")
037for ITEM_DIR_NAME in "${LIST_SUB_DIR_NAME[@]}"; do
038  STR_CHK_PATH="/Users/$CONSOLE_USER/${ITEM_DIR_NAME}"
039  /bin/chmod 700 "$STR_CHK_PATH"
040  /bin/chmod +a "group:everyone deny delete" "$STR_CHK_PATH"
041done
042
043STR_CHK_PATH="/Users/$CONSOLE_USER/Sites"
044/bin/chmod 755  "$STR_CHK_PATH"
045
046
047########################################
048#ユーザー環境
049PATH_PREF_DIR="/Users/${STAT_USR}/Library/Preferences/FeatureFlags/Domain"
050/bin/mkdir -p "$PATH_PREF_DIR"
051##
052PATH_PLIST_FILE="${PATH_PREF_DIR}/UIKit.plist"
053#空のPLIST
054/usr/libexec/PlistBuddy -c "Save" "$PATH_PLIST_FILE"
055#DICTを作って
056/usr/libexec/PlistBuddy -c "Add :redesigned_text_cursor dict" "$PATH_PLIST_FILE"
057#KEY VALUE
058/usr/libexec/PlistBuddy -c "Add :redesigned_text_cursor:Enabled bool true" "$PATH_PLIST_FILE"
059#値を変更するか?削除してしまうか?はお好みで
060#値の変更
061/usr/libexec/PlistBuddy -c "Set :redesigned_text_cursor:Enabled true" "$PATH_PLIST_FILE"
062# redesigned_text_cursorを削除する
063/usr/libexec/PlistBuddy -c "Delete :redesigned_text_cursor" "$PATH_PLIST_FILE"
064#保存
065/usr/libexec/PlistBuddy -c "Save" "$PATH_PLIST_FILE"
066#確認
067/usr/bin/defaults read "$PATH_PLIST_FILE" redesigned_text_cursor
068#
069#/usr/bin/defaults write "$PATH_PLIST_FILE" redesigned_text_cursor -dict-add Enabled -true
070exit 0
071########################################
072#ローカル環境
073PATH_PREF_DIR="/Library/Preferences/FeatureFlags/Domain"
074/usr/bin/sudo /bin/mkdir -p "$PATH_PREF_DIR"
075##
076PATH_PLIST_FILE="${PATH_PREF_DIR}/UIKit.plist"
077#空のPLIST
078/usr/bin/sudo /usr/libexec/PlistBuddy -c "Save" "$PATH_PLIST_FILE"
079#DICTを作って
080/usr/bin/sudo /usr/libexec/PlistBuddy -c "Add :redesigned_text_cursor dict" "$PATH_PLIST_FILE"
081#KEY VALUE
082/usr/bin/sudo /usr/libexec/PlistBuddy -c "Add :redesigned_text_cursor:Enabled bool true" "$PATH_PLIST_FILE"
083#値を変更するか?削除してしまうか?はお好みで
084#値の変更
085/usr/bin/sudo /usr/libexec/PlistBuddy -c "Set :redesigned_text_cursor:Enabled true" "$PATH_PLIST_FILE"
086# redesigned_text_cursorを削除する
087/usr/bin/sudo /usr/libexec/PlistBuddy -c "Delete :redesigned_text_cursor" "$PATH_PLIST_FILE"
088#保存
089/usr/bin/sudo /usr/libexec/PlistBuddy -c "Save" "$PATH_PLIST_FILE"
090#確認
091/usr/bin/defaults read "$PATH_PLIST_FILE" redesigned_text_cursor
092#
093#/usr/bin/sudo /usr/bin/defaults write "$PATH_PLIST_FILE" redesigned_text_cursor -dict-add Enabled -true
094exit 0
AppleScriptで生成しました

|

[UI]AdobeReaderの環境設定・ユーザー情報を開く


あくまでも参考にしてください

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

サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# com.cocolog-nifty.quicktimer.icefloe
005----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
006use AppleScript version "2.8"
007use scripting additions
008
009tell application "Adobe Acrobat Reader" to activate
010
011tell application id "com.adobe.Reader"
012  tell application "System Events"
013    tell process "AdobeReader"
014      key down {command}
015      keystroke ","
016      key up {command}
017    end tell
018  end tell
019end tell
020tell application id "com.adobe.Reader"
021  tell application "System Events"
022    click static text "ユーザー情報" of row 22 of outline 1 of scroll area 1 of window "環境設定" of application process "AdobeReader"
023    select row 22 of outline 1 of scroll area 1 of window "環境設定" of application process "AdobeReader"
024  end tell
025end tell
AppleScriptで生成しました

|

[UI]システム設定のUI項目を取得する

こちらを参考にした
https://www.sudoade.com/scripting-the-unscriptable-macadmins-2023-presentation/

あくまでも参考にしてください

サンプルソース(参考)
行番号ソース
001(*
002参考スクリプト
003https://stream.lib.utah.edu/
004MacAdmins Slack: @Xirias
005*)
006
007
008###起動
009tell application id "com.apple.systempreferences"
010  # launch launchを使うとストールする事がある
011  activate
012end tell
013###起動待ち
014tell application id "com.apple.systempreferences"
015  ###起動確認 最大10秒
016  repeat 10 times
017    activate
018    set boolFrontMost to frontmost as boolean
019    if boolFrontMost is true then
020      exit repeat
021    else
022      delay 1
023    end if
024  end repeat
025end tell
026###本処理
027tell application id "com.apple.systempreferences"
028  tell application "System Events"
029    tell process "System Settings"
030      tell front window
031        ##全てのエレメントを書き出す
032        set listUIelement to entire contents
033        repeat with itemElement in listUIelement
034          log itemElement
035          tell itemElement
036            properties
037            log role description as text
038          end tell
039        end repeat
040      end tell
041    end tell
042  end tell
043end tell
044
045
AppleScriptで生成しました

|

[Quartz]マウスカーソルの移動


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

[Quartz]マウスカーソルの移動 .scpt
ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(*
004
005
006com.cocolog-nifty.quicktimer.icefloe *)
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use framework "AppKit"
011use framework "CoreGraphics"
012use scripting additions
013
014property refMe : a reference to current application
015
016#X秒間移動を続ける
017set numCntTimer to 10 as integer
018
019
020repeat numCntTimer times
021   
022   ###移動させたい位置(左上が0x0
023   set ocidNSpoint to refMe's NSPoint's NSMakePoint(460, 360)
024   ###移動前の位置
025   set mouseLoc to refMe's NSEvent's mouseLocation()
026   log mouseLoc
027   ###移動
028   refMe's CGWarpMouseCursorPosition(ocidNSpoint)
029   ###移動後の位置
030   set mouseLoc to refMe's NSEvent's mouseLocation()
031   log mouseLoc
032   #
033   delay 0.25
034   ###移動させたい位置(左上が0x0
035   set ocidNSpoint to refMe's NSPoint's NSMakePoint(360, 460)
036   ###移動前の位置
037   set mouseLoc to refMe's NSEvent's mouseLocation()
038   log mouseLoc
039   ###移動
040   refMe's CGWarpMouseCursorPosition(ocidNSpoint)
041   ###移動後の位置
042   set mouseLoc to refMe's NSEvent's mouseLocation()
043   log mouseLoc
044   #
045   delay 0.25
046   ###移動させたい位置(左上が0x0
047   set ocidNSpoint to refMe's NSPoint's NSMakePoint(260, 360)
048   ###移動前の位置
049   set mouseLoc to refMe's NSEvent's mouseLocation()
050   log mouseLoc
051   ###移動
052   refMe's CGWarpMouseCursorPosition(ocidNSpoint)
053   ###移動後の位置
054   set mouseLoc to refMe's NSEvent's mouseLocation()
055   log mouseLoc
056   #
057   delay 0.25
058   ###移動させたい位置(左上が0x0
059   set ocidNSpoint to refMe's NSPoint's NSMakePoint(360, 260)
060   ###移動前の位置
061   set mouseLoc to refMe's NSEvent's mouseLocation()
062   log mouseLoc
063   ###移動
064   refMe's CGWarpMouseCursorPosition(ocidNSpoint)
065   ###移動後の位置
066   set mouseLoc to refMe's NSEvent's mouseLocation()
067   log mouseLoc
068   #
069   delay 0.25
070   
071end repeat
072
073
074
AppleScriptで生成しました

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

[Quartz]マウスカーソルの移動 .scpt
ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(*
004
005
006com.cocolog-nifty.quicktimer.icefloe *)
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use framework "AppKit"
011use framework "Quartz"
012use scripting additions
013
014property refMe : a reference to current application
015
016#X秒間移動を続ける
017set numCntTimer to 10 as integer
018
019repeat numCntTimer times
020   
021   ###移動させたい位置(左上が0x0
022   set ocidNSpoint to refMe's NSPoint's NSMakePoint(0, 0)
023   
024   ###移動前の位置
025   set mouseLoc to refMe's NSEvent's mouseLocation()
026   log mouseLoc
027   
028   ###移動
029   refMe's CGWarpMouseCursorPosition(ocidNSpoint)
030   
031   ###移動後の位置
032   set mouseLoc to refMe's NSEvent's mouseLocation()
033   log mouseLoc
034   delay 0.2
035   ###移動させたい位置(左上が0x0
036   set ocidNSpoint to refMe's NSPoint's NSMakePoint(100, 100)
037   
038   ###移動前の位置
039   set mouseLoc to refMe's NSEvent's mouseLocation()
040   log mouseLoc
041   
042   ###移動
043   refMe's CGWarpMouseCursorPosition(ocidNSpoint)
044   
045   ###移動後の位置
046   set mouseLoc to refMe's NSEvent's mouseLocation()
047   log mouseLoc
048   delay 0.2
049   ###移動させたい位置(左上が0x0
050   set ocidNSpoint to refMe's NSPoint's NSMakePoint(200, 200)
051   
052   ###移動前の位置
053   set mouseLoc to refMe's NSEvent's mouseLocation()
054   log mouseLoc
055   
056   ###移動
057   refMe's CGWarpMouseCursorPosition(ocidNSpoint)
058   
059   ###移動後の位置
060   set mouseLoc to refMe's NSEvent's mouseLocation()
061   log mouseLoc
062   
063   delay 0.2
064end repeat
065
066
067
AppleScriptで生成しました

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

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "Quartz"

property refMe : a reference to current application

###移動させたい位置(左上が0x0
set ocidNSpoint to refMe's NSMakePoint(0, 0)

###移動前の位置
set mouseLoc to refMe's NSEvent's mouseLocation()
log mouseLoc

###移動
refMe's CGWarpMouseCursorPosition(ocidNSpoint)

###移動後の位置
set mouseLoc to refMe's NSEvent's mouseLocation()
log mouseLoc

|

[UI]Wi-Fi システム設定

Screencapture_20230324_23_08_032


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



tell application "System Settings" to launch

--システム環境設定が開くのを待つ
repeat
  set doLaunchApp to get running of application "System Settings"
  if doLaunchApp is false then
    delay 1
  else
    exit repeat
  end if
end repeat

open location "x-apple.systempreferences:com.apple.Network-Settings.extension?Wi-Fi"

repeat
  tell application "System Settings"
    tell window 1
      set strWindowName to name as text
    end tell
  end tell
  if strWindowName is "Wi-Fi" then
    exit repeat
  else
    delay 1
  end if
end repeat


tell application "System Settings"
  tell application "System Events" to tell application process "System Settings"
    
    tell window "Wi-Fi"
      tell group 1
        # get properties of every UI element
        tell splitter group 1
          #   get properties of every UI element
          tell group 2
            #   get properties of every UI element
            tell group 1
              #   get properties of every UI element
              tell group 1
                #   get properties of every UI element
                tell scroll area 1
                  #   get properties of every UI element
                  tell group 1
                    get properties of every UI element
                    tell button 1
                      click
                    end tell
                  end tell
                end tell
              end tell
            end tell
          end tell
        end tell
      end tell
    end tell
  end tell
end tell



Screencapture-20230324-231707

|

UI BROWSER

20221031-110035

https://latenightsw.com/freeware/ui-browser/

|

[System Events]モニタの数(システム環境設定のUI)

ボタンの『"ディスプレイ設定…"』の有無で判断つきます

tell application "System Preferences"
activate
reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
end tell


tell application "System Preferences"
activate
properties
tell pane id "com.apple.preference.displays"
properties
end tell
end tell


tell application "System Preferences"
activate
properties
tell pane id "com.apple.preference.displays"
properties
end tell
tell window 1
properties
end tell

end tell

tell application "System Preferences"
activate
delay 3
tell application "System Events"
tell process "System Preferences"
activate
get properties of every UI element
tell window "ディスプレイ"
get properties of every UI element
tell button "ディスプレイ設定…"
try
get properties of every UI element
log "デュアルディスプレイで利用中"
click
on error
log "シングルディスプレイで利用中"
end try
end tell
end tell
end tell
end tell
end tell

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat 2024 Acrobat AddOn Acrobat Annotation Acrobat AppleScript Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat GentechAI Acrobat JS Acrobat JS Word Search Acrobat Maintenance Acrobat Manifest Acrobat Menu Acrobat Merge Acrobat Open Acrobat PDFPage Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat Print Acrobat Python Acrobat Reader Acrobat Reader Localized Acrobat Reference Acrobat Registered Products Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat URL List Mac Acrobat URL List Windows Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin ConfigCode Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin NetWork Admin Permission Admin Pkg Admin Power Management Admin Printer Admin Printer Basic Admin Printer Custompapers Admin SetUp Admin SMB Admin softwareupdate Admin Support Admin System Information Admin TCC Admin Tools Admin Umask Admin Users Admin Volumes Admin XProtect Adobe Adobe AUSST Adobe Bridge Adobe Documents Adobe FDKO Adobe Fonts Adobe Reference Adobe RemoteUpdateManager Adobe Sap Code AppKit Apple AppleScript AppleScript Duplicate AppleScript entire contents AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Video Applications AppStore Archive Archive Keka Attributes Automator BackUp Barcode Barcode Decode Barcode QR Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome Chromedriver CIImage CityCode CloudStorage Color Color NSColor Color NSColorList com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Desktop Position Device Diff Disk do shell script Dock Dock Launchpad DropBox Droplet eMail Encode % Encode Decode Encode HTML Entity Encode UTF8 Error EXIFData exiftool ffmpeg File File Name Finder Finder Window Firefox Folder FolderAction Font List FontCollections Fonts Fonts Asset_Font Fonts ATS Fonts Emoji Fonts Maintenance Fonts Morisawa Fonts Python Fonts Variable Foxit GIF github Guide HTML Icon Icon Assets.car Illustrator Image Events ImageOptim Input Dictionary iPhone iWork Javascript Jedit Ω Json Label Language Link locationd lsappinfo m3u8 Mail Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Microsoft Fonts Microsoft Office Microsoft Office Link Microsoft OneDrive Microsoft Teams Mouse Music Node Notes NSArray NSArray Sort NSAttributedString NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSGraphicsContext Crop NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMetadataItem NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSet NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSUbiquitous NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth PDF PDF Image2PDF PDF MakePDF PDF nUP PDF Pymupdf PDF Pypdf PDFContext PDFDisplayBox PDFImageRep PDFKit PDFKit Annotation PDFKit AnnotationWidget PDFKit DocumentPermissions PDFKit OCR PDFKit Outline PDFKit Start PDFPage PDFPage Rotation PDFView perl Photoshop PlistBuddy pluginkit plutil postalcode PostScript PowerShell prefPane Preview Python Python eyed3 Python pip QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver Script Editor Script Menu SF Symbols character id SF Symbols Entity Shortcuts Shortcuts Events sips Skype Slack Sound Spotlight sqlite StandardAdditions StationSearch Subtitles LRC Subtitles SRT Subtitles VTT Swift swiftDialog System Events System Settings TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom Weather webarchive webp Wifi Windows XML XML EPUB XML HTML XML LSSharedFileList XML LSSharedFileList sfl2 XML LSSharedFileList sfl3 XML objectsForXQuery XML OPML XML Plist XML Plist System Events XML RSS XML savedSearch XML SVG XML TTML XML webloc XML xmllint XML XMP YouTube Zero Padding zoom