Ok so I’m gui scripting and if someone could tell me what to put after the “repeat until” blocks in place of my english explanation of what I’m trying to do below in the script that would be great! Thanks
It’s going to look like this, but not so much English
It’s not possible with GUI scripting to detect if the user has clicked a button.
You can either use an AppleScript dialog box to make the decision or
you must check other UI elements for change or existence like windows or buttons
As always, thanks StefanK I didn’t really think about your second option so I guess I’ll give that a whirl. I just assumed there was something like what I was asking. I’m sure your probably gone for the night, but I’m curious to know if there is an opposite to repeat until, like for example, repeat while exists sheet 1 of window 1 ¬ delay .5 ¬ end repeat or something so you could provide user input while it delayed because said sheet was existing to choose a file.
Edit: It seems I will need both techniques you described. repeat until not’s for all of the delays while the user is inputting information and then a dialog with “add more” or “continue” on it or something at the beginning of the repeat loop for creating more tasks
An alternative approach that I like is a repeat with no conditions, and “exit repeats” in the followup to dialog entries or tests.
-- Try this with entries like 2, 22, and "A". The only ways out are to cancel or meet the conditions.
repeat
set N to text returned of (display dialog "Enter an integer from 1 to 9" default answer "")
try
set A to N as integer
if A > 0 and A < 10 then
exit repeat
else
display dialog "Your entry was out of bounds"
end if
on error
display dialog "An Integer, Please"
end try
end repeat
A
Hey thanks Adam Bell. That’s actually the same thing StefanK told me in PM. I’ve drastically modified my code and I’ll put it up since I think it’s worth noting what I thought of. Previously I had one large system events tell block with one large tell process d-vision 3 block but if you did anything to loose focus, you couldn’t tell application d-vision 3 to activate. So instead I’ve removed the tell process block and just have “of process x” on the end of all of the gui scripting and then activate application x before gui events so you don’t loose focus. Loosing focus was my other question btw, but I brought it up PM.
(My script is for demuxing ogm files in D-Vision 3 so far, but I have more planned.)
--Create "OGM Parts" folder on the Desktop
activate application "Finder"
tell application "Finder"
try
make new folder at desktop with properties {name:"OGM Parts"}
end try
end tell
--Start GUI Scripting D-Vision 3
activate application "D-Vision 3"
tell application "System Events"
repeat until exists window "D-Vision 3" of process "D-Vision 3"
delay 0.2
end repeat
--Click Tools
activate application "D-Vision 3"
click button 4 of window "D-Vision 3" of process "D-Vision 3"
repeat until exists window "D-Vision 3: the tools" of process "D-Vision 3"
delay 0.2
end repeat
--Click Demux OGM
activate application "D-Vision 3"
click button 6 of window "D-Vision 3: the tools" of process "D-Vision 3"
delay 1
--Open destination folder dialog
activate application "D-Vision 3"
click button 1 of group 1 of group 1 of window 1 of process "D-Vision 3"
--Delay for user to select destination folder
activate application "D-Vision 3"
repeat until not (exists sheet 1 of window 1) of process "D-Vision 3"
delay 0.5
end repeat
repeat
--Open File to demux dialog
activate application "D-Vision 3"
click button 2 of group 1 of group 1 of window 1 of process "D-Vision 3"
--Delay for user to select file
activate application "D-Vision 3"
repeat until not (exists sheet 1 of window 1) of process "D-Vision 3"
delay 0.5
end repeat
--Uncheck extract subtitles
activate application "D-Vision 3"
click checkbox 2 of group 1 of group 1 of window 1 of process "D-Vision 3"
delay 0.5
--Click create task
activate application "D-Vision 3"
click button 1 of group 1 of window 1 of process "D-Vision 3"
display dialog "What would you like to do?" buttons {"Add More", "End Loop"}
if button returned of result is "End Loop" then exit repeat
end repeat
activate application "D-Vision 3"
--Launch the queue
click menu item 3 of menu 5 of menu bar 1 of process "D-Vision 3"
end tell