Custom functions

Questions and answers about 3Dconnexion devices on Windows.

Moderator: Moderators

spainman
Posts: 53
Joined: Mon Jun 04, 2007 8:58 am

Custom functions

Post by spainman »

I'm trying to assign Ctrl-Z to one of the SpacePilot buttons using the "custom functions" functionality. Can't get it to work. I can record the keystrokes and assign the new function to a button but they are not played back. Even checked with a own test program and no WM_KEYDOWN/UP reaches the window.

No custom function works. Even recorded readable stuff in the "Any application" profile and tried to play it back in notepad, but it does nothing. Of course any predefined key selectable in 3dxware works (e.g. end or home), just the custom stuff

Original motivation is something as simple as assigning "Undo" to a space pilot button in NX8. This is so basic I can't believe it does not work without even having to think about it :-( Any help is highly appreciated! Thanks.

My configuration:
Win7 x64
Spacepilot
3dxware 3.15.3 / driver 6.15.3
3DxNx plugin
NX 8
spainman
Posts: 53
Joined: Mon Jun 04, 2007 8:58 am

Post by spainman »

Just installed the 3dxware 10 beta. With this version the space pilot does not even display the button assignments when in NX. Instead it reads "Application use" on every button.

This is all beyond annoying!!!!! C'mon - setting UNDO on a button for NX? Using custom keystrokes? Using the beta version with NX? Are these such exotic use cases that I need to find out myself that it doesn't work?

I'm really disappointed. The NX plugin is ugly and a usability nightmare when it comes to button assignments anyway - give us at least the ability to use custom keystrokes. :roll:
Barbara
Posts: 534
Joined: Fri May 14, 2010 11:11 am

Post by Barbara »

Hi spainman-

Button mapping for NX needs to be done from the 'Customize buttons' editor within NX rather than from the 3Dconnexion Control Panel. 'Customize buttons' is located on the pop-up menu that opens in NX when you press the Panel button on the SpacePilot. Buttons mapped from the 3Dconnexion Control Panel return to defaults since they are overwritten by the internal editor - the editor inside NX has priority.

When you create a macro from the Custom Functions editor, it is added to the 3DxWare category in the NX editor when you restart NX. If you are having a problem with any of these steps using the released driver, please let us know what you are seeing.

You mentioned Notepad as an example. Using the released driver, custom functions would not work in a application like Notepad that does not recognize a 3d device. Doing that would require manual editing of profiles as discussed here.

The beta driver has a separate forum. Any issues you are seeing with the beta driver would need to be addressed there. The beta driver works in a way quite different from the released driver so the conversations are kept to avoid confusion. The beta is still a work in progress with issues addressed in each release.

If your goal is using the Space Pilot in NX and mapping buttons for NX rather than testing a driver that can be used in multiple applications, one advantage to using the released driver is the available support both here and through our technical support.
------------------
Barbara
spainman
Posts: 53
Joined: Mon Jun 04, 2007 8:58 am

Post by spainman »

Hi Barbara,

thanks for the fast anwer again :-)
Forget the beta driver for now. Annoying, but back to the actual problem:

I don't have the slightest problem following the steps and I fully understand that the button assignment needs to be done in the NX plugin in order to not get things mixed up.

This is what I've done (every baby step included):

1) I created a custom function in the 3dxware panel containing the "ctrl+z" keystroke, named "Undo".

2) closed the 3dxware panel

3) started NX

4) opened the 3dx button mapping editor inside NX

5) In "Command Categories" selected 3DxWare

6) In "Available Commands" located my "Undo" command and dragged it to one of the "Button Assignment" entries

Pressing the assigned button does unfortunately nothing! Adding for example the predefined "Page Up Key" from the same Command Category works. So this is not an "user error". Same steps, just the difference that one entry comes predefined and the other is user defined.

Meanwhile I've found out that every time I press the non-working "Undo" button an entry in the file C:\Users\...\AppData\Roaming\3Dconnexion\3DxWare\3DxWare.log is generated:

