Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Getting keyboard/input while in other programs?  (Read 1467 times)
0 Members and 1 Guest are viewing this topic.
Offline Eli Delventhal

JGO Kernel

Medals: 42
Projects: 11
Exp: 10 years

Game Engineer

« Posted 2006-10-18 17:52:48 »

I don't know if this is possible, but I'm making a program to save certain keyboard or mouse actions you have done on your computer and reproduce them for you, helping out with a lot of things like mundane multimedia tasks and whatnot. I've got the reproduction part and right now I have a fullscreen undecorated semi-transparent JFrame pop up so that you can simulate the mouse and keyboard movement you are doing, but it obviously isn't recording the actual ones and so multistep recordings that require the program you are working in to change (like pressing a button and having a window pop up) clearly won't work, unless you guess where things are going to happen.

So, my question is – is there any way to record mouse and keyboard input from anywhere on the computer, even while some Swing component does not have focus? Can I trick a Swing component to always thinking it has focus, and therefore it will always record everything anyway? Could I override some hasFocus() method or something?

Thanks once again, guys.

See my work:
OTC Software
Offline endolf

JGO Coder

Medals: 7
Exp: 15 years

Current project release date: sometime in 3003

« Reply #1 - Posted 2006-10-19 11:09:10 »

JInput can works with no windows, so yes, it will work Smiley


Offline Eli Delventhal

JGO Kernel

Medals: 42
Projects: 11
Exp: 10 years

Game Engineer

« Reply #2 - Posted 2006-10-19 23:42:07 »

Ha, that's kind of a copout, though, isn't it? I suppose I could use that if I needed to, but are there any Swing methods anyone knows of?

See my work:
OTC Software
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Kova

Senior Devvie

« Reply #3 - Posted 2006-10-21 23:06:56 »

well, if it's imperative for swing to receive events you could pass your stuff you recorded from JInput (or awt listener) to them... I myself don't know technically how, just a theory I have.
Offline CommanderKeith
« Reply #4 - Posted 2006-10-22 06:00:35 »

I've made a similar program but couldn't find a way to do that kind of macro-recording either.

By the way, how are you doing the scripting for yours?  I made the program take a kind of script that could do loops, ifs methods etc but it was pretty hit & miss - I basically invented my own useless language.  I think it'd be best to use one of the scripting APIs in JDK 6 now. 


PS: something I just learned recently was that toolkit has a method to set the locking state of caps, num lock etc.  Don't use Robot to do this since it doesn't work properly.

Offline Eli Delventhal

JGO Kernel

Medals: 42
Projects: 11
Exp: 10 years

Game Engineer

« Reply #5 - Posted 2006-10-22 07:19:41 »

I don't invent my own scripting language – although I have done it before – all I do is basically have a LinkedList of conditions and actions. Condition and Action are each an interface, with one method. A Condition knows if it is true, and an Action knows how to perform itself. Essentially, if everything in the conditions list is true, everything in the actions list performs. A new Condition can also be a new action, allowing for nested ifs.

As for the scripting language, the best way I've found is to write a language then translate it into Java code, then use javac to compile the Java into bytecode, which will in effect run as quickly as the rest of your program. I tried to create a scripting language from the ground up and it was really god damned slow because I didn't have the time to spend on making it very good. This is the best option if that's what you want.

See my work:
OTC Software
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

SHC (37 views)
2015-08-01 03:58:20

Jesse (24 views)
2015-07-29 04:35:27

Riven (44 views)
2015-07-27 16:38:00

Riven (24 views)
2015-07-27 15:35:20

Riven (27 views)
2015-07-27 12:26:13

Riven (18 views)
2015-07-27 12:23:39

BurntPizza (39 views)
2015-07-25 00:14:37

BurntPizza (48 views)
2015-07-24 22:06:39

BurntPizza (33 views)
2015-07-24 06:06:53

NoxInc (40 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!