GlobalKeyCommand AutoExec on start-up

I have just completed a small Module Extension, attached, that implements the invocation of a Global Key Command on module load. It contains two small java class files, and the barebones of a module extension. The complete Java class name is for import to a:
VASSAL.build.module.AutoExecGKC

The complete process to access this functionality in a VASSAL module is as follows:
Extract the folder VASSAL from the attachment to your hard-drive;
Copy this VASSAL folder into the root of your module archive;
In the module Editor, right click on the root of your module tree and select Import Class;
Type the class name exactly as follows (class names are case sensitive):
VASSAL.build.module.AutoExecGKC
and select OK; and finally
Complete the dialog box as for a normal Global Key Command, except that some fields not relevant for this usage have been defaulted to nulls.

Last but not least, please send me $10 CAD if you find this useful
:astonished:

P.S.

Interaction with PlugIn.init():
The PlugInLoader invokes the init() method after the module is completely built, but before the Key Listeners are active. This is an appropriate time to complete PlugIn initialization, but to invoke a GKC the Key Listeners must first be active; hence this extension.

Joel,

I discovered the GameComponent class, so have not used my AutoRun class and the amendments to Player that I initially thought were required for this.

Hi there, does this only affect certain things?
I have set a deck to reshuffle via right click menu and assigned the key to it. If I use your AutoExex to do that key the deck isn’t shuffled, however I can see it work to a Single piece in an At-Start Stack.

It should work exactly the same as a Global Key Command added to the module. Unless the Key Listeners for the deck are initialized later than others, i cannot see why decks should behave differently than at-start stacks. I will investigate this evening.

A Global Key Command (GKC) at the module level acts only as a Global Hot Key (GHK) on each map, so it is necessary to have a ‘Relay’ GKC on each map where you would like the AutoExec to have effect, that converts the GHK to a GKC for that map. I suspect that the at-start stack you see reacting is already has that, but the deck doesn’t.

Try this and let me know if it works.

Sorry, something isn’t quite right here, probably my understanding.
I use your AutoExecGKC and use a key of Ctlr-E that I add to a module extension. This way when the module extension is applied then I can do certain set up, but without it it will have no effect.
On my main map I can have a Replace With action triggered by Ctrl-E in one of my Single Pieces on an At-Stack Start. This is triggered ok. However on one of my Decks on the same board my Deck Global Key Command with Ctrl-E is not triggering.
On another map board I have set Reshuffle to Ctrl-E and that doesn’t trigger.

On your advice I changed the reshuffle to Ctrl-W and then created a Global Key Command at the Map Window level that triggered from Ctrl-E and did command Ctrl-W. Nothing occurred and when I set a report for that GKC the report didn’t occur so it is not being triggered.

Do you have a report set for the AutoExec? Are you seeing that reporting?

Hi,

To reshuffle a deck … or operation like these ones … You need a Global HotKey trait or action button … not a Global Key Command …

This is why, your GKC does not affect the deck …

Regards from Paris,

Grégory

Ok I got the decks to shuffle by adding a Global HotKey trait to a single piece on my board, thanks a lot for your help. Shame I can’t suppress reports for that one but it does the job.

Thanks a lot for the java class, I really found it frustrating there was no “initialisation” method for a module.

Glad to hear it is working.

Just a heads up on this. I used this to do stuff like shuffling on start up however what ended up happening is that decks got shuffled every time a new player joined or you would load a log file or save game.
This is great for 1 shot things. I ended up using this to fire a global hot key but made it so the global hot key checked a dynamic property that would be set to show this has already happened once.

Pieter, can you recompile this in 1.5? We are getting bugs from this class in the BSG module Haree78 used it in, so he can replace it and I can close the bug out.

Thanks

While I wait for Java 1.5-22 to download; what is our current standarad for 1.6? 26 or 27?

Thank you.

Here is AutoExecGKC recompiled against VASSAL 3.1.16, with the JAVA compiler option ‘compatible with 1.5’ selected. The class GameModule, from VASSAL 3.1.16 modified to add AutoExecGKC as an allowed child, is also included but does not activate automatically.

Thanks, I’ll test it in the offending module before closing the bug out tonight

Sorry for bringing this up from the dead, but how can I edit an AutoExec GKC? It’s in an existing module and I’d like to take a look at it so I don’t accidentally give something the same trigger, but if I click on it, it will just say “Eeek! an error occured!” or something to that effect. Any ideas?

Thus spake DLoke:

