[python-win32] Help calling a windows function in user32

Tim Roberts timr at probo.com
Tue Mar 23 21:54:24 CET 2010


You wrote:
>
>Hey guys im having a little difficulty sending data to my C application
>through python. I have my test.exe that has a input box in a window. I 
>am trying to populate the edit box with input i send to it through
>python. This is a far as I have been able to get so far. any help 
>would be much appreciated. 
>
>import os,sys,subprocess,win32con
>
>from subprocess import *
>from os import *

You don't need those two lines.  In fact, they are a bad idea.  Just say "subprocess.Popen" (which is what you are actually doing).

>from ctypes import *
>from ctypes.wintypes import *
>
>appPath=r'"C:\Dev-Cpp\windowsapp.exe"'

You don't need two sets of quotes here.  The file name does not actually have quotes.

>p = subprocess.Popen(appPath)
>
>user32 = windll.user32
>
>user32.SetDlgItemTextA(need to put the hwnd handle here i think??? not sure how this is done, 1, "some text") // this is a user32 function that sends text to my inputbox. 

Yes, you need to find the window handle of your dialog.  You can use the FindWindow API to do that.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.


More information about the python-win32 mailing list