Automator noob question

Discussion in 'Mac Programming' started by Manuelrodrigues, Apr 24, 2014.

  1. Manuelrodrigues, Apr 24, 2014
    Last edited by a moderator: Apr 24, 2014

    Manuelrodrigues macrumors member

    Manuelrodrigues

    Joined:
    Nov 16, 2011
    Location:
    Amsterdam
    #1
    Hi there!

    Im writing a short Apple script that wil automate some tasks in my lighting design software tool. Much of the functionality can be reached through simple keyboard shortcuts.

    The script looks like this now

    Code:
    activate application "MagicQ"
    tell application "System Events"
    	keystroke "92**"
    	keystroke "c" using {control down}
    	keystroke "11"
    	keystroke "r"
    	--Simulate enter key
    	key code 36
    	keystroke "x"
    	keystroke "s"
    	key code 36
    	keystroke "name test"
    	--Simulate enter key
    	key code 36
    	delay 1
    	keystroke "d"
    end tell
    The last letter "d" is for delete. Sadly the software does not allow to select the item to be deleted item though a key press. So I need to do a mouse click. I succeeded in generating a mouse click thought a "watch me do" function.
    But, because this is only a tiny part of the total number of commands i want to incorporate this click in my script. So I have one document which contains all the info.

    To try and integrate the "watch me do" function in my script I imported the watch me do function in the apple script editor and this came up:

    Code:
    -- Click the “<Select & delete mouseclick>” button.
    delay 0.050416
    set timeoutSeconds to 2.000000
    set uiScript to "click UI Element 31 of window \"MagicQ PC (Demo Mode)\" of application process \"MagicQ\""
    my doWithTimeout( uiScript, timeoutSeconds )
    
    on doWithTimeout(uiScript, timeoutSeconds)
    	set endDate to (current date) + timeoutSeconds
    	repeat
    		try
    			run script "tell application \"System Events\"
    " & uiScript & "
    end tell"
    			exit repeat
    		on error errorMessage
    			if ((current date) > endDate) then
    				error "Can not " & uiScript
    			end if
    		end try
    	end repeat
    end doWithTimeout
    I noticed that the "watch me do" script clicks the following UI element:

    Code:
    set uiScript to "click UI Element [COLOR="red"]31[/COLOR] of window \"MagicQ PC (Demo Mode)\" of application process \"MagicQ\""
    Can someone help me to generate a mouse click inside my script to this element?

    Hope you can help!

    Cheers,

    Manuel
     
  2. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    I think answer to your question is already in your post eg

    Code:
    click UI Element 31 of window \"MagicQ PC (Demo Mode)\" of application process \"MagicQ\"
    Also take a look at UI Browser or Apple's free UIElementInspector (sometimes known as Accessibility Inspector) for al things related to GUI Scripting.

    Info : http://pfiddlesoft.com/uibrowser/
     

Share This Page