[python-win32] Emulate a keystroke for Kbhit function (Conio.h)

2007-04-10 Thread Frank Günther

Hi All,

I've automated a console application using win32pipe.popen2 by capturing the
output stream and writing the input stream. So far it works fine but the
console application uses Kbhit() from conio.h in some cases. Is there a
possibility to fill the keyboard buffer and emulate a keystroke for the
process opened by win32pipe? 
Win32api.SendMessage can't be used because there is no window for the
console application. The user keystrokes are captured by my wx-application
that automates the console application but I don't know how to forward the
keystroke to Kbhit.

Ciao,
 Frank 


___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Recovering a DLL with ctypes from a VB project

2007-04-10 Thread Grzegorz Adam Hankiewicz




Hello.

I have an old VB project using a dynamic library. I thought it would be
good to use this from Python through ctypes. However, the information
of function names in the dll is stripped. If I open the dll with the
dependency viewer I get something like:

    4 (0x0004) Function N/A Entry point 0x0006C3A8
    6 (0x0006) Function N/A Entry point 0x1000
    ...
up to entry 1081.

However, the VB project using this DLL contains a "Public declare" file
which only uses 22 functions, and they are in the form:

    Public Declare Function DllGetVersion _
        Lib "LIBDLL" _
        Alias "#2" _
        () _
        As String

where the only thing changing is the name of the function, the alias
number and the type of parameters (this function doesn't require any).
The aliases start with "#1" and go up to "#21".

Now, how do I relate this into Python? I can access the DLL:

    dll = ctypes.windll.LIBDLL

    prototype = ctypes.WINFUNCTYPE(ctypes.wintypes.LPCSTR)
    GetDllVersion = prototype(dll[6])
    print "GetDllVersion: '%s'" % repr(GetDllVersion())

So I thought the alias #2 thingy specifies the order inside the DLL,
which would be function 6, since that is the second one. But the result
I'm getting is 

    GetDllVersion: ''  \x07\x10D''

The respective VB code would be:

    MsgBox ("Version " & DllGetVersion)

Which outputs:

    Version 1.3.0 (Build 403)

Far different from what I'm getting in python. So how can I use the VB
declaration file to access the DLL the same way? Unfortunately the DLL
doesn't expose the names, so I can only access functions with the
attribute getter using an index.

I tried to search for the function using a loop over all the functions,
but that seems to hang up on nearly every second function. Besides, I
might be doing something wrong with the return value.

Any suggestions?


-- 

  

   
  
Grzegorz Adam Hankiewicz
  Jefe de Producto TeraVial
   C/ Perfumería 21. Nave I. Polígono
industrial La Mina
28770 Colmenar Viejo. Madrid (España) 
  

  
Tel. +34 918 467 390 (Ext.18)
  ·  
Fax +34 918 457 889
  
  
[EMAIL PROTECTED]
  ·  
www.rastertech.es
  

  
  
  

  




___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Emulate a keystroke for Kbhit function (Conio.h)

2007-04-10 Thread Tim Golden
Frank Günther wrote:
> I've automated a console application using win32pipe.popen2 by capturing the
> output stream and writing the input stream. So far it works fine but the
> console application uses Kbhit() from conio.h in some cases. Is there a
> possibility to fill the keyboard buffer and emulate a keystroke for the
> process opened by win32pipe? 
> Win32api.SendMessage can't be used because there is no window for the
> console application. The user keystrokes are captured by my wx-application
> that automates the console application but I don't know how to forward the
> keystroke to Kbhit.

Not at all my area, I'm afraid, but I have thought about
it a bit. Console windows do have a window handle (which
you can get hold of via the win32console functions) so
there *might* be a way of sending keys to it, but I'm
not at all sure of the interactions between the Windows
messaging and c-lib things like kbhit.

This is really pexpect territory which doesn't seem to
be available under Windows (unless you're prepared to
try Cygwin which I can never bring myself to like).

TJG
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] ANN: pywinauto 0.3.7 now released

2007-04-10 Thread Mark Mc Mahon
Hi,

0.3.7 release of pywinauto is now available.

pywinauto is an open-source (LGPL) package for using Python as a GUI
automation 'driver' for Windows NT based Operating Systems (NT/W2K/XP/Vista?).

