Hi there,
a few days ago I purchased a PC Sensor’s gold TEMPer (cheap USB thermometer device).
Since I was not not able to find a working shell tool for this device that works under OS X I tried to use the only working graphical tool TEMPer1X (http://ssl-lab.blogspot.de/2012/02/controlling-your-temper-on-mac-os-x.html)
and get the temp values with GUI scripting.
So far I was able to use the READ button but had no success to read the text field to get the temp.
Do you have any hints for me???
Here is my script part and the info I found with UIElementInspector and “get every UI element”
Many thanks… WürfelMac
tell application "System Events" to set frontmost of process "TEMPer1X" to true
set TEMP to "text"
tell application "System Events"
tell process "TEMPer1X"
tell window "TEMPer1X"
click button "Read" -- this works, the temp appears in the before empty text field
-- Try 1: set TEMP to value of text field 1
-- Try 2: set TEMP to value of attribute "AXStaticText" of window "TEMPer1X"
if attribute "AXIdentifier" of UI element is "_NS:28" then set TEMP to value of UI element -- Try 3
get TEMP
end tell
end tell
end tell
UIElementInspector (Temp-Field):
<AXApplication: “TEMPer1X”>
<AXWindow: “TEMPer1X”>
Attributes:
AXRole: “AXStaticText”
AXRoleDescription: “text”
AXHelp: “(null)”
AXValue: “27,125”
AXEnabled: “1”
AXFocused: “1”
AXParent: “<AXWindow: “TEMPer1X”>”
AXWindow: “<AXWindow: “TEMPer1X”>”
AXTopLevelUIElement: “<AXWindow: “TEMPer1X”>”
AXPosition: “x=1073 y=120”
AXSize: “w=96 h=22”
AXChildren: “<array of size 0>”
AXSelectedText: “27,125”
AXSelectedTextRange (W): “pos=0 len=6”
AXNumberOfCharacters: “6”
AXVisibleCharacterRange (W): “pos=0 len=6”
AXInsertionPointLineNumber: “(null)”
AXPlaceholderValue: “(null)”
AXIdentifier: “_NS:28”
Actions:
AXShowMenu - show menu
get every UI element:
button 1 of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
button 2 of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
button 3 of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
UI element 4 of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
button “Read” of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
static text “25,25” of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
static text “0” of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
static text “-20” of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
static text “20” of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
static text “40” of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
static text “60” of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
static text “80” of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
static text “100” of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”
static text “TEMPer1X” of window “TEMPer1X” of application process “TEMPer1X” of application “System Events”}