|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
スタートアッププログラムの情報を見る |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
・実行すると、下図のようにスタートアッププログラムの情報リストが表示されます。
・任意の項目をダブルクリックすると、下図のような書類の情報を表示することができます。
・右下の『ファイルの場所を開く』ボタンをクリックすると、ファイルの入ったフォルダが表示されます。
・『閉じる』で情報の表示が閉じられ、リストが再度表示されます。
・『Appleのファイルを隠す』のチェックボタンをONにすることでシステム標準の書類を非表示にできる。
(MacOS標準のスタートアッププログラムをすべて非表示にできているわけではありません。com.apple.・・・が含まれているものだけ)
だいぶ整理されて見やすくなっていると思います。
・このプログラムでは、スタートアッププログラムを停止たりはできません。
該当のファイルを表示させてから削除(または移動)をすると、次回から起動しなくなります。
(注意)システムで使用しているものを不用意に削除すると不具合や最悪Macが起動しなくなる場合がありますので、慎重に作業をしてください。
|
スクリプトエディター(AppleScript) |
|
|
--初期設定 use AppleScript version "2.7" use scripting additions use framework "Foundation" use framework "AppKit" global myApp global theWindow, mainView global closeFlg global minXMargin, maxXMargin, minYMargin, maxYMargin, widthSizable, heightSizable global view1, switch1, textView1 global aTableView, theDataSource, sourceList global selectionAddress on run --起動直後の処理 my performSelectorOnMainThread:"mainMakeObject:" withObject:(missing value) waitUntilDone:true log "End" end run on mainMakeObject:inputObj --オブジェクトを処理 set myApp to current application set closeFlg to false -- set aTitle to "スタートアッププログラムの閲覧" set aRect to {300, 150, 1000, 640} set moveCenter to true set theWindow to my makeNewWindow(aTitle, aRect, moveCenter) -- my makeObject() -- repeat if closeFlg then my closeWin:theWindow exit repeat end if delay 0.2 end repeat end mainMakeObject: on makeNewWindow(aTitle, aRect, moveCenter) --ウインドウの作成 set {windowX, windowY, windowW, windowH} to aRect set theRect to myApp's NSMakeRect(windowX, windowY, windowW, windowH) set aScreen to myApp's class "NSScreen"'s mainScreen() set aStyle to (myApp's NSWindowStyleMaskTitled as integer) set aStyle to aStyle + (myApp's NSWindowStyleMaskClosable as integer) set aStyle to aStyle + (myApp's NSWindowStyleMaskMiniaturizable as integer) set aStyle to aStyle + (myApp's NSWindowStyleMaskResizable as integer) set aBacking to myApp's NSBackingStoreBuffered set aWindow to myApp's class "NSWindow"'s alloc()'s initWithContentRect:theRect styleMask:aStyle backing:aBacking defer:false screen:aScreen tell aWindow setDelegate_(me) setTitle_(aTitle) setMinSize_(myApp's NSMakeSize(300, 200)) setMaxSize_(myApp's NSMakeSize(10000, 10000)) setBackgroundColor_(myApp's class "NSColor"'s colorWithCalibratedRed:0.95 green:0.95 blue:0.95 alpha:1.0) setDisplaysWhenScreenProfileChanges_(true) setReleasedWhenClosed_(true) makeKeyAndOrderFront_(me) end tell -- if moveCenter then aWindow's |center|() -- return aWindow end makeNewWindow on makeObject() --各オブジェクトの配置 set mainView to theWindow's contentView set theWindowFrame to mainView's frame() set {{windowX, windowY}, {windowWidth, windowHeight}} to theWindowFrame -- set minXMargin to (myApp's NSViewMinXMargin) as integer -- 左の余白を柔軟に set maxXMargin to (myApp's NSViewMaxXMargin) as integer -- 右の余白を柔軟に set minYMargin to (myApp's NSViewMinYMargin) as integer -- 下の余白を柔軟に set maxYMargin to (myApp's NSViewMaxYMargin) as integer -- 上の余白を柔軟に set widthSizable to (myApp's NSViewWidthSizable) as integer -- 横方向の幅を柔軟に set heightSizable to (myApp's NSViewHeightSizable) as integer -- 縦方向の幅を柔軟に -- try -- 新しくオブジェクトを配置する部分 -------------------- --make new tableView set theDataSource to {} set {x, y, w, h} to {3, 1, windowWidth - 6, windowHeight - 25} set sourceList to {} set theDataSource to myApp's class "NSMutableArray"'s alloc()'s init() theDataSource's addObjectsFromArray:sourceList set aColumn1 to myApp's class "NSTableColumn"'s alloc()'s initWithIdentifier:"data1" tell aColumn1 headerCell()'s setTitle:"ファイル名" setEditable_(false) setWidth_(300) end tell set aColumn2 to myApp's class "NSTableColumn"'s alloc()'s initWithIdentifier:"data2" tell aColumn2 headerCell()'s setTitle:"アドレス" setEditable_(false) setWidth_(windowWidth - 450) end tell set aColumn3 to myApp's class "NSTableColumn"'s alloc()'s initWithIdentifier:"data3" tell aColumn3 headerCell()'s setTitle:"対象" setEditable_(false) setWidth_(80) end tell set aTableView to myApp's class "NSTableView"'s alloc()'s initWithFrame:(myApp's NSMakeRect(0, 0, w, h)) tell aTableView addTableColumn_(aColumn1) addTableColumn_(aColumn2) addTableColumn_(aColumn3) setDelegate_(me) setDataSource_(me) setUsesAlternatingRowBackgroundColors_(true) setDoubleAction_("tableAction1:") end tell set aScroll to myApp's class "NSScrollView"'s alloc()'s initWithFrame:(myApp's NSMakeRect(x, y, w, h)) aScroll's setDocumentView:aTableView mainView's addSubview:aScroll tell aScroll setHasHorizontalScroller_(true) setHasVerticalScroller_(true) setAutohidesScrollers_(true) setAutoresizingMask_(widthSizable + heightSizable) end tell aTableView's reloadData() --make new CheckBoxButton set theRect to myApp's NSMakeRect(10, windowHeight - 24, 150, 25) set switch1 to myApp's class "NSButton"'s alloc()'s initWithFrame:theRect tell switch1 setButtonType_(myApp's NSButtonTypeSwitch) setTitle_("Appleのファイルを隠す") setTarget_(me) setAllowsMixedState_(false) setState_(0) setAction_("switchAction1:") setAutoresizingMask_(maxXMargin + minYMargin) end tell mainView's addSubview:switch1 --subView set theRect to myApp's NSMakeRect(20, 0 - windowHeight, windowWidth - 40, windowHeight - 40) set view1 to myApp's class "NSView"'s alloc()'s initWithFrame:theRect tell view1 setBackgroundColor_(myApp's class "NSColor"'s colorWithCalibratedRed:0.8 green:0.9 blue:0.95 alpha:0.6) setFlipped_(false) setAutoresizingMask_(maxYMargin) end tell mainView's addSubview:view1 --textView set {view_w, view_h} to item 2 of (view1's frame()) set {x, y, w, h} to {10, 25, view_w - 20, view_h - 35} set theRect to myApp's NSMakeRect(x, y, w, h) set scrollview1 to myApp's class "NSScrollView"'s alloc()'s initWithFrame:theRect tell scrollview1 setBorderType_(0) setHasVerticalScroller_(true) setHasHorizontalScroller_(false) setAutoresizingMask_(widthSizable + heightSizable) setDrawsBackground_(false) end tell set textView1 to myApp's class "NSTextView"'s alloc()'s initWithFrame:theRect tell textView1 setMinSize_(myApp's NSMakeSize(0, h)) setMaxSize_(myApp's NSMakeSize(10000, 10000)) setVerticallyResizable_(true) setHorizontallyResizable_(false) setAutoresizingMask_(maxXMargin) textContainer()'s setContainerSize:(myApp's NSMakeSize(w, 10000)) setString_("") setDrawsBackground_(true) setBackgroundColor_(myApp's class "NSColor"'s colorWithCalibratedRed:0.98 green:0.98 blue:0.98 alpha:0.5) setEditable_(false) end tell textView1's textContainer's setWidthTracksTextView:true scrollview1's setDocumentView:textView1 view1's addSubview:scrollview1 --view close button set theRect to myApp's NSMakeRect(windowWidth - 130, 0, 80, 24) set button1 to myApp's class "NSButton"'s alloc()'s initWithFrame:theRect tell button1 setBezelStyle_(1) setButtonType_(0) setTitle_("閉じる") setTarget_(me) setAction_("buttonAction1:") setAutoresizingMask_(minXMargin + maxYMargin) end tell view1's addSubview:button1 -- set theRect to myApp's NSMakeRect(windowWidth - 300, 0, 160, 24) set button2 to myApp's class "NSButton"'s alloc()'s initWithFrame:theRect tell button2 setBezelStyle_(1) setButtonType_(0) setTitle_("ファイルの場所を開く") setTarget_(me) setAction_("buttonAction2:") setAutoresizingMask_(minXMargin + maxYMargin) end tell view1's addSubview:button2 -- try set aData to my getStartupFile() on error errText log "Err--" log errText end try ---------------------------------------------------------- on error errText log errText end try end makeObject on switchAction1:sender --チェックボックスが変更された時のアクション set f to my getStartupFile() end switchAction1: on buttonAction1:sender --ファイル閲覧ビューを隠す set {w, h} to item 2 of (mainView's frame()) set theRect to myApp's NSMakeRect(20, 0 - h, w - 40, h - 40) tell view1 setFrame_(theRect) view1's setAutoresizingMask:(maxYMargin) end tell switch1's setEnabled:true aTableView's setEnabled:true end buttonAction1: on buttonAction2:sender -- 選択したファイルを表示する tell application "Finder" activate select (selectionAddress as POSIX file) end tell end buttonAction2: on tableAction1:sender --テーブルビューの項目でダブルクリックされた時のアクション log "tableAction1" set lineNo to sender's clickedRow() set selectionAddress to (item (lineNo + 1) of sourceList)'s data2 set aData to do shell script ("cat '" & selectionAddress & "' ;") switch1's setEnabled:false aTableView's setEnabled:false textView1's setString:aData set {w, h} to item 2 of (mainView's frame()) set theRect to myApp's NSMakeRect(20, 20, w - 40, h - 40) log theRect tell view1 setFrame_(theRect) setAutoresizingMask_(widthSizable + heightSizable) end tell end tableAction1: on getStartupFile() --スタートアップアプリケーションファイルをすべて取得してリスト化 --get file set addList to "/Library/LaunchDaemons ~/Library/LaunchAgents ~/Library/LaunchDaemons /System/Library/LaunchAgents /System/Library/LaunchDaemons" try set aData to do shell script ("a=`echo '" & addList & "' | tr '\\n\\r' ' ' ;` ; for b in $a ; do du -a $b | grep -e '.plist' | cut -f2- ; done;") on error return false end try --Apple File status set appleHideFlg to (switch1's state()) ≠ 1 --Table view data set sourceList to {} if aData ≠ "" then repeat with obj in (paragraphs of aData) set obj to obj as string set aName to text (1 - (offset in ((reverse of items of obj) as string) of "/")) thru -1 of obj set aApplication to "-" if aName contains "com.apple." then set aApplication to "Apple" if aName contains "com.adobe." then set aApplication to "Adobe" if aApplication = "Apple" then if appleHideFlg then set sourceList to sourceList & {{data1:aName, data2:obj, data3:aApplication}} else set sourceList to sourceList & {{data1:aName, data2:obj, data3:aApplication}} end if end repeat end if --Table view reload set theDataSource to myApp's class "NSMutableArray"'s alloc()'s init() theDataSource's addObjectsFromArray:sourceList aTableView's reloadData() -- return true end getStartupFile on numberOfRowsInTableView:aTableView --テーブルビュー表示用(1) set c to count of (my theDataSource) return c end numberOfRowsInTableView: on tableView:aTableView objectValueForTableColumn:aColumn row:aRow --テーブルビュー表示用(2) set aRec to (my theDataSource)'s objectAtIndex:(aRow as number) set aIdentifier to (aColumn's identifier()) as string set aRes to (aRec's valueForKey:aIdentifier) return aRes end tableView:objectValueForTableColumn:row: on windowShouldClose:sender --ウインドウが閉じられた時のアクション set closeFlg to true end windowShouldClose: on closeWin:aWindow --ウインドウが閉じられた時のアクション aWindow's orderOut:me if (name of myApp) ≠ "Script Editor" then quit me end closeWin: |