SourceForge project page:
http://sourceforge.net/projects/pywinauto

Download from SourceForge
http://sourceforge.net/project/showfiles.php?group_id=157379


Here is the list of changes from the previous release (0.3.6):

0.3.7 Merge of Wait changes and various bug fixes/improvements
--
10-April-2007

* Added Timings.WaitUntil() and Timings.WaitUntilPasses() which
  handle the various wait until something in the code. Also
  refactored existing waits to use these two methods.

* Fixed a major Handle leak in RemoteMemorBlock class (which is
  used extensively for 'Common' controls. I was using OpenHandle
  to open the process handle, but was not calling CloseHandle()
  for each corresponding OpenHandle().

* Added an active_() method to Application class to return the
  active window of the application.

* Added an 'active' option to WindowSpecification.Wait() and
  WaitNot().

* Some cleanup of the clipboard module. GetFormatName()
  was improved and GetData() made a little more robust.

* Added an option to findwindows.find_windows() to find only
  active windows (e.g. active_only = True). Default is False.

* Fixed a bug in the timings.Timings class - timing values are
  Now accessed through the class (Timings) and not through the
  intance (self).

* Updated ElementTree import in XMLHelpers so that it would work
  on Python 2.5 (where elementtree is a standard module) as well
  as other versions where ElementTree is a separate module.

* Enhanced Item selection for ListViews, TreeViews - it is now
  possible to pass strings and they will be searched for. More
  documentation is required though.

* Greatly enhanced Toolbar button clicking, selection, etc.
  Though more documentation is required.

* Added option to ClickInput() to allow mouse wheel movements
  to be made.

* menuwrapper.Menu.GetProperties() now returns a dict like all other
  GetProperties() methods. This dict for now only has one key
  'MenuItems' which contains the list of menuitems (which had been
  the previous return value).


Thanks
 Mark

Mark Mc Mahon
Manchester, NH 03110, USA

http://sourceforge.net/projects/pywinauto";>pywinauto 0.3.7
Simple Windows GUI automation with Python. (10-Apr-07)
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Re: Emulate a keystroke for Kbhit function (Conio.h)

2007-04-10 Thread Roger Upole
Frank Günther wrote:
> Hi All,
>
> I've automated a console application using win32pipe.popen2 by capturing the
> output stream and writing the input stream. So far it works fine but the
> console application uses Kbhit() from conio.h in some cases. Is there a
> possibility to fill the keyboard buffer and emulate a keystroke for the
> process opened by win32pipe?
> Win32api.SendMessage can't be used because there is no window for the
> console application. The user keystrokes are captured by my wx-application
> that automates the console application but I don't know how to forward the
> keystroke to Kbhit.
>
> Ciao,
> Frank

You should be able to use PyConsoleScreenBuffer.WriteConsoleInput
to send keystrokes to the app.  The tricky part will be getting a handle
to the console for the child process.

  Roger

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Re: Constants quit working under Python 2.5

2007-04-10 Thread Roger Upole
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
>> > Hi list,
>> >
>> > I upgraded to Python 2.5 for evaluation and testing.
>> After installing the pywin32-210.win32-py2.5.exe, I found that the
>> > constants module doesn't work.  For example, this code fails:
>> >
>> >   from win32com.client import Dispatch, constants
>> >
>> >   print constants.xlDown
>> >
>> > I re-execute makepy.py and selected "Microsoft Office 10.0 Object
>> > Library (2.2)" but the problem persists.
>> >
>> > What should I do?
>> >
>> > Thanks,
>> >
>> > --
>> > John Henry
>>
>> xlDown appears to be in the Excel object library rather than
>> the Office object library.
>>
>>hth
>>Roger
>>
>>
>>
>
> Thanks for the reply.
>
> That's the one I've been using before the migration to 2.5.  I went back and 
> tried both Microsoft Excel 10.0 (1.4) and 5.0 
> (1.0) Object Library and the failures are the same.
>

Try clearing out your gen_py folder and starting from scratch.
The below works for me with 2.5.

>>> import win32com.client
>>> xl=win32com.client.gencache.EnsureDispatch('Excel.Application',0)
>>> print win32com.client.constants.xlDown
-4121
>>>

   Roger

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32