Hack Forums
[Java] MouseListener for all actions? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Java] MouseListener for all actions? (/showthread.php?tid=5713662)



MouseListener for all actions? - Loses - Sep 8, 2017

Basically I want to make a quick program personally that uses hotkeys, so if I click mouse_3 I want it to type something specific. I don't want it to be bounded to any particular jframe I want it to work if I was making a post like on here.

Any direction would be appreciated, from what I know about mouselisteners is that they're usually binded to a JFrame of some sorts.


* - clrlslwi - Sep 8, 2017

I don't think keyboard hooks are natively supported in the JVM.

https://en.wikipedia.org/wiki/Java_Native_Interface
https://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85).aspx

Code
WH_KEYBOARD_LL



* - nOrr - Sep 9, 2017

Use a different language. AutoIt comes to mind


* - matt - Sep 9, 2017

(Sep 9, 2017 04:21 AM)nOrr Wrote:  Use a different language. AutoIt comes to mind

This.
Or if you're keen on using Java, another alternative is using JNI/JNA and learn to write some C code :P


* - Dezzz - Sep 9, 2017

If you want to hook all input events without doing some sort of overlay or having the events register thru your program you're gonna need to use JNA
https://github.com/java-native-access/jna

You're much better off doing it in another language tho
It's just gonna be a bitch to work with native stuff in java like that


* - nOrr - Sep 10, 2017

(Sep 9, 2017 05:30 PM)Midnight Blue™ Wrote:  This.
Or if you're keen on using Java, another alternative is using JNI/JNA and learn to write some C code :P

Why on earth would you want to even touch Java if you need C? >_>