Mouse position: Difference between revisions
Content added Content deleted
m (typo) |
(Added Kotlin) |
||
Line 514: | Line 514: | ||
In the above example, the window may not be external. |
In the above example, the window may not be external. |
||
It must in fact be a web browser window, which runs the script. |
It must in fact be a web browser window, which runs the script. |
||
=={{header|Kotlin}}== |
|||
{{trans|Groovy}} |
|||
<lang scala>// version 1.1.1 |
|||
import java.awt.MouseInfo |
|||
fun main(args: Array<String>) { |
|||
(1..5).forEach { |
|||
Thread.sleep(1000) |
|||
val p = MouseInfo.getPointerInfo().location // gets screen coordinates |
|||
println("${it}: x = ${"%-4d".format(p.x)} y = ${"%-4d".format(p.y)}") |
|||
} |
|||
}</lang> |
|||
Sample output: |
|||
{{out}} |
|||
<pre> |
|||
1: x = 752 y = 483 |
|||
2: x = 1112 y = 478 |
|||
3: x = 1331 y = 511 |
|||
4: x = 269 y = 562 |
|||
5: x = 247 y = 505 |
|||
</pre> |
|||
=={{header|Liberty BASIC}}== |
=={{header|Liberty BASIC}}== |