0

I am trying to write a code to access through a Tab panel of a windows GUI, and for that I want to make a DllCall to user32.dll in my python code, I am using Pywin32 for accessing autoit's functions and I think I am able to call DllCall and this is how I am doing it.

TabID = autoit.DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", hTab)
TabID = autoit.TabID[0]

but everytime I run this code, it gives me the following error -:

    raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: AutoItX3.Control.DllCall

the entire code looks like the following:

import time
import LogIt
import datetime
import win32con
import win32gui
import win32com.client

# this makes use of the AutoITX.dll that we registered with the Windows OS
autoit = win32com.client.Dispatch("AutoItX3.Control")

autoit.DllCall("user32.dll", "int", "GetDlgCtrlID")

can somebody help me figure this error out, also there is not much that I found on the web.

AnkitSablok
  • 3,021
  • 7
  • 35
  • 52

1 Answers1

0

DllCall doesn't appear in the function listing for AutoItX, hence the error that it is not available. This is normally because it is technically difficult to implement in the dll, as is the case with functions like HotkeySet. AutoItX is a pretty small side project of AutoIt, so if it would take a lot of effort to port then it tends to not happen.

The alternative is to implement the same sort of mechanism as DllCall:

Normally in windows you use GetModuleHandle to get a handle to user32.dll and then use GetProcAddress to get the address of the function. In python most code snippets do exactly that using kernel32 from ctypes, or win32api.

Matt
  • 7,100
  • 3
  • 28
  • 58
  • Thanks Matt for replying, can you like show me some code snippet that can do that, I need to get this done, I am like stuck at this from yesterday still not able to figure out a way. – AnkitSablok Jul 09 '14 at 14:00
  • I execute the following commands and got the following output - >>> dllhandle = win32api.GetModuleHandle("user32.dll") >>> dllhandle 2004746240L >>> function = win32api.GetProcAddress(dllhandle,"GetDlgCtrlID") >>> function 2004843844L >>> – AnkitSablok Jul 09 '14 at 14:27
  • How do I get to call this function now that I have the pointer to this function? – AnkitSablok Jul 09 '14 at 14:40
  • I don't know, I don't use python. Something like [this](http://stackoverflow.com/questions/252417/how-can-i-use-a-dll-from-python) or [this](http://code.activestate.com/recipes/181063-windows-dll-with-pointers-parameters-calling-with-/) perhaps? – Matt Jul 09 '14 at 17:53