Author Topic: Managed HotKeys  (Read 53886 times)

0 Members and 1 Guest are viewing this topic.

Chuck Gabriel

  • Guest
Managed HotKeys
« on: June 14, 2006, 08:24:54 PM »
For those of you who care, I've been working on a C# version of HotKeys to address the requests I've been getting for an AutoCAD 2007 compatible version of the app.  I built it using Visual C# 2005 Express, version 2.0 of the .NET framework, and the ObjectARX 2007 API.

This is my first attempt at writing a managed app for AutoCAD, and I don't have a .NET enabled version of AutoCAD to test it with, so it might not work quite right just yet.  Hopefully it can be knocked into shape with a little user feedback.

For current HotKeys users, copy HotKeys.dll into your current HotKeys application folder and netload it.  The program should set up necessary registry keys, load your keys file, and turn on the hooks upon loading.

The app defines the following commands:

KeysOn -> Turns on the hooks
KeysOff -> Turns off the hooks
KeysToggle -> Toggles the on/off status of the hooks
KeysConfig -> Displays the configuration dialog
EditKeys -> Runs the keys file editor (should force a reload of the keys file upon closing)

The editor isn't in the zip file, so expect the editkeys command to flop if you don't already have an older version of HotKeys installed.

[added.kdub]
Revised 2010.11.17
Hotkeys[2010]
http://www.theswamp.org/index.php?topic=10570.msg409779#msg409779
« Last Edit: November 17, 2010, 06:51:27 AM by Kerry »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Managed HotKeys
« Reply #1 on: June 14, 2006, 08:43:29 PM »
Ohhhh shiney !!

I'll have a look tonight Chuck .. THANKS !!
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Glenn R

  • Guest
Re: Managed HotKeys
« Reply #2 on: June 14, 2006, 09:46:14 PM »
Chuck, of course we care...where-ever did you get the idea we didn't? :)

Chuck Gabriel

  • Guest
Re: Managed HotKeys
« Reply #3 on: June 14, 2006, 10:45:46 PM »
Thanks Glenn.  I was thinking more of the people who might read this thread and think "What the heck is a HotKeys?"

FengK

  • Guest
Re: Managed HotKeys
« Reply #4 on: June 15, 2006, 01:47:09 AM »
Thanks a lot Chuck.  I'll be glad to test it out.  I've been using HotKeys for couple of months and really liked it.

hudster

  • Gator
  • Posts: 2848
Re: Managed HotKeys
« Reply #5 on: June 15, 2006, 03:21:09 AM »
Oh I've been waiting for this to be updated for ages.

I love your hotkeys program, I've setup so many shortcuts with it, when it didn't work with 2007 I was lost, i still type in the shortcuts I used with hotkeys now.

Hooray Chuck your a gent mate. :-D
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

hudster

  • Gator
  • Posts: 2848
Re: Managed HotKeys
« Reply #6 on: June 15, 2006, 03:48:08 AM »
Ok I get this when I try keysconfig

Code: [Select]
Application does not support just-in-time (JIT)
debugging. See the end of this message for details.

************** Exception Text **************
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'HotKeys.Main' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at HotKeys.AppRegistry.get_allowCapsLockMod()
   at HotKeys.Main..ctor()
   at HotKeys.Main..cctor()
   --- End of inner exception stack trace ---
   at HotKeys.Main.keysOn()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at AcMgCommandClass.InvokeWorker(AcMgCommandClass* , MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at AcMgCommandClass.Invoke(AcMgCommandClass* , gcroot<System::Reflection::MethodInfo ^>* mi, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.TargetInvocationSEHExceptionFilter.InvokeWorker()
   at Autodesk.AutoCAD.Runtime.ExceptionFilter.Invoke()


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
acdbmgd
    Assembly Version: 17.0.54.0
    Win32 Version: 17.0.54.0
    CodeBase: file:///C:/Program%20Files/AutoCAD%202007/AcdbMgd.DLL
----------------------------------------
msvcm80
    Assembly Version: 8.0.50608.0
    Win32 Version: 8.00.50727.42
    CodeBase: file:///C:/WINDOWS/WinSxS/x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd/msvcm80.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
acmgd
    Assembly Version: 17.0.54.0
    Win32 Version: 17.0.54.0
    CodeBase: file:///C:/Program%20Files/AutoCAD%202007/acmgd.DLL
----------------------------------------
AcDxUi
    Assembly Version: 17.0.54.0
    Win32 Version: 17.0.54.0
    CodeBase: file:///C:/Program%20Files/AutoCAD%202007/AcDxUi.DLL
----------------------------------------
AcDx
    Assembly Version: 17.0.54.0
    Win32 Version: 17.0.54.0
    CodeBase: file:///C:/Program%20Files/AutoCAD%202007/AcDx.DLL
----------------------------------------
AcDxUi.resources
    Assembly Version: 17.0.54.0
    Win32 Version: 17.0.54.0
    CodeBase: file:///C:/Program%20Files/AutoCAD%202007/en-US/AcDxUi.resources.DLL
----------------------------------------
AcMgdShared
    Assembly Version: 17.0.54.0
    Win32 Version: 17.0.54.0
    CodeBase: file:///C:/Program%20Files/AutoCAD%202007/AcMgdShared.DLL
----------------------------------------
AcLayer
    Assembly Version: 17.0.54.0
    Win32 Version: 17.0.54.0
    CodeBase: file:///C:/Program%20Files/AutoCAD%202007/AcLayer.DLL
----------------------------------------
AcLayer.resources
    Assembly Version: 17.0.54.0
    Win32 Version: 17.0.54.0
    CodeBase: file:///C:/Program%20Files/AutoCAD%202007/en-US/AcLayer.resources.DLL
----------------------------------------
HotKeys
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Program%20Files/HotKeys2004/HotKeys.dll
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------

************** JIT Debugging **************
Application does not support Windows Forms just-in-time (JIT)
debugging. Contact the application author for more
information.


Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Chuck Gabriel

  • Guest
Re: Managed HotKeys
« Reply #7 on: June 15, 2006, 07:32:44 AM »
Thanks Andy.  That's just the sort of feedback I'm looking for.

I'll look into that and post back here once I know more, though I may have to rely on the kindness of other members, who are more experienced with .NET, to help me debug it.

hudster

  • Gator
  • Posts: 2848
Re: Managed HotKeys
« Reply #8 on: June 15, 2006, 08:56:57 AM »
what ever it takes to get this excellent piece of software working with 2007, I'm there to help if I can.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Chuck Gabriel

  • Guest
Re: Managed HotKeys
« Reply #9 on: June 15, 2006, 12:32:36 PM »
Ok.  I did some investigation and discovered that the problem Andy encountered had two causes.

1) I was trying to read a non-existent value from the registry.

2) I had a fundamental misunderstanding of how static objects are handled in .NET.  They aren't initialized until they are used (unlike C++).

