Jump to content

Capture OnEntry event, Help?


Recommended Posts

So I'm looking for a way to fire off a function when  an event occurs, this event being in any window of any program. The event I'm trying to capture is (I'm told) something like OnEntry???

Here's what I want, when I click in any input field/edit box/etc and a blinking caret appears my function fires. So I need to know if it is possible to know when the users is entering text/data.

I tried:

#include <Misc.au3>
#include <Array.au3>
#Include <Constants.au3>
#Include <EditConstants.au3>
#Include <WinAPI.au3>
#include <WinAPIRes.au3>
#Include <WindowsConstants.au3>


Do
    Local $test=_WinAPI_GetCaretBlinkTime()
    Sleep(100)
    If $test=@error Then
    Else
        If _IsPressed("04") Then _ArrayDisplay($test)
    EndIf

until _IsPressed("1B")

Exit

 To check if I could monitor the caret's blinking time and use it as a flag as to whether or not the user is editing/entering text. This code does nothing though, with no errors, which I attribute to my lack of knowledge in WinAPI functionality.

So please help?

Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

Sorry, a last minute edit while typing the post left the 2 at the end of $test

But yes I'm a dum@ss.... I was working with Wingetcaretpos and was used to getting an array returned.

Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

Ok so this:

#include <Misc.au3>
#include <Array.au3>
#Include <Constants.au3>
#Include <EditConstants.au3>
#Include <WinAPI.au3>
#include <WinAPIRes.au3>
#Include <WindowsConstants.au3>

Do
    Local $test2=_WinAPI_GetCaretBlinkTime()
    If _IsPressed("04") Then MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & '$test2' & @CRLF & @CRLF & 'Return:' & @CRLF & $test2) ;### Debug MSGBOX


until _IsPressed("1B")

Exit

is returning a value of 530 even if I'm not editing text. 

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

the same, it's always showing 530 as the value returned

Edit: so should I break that down to understand that it's not based on if the caret exists so I cannot use it to accomplish my goal?

Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

That's what I suspected actually, as the command to change the blink rate would likely need to edit a registry value to achieve its function....

So any ideas?

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

I was afraid you would reply with that, I was hoping to avoid that and to capture an system message or something that gives the keyboard focus.... looks like I've got a lot of code ahead of me  :doh:

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

Don't write a generic method off just yet, I'm a shit coder and it would not surprise me if someone comes along and shows how I'm totally wrong.

Either way there will be a lot of coding ahead of you, but chin up.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Either way there will be a lot of coding ahead of you, but chin up.

 

Very good point, and painfully true.

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

In fact there is a big UIAutomation UDF project in example scripts which might be greatly useful to you.

It can access all kinds of window controls which general win32 programming cannot.

Worth a look like.

Sticky at the top.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I rummaged through the thread and found this: 

Which could be helpful but it only works on calculator and I haven't the faintest idea of where to begin editing that code... 

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

Wombat, This is not true. The example works for all windows, which can get the keyboard input. Try to switch between different windows, and you'll get an event for each window. Try with Windows Explorer. You'll get an event every time you select a new file/folder. Then press F2 to edit the name, and you'll get e new event. This seems to be exactly what you need.

Link to comment
Share on other sites

Wombat, This is not true. The example works for all windows, which can get the keyboard input. Try to switch between different windows, and you'll get an event for each window. Try with Windows Explorer. You'll get an event every time you select a new file/folder. Then press F2 to edit the name, and you'll get e new event. This seems to be exactly what you need.

 

it does appear to be a start in the correct direction, but it needs a little more. Could you tell me why it runs so slowly and how I could possibly speed it up?, and also it doesn't return for all things such as when I clicked into this box to type this comment. How could I go about adding support for edits such as the ones used in this forum? 

You are indeed right LArsJ, I just simply didn't wait long enough the first time I ran it to see the results in the console. 

What I believe I am seeing is that I need to make my function fire when the control type is 5004??

also, it appears to be slowed greatly as it tries to retrieve the value of those controls so if I click into SciTE it tries to grab all the text within the script. I'm thinking I could disable the value portion to speed it up??

Thank you JohnOne for the direction I believe I'm on the right track now, thank you for the focus follow code LarsJ it seems with some help and advice from more experienced persons this script could be my solution.

Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...