Skip to content

Commit

Permalink
Updated lock preventer
Browse files Browse the repository at this point in the history
  • Loading branch information
waicool20 committed Apr 29, 2017
1 parent bdacb58 commit 4a97631
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/main/kotlin/com/waicool20/kaga/util/LockPreventer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,19 @@ package com.waicool20.kaga.util
import java.awt.Robot
import java.awt.event.KeyEvent
import java.util.*
import kotlin.concurrent.timerTask

class LockPreventer {
private var timer: Timer? = null
private val robot = Robot()
private val timerTask = object : TimerTask() {
override fun run() {
private val timer by lazy { Timer() }
private val robot by lazy { Robot() }
private val task by lazy {
timerTask {
robot.keyPress(KeyEvent.VK_SHIFT)
Thread.sleep(10)
robot.keyRelease(KeyEvent.VK_SHIFT)
}
}

fun start() {
timer = Timer()
timer?.schedule(timerTask, 0L, 60 * 1000L)
}

fun stop() = timer?.cancel()
fun start() = timer.schedule(task, 0L, 60 * 1000L)
fun stop() = task.cancel()
}

0 comments on commit 4a97631

Please sign in to comment.