Sorry for bringing this up from the dead, but how can I edit an AutoExec
GKC? It’s in an existing module and I’d like to take a look at it so I
don’t accidentally give something the same trigger, but if I click on
it, it will just say “Eeek! an error occured!” or something to that
effect. Any ideas?

What’s the error?


J.

Uncaught Exception:

Eeek! A bug!

Vassal had an internal error. You can help by sending an error report, etc.

It then asks me to submit the following.

[quote]
2013-12-20 12:19:51,150 [0-main] INFO  VASSAL.launch.StartUp - Starting
2013-12-20 12:19:51,176 [0-main] INFO  VASSAL.launch.StartUp - OS Windows 7 6.1
2013-12-20 12:19:51,176 [0-main] INFO  VASSAL.launch.StartUp - Java version 1.7.0_03
2013-12-20 12:19:51,176 [0-main] INFO  VASSAL.launch.StartUp - VASSAL version 3.2.8
2013-12-20 12:19:51,482 [0-AWT-EventQueue-0] INFO  VASSAL.launch.ModuleManager - Manager
2013-12-20 12:20:06,891 [0-SwingWorker-pool-1555674791-thread-1] INFO  VASSAL.launch.AbstractLaunchAction - Loading module file C:\Users\DanielNew\Dropbox\BSG BGG\BSG BGG.vmod
2013-12-20 12:20:10,110 [0-SwingWorker-pool-1555674791-thread-1] INFO  VASSAL.launch.TilingHandler - No images to tile.
2013-12-20 12:20:10,111 [0-SwingWorker-pool-1555674791-thread-1] INFO  VASSAL.launch.AbstractLaunchAction - Loading module BSG BGG
2013-12-20 12:20:10,142 [0-SwingWorker-pool-1555674791-thread-1] INFO  VASSAL.tools.io.ProcessLauncher - launching C:\Program Files\Java\jre7\bin\java -Xms256M -Xmx512M -DVASSAL.id=1 -DVASSAL.port=49306 -Duser.home=C:\Users\DanielNew -cp lib\Vengine.jar VASSAL.launch.Player --load -- C:\Users\DanielNew\Dropbox\BSG BGG\BSG BGG.vmod
2013-12-20 12:20:10,885 [1-main] INFO  VASSAL.launch.StartUp - Starting
2013-12-20 12:20:10,890 [1-main] INFO  VASSAL.launch.StartUp - OS Windows 7 6.1
2013-12-20 12:20:10,890 [1-main] INFO  VASSAL.launch.StartUp - Java version 1.7.0_03
2013-12-20 12:20:10,890 [1-main] INFO  VASSAL.launch.StartUp - VASSAL version 3.2.8
2013-12-20 12:20:10,890 [1-main] INFO  VASSAL.launch.Launcher - Player
2013-12-20 12:20:12,448 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - VASSAL images folder found at jar:file:/C:/Program%20Files%20(x86)/VASSAL-3.2.8/lib/Vengine.jar!/images/
2013-12-20 12:20:12,455 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family go-up created for go-up.png
2013-12-20 12:20:12,455 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family go-down created for go-down.png
2013-12-20 12:20:12,456 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family calculator created for calculator.png
2013-12-20 12:20:12,456 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family network-server created for network-server.png
2013-12-20 12:20:12,456 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family yes created for yes.png
2013-12-20 12:20:12,456 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family no created for no.png
2013-12-20 12:20:12,456 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family VASSAL-jabber created for VASSAL-jabber.png
2013-12-20 12:20:12,456 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family VASSAL created for VASSAL.png
2013-12-20 12:20:12,456 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family network-idle created for network-idle.png
2013-12-20 12:20:12,456 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family jabber created for jabber.png
2013-12-20 12:20:12,457 [1-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family bug created for bug.svg
2013-12-20 12:20:21,907 [1-AWT-EventQueue-0] WARN  VASSAL.launch.BasicModule - BSG BGG version 1.0
2013-12-20 12:20:32,715 [1-AWT-EventQueue-0] INFO  VASSAL.build.GameModule - Exiting
2013-12-20 12:20:33,201 [0-IPC receiver for 1881595774] ERROR VASSAL.tools.ipc.IPCMessageReceiver - 
java.net.SocketException: Connection reset
	at java.net.SocketInputStream.read(Unknown Source) ~[na:1.7.0_03]
	at java.net.SocketInputStream.read(Unknown Source) ~[na:1.7.0_03]
	at java.net.SocketInputStream.read(Unknown Source) ~[na:1.7.0_03]
	at java.io.ObjectInputStream$PeekInputStream.peek(Unknown Source) ~[na:1.7.0_03]
	at java.io.ObjectInputStream$BlockDataInputStream.peek(Unknown Source) ~[na:1.7.0_03]
	at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source) ~[na:1.7.0_03]
	at java.io.ObjectInputStream.readObject0(Unknown Source) ~[na:1.7.0_03]
	at java.io.ObjectInputStream.readObject(Unknown Source) ~[na:1.7.0_03]
	at VASSAL.tools.ipc.IPCMessageReceiver.run(IPCMessageReceiver.java:34) ~[Vengine.jar:na]
	at java.lang.Thread.run(Unknown Source) [na:1.7.0_03]