22:56:45.476: SendKey.dll:SendKeys: Error 0x5 from SetWindowsHookEx
22:56:45.819: SendKey.dll:SendKeys: Error 0x5 from SetWindowsHookEx
22:56:50.889: SendKey.dll:SendKeys: Error 0x5 from SetWindowsHookEx

Error 5 means "Access denied" btw.

Hope this helps to provide a solution. I'm going to keep digging deeper with an api monitor to see what hook your software is exactly trying to install and in which scope.

Having a several hundred Euro device on the desk intended for use in CAD and not being able to assign a simple Undo command to one of it's buttons in the no1 CAD software is REALLY nagging me!

Cheers,
Ruben
spainman
Posts: 53
Joined: Mon Jun 04, 2007 8:58 am

Post by spainman »

Found a post from one of your colleagues that actually describes doing exactly what I'm trying to do... maybe it helps solving the problem:

viewtopic.php?p=25463#25463
Barbara
Posts: 534
Joined: Fri May 14, 2010 11:11 am

Post by Barbara »

Hi spainman -

It is possible for the Windows UAC [User Account Control] to block the 3Dconnexion commands inside NX. One option is to turn off the UAC, however, this lowers the level of security. You may want to do this temporarily to determine whether UAC is preventing the commands from generating.

If NX is installed as administrator you may also need to run the 3Dconnexion executable 3dxsrv.exe as administrator.
------------------
Barbara
spainman
Posts: 53
Joined: Mon Jun 04, 2007 8:58 am

Post by spainman »

Hi Barbara,

already tried starting 3dxsrv.exe as admin - doesn't help.
I've disabled UAC entirely now and indeed it works!

Of course I need to turn it on again but tracking down the problem usually is 90% of the solution. ;-) Any suggestions?

Cheers,
Ruben
Barbara
Posts: 534
Joined: Fri May 14, 2010 11:11 am

Post by Barbara »

Hello Ruben -

This is something that will need to be changed in a driver update. Unfortunately I do not have a date for the next driver.

Driver releases are posted on our download page on the day they become available and are not pre-announced.The Release Notes .PDF for the driver lists issues that have been addressed and plugins that have been updated .

----------------
Barbara
spainman
Posts: 53
Joined: Mon Jun 04, 2007 8:58 am

Post by spainman »

No workarounds till it is fixed in the next release?

I was hoping that I can use the MS Application Compatibility Toolkit to define an application fix for the 3dxsrv.exe that takes care of the UAC issue. Of course it would help to get a little more info from your side on the problem we are seeing here.

Cheers,
Ruben
spainman
Posts: 53
Joined: Mon Jun 04, 2007 8:58 am

Post by spainman »

Did a little tracing:
The call that leads to the error tries to install a journal playback hook. Makes sense although a simple ::SendInput(...) would work too and would not pose a problem regarding the UAC stuff. Wish I had the code to fix it myself instead of waiting :wink:

Module:
SendKey.dll

Call:
SetWindowsHookExW ( WH_JOURNALPLAYBACK, 0x0000000066401100, 0x0000000066400000, 0 )

Retval:
NULL

GetLastError:
5 = Access is denied
spainman
Posts: 53
Joined: Mon Jun 04, 2007 8:58 am

Post by spainman »

This might be help full when fixing the problem:
http://www.wintellect.com/CS/blogs/jrob ... think.aspx

The article sums up the whole UAC and journal playback issue.

I've checked the manifest ressources in the sendkeys.dll and 3dxsrv.exe and they seem to lack the required settings (uiAccess is false and the required execution level need to be admin in order to run a journal playback). So most likely you just need to change the manifest settings and rebuild to make thinks work (additionally the binary must be digitally signed).

I would be HAPPY to test the fix as soon as it is available even if its just in alpha state...

Cheers,
Ruben
spainman
Posts: 53
Joined: Mon Jun 04, 2007 8:58 am

Post by spainman »

Hi Barbara,

I resolved the issue myself with round about 150 lines of code that redirect your non working Journal-Playback experiment (:wink:) into SendInput() calls that are NOT blocked by UAC.

