AppleScript QuickLook

[Applescript]OpenSaveパネルを終了させる(ちょっと修正)


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

#!/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
##UIDを取得する
set objSysInfo to system info
set strUserID to (user ID of objSysInfo) as text
################################################
##QuickLookのユーザープロセスPIDを取得
set strCommandText to ("/bin/ps -alx | grep " & strUserID & " | grep 'QuickLook' | grep -v grep | awk '{print $2}'") as text
set strResponse to (do shell script strCommandText) as text
##リストにして
set AppleScript's text item delimiters to "\r"
set listPID to every text item of strResponse
set AppleScript's text item delimiters to ""
set numCntPID to (count of listPID) as integer
if numCntPID = 0 then
log "プロセス無し終了"
end if
##プロセスがあれば終了していく
repeat with itemPID in listPID
  set strPID to itemPID as text
  set strCommandText to ("/bin/kill -9 " & strPID & "")
do shell script strCommandText
end repeat

################################################
##openAndSavePanelServiceのユーザープロセスPIDを取得
set strCommandText to ("/bin/ps -alx | grep " & strUserID & " | grep 'openAndSavePanelService' | grep -v grep | awk '{print $2}'") as text
set strResponse to (do shell script strCommandText) as text
##リストにして
set AppleScript's text item delimiters to "\r"
set listPID to every text item of strResponse
set AppleScript's text item delimiters to ""
set numCntPID to (count of listPID) as integer
if numCntPID = 0 then
return "プロセス無し終了"
end if
##プロセスがあれば終了していく
repeat with itemPID in listPID
  set strPID to itemPID as text
  set strCommandText to ("/bin/kill -9 " & strPID & "")
do shell script strCommandText
end repeat

return



#com.apple.quicklook.QuickLookUIService
#QuickLookUIService

|

[bash]OpenSaveパネルを終了させる(ちょっと修正)


