Detect amount of clicks on wall switch

Posted on
Sat Feb 14, 2015 2:56 pm
davinci offline

Detect amount of clicks on wall switch

I want to detect how many times I click on a wall switch.

This code would be working if it is triggered and run as I switch the wall switch multiple times. But it seems like it waits for the first one to complete. Has anyone an idea how to do it?

Trigger is the switch.

Code: Select all
if value of variable "SwitchLock" is equal to true then
   set value of variable "Switch" to (value of variable "Switch") + 1
else
   tell application "IndigoServer"
      set value of variable "SwitchLock" to true
      set value of variable "Switch" to 1
      
   end tell
   delay 0.5
   if value of variable "Switch" is equal to 2 then
         
      DO SOMETHING - 2 clicks
      
   end if
   
   if value of variable "Switch" is equal to 1 then
            
      DO SOMETHING - 1 click1

   end if
   
   value of variable "Switch"
   
   set value of variable "Switch" to 1
   set value of variable "SwitchLock" to false
end if

Posted on
Mon Feb 16, 2015 6:17 pm
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Detect amount of clicks on wall switch

AppleScript delays should never be done in an embedded AppleScript because those scripts have to be run on the main executing thread of the server - so everything is held up until the script finishes executing (which is probably what you're seeing).

Maybe if you could describe more generally what you're trying to accomplish we can find the right solution...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 19 guests