I'm using Applescript in conjunction with Alfred to provide a keyboard shortcut for starting and stopping the timer in Billings. This is really useful for my keeping track of my freelance work.
Here's the code I'm using:
tell application "Billings" to activate
tell application "System Events"
tell process "Billings"
tell menu bar 1
tell menu bar item "Slips"
tell menu "Slips"
if menu item "Start Timer" exists then
click menu item "Start Timer"
else
click menu item "Stop Timer"
end if
end tell
end tell
end tell
keystroke "h" using {command down}
end tell
end tell
I have it popped into an Alfred extension set to activate with CTRL+ALT+CMD+T.
Unfortunately, it's a bit clunky. Before yesterday I'd never touched Applescript, so I fear my chops are a bit poor. The Billings window momentarily pops up into the foreground and is then hidden again. It also won't hide if any modifier keys other than H happen to be pressed on the keyboard.
Thus:
Edit for clarity:
Billings is an OSX freelance time tracking and invoicing package. I use the timer to track how much time I spend on each task, so that I can accurately bill my clients. I personally find it very useful. The timer (for the current item I'm working on) is displayed in the menubar, and can be toggled by a mouse click. Ideally I'd be able to easily start and stop it with a keyboard shortcut when Billings isn't in the foreground, but there's no inbuilt functionality for doing so. It looks like this: 
Here is a solution to keep the application in the background.
-- no activate
tell application "System Events"
tell group 1 of group 2 of window "Billings" of process "Billings"
perform action "AXPress" of (get first button whose its name ends with " Timer")
end tell
end tell
--
If it does not work, here is the solution that hides the application without using the shortcut
activate application "Billings"
tell application "System Events"
tell process "Billings"
tell menu "Slips" of menu bar item "Slips" of menu bar 1
click (get first menu item whose its name ends with " Timer")
end tell
set visible to false
end tell
end tell
Here is another approach:
tell application "System Events" to set xxx to (1st process whose frontmost is true)
activate application "Billings"
tell application "System Events"
tell process "Billings"
click menu item 7 of menu 1 of menu bar item 7 of menu bar 1
if visible then
set visible to false
end if
end tell
end tell
set frontmost of xxx to true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With