#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
#################################################
###UID
STR_UID=$(/usr/bin/id -u)
/bin/echo "ユーザー名(id): $STR_UID"
###PID
STR_PID=$(/bin/ps -alx | grep "$STR_UID" | grep 'QuickLook' | grep -v grep | awk '{print $2}')
/bin/echo "プロセスID: $STR_PID"
###リストにする
read -d '\\n' -r -a LIST_PID <<<"$STR_PID"
###リスト内の項目数
NUM_CNT=${#LIST_PID[@]}
/bin/echo "プロセス数:" "$NUM_CNT"
##リストの数だけ終了させる
for ITEM_LIST in "${LIST_PID[@]}"; do
/bin/kill -9 "$ITEM_LIST"
done
sleep 1
###PID
STR_PID=$(/bin/ps -alx | grep "$STR_UID" | grep 'openAndSavePanelService' | grep -v grep | awk '{print $2}')
/bin/echo "プロセスID: $STR_PID"
###リストにする
read -d '\\n' -r -a LIST_PID <<<"$STR_PID"
###リスト内の項目数
NUM_CNT=${#LIST_PID[@]}
/bin/echo "プロセス数:" "$NUM_CNT"
##リストの数だけ終了させる
for ITEM_LIST in "${LIST_PID[@]}"; do
/bin/kill -9 "$ITEM_LIST"
done

exit 0


|

[bash]OpenSaveパネルを終了させる

ディスク "XXXXXXX" を取り出せませんでした。1つ以上のプログラムが使用している可能性があります。
すぐにディスクを取り出すには、"強制的に取り出ず"ボタンをクリックします。が出た時用 Screen_2_20240201172201

#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
#################################################
###UID
STR_UID=$(/usr/bin/id -u)
/bin/echo "ユーザー名(id): $STR_UID"
###PID
STR_PID=$(/bin/ps -alx | grep "$STR_UID" | grep 'QuickLookUIService' | grep -v grep | awk '{print $2}')
/bin/echo "プロセスID: $STR_PID"
###リストにする
read -d '\\n' -r -a LIST_PID <<<"$STR_PID"
###リスト内の項目数
NUM_CNT=${#LIST_PID[@]}
/bin/echo "プロセス数:" "$NUM_CNT"
##リストの数だけ終了させる
for ITEM_LIST in "${LIST_PID[@]}"; do
/bin/kill -9 "$ITEM_LIST"
done

exit 0


|

OpenSaveパネルを終了させる

ディスク "XXXXXXX" を取り出せませんでした。1つ以上のプログラムが使用している可能性があります。
すぐにディスクを取り出すには、"強制的に取り出ず"ボタンをクリックします。が出た時用 Screen_2_20240201172201

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

#!/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
##UIDを取得する
set objSysInfo to system info
set strUserID to (user ID of objSysInfo) as text
##OPENパネルのPIDを取得
set strCommandText to ("/bin/ps -alx | grep " & strUserID & " | grep 'QuickLookUIService' | grep -v grep | awk '{print $2}'") as text
set strResponse to (do shell script strCommandText) as text
##リストにして
set AppleScript's text item delimiters to "\r"
set listPID to every text item of strResponse
set AppleScript's text item delimiters to ""
set numCntPID to (count of listPID) as integer
if numCntPID = 0 then
return "プロセス無し終了"
end if
##プロセスがあれば終了していく
repeat with itemPID in listPID
  set strPID to itemPID as text
  set strCommandText to ("/bin/kill -9 " & strPID & "")
do shell script strCommandText
end repeat

return



#com.apple.quicklook.QuickLookUIService
#QuickLookUIService

|

Finder再起動(QuickLookも)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

set strBundleID to "com.apple.finder"


##バンドルからアプリケーションのURLを取得
set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
if ocidAppBundle ≠ (missing value) then
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else if ocidAppBundle = (missing value) then
  set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
  set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
end if
##予備(アプリケーションのURL)
if ocidAppPathURL = (missing value) then
  tell application "Finder"
    try
      set aliasAppApth to (application file id strBundleID) as alias
      set strAppPath to POSIX path of aliasAppApth as text
      set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
      set strAppPath to strAppPathStr's stringByStandardizingPath()
      set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(strAppPath) isDirectory:true
    on error
return "アプリケーションが見つかりませんでした"
    end try
  end tell
end if

##終了
set ocidRunningApplication to refMe's NSRunningApplication
###起動中のすべてのリスト
set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
###複数起動時も順番に終了
repeat with itemAppArray in ocidAppArray
  ###終了
itemAppArray's terminate()
end repeat
##1秒まって終了を確認
delay 1
##終了できない場合は強制終了
repeat with itemAppArray in ocidAppArray
  set boolTerminate to itemAppArray's terminated
  if boolTerminate = false then
itemAppArray's forceTerminate()
  end if
end repeat
###起動
set ocidOpenConfig to refMe's NSWorkspaceOpenConfiguration's configuration
###コンフィグ
(ocidOpenConfig's setActivates:(refMe's NSNumber's numberWithBool:true))
###起動
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
(appSharedWorkspace's openApplicationAtURL:(ocidAppPathURL) configuration:(ocidOpenConfig) completionHandler:(missing value))


###ついでにQuickLOOK関連も再起動しておく

set strBundleID to "br.com.guilhermerambo.AssetCatalog"
##終了
set ocidRunningApplication to refMe's NSRunningApplication
###起動中のすべてのリスト
set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
###複数起動時も順番に終了
repeat with itemAppArray in ocidAppArray
  ###終了
itemAppArray's terminate()
end repeat
##1秒まって終了を確認
delay 1
##終了できない場合は強制終了
repeat with itemAppArray in ocidAppArray
  set boolTerminate to itemAppArray's terminated
  if boolTerminate = false then
itemAppArray's forceTerminate()
  end if
end repeat

set strBundleID to "com.latenightsw.sdquicklookgenerator"
##終了
set ocidRunningApplication to refMe's NSRunningApplication
###起動中のすべてのリスト
set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
###複数起動時も順番に終了
repeat with itemAppArray in ocidAppArray
  ###終了
itemAppArray's terminate()
end repeat
##1秒まって終了を確認
delay 1
##終了できない場合は強制終了
repeat with itemAppArray in ocidAppArray
  set boolTerminate to itemAppArray's terminated
  if boolTerminate = false then
itemAppArray's forceTerminate()
  end if
end repeat

set strBundleID to "com.apple.quicklook.QuickLookUIService"
##終了
set ocidRunningApplication to refMe's NSRunningApplication
###起動中のすべてのリスト
set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
###複数起動時も順番に終了
repeat with itemAppArray in ocidAppArray
  ###終了
itemAppArray's terminate()
end repeat
##1秒まって終了を確認
delay 1
##終了できない場合は強制終了
repeat with itemAppArray in ocidAppArray
  set boolTerminate to itemAppArray's terminated
  if boolTerminate = false then
itemAppArray's forceTerminate()
  end if
end repeat

|

[qlmanage]SVG to PNG


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#qlmanage クイックルックを使ってSVGをPNGに
#
#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 strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

####ダイアログ用デスクトップパス
set aliasDefaultLocation to path to desktop folder from user domain as alias
####ダイアログ
set listChooseFiles to (choose file with prompt "ファイルを選んでください" default location aliasDefaultLocation of type {"public.svg-image"} with multiple selections allowed without showing package contents and invisibles) as list

#############################
###ダイアログ
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
############
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
############
set strMes to "フォルダを選んでください" as text
set strPrompt to "フォルダを選択してください" as text
try
  set aliasSaveDirPath to (choose folder strMes with prompt strPrompt default location aliasDefaultLocation with invisibles and showing package contents without multiple selections allowed) as alias
on error
  log "エラーしました"
return "エラーしました"
end try

set strSaveDirPath to (POSIX path of aliasSaveDirPath) as text

####ファイルの数だけ繰り返し
repeat with objFile in listChooseFiles
  ###UNIXパスに変換
  set theFilePath to POSIX path of objFile as text
  ###スクリプトに渡す
  set strCommandText to ("\"/System/Library/Frameworks/QuickLook.framework/Versions/A/Resources/qlmanage.app/Contents/MacOS/qlmanage\" -t -s 800 \"" & theFilePath & "\" -o \"" & strSaveDirPath & "\"") as text
  do shell script strCommandText
  
end repeat



  Usage: qlmanage [OPTIONS] path...
-h Display this help
-r Force reloading Generators list
-r cache Reset thumbnail disk cache
-m [name ...]   Display statistics about quicklookd. Stats names:
* plugins       Show the generators list
* server Show quicklookd life information
* memory Show quicklookd memory consumption
* burst Show statistics about the last burst
* threads       Show concurrent accesses stats
* other Show other information about quicklookd
-p Compute previews of the documents
-t Compute thumbnails of the documents
-x Use quicklookd (remote computation)
-i Compute thumbnail in icon mode
-s size Size for the thumbnail
-f factor       Scale factor for the thumbnail
-F factor       Scale factor for the thumbnail, draw downscaled and compare to 1x
-z Display generation performance info (don't display thumbnails)
-o dir Output result in dir (don't display thumbnails or previews)
-c contentType  Force the content type used for the documents
-g generator    Force the generator to use

|

その他のカテゴリー

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