I'm trying to find a way how I can read the textbox inside the idle. The Idle is (I think) written in python (Tkinter ?).

I have tried to find the function which reads the textbox.text through checking the exports function inside the tk85.dll but I coudn't find it. A normal windows exe would be easier since I have to search for GetDlgItemText(). But how I can done something like this with python written code :O

enter image description here

  • You can use winapi as described here: stackoverflow.com/questions/1025029/…
    – w s
    May 17 '15 at 12:00
  • My idea was to inject a dll (written in c#) and read the textbox which is inside the python idle. If I have read it correctly your link shows how I can use win32api inside a python script
    – Sens4
    May 17 '15 at 12:23
  • a small bump <.< Edited my text + header
    – Sens4
    May 19 '15 at 20:40
  • 1
    Your question is not fully clear. If all you want to do is to obtain the text inside the multiline edit control, you would need to get a handle of the control, and use GetWindowText to retrieve the text within. You can use both the win32 api with ctypes or PyWin32
    – 0xec
    May 20 '15 at 6:37
  • Currently I'm trying it with your suggestion. Well I want to get the text from the python idle (image) with c# code. It doesn't matter: injection or without. Thats why I thought I can simply use a call from tk85.dll to get the text out of the Untitled window.
    – Sens4
    May 20 '15 at 16:38

The script below seems to read the data from idle TkChild Window the Data read is available in clipboard pastable to say notepad is this what you are trying to achieve ?

from ctypes import *
u32 = windll.user32
k32 = windll.kernel32
toppywin = u32.FindWindowA("TkTopLevel","*Untitled*");
subpywin = u32.FindWindowExA(toppywin,0,"TKChild","")
#simulating ctrl+A , Ctrl+c , Right Arrow, enter  and ctrl+V keys 
u32.keybd_event (0x11, u32.MapVirtualKeyA(0x11,0), 1, 0) #ctrl dn
u32.keybd_event (0x41, u32.MapVirtualKeyA(0x41,0), 1, 0) #selA dn
u32.keybd_event (0x41, u32.MapVirtualKeyA(0x41,0), 3, 0) #   A up
u32.keybd_event (0x43, u32.MapVirtualKeyA(0x43,0), 1, 0) #cpyC dn
u32.keybd_event (0x43, u32.MapVirtualKeyA(0x43,0), 3, 0) #   C up
u32.keybd_event (0x11, u32.MapVirtualKeyA(0x11,0), 3, 0) #ctrl up
u32.keybd_event (0x27, u32.MapVirtualKeyA(0x27,0), 1, 0) #rightdn
u32.keybd_event (0x27, u32.MapVirtualKeyA(0x27,0), 3, 0) #rightup
u32.keybd_event (0x0D, u32.MapVirtualKeyA(0x0D,0), 1, 0) #enterdn
u32.keybd_event (0x0D, u32.MapVirtualKeyA(0x0D,0), 3, 0) #enterup
u32.keybd_event (0x11, u32.MapVirtualKeyA(0x11,0), 1, 0) #ctrl dn
u32.keybd_event (0x56, u32.MapVirtualKeyA(0x56,0), 1, 0) #pastVdn
u32.keybd_event (0x56, u32.MapVirtualKeyA(0x56,0), 3, 0) #   V up
u32.keybd_event (0x11, u32.MapVirtualKeyA(0x11,0), 3, 0) #ctrl up


retrieve text from python idle window

  • Ty for your effort. Unfortunately wasn't this my idea. I fixed it now.
    – Sens4
    May 22 '15 at 21:44

After lots of research I have found an option: Python C# Pipe

It creates a temp file where I then can communicate between Python and C#. So I can now write an extension for the idle which will get the text inside the tkinter textbox and sends it to my c# wpf window :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.