November 15, 2010

Filed under: General,Scripting — Marcus Tettmar @ 11:08 am

The other day I posted a response on the forums which uses LibFunc to run the Win32 API function GetKeyState. This prompted someone to email me the following:

I didn’t know the Win API call to check for a key being down. The API call works but have you considered adding a native MS command called KeyDown> or maybe CheckKeyDown>

Well, it’s already possible to create native looking functions for DLL functions and therefore Win32 API functions.

We can do this by creating an Imports file in the Imports sub folder of Macro Scheduler. Let’s make an import file for some functions in User32.dll:

Step 1. If you don’t already have an Imports subfolder inside the Macro Scheduler program folder, create one: c:\program files\Macro Scheduler12\Imports

Step 2. Create a symbolic link to the appropriate DLL in this folder. Start a CMD prompt and CD to the Imports folder and for User32.dll type the following:

mklink user32.dll c:\windows\system32\user32.dll

If on a 64 bit system replace system32 with syswow64

This will create a link to the DLL in the Imports folder. Next we need to make a corresponding INI file.

Step 3. Create a file called User32.ini in the Imports folder. Inside this file create entries for each function you wish to import. E.g.:




Now, instead of writing:


You can write:


So here’s a project for someone or a group of people: Create a User32.ini file for a fuller list of compatible functions which we can share on the website. Any function that accepts either integers (INT) or strings (PCHAR) and returns an integer (or nothing) can be included. And then we want another one for Kernel32.dll … etc.


  1. Will this method work with compiled scripts?

    Comment by Dick Lockey — November 15, 2010 @ 5:23 pm

  2. Yes, but the Imports folder will need to be distributed with and exist next to the EXE file. [It could be created dynamically by the script – e.g. import the INI file into the script and have the script create the folder, export the INI file and make the sym link.] But of course if you know the script is going to be compiled you may prefer to just continue using LibFunc.

    Comment by Marcus Tettmar — November 15, 2010 @ 7:06 pm

  3. Thanks.

    By the way, great blog subject.

    Comment by Dick Lockey — November 15, 2010 @ 7:32 pm

  4. Heh… when I posed that additional question, I didn’t expect it to already be possible.

    Thanks for this Marcus and take care

    Comment by jpuziano — November 16, 2010 @ 6:59 am

RSS feed for comments on this post. TrackBack URL

Leave a comment