Here is my next attempt.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Managed HotKeys
« Reply #10 on: June 15, 2006, 06:43:53 PM »
Hi Chuck, if you want to have a class that's guaranteed to be created on loading you can use the IExtensionApplication interface, this is an example I use for a current app -
Code: [Select]
namespace DCS_3D


{
///
/// The entry point for Autocad, it get's called at least once
/// when you use 'Netload' to load and configure your application
/// There can only be one instance of inherited IExtensionApplication
/// per class library.
///
public class App : IExtensionApplication
{
public static string appPath;
public void
Initialize()
{
appPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
//Let the user know what's happening while loading your app
//You could also alert user of failed loading operations here.

//load the hlr api:
Autodesk.AutoCAD.Runtime.SystemObjects.DynamicLinker.LoadModule("AsdkHlrApi16.dbx",true,true);

Utils.PrintMessage("\n Loading DCS_3D application...\n");
Utils.PrintMessage("\n Beta Version 0.1.6 2nd.June.2006.");
Utils.PrintMessage("\nEnter DCS3D to open DCS3D tools dialog:\n");

}

public void
Terminate()
{
//Nothing to put here yet!

}
}
}

I use this in all of my .net arx dll's to initialise application static ('global' like) variables or to load other classes or dialogs etc.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Chuck Gabriel

  • Guest
Re: Managed HotKeys
« Reply #11 on: June 15, 2006, 07:39:39 PM »
Thanks Mick.  That's actually exactly what I did to resolve the issue I was having.

hudster

  • Gator
  • Posts: 2848
Re: Managed HotKeys
« Reply #12 on: June 16, 2006, 03:51:45 AM »
Ok all the native hotkey commands, keysconfig etc, work fine.

Can't load the Arx file via startup suite though.

Also when i try to use any hotkeys, I get a fatal error. Autocad error details
Code: [Select]

UnloadedApps:AcLaunchNFWWS.arx(621a0000,b000);C:\Program Files\AutoCAD 2007\AcStar.arx(60170000,14000);
Clr Data:
   at HotKeys.HookProcedures.keyboardProc(Int32 code, IntPtr wParam, IntPtr lParam) in C:\Documents and Settings\Chuck2000\My Documents\Visual Studio 2005\Projects\HotKeys\HotKeys\HookProcedures.cs:line 165


  ]]>
  </AppCDATA>
  <OpenGLInfo Vendor="ATI Technologies Inc." Renderer="RADEON 7500 DDR x86/SSE2" Version="1.3.4454 WinXP Release" />
  </CERInfo>
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Chuck Gabriel

  • Guest
Re: Managed HotKeys
« Reply #13 on: June 16, 2006, 07:11:12 AM »
Well I sure didn't see that coming.  I'll take another look and see what I can see.

Incidentally, you should not have to resort to the startup suite.  If you check "Load HotKeys at AutoCAD startup," then close and reopen AutoCAD, does it not load the DLL automatically?
« Last Edit: June 16, 2006, 07:41:40 AM by Chuck Gabriel »

hudster

  • Gator
  • Posts: 2848
Re: Managed HotKeys
« Reply #14 on: June 16, 2006, 07:21:42 AM »
Nope, it only gives the option to load the arx file at startup, but this isn't compatible.

I need to reload the dll using netload each time.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue