[OS X TeX] Re: ANN: ChkTeX for TeXShop 1.4

Ramón Figueroa-Centeno ramonf at hawaii.edu
Tue Jun 15 01:23:05 CEST 2010


Here you go.

--Applescript direct

-- Ramon Figueroa-Centeno (June 3, 2010)
-- http://www2.hawaii.edu/~ramonf

try
    tell application "System Events"
        if UI elements enabled then
            tell process "ChkTeX for TeXShop"
                set window_pos to the position of window "ChkTeX for
TeXShop"
                set window_size to the size of window "ChkTeX for TeXShop"
            end tell
        end if
    end tell
on error
    try
        try
            set oldDelims to AppleScript's text item delimiters -- save
their current state
            set AppleScript's text item delimiters to {" "} -- declare new
delimiters
            
            set command to "defaults read TeXShop \"NSWindow Frame
PdfKitWindow\" | sed 's/ +/ /g'"
            tell me to set ventana to do shell script command
            tell ventana
                set window_pos to {text item 1, 0}
                if text item 3 > 600 then
                    set window_size to {600, (text item 4 as integer)}
                else
                    set window_size to {text item 3, (text item 4 as
integer)}
                end if
            end tell
            set AppleScript's text item delimiters to oldDelims -- restore
them
        on error
            set AppleScript's text item delimiters to oldDelims -- restore
them in case something went wrong
        end try
    on error
        set window_pos to {640, 0}
        set window_size to {600, 640}
    end try
end try

tell application "ChkTeX for TeXShop" to quit

-- Force Quit a given application using applescript?
-- http://macscripter.net/viewtopic.php?id=15240
set myProcesses to {"TeXShop Webpage Helper", "ChkTeX for TeXShop"} -- The
ones to quit.

tell application "System Events"
    repeat with myProcess in myProcesses
        set theID to (unix id of processes whose name is myProcess)
        try
            -- Should stop the application with no dialogs and no items
saved.
            do shell script "kill -9 " & theID
        end try
    end repeat
end tell

tell application "TeXShop"
    activate
    try
        path of the front document
        set TeX_path to the result
    on error
        -- There is no front document  or it has not ever been saved
        beep
        display dialog "there is no front document" & return & "or it has
not ever been saved!" buttons {"Ok"} default button "Ok" with icon stop
giving up after 20
        return
    end try
    
    if the front document is modified then
        set saveme to 1
    else
        set saveme to 0
    end if
    
    set command to "open -a \"ChkTeX for TeXShop\" " & quoted form of
TeX_path
    if saveme = 1 then
        set command to command & " --args  " & saveme & "  " & quoted form
of (name of the front document as string)
    end if
    do shell script command
end tell

activate application "ChkTeX for TeXShop"
tell application "System Events"
    if UI elements enabled then
        tell process "ChkTeX for TeXShop"
            set position of window "ChkTeX for TeXShop" to window_pos
            set size of window "ChkTeX for TeXShop" to window_size
        end tell
    end if
end tell


-- 
View this message in context: http://macosx-tex.576846.n2.nabble.com/ANN-ChkTeX-for-TeXShop-1-4-tp5176033p5179765.html
Sent from the MacOSX-TeX mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/macostex-archives/attachments/20100614/35790aa3/attachment.html>


More information about the macostex-archives mailing list