Marcus' Macro Blog

Tips and News on Macro Recording and Automating Windows with Macro Scheduler
November 15th, 2010 by Marcus Tettmar

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.

Related posts:

  1. OCR Functions Anyone?
  2. Templates and Default Templates

4 Responses to “Creating Native Function Aliases for Win32 Functions”

  1. Dick Lockey says:

    Will this method work with compiled scripts?

  2. Marcus Tettmar says:

    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.

  3. Dick Lockey says:


    By the way, great blog subject.

  4. jpuziano says:

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

    Thanks for this Marcus and take care

Leave a Reply


    • Categories