Knows everyone a way how to export or trigger the screenshot function automatically? As far as I know there is just the way with pressing the spacebar. Is there a way to hack this?
Hi Ferdinand! Welcome!
There is currently not a clean way to do it (I will keep it in mind for the next release). However, what you can do is the following to fake key presses.
fun main() {
application {
program {
extend(Screenshots())
extend {
keyboard.keyDown.trigger(KeyEvent(KeyEventType.KEY_DOWN, ' '.toInt(), "space", emptySet()))
}
}
}
}
Hey Edwin!
That’s perfect working, thanks.
This could may a stupid question but how can I set an precise interval every 2 seconds only one screenshot.
I tried this, but its nur accurate enough:
fun main() = application {
program {
extend(Screenshots())
extend {
val timer = seconds%2if (timer < 0.02) { keyboard.keyDown.trigger(KeyEvent(KeyEventType.KEY_DOWN, ' '.toInt(), "space", emptySet())) } } }
}
As well as a map function including sin(seconds). Its also not accurate enough.
Thanks Edwin.
To achieve as close as possible interval screenshots you would introduce a timestamp (lastTime
in my example), you check against the timestamp and reset it when enough time has passed.
fun main() = application {
program {
extend(Screenshots())
var lastTime = seconds
extend {
if (seconds - lastTime > 2.0) {
keyboard.keyDown.trigger(KeyEvent(KeyEventType.KEY_DOWN, ' '.toInt(), "space", emptySet()))
lastTime = seconds
}
}
}
}
This is exactly what I need, thank you!