1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import java.awt.AWTException import java.awt.MouseInfo import java.awt.Robot import java.awt.event.InputEvent import java.awt.event.MouseEvent fun main() { try { val robot = Robot() while (true) { val mouseInfo = MouseInfo.getPointerInfo().location val mouseX = mouseInfo.x val mouseY = mouseInfo.y if (mouseX == 0 && mouseY == 0) { println("El ratón ha pasado por la posición específica (0, 0).") } // Esperar un momento antes de volver a verificar Thread.sleep(500) } } catch (e: AWTException) { e.printStackTrace() } catch (e: InterruptedException) { e.printStackTrace() } } |