Looking through the threads I've seen that the issue seems to exist for a pretty long time. Is it ok for you if I open another thread in the forum offering the binaries to other users that might be interested in using the macro functionality?

Cheers,
Ruben
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Hi Ruben,

Do you still have to run 3DxSrv.exe as admin?

Normally you can switch between Journal hooks and SendInput by modifying the scg file. Unfortunately when we switched our default mechanism to SendInput many years ago, it didn't work with UG. This is the first I heard of a version of UG that works with SendInput. And unfortunately 3DxSrv is hard-coded to use journal hooks for UGRAF.EXE. You can test SendInput from the driver by renaming UGRAF.EXE to something else and making a new scg file for the new executable -- or just modify the existing UGSNX.scg.

Feel free to post your hack. But, obviously, we can't recommend a piece of blind code that we can't confirm the contents of.

One more thing. When we said, use the 3Dx plugin to map keys, we didn't mean, create a macro in 3DxWare, then map that in 3DxNX. We meant, map the key in NX directly to a NX command. We give you the entire list of commands to choose from. This keeps everything inside NX's process. And AFAIK, that works perfectly.

Jim
3Dx Software Development
spainman
Posts: 53
Joined: Mon Jun 04, 2007 8:58 am

Post by spainman »

Hi Jim,
thanks for the feedback.

With my solution I don't need to run anything as admin. What I do is redirect any tries of your 3dxsrv process to do a journal hook playback into my own code which then plays the recorded sequence back with SendInput instead. The code kind of mediates between your process and the real SetWindowsHookEx/UnhookWindowsHookEx and gets active when WH_JOURNALPLAYBACK is requested.

NX has no problem in reacting to SendInput. Only problem I encountered initially is that it does not react if the key scan code is omitted. Sending the vkey code + scan code it reacts as if the keys were pressed on the "physical" keyboard. In the end ugraf is just an ordinary MFC application, I don't see why it shouldn't react to SendInput.

Could you please elaborate what changes I need to do to the ugsnx.scg in order to enable playing back recorded macros with SendInput instead of journal playback? Would like to try it. If it works I would prefer that solution instead of having to instrument (or in your words "hack" :wink:) your process with my code.

3DxNx seems to lists all ug_xxx functions that are available in the loaded *.men files but that is not ALL functions. For example the undo button is not in the menus (because nx displays an undo list instead) so it's not possible to use it in your plugin. Adding the undo function to the edit menu using nx customize functionality doesn't help either because 3dxnx doesn't notice that the menu was altered. It seems to read only the naked *.men file but does not take into account customizations that are saved in the nx role file and manually editing the *.men file is really no option because the change might get lost when installing the next update/ maintenance pack.

Overall I would love to see some improvements in future versions of the plugin:

- Searchbox where I can enter text to find an assignable command quickly

- Remove that annoying "Unassigned" string from unassigned buttons! Nobody need to read "unassigned" on the device display to realize that the button is not assigned. It's much more ergonomic to see strings only for assigned buttons on the display. (fixed this myself by patching the string table of 3dxnx.dll)

- Macro support for arbitrary key combinations

Cheers,
Ruben
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Hi Ruben,

Wow, you really have put a lot of time and thought into this. I'll pass the suggestions on to our 3DxNX developer. I like them.

To experiment with SendInput, rename UGRAF.EXE (the executable on disk--make a copy) to NOT_NX.EXE, then change the following lines in UGSNX.scg.

MACRO_MECHANISM = 0
...
EXECUTABLES = { "NOT_NX.EXE" }

MACRO_MECHANISM is probably already 0. 1 will make it use the journal hook.

I'm assuming NX will still run if you rename the executable. Obviously any links won't work. You will have to run the executable from its directory.

OTOH, your mentioning that the scan code needs to be filled in, might still be a problem. I'd have to investigate that a bit further to see if I filled that field in. This may be why SendInput never worked for us--it was always a mystery--even NX development threw up their hands. 3DxWare 10 uses a completely new mechanism.

Jim
Post Reply