text [在标记2中打开当前的Scivener文件] #marked #scrivener #applescript

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text [在标记2中打开当前的Scivener文件] #marked #scrivener #applescript相关的知识,希望对你有一定的参考价值。

property myName : "_display"
property pX : missing value
property pY : missing value

-- GRAB FILEPATH
tell application "System Events"
	tell process "Scrivener"
		activate
		set documentPath to value of attribute "AXDocument" of window 1
		
	end tell
end tell
set o_set to offset of "/Users" in documentPath
set fixFile to characters o_set thru -1 of documentPath
set documentPath to fixFile as string
set documentPath to do shell script "python -c \"import urllib, urlparse, sys; print urllib.unquote(urlparse.urlparse(sys.argv[1])[2])\" " & quoted form of documentPath

-- ALIGN WINDOW
send_window_half_screen("Scrivener", "left")

-- OPEN IN MARKED
tell application "Marked 2"
	activate
	open documentPath
end tell

-- ALIGN WINDOW
send_window_half_screen("Marked 2", "right")


-- SOURCE: https://github.com/RobTrew/txtquery-tools/blob/master/utilities/OpeniThoughtsMapinMarked.applescript
-- CREDIT: Rob Trew (https://twitter.com/complexpoint)
on displayResoln()
	if (pX is missing value) or (pY is missing value) then
		set {dlm, my text item delimiters} to {my text item delimiters, "Resolution"}
		set lstDisplays to text items of (do shell script "system_profiler SPDisplaysDataType")
		
		repeat with i from 2 to length of lstDisplays
			set strLine to item i of lstDisplays
			if strLine contains "Main Display: Yes" then exit repeat
		end repeat
		set my text item delimiters to space
		set lstParts to text items of strLine
		set my text item delimiters to dlm
		set {strX, strY} to {item 2, item 4} of lstParts
		
		set {pX, pY} to {strX as integer, strY as integer}
		
		-- fix for retina display
		if {pX, pY} is equal to {2880, 1800} then
			set {pX, pY} to {1920, 1200}
		end if
		if {pX, pY} is equal to {6720, 3780} then
			set {pX, pY} to {3360, 1890}
		end if
		
	end if
	return {pX, pY}
end displayResoln


-- summary of function
on send_window_half_screen(appName, windowPosition)
	
	-- variables --
	set windowSize to 0.5
	set windowMargin to 5
	
	tell application "System Events"
		
		-- The screen dimensions
		set {displayWidth, displayHeight} to my displayResoln()
		-- get the app process
		set appProcess to application processes where name contains appName
		--  set some window variables
		set leftRightWindowWidth to ((displayWidth * windowSize) as integer) - windowMargin * 2
		set topBottomWindowHeight to ((displayHeight * windowSize) as integer) - windowMargin * 2
		set fullWindowHeight to displayHeight - windowMargin * 2
		set fullWindowWidth to displayWidth - windowMargin * 2
		
		if appProcess is not equal to {} then
			
			tell process appName
				if value of attribute "AXFullScreen" of window 1 then
					set value of attribute "AXFullScreen" of window 1 to false
					delay 1.5
				end if
			end tell
			
			set appWindow to front window of (item 1 of appProcess)
			
			if windowPosition is equal to "left" then
				tell appWindow to set {position, size} to {{windowMargin, windowMargin}, {leftRightWindowWidth, fullWindowHeight}}
			else if windowPosition is equal to "right" then
				tell appWindow to set {position, size} to {{leftRightWindowWidth + windowMargin * 3, windowMargin}, {leftRightWindowWidth, fullWindowHeight}}
			else if windowPosition is equal to "top" then
				tell appWindow to set {position, size} to {{windowMargin, windowMargin}, {fullWindowWidth, topBottomWindowHeight}}
			else if windowPosition is equal to "bottom" then
				tell appWindow to set {position, size} to {{windowMargin, topBottomWindowHeight + windowMargin}, {fullWindowWidth, topBottomWindowHeight}}
			end if
		end if
	end tell
end send_window_half_screen

以上是关于text [在标记2中打开当前的Scivener文件] #marked #scrivener #applescript的主要内容,如果未能解决你的问题,请参考以下文章

更改文本区域 jquery 内的 html 标记之间的文本

jQuery选择当前脚本标记

Sublime Text快捷键整理

怎样查看linux进程打开的文件数

CentOS7 查看当前打开文件数

Linux最大打开文件数