I'm a teacher and would like to use Keynote slides as flashcards for spelling. I cannot script and am looking for something to be copy/pasted into Applescript Editor and run from there. I came across the following script in another thread and it is close to what I need.
tell application "Keynote"
tell slideshow 1
show slide 3
show slide 2
show slide 1
show slide 4
end tell
end tell
However, there are two problems for my purposes:
1. It is not a random order and would be tedious to write out for several different presentations of different lengths.
2. There is no control for the length of time each card is shown.
Any advice would be greatly appreciated.
Here is a script that mixes the indexes and wait between each slide
set tdelay to 5 -- seconds -- the length of time each card is shown.
tell application "Keynote"
activate
tell slideshow 1 to repeat with i in my mixIndexes(count slides)
show slide i
delay tdelay
end repeat
end tell
on mixIndexes(n)
set l to {1}
if n is 1 then return l
repeat with i from 2 to n
set end of l to i
set j to some item of l
tell item i of l to set {item i of l, item j of l} to {item j of l, it}
end repeat
return l
end mixIndexes
Related
I was working on the AppleScript below and I was wondering if there is a way to make a repeat, repeat a variable amount of times. Here's what I tried to do but it didn't work. Does anybody have a solution? Thanks!
tell application "System Events"
set blue to 1
repeat blue times
keystroke "s"
end repeat
set blue to blue + 1
end tell
I am working on a game in Corona (with Lua) where the player colours in a plant and then adds it to a box. once the player has made enough plants a dinosaur walks over and eats the plants. after which the dinosaur is supposed to change colour filtering through the colours used to colour in the plants.
-- this creates a loop that will cycle through the table "RecentColours" and "change the dinosaurs colour each time and" then stop on the last colour used
X=1
--changes dino colour
for ListColors = 1, #RecentColours do
Colour = RecentColours[X]
Dino:setFillColor(unpack(Colour))
X = X + 1
print(unpack(Colour))
--sets CurrentColour to the current colour of the dinosaur
CurrentColour = Colour
end
--emptys dinour colour list
for ListColors = 1, #RecentColours do
Y = #RecentColours
table.remove(RecentColours,Y)
end
this loop runs for the length of a list of colours but the problem is the dinosaur only changes to the last colour in the list rather then cycleing through all of them
I have tried changing the style of loop but that changed nothing and i have tried a .preformwithdelay event and I have tried putting into its own function.
I have also tested with printing to the console and It definitely adds all the colours to the list and it definitely runs through the whole list as it prints the current part of the table that it's up to
The comments helped greatly and solved the problem. but if you know a way to slow down a loop I would love to know
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I'm making a pairs game. The users can click and match pairs which is working great. However, I'd like to add a timer. I'm not sure how to do this.
I already have a button "start" which is used to start and reset the game. I've added a field "counter" which I'll use to display the time. I'm just not sure how to make a timer work without blocking the game play.
Considering this is a game I would expect you're wanting to display the seconds and end the game after a certain period of time.
LiveCode has great syntax for this. The 'send' command lets you send messages in a designated amount of time. For example:
send "handlerName" to target in 1 second
So applying this principle allows us to create timers in a couple of lines of script
local sSeconds
on countSeconds
add 1 to sSeconds
send "timerIncrease" to me in 1 second
end countSeconds
This example will count forever so might not be that useful!
You described a simple game so I would imagine you want to count down from say 60 seconds to 0. When you hit 0, tell the user their time is up.T In your button you could try the following script
local sGameSeconds
local sTimerRunning
on mouseUp
if the label of me is "start" then
set the label of me to "reset"
put true into sTimerRunning
put 60 into sGameSeconds
send "timerRun" to me in 1 second
else
set the label of me to "start"
put false into sTimerRunning
put 60 into field "counter"
end if
end mouseUp
on timerRun
if sTimerRunning is true then
subtract 1 from sGameSeconds
if sGameSeconds < 1 then
put 0 into field "counter"
put false into sTimerRunning
set the label of button "start" to "start"
timerFinished
else
put sGameSeconds into field "counter"
send "timerRun" to me in 1 second
end if
end if
end timerRun
on timerFinished
answer "Time Up!"
end timerFinished
It isn't entirely clear what you are asking. You write that you want a timer, but you don't say what you want to use it for. Neither do you say if you want this timer to actually display the time or if you just want something to happen after a particular amount of time.
Here's a simple way to display the time:
on showTime
put the long time into fld "Time"
send "showTime" to me in 100 milliseconds
end showTime
By refereshing the time every 100 milliseconds, the time on display is never more than 1/10th of a second off.
Here's an efficient way to display a timer that only shows hours and minutes. It sends a showTime message just in time and uses a minimum of processing power:
on mouseUp
if showTime is in the pendingMessages then
put the pendingMessages into myMsgs
filter myMsgs with "*showTime*"
repeat for each line myMsg in myMsgs
cancel item 1 of myMsg
end repeat
else
showTime
end if
end mouseUp
on showTime
set the itemDel to colon
put the system time into myTime
put myTime into fld 1
put item 2 of myTime into myMinutes
if myMinutes is 59 then
add 1 to item 1 of myTime
if item 1 of myTime >= 24 then
put 0 into item 1 of myTime
end if
put "00" into item 2 of myTime
else
add 1 to item 2 of myTime
end if
convert myTime to seconds
put myTime - the seconds into myTime
send "showTime" to me in myTime seconds
end showTime
You can start the timer by clicking on the button containing the mouseUp handler and you can stop it by clicking the same button again.
If this isn't what you need, please explain more.
I am trying to print a report where we have several different components within the xaml.
By what I`ve found, when printing, you have to treat every UIelement as a single one, thus if the desiredSize is bigger than the AvailableSize you have to activate the flag HasMorePages.
But here comes the problem.
My user can write as much text as he/she wants on the grid, therefore, depending on the amount, the row expands and goes off the printable area, as you can see on the picture below.
I thought about giving a whole page to the grid, but it was to big still, which got me into a loop where the DesizedSize was always bigger than the PrintableArea.
My code is not very different from any source you find on internet when searching for Multiple Page printing.
It is based on this http://eswarbandaru.blogspot.com.au/2011/02/print-mulitple-pages-using-silverlight.html , but using Stackpanels instead of Textboxes.
Any idea?
Thank you in advance.
First you need to work out how many pages are needed
Dim pagesNeeded As Integer = Math.Ceiling(gridHeight / pageHeight) 'gets number of pages needed
Then once the first page has been sent to the printer, you need to move that data out of view and bring the new data into view ready to print. I do this by converting the whole dataset into an image/UI element, i can then adjust Y value accordingly to bring the next set of required data on screen.
transformGroup.Children.Add(New TranslateTransform() With {.Y = -(pageIndex * pageHeight)})
Then once the number of needed pages is reached, tell the printer to stop
If pagesLeft <= 0 Then
e.HasMorePages = False
Exit Sub
Else
e.HasMorePages = True
End If
Or if this is too much work, you can simply just scale all the notes to fit onto screen. Again probably by converting to UI element.
Check out this link for converting to a UI element.
http://www.codeproject.com/Tips/248553/Silverlight-converting-to-image-and-printing-an-UI
Hope this helps
Can someone shed some light on how Install4j's back button actually works? I should note at this point that I'm using install4j Multi-Platform Edition 5.1.2 (build 5492).
Loop Example
This example is based on a screen group containing 2 screens ('Screen 1' and 'Screen 2').
Start screen
Screen 1 (in the looped group)
Screen 2 (in the looped group)
End screen
Screen group properties:
Loop index start: 0
Loop index step: 1
Loop expression: (Integer)context.getVariable("i") < 2
Loop index variable name: i
As expected, clicking next repeatedly results in the following screen flow:
Start screen
Screen 1 (i=0)
Screen 2 (i=0)
Screen 1 (i=1)
Screen 2 (i=1)
Screen 1 (i=2)
Screen 2 (i=2)
End screen
I would expect the back button to step backwards through the history listed above. However, the actual behaviour is as follows:
End screen
Screen 2 (i=3)
Screen 1 (i=3)
Screen 1 (i=3)
Screen 1 (i=3)
Start screen
Clearly this is not what any rational user would expect. To complicate matters further, the change Log Install4j for 5.1 Build 5435 includes the following:
Fixed wrong behavior when going back in the screen history where
screen loops were present
The other issue raised in this example, is how do you decrement the loop counter when stepping backwards? It would appear there's no practical way of doing this when using a looped screen group.
If this is case, the only way of implementing a loop which can be stepped through backwards is to implement your own screens in order to override previous(). The side effect being that you have to hand code your screens just to get the correct back button behaviour for loops, which seems ridiculous.
Has anyone else found a decent workaround for this problem? The install4j manual is pretty lame in that the word 'history' only appears once. There's no specification for how the back button works whatsoever.
This is a bug, it will be fixed in 5.1.4. Please contact support#ej-technologies.com to get the current build where it is fixed.
The other issue raised in this example, is how do you decrement the
loop counter when stepping backwards? It would appear there's no
practical way of doing this when using a looped screen group.
This will work automatically in 5.1.4.