Display VMware Fusion Library Window using keystrokes

--
-- A simple launcher to display the VMware Library
--
-- 20101222 by fidel
--
try
    tell application "VMware Fusion"
        -- activate it if not running already
        activate
        -- keystroke to open VM Lib Window (Shift + Apple + L)
        tell application "System Events"
            keystroke "L" using {command down, shift down}
        end tell
    end tell
on error
    display dialog "Something weird happened dude" with title "error"
end try

ping-check with error handling

--
-- ping-check with error handling
--

-- define target
set pingTarget to "192.168.1.1"

try
    --ping pingTarget
    set pingResult to (do shell script "/sbin/ping -c 1 " & pingTarget)
   
    -- if that was working - do something   
    display dialog "Your target " & pingTarget & " was pingable" buttons {"yeah"} with icon 1
   
on error errStatement number errNum
    -- ping was not successful
    display dialog "Your target " & pingTarget & " was not pingable" buttons {"damn"} with icon 0
    --errStatement contains ping result
    --errNum contains error code - see man ping
end try

open a choose folder dialog

--
-- open a choose folder dialog
--

-- a simple choose folder dialog
set selectedFolder to choose folder
-- as a result selectedFolder should contain an alias to the selected folder
-- example: alias "MacHDName:Path:To:Some:Random:Folder

-- some additional options

-- simple choose-folder dialog with custom string
set selectedFolder to choose folder with prompt "your personal string"


-- simple choose-folder dialog which displays hidden folders too
set selectedFolder to choose folder with invisibles


-- simple choose-folder dialog which allows multiple folder-selections at once
set selectedFolders to choose folder with multiple selections allowed

open a choose file dialog

--
-- open a choose file dialog
--

-- a simple choose-file dialog
set selectedFile to choose file
-- as a result selectedFile should contain an alias to the selected file
-- example: alias "MacHDName:Path:To:Some:Random:Folder:filename.extension

-- some additional options

-- simple choose-file dialog with custom string
set selectedFile to choose file with prompt "your personal string"


-- simple choose-file dialog which displays hidden files too
set selectedFile to choose file with invisibles


-- simple choose-fileS dialog which allows multiple file-selections at once
set selectedFiles to choose file with multiple selections allowed

check for processes using System Events

--
-- check for processes using System Events
--

tell application "System Events"
    -- check for specific process name
    set foo to count (every process whose name is "Safari")
   
    -- check for a String in all process-names
    set bar to count (every process whose name contains "System")
end tell


-- Warning:
--
-- Keep in mind that System Events has a pretty special (let's call it crapple'd)
-- list of processes which might differ from a simple ps in Terminal