2013-12-20 12:20:35,314 [0-SwingWorker-pool-1555674791-thread-2] INFO  VASSAL.launch.AbstractLaunchAction - Loading module file C:\Users\DanielNew\Dropbox\BSG BGG\BSG BGG.vmod
2013-12-20 12:20:35,382 [0-SwingWorker-pool-1555674791-thread-2] INFO  VASSAL.launch.TilingHandler - No images to tile.
2013-12-20 12:20:35,383 [0-SwingWorker-pool-1555674791-thread-2] INFO  VASSAL.launch.AbstractLaunchAction - Loading module BSG BGG
2013-12-20 12:20:35,384 [0-SwingWorker-pool-1555674791-thread-2] INFO  VASSAL.tools.io.ProcessLauncher - launching C:\Program Files\Java\jre7\bin\java -Xms256M -Xmx512M -DVASSAL.id=3 -DVASSAL.port=49337 -Duser.home=C:\Users\DanielNew -cp lib\Vengine.jar VASSAL.launch.Editor --edit -- C:\Users\DanielNew\Dropbox\BSG BGG\BSG BGG.vmod
2013-12-20 12:20:36,032 [3-main] INFO  VASSAL.launch.StartUp - Starting
2013-12-20 12:20:36,038 [3-main] INFO  VASSAL.launch.StartUp - OS Windows 7 6.1
2013-12-20 12:20:36,038 [3-main] INFO  VASSAL.launch.StartUp - Java version 1.7.0_03
2013-12-20 12:20:36,038 [3-main] INFO  VASSAL.launch.StartUp - VASSAL version 3.2.8
2013-12-20 12:20:36,038 [3-main] INFO  VASSAL.launch.Launcher - Editor
2013-12-20 12:20:37,198 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - VASSAL images folder found at jar:file:/C:/Program%20Files%20(x86)/VASSAL-3.2.8/lib/Vengine.jar!/images/
2013-12-20 12:20:37,203 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family go-up created for go-up.png
2013-12-20 12:20:37,203 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family go-down created for go-down.png
2013-12-20 12:20:37,203 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family calculator created for calculator.png
2013-12-20 12:20:37,203 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family network-server created for network-server.png
2013-12-20 12:20:37,203 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family yes created for yes.png
2013-12-20 12:20:37,203 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family no created for no.png
2013-12-20 12:20:37,203 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family VASSAL-jabber created for VASSAL-jabber.png
2013-12-20 12:20:37,203 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family VASSAL created for VASSAL.png
2013-12-20 12:20:37,204 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family network-idle created for network-idle.png
2013-12-20 12:20:37,204 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family jabber created for jabber.png
2013-12-20 12:20:37,204 [3-IconFactory-preload] INFO  VASSAL.tools.icon.IconFactory - Icon family bug created for bug.svg
2013-12-20 12:20:38,535 [3-AWT-EventQueue-0] WARN  VASSAL.launch.BasicModule - BSG BGG version 1.0
2013-12-20 12:20:50,438 [3-AWT-EventQueue-0] ERROR VASSAL.tools.ErrorDialog - 
java.lang.ClassCastException: javax.swing.KeyStroke cannot be cast to VASSAL.tools.NamedKeyStroke
	at VASSAL.build.module.map.MassKeyCommand.setAttribute(MassKeyCommand.java:468) ~[Vengine.jar:na]
	at VASSAL.build.module.AutoExecGKC.setAttribute(AutoExecGKC.java:120) ~[na:na]
	at VASSAL.configure.AutoConfigurer.propertyChange(AutoConfigurer.java:200) ~[Vengine.jar:na]
	at java.beans.PropertyChangeSupport.fire(Unknown Source) ~[na:1.7.0_03]
	at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) ~[na:1.7.0_03]
	at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) ~[na:1.7.0_03]
	at VASSAL.configure.Configurer.setValue(Configurer.java:104) ~[Vengine.jar:na]
	at VASSAL.configure.HotKeyConfigurer.setValue(HotKeyConfigurer.java:49) ~[Vengine.jar:na]
	at VASSAL.configure.HotKeyConfigurer.setValue(HotKeyConfigurer.java:65) ~[Vengine.jar:na]
	at VASSAL.configure.AutoConfigurer.<init>(AutoConfigurer.java:87) ~[Vengine.jar:na]
	at VASSAL.build.AbstractConfigurable.getConfigurer(AbstractConfigurable.java:173) ~[Vengine.jar:na]
	at VASSAL.configure.ConfigureTree.updateEditMenu(ConfigureTree.java:1049) ~[Vengine.jar:na]
	at VASSAL.configure.ConfigureTree.valueChanged(ConfigureTree.java:1039) ~[Vengine.jar:na]
	at javax.swing.JTree.fireValueChanged(Unknown Source) ~[na:1.7.0_03]
	at javax.swing.JTree$TreeSelectionRedirector.valueChanged(Unknown Source) ~[na:1.7.0_03]
	at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(Unknown Source) ~[na:1.7.0_03]
	at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(Unknown Source) ~[na:1.7.0_03]
	at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(Unknown Source) ~[na:1.7.0_03]
	at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(Unknown Source) ~[na:1.7.0_03]
	at javax.swing.JTree.setSelectionPath(Unknown Source) ~[na:1.7.0_03]
	at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(Unknown Source) ~[na:1.7.0_03]
	at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(Unknown Source) ~[na:1.7.0_03]
	at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(Unknown Source) ~[na:1.7.0_03]
	at java.awt.AWTEventMulticaster.mousePressed(Unknown Source) ~[na:1.7.0_03]
	at java.awt.Component.processMouseEvent(Unknown Source) ~[na:1.7.0_03]
	at javax.swing.JComponent.processMouseEvent(Unknown Source) ~[na:1.7.0_03]
	at java.awt.Component.processEvent(Unknown Source) ~[na:1.7.0_03]
	at java.awt.Container.processEvent(Unknown Source) ~[na:1.7.0_03]
	at java.awt.Component.dispatchEventImpl(Unknown Source) ~[na:1.7.0_03]
	at java.awt.Container.dispatchEventImpl(Unknown Source) ~[na:1.7.0_03]
	at java.awt.Component.dispatchEvent(Unknown Source) ~[na:1.7.0_03]
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) ~[na:1.7.0_03]
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) ~[na:1.7.0_03]
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) ~[na:1.7.0_03]
	at java.awt.Container.dispatchEventImpl(Unknown Source) ~[na:1.7.0_03]
	at java.awt.Window.dispatchEventImpl(Unknown Source) ~[na:1.7.0_03]
	at java.awt.Component.dispatchEvent(Unknown Source) ~[na:1.7.0_03]
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source) ~[na:1.7.0_03]
	at java.awt.EventQueue.access$000(Unknown Source) ~[na:1.7.0_03]
	at java.awt.EventQueue$3.run(Unknown Source) ~[na:1.7.0_03]
	at java.awt.EventQueue$3.run(Unknown Source) ~[na:1.7.0_03]
	at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_03]
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) ~[na:1.7.0_03]
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) ~[na:1.7.0_03]
	at java.awt.EventQueue$4.run(Unknown Source) ~[na:1.7.0_03]
	at java.awt.EventQueue$4.run(Unknown Source) ~[na:1.7.0_03]
	at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_03]
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) ~[na:1.7.0_03]
	at java.awt.EventQueue.dispatchEvent(Unknown Source) ~[na:1.7.0_03]
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) [na:1.7.0_03]
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) [na:1.7.0_03]
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) [na:1.7.0_03]
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source) [na:1.7.0_03]
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source) [na:1.7.0_03]
	at java.awt.EventDispatchThread.run(Unknown Source) [na:1.7.0_03]
[/quote]

Thus spake DLoke:

Uncaught Exception:

Eeek! A bug!

Vassal had an internal error. You can help by sending an error report,
etc.

It then asks me to submit the following.

at VASSAL.build.module.AutoExecGKC.setAttribute(AutoExecGKC.java:120)

Your problem is that you have an AutoExecGKC at all. No class with that
name ever existed in a released version of VASSAL, so this module must
have been created with a development build. The correct class name is
StartupGlobalKeyCommand. You might need to hand-edit the buildFile
inside the module to replace AutoExecGKC with StartupGlobalKeyCommand.


J.

I’ve replaced it in the build file. Thanks a lot!