Making a C# kill event for a vb6 app?

Here is a pretty standard scheme for asynchronous background processing with VB6 clients and VB6 servers. (For instance it’s in Dan Appleman’s book and Microsoft’s VB6 samples.) I think it should work for a C# client too. The VB6 ActiveX EXE object should expose an event CheckQuitDoStuff(). This takes a ByRef Boolean called Quit. The … Read more

Interoperating between Matlab and C#

Beginning with the R2009a release of MATLAB, .NET objects can be accessed from MATLAB: http://www.mathworks.com/help/techdoc/matlab_external/brpb5k6.html In older versions of MATLAB, it is possible to access .NET objects from MATLAB using CCW: http://www.mathworks.com/support/solutions/data/1-5U8HND.html?solution=1-5U8HND and the MATLAB engine from .NET: http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_external/f135590.html#f135616 You can also use the MATLAB Builder NE to wrap m-code into .NET assemblies. http://www.mathworks.com/products/netbuilder/

Jython and python modules

You embed jython and you will use some Python-Modules somewere: if you want to set the path (sys.path) in your Java-Code : public void init() { interp = new PythonInterpreter(null, new PySystemState()); PySystemState sys = Py.getSystemState(); sys.path.append(new PyString(rootPath)); sys.path.append(new PyString(modulesDir)); } Py is in org.python.core. rootPath and modulesDir is where YOU want ! let rootPath … Read more

WinWord.exe won’t quit after calling Word.Documents.Add – Word .NET Interop

(All of my advice is adapted from this answer about Excel interop.) There are a few important things here: 1) Never use 2 dots on the same line. Also consider an indexer as a dot Good Word.Documents d = wordApp.Documents; Word.Document aDoc = d.Open(/*…*/); BAD Word.Document aDoc = wordApp.Documents.Open(/*…*/); 2) Release all of your pointers. … Read more

How do I read text from the Windows clipboard in Python?

You can use the module called win32clipboard, which is part of pywin32. Here is an example that first sets the clipboard data then gets it: import win32clipboard # set clipboard data win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboardText(‘testing 123’) win32clipboard.CloseClipboard() # get clipboard data win32clipboard.OpenClipboard() data = win32clipboard.GetClipboardData() win32clipboard.CloseClipboard() print data An important reminder from the documentation: When the … Read more

keybd_event along with PostMessage win32 not working when Visual Studio has focus (or any application run as admin)

These are the VK_MEDIA_NEXT_TRACK and VK_MEDIA_PREV_TRACK virtual keys. The processing for them is highly convoluted: Whatever program owns the foreground window will retrieve his keystroke from its message queue when it calls GetMessage() The TranslateMessage() call in that program’s message loop translates the keystroke to a WM_APPCOMMAND message, APPCOMMAND_MEDIA_NEXTTRACK or APPCOMMAND_MEDIA_PREVIOUSTRACK and sends it to … Read more

No definition found for GetActiveObject from System.Runtime.InteropServices.Marshal C#

We need to pull the GetActiveObject(String ProgID) function from the source code GitHub.Microsoft Create your own class, for example – Marshal2 And use as before Marshal2.GetActiveObject(progID); Source code public static class Marshal2 { internal const String OLEAUT32 = “oleaut32.dll”; internal const String OLE32 = “ole32.dll”; [System.Security.SecurityCritical] // auto-generated_required public static Object GetActiveObject(String progID) { Object … Read more