Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
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 1183 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 19: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


Current project release date: sometime in 3003


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

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

Endolf

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #2 - Posted 2006-10-20 01: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 Member





« Reply #3 - Posted 2006-10-22 01: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.
Online CommanderKeith
« Reply #4 - Posted 2006-10-22 08: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. 

Keith

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 09: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org 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‑gaming.org
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!