[python-win32] help writing text to a windows edit control
Richard Leahy
leahy_rich at hotmail.com
Wed Mar 24 14:45:19 CET 2010
Hi guys. I have been struggling with writing a string into an edit control using the windows api calls. What I have noticed is that if i write text to a different control like a button control for example it works. Is there something in place like a security thing that prevents writing to an edit control? code below. thanks. I have put my C code at the very bottom for reference.
import os,sys,subprocess,time
from subprocess import *
from os import *
from ctypes import *
from ctypes.wintypes import *
PROCESS_ALL_ACCESS = ( 0x000F0000 | 0x00100000 | 0xFFF )
kernel32 = windll.kernel32
pid = sys.argv[1]
h_process = kernel32.OpenProcess( PROCESS_ALL_ACCESS, False, int(pid) )
if not h_process:
print "[*] Couldn't acquire a handle to PID: %s" % pid
sys.exit(0)
# parent window
window_handle = windll.user32.FindWindowA(None, "Windows App")
if not window_handle:
print "[*] cant find window"
sys.exit(0)
my_string = "testing"
windll.user32.SetDlgItemTextA(window_handle,1, my_string)
C CODE
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
CreateWindow( "EDIT", "",
WS_VISIBLE|WS_CHILD,
0, 0, 300, 50, hwnd, (HMENU)1, hThisInstance, NULL);
CreateWindow( "BUTTON", "",
WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
0, 50, 100, 30, hwnd, (HMENU)2, hThisInstance, NULL);
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100324/5a76693b/attachment.html>
More information about the python-win32
mailing list