RE: winapi: mouseclick

Discussion in 'Python' started by Tim Golden, Jan 27, 2004.

  1. Tim Golden

    Tim Golden Guest

    >From: KNS [mailto:]
    >
    >
    >Thank you for the response. I am actually using win32all to launch an
    >application and am waiting for user actions or changes in state. Once
    >the application is launched (e.g., IE) the program just
    >records changes
    >in URLs. Now I would like the various states (e.g., time, mouse
    >position) saved whenever the mouse is clicked on the application (or
    >even the desktop). So, can I just use an 'if' (within a
    >while-loop) to
    >test whether WM_LBUTTONDOWN == 0 and if so what is the appropriate
    >syntax with win32all?
    >
    >Thanks.


    Could you *please* post some code, or at least pseudo-code, to
    show us what you're doing. What is sounds like to me, is that
    you're doing this, say:

    import win32api
    win32api.ShellExecute (0, "open", "iexplore.exe", None, None, 1)

    and then you want to know what the user's doing within that
    application so that you can, eg, keep track of URLs accessed etc.

    Am I close?

    If I am, this isn't easy. If it is, strictly, Internet Explorer that
    you're trying to use, then it does have an Events mechanism (about
    which I know nothing) which I believe can be accessed from Python.

    If it is any application in general which you're trying to keep track
    of, that's more difficult. Windows (and by that I mean any modern GUI
    system) apps don't work like your old-fashioned batch / terminal
    apps. You don't "wait" for a user to press something; rather, you set
    up an event loop and handle or ignore any event which comes in. Each
    application does this on its own behalf. To do the same on behalf of
    another application requires either subclassing (messy) or system
    key / mouse hooks (cf
    http://cvs.sourceforge.net/viewcvs.py/uncpythontools/pyHook/)
    or some other arcane mechanism.

    TJG


    ________________________________________________________________________
    This e-mail has been scanned for all viruses by Star Internet. The
    service is powered by MessageLabs. For more information on a proactive
    anti-virus service working around the clock, around the globe, visit:
    http://www.star.net.uk
    ________________________________________________________________________
    Tim Golden, Jan 27, 2004
    #1
    1. Advertising

  2. Tim Golden

    KNS Guest

    This snippet launches the application...It's not strictly
    meant for IE.

    w=DispatchEx("InternetExplorer.Application")
    w.Navigate(startpage)

    w.Left=225
    w.Top=25
    w.Width=900
    w.Height=960
    w.Resizable=0
    w.Visible=1
    handle=w.HWND

    lasturl = w.LocationURL
    cururl = w.LocationURL

    while w.Visible:
    if cururl != lasturl:
    #bunch of stuff here to check ReadyState
    #would also like to see if mouse click/keypress here...


    This is an attempt to explore simple possibilities first. If such
    a solution doesn't exist, then 'yes' the use of pyHook will have to
    be considered or even mandated. Not knowing before hand can't be avoided.



    Tim Golden wrote:

    >
    >
    > Could you *please* post some code, or at least pseudo-code, to
    > show us what you're doing. What is sounds like to me, is that
    > you're doing this, say:
    >
    > import win32api
    > win32api.ShellExecute (0, "open", "iexplore.exe", None, None, 1)
    >
    > and then you want to know what the user's doing within that
    > application so that you can, eg, keep track of URLs accessed etc.
    >
    > Am I close?
    >
    > If I am, this isn't easy. If it is, strictly, Internet Explorer that
    > you're trying to use, then it does have an Events mechanism (about
    > which I know nothing) which I believe can be accessed from Python.
    >
    > If it is any application in general which you're trying to keep track
    > of, that's more difficult. Windows (and by that I mean any modern GUI
    > system) apps don't work like your old-fashioned batch / terminal
    > apps. You don't "wait" for a user to press something; rather, you set
    > up an event loop and handle or ignore any event which comes in. Each
    > application does this on its own behalf. To do the same on behalf of
    > another application requires either subclassing (messy) or system
    > key / mouse hooks (cf
    > http://cvs.sourceforge.net/viewcvs.py/uncpythontools/pyHook/)
    > or some other arcane mechanism.
    >
    > TJG
    >
    >
    > ________________________________________________________________________
    > This e-mail has been scanned for all viruses by Star Internet. The
    > service is powered by MessageLabs. For more information on a proactive
    > anti-virus service working around the clock, around the globe, visit:
    > http://www.star.net.uk
    > ________________________________________________________________________
    >
    KNS, Jan 28, 2004
    #2
    1. Advertising

  3. Tim Golden

    KNS Guest

    It's looking like I must use pyHooks...Thanks.
    KNS, Jan 28, 2004
    #3
  4. Tim Golden

    Barry Drake Guest

    KNS <> wrote in message news:<FzDRb.20396$>...
    > It's looking like I must use pyHooks...Thanks.


    I would like to use pyHooks also. I've downloaded and installed using
    the .exe installer and grabbed the CVS tree. But, there is no pyHooks
    module??? The first line of the pyHooksManager.py file is

    from pyHook import *

    and in the example.py

    from pyHookManager import *

    Without a pyHook module these both fail. Anyone know what I need to
    do to make this work? I've also tried to install the CVS version, but
    it requires MS VC++ 6.0, which I don't have.

    Thanks.
    Barry Drake
    Barry Drake, Feb 9, 2004
    #4
  5. Tim Golden

    Barry Drake Guest

    Barry Drake) wrote in message news:<>...
    > KNS <> wrote in message news:<FzDRb.20396$>...
    > > It's looking like I must use pyHooks...Thanks.

    >
    > I would like to use pyHooks also. I've downloaded and installed using
    > the .exe installer and grabbed the CVS tree. But, there is no pyHooks
    > module??? The first line of the pyHooksManager.py file is
    >
    > from pyHook import *
    >
    > and in the example.py
    >
    > from pyHookManager import *
    >
    > Without a pyHook module these both fail. Anyone know what I need to
    > do to make this work? I've also tried to install the CVS version, but
    > it requires MS VC++ 6.0, which I don't have.
    >
    > Thanks.
    > Barry Drake


    Found the problem:
    1. created the site-packages/pyHook directory myself
    2. moved the _pyHook.pyd, pHookManager.py, and example.py (CVS
    version) into the pyHook directory.
    3. created an empty __init__.py file.
    4. ran the example from UltraEdit, which opens a wx frame. If the
    show dos box option is set, the program output is shown there. Every
    key and mouse press is displayed!

    Cool.
    Thank you to the developer.
    Barry Drake, Feb 10, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. watzlaw wutz
    Replies:
    2
    Views:
    791
    Pasturel
    May 11, 2004
  2. KNS

    winapi: mouseclick

    KNS, Jan 26, 2004, in forum: Python
    Replies:
    1
    Views:
    375
  3. Tim Golden

    RE: winapi: mouseclick

    Tim Golden, Jan 27, 2004, in forum: Python
    Replies:
    1
    Views:
    437
  4. Tim Golden

    RE: winapi: mouseclick

    Tim Golden, Jan 27, 2004, in forum: Python
    Replies:
    0
    Views:
    373
    Tim Golden
    Jan 27, 2004
  5. tw
    Replies:
    3
    Views:
    544
Loading...

Share This Page