LeVanPhuUIT / jnativehook

Automatically exported from code.google.com/p/jnativehook
0 stars 0 forks source link

The method getInstance() is undefined for the type GlobalScreen #96

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.The method getInstance() is undefined for the type GlobalScreen
2.
3.

What is the expected output? What do you see instead?
Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    The method getInstance() is undefined for the type GlobalScreen

What version of the product are you using? On what operating system?
JNativeHook v2.0.1 | OSX Yosemite

Please provide any additional information below.
I see that output when I try to implement your code with mine. Everything else 
works, I imported your jar file but I don't know why it can't see getInstance().

Original issue reported on code.google.com by nicolas....@gmail.com on 17 Apr 2015 at 4:11

GoogleCodeExporter commented 8 years ago
Hi, The api has changed between 1.X and 2.0 for the GlobalScreen class and a 
few other things.  GlobalScreen is no longer a singleton and was converted to a 
static class.  You should be able to remove the .getInstance() method for all 
of the GlobalScreen method calls and just call them statically.  There is 
updated documentation no the GitHub wiki.  See: 
https://github.com/kwhat/jnativehook/wiki/Usage

Original comment by a...@1stleg.com on 17 Apr 2015 at 4:15

GoogleCodeExporter commented 8 years ago
Thanks it works!! Amazing response time as well, thanks for all the hard work 
on this great library. :)

Original comment by nicolas....@gmail.com on 17 Apr 2015 at 4:31

GoogleCodeExporter commented 8 years ago
A couple more things while you're here...
1. Is the red text in the console from your library? If so, how do I disable it?
2. I am trying to check for mouse wheel presses. How could I go about doing 
that?

Original comment by nicolas....@gmail.com on 17 Apr 2015 at 4:44

GoogleCodeExporter commented 8 years ago
NP, you happened to catch me right when I sat down ;)  

1. Is the red text in the console from your library? If so, how do I disable it?
What red text are you referring to?  The library does have console output that 
can be disabled with Java's logger api.  There are some docs in the wiki about 
how to do it.

2. I am trying to check for mouse wheel presses. How could I go about doing 
that?
You will probably listen for button 3 press events, but the mouse wheel being 
button 3 is not guaranteed.  There is no way to explicitly get the mouse 
"wheel" button, it is just a button that can be configured by the system.

Original comment by a...@1stleg.com on 17 Apr 2015 at 2:57

GoogleCodeExporter commented 8 years ago
1. Yes, This red output:

Apr 17, 2015 3:36:11 PM org.jnativehook.DefaultLibraryLocator getLibraries
INFO: Library extracted successfully: 
/var/folders/kj/xq9z0nsd2rgfz068vs_353ym0000gn/T/libJNativeHook-2.0.1.dylib 
(0x49D7B8F902DF8D37C513780298231CC125D63B5C).

JNativeHook: Global keyboard and mouse hooking for Java.
Copyright (C) 2006-2015 Alexander Barker.  All Rights Received.
https://github.com/kwhat/jnativehook/

JNativeHook is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

JNativeHook is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
Apr 17, 2015 3:36:11 PM java.lang.ClassLoader$NativeLibrary load
INFO: hook_get_auto_repeat_rate [107]: IOHIDGetParameter: 75.

Apr 17, 2015 3:36:11 PM java.lang.ClassLoader$NativeLibrary load
INFO: hook_get_auto_repeat_delay [189]: IOHIDGetParameter: 450.

2. Great! Looks like for my mac it is button 3. How could I set up an if 
statement in nativeMouseClicked()? Something like if(BUTTON_PRESSED == 
BUTTON_3) or something like that?

Original comment by nicolas....@gmail.com on 17 Apr 2015 at 10:39

GoogleCodeExporter commented 8 years ago
Yes, you can disable that output, although IDK Why its red ;)  Look in the wiki 
on github for disabling console output.

And yes again,  You can add a mouse button listener and check for either a 
Mouse down, up or click event.  You should use something like if (e.getButton() 
== NativeMouseEvent.BUTTON3) { ... }.  The listeners work almost exactly the 
same way as Java's built in listeners, you just need to register an 
implementing class with the GlobalScreen.

Original comment by alex.bar...@resignationmedia.com on 17 Apr 2015 at 11:31

GoogleCodeExporter commented 8 years ago
1. Hmm... I got 
Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
        logger.setLevel(Level.OFF);
to work, but for the other part:

Handler[] handlers = Logger.getLogger("").getHandlers();
for (int i = 0; i < handlers.length; i++) {
    handlers[i].setLevel(Level.OFF);
}
Its somehow trying to cast Handler[] and gives me this:
"cannot convert from java.util.logging.Handler[] to 
javax.xml.ws.handler.Handler[]
The method setLevel(Level) is undefined for the type Handler"

2. sorry I'm kind of new to programming, but what do you mean by "you just need 
to register an implementing class with the GlobalScreen." ?

Original comment by nicolas....@gmail.com on 18 Apr 2015 at 3:07