Wombat Posted June 19, 2014 Share Posted June 19, 2014 (edited) 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 June 19, 2014 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 More sharing options...
JohnOne Posted June 19, 2014 Share Posted June 19, 2014 You're checking Sleep functions @error value. 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 More sharing options...
JohnOne Posted June 19, 2014 Share Posted June 19, 2014 And then you're trying to arraydisplay a non array. 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 More sharing options...
Wombat Posted June 19, 2014 Author Share Posted June 19, 2014 (edited) 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 June 19, 2014 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 More sharing options...
JohnOne Posted June 19, 2014 Share Posted June 19, 2014 same. 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 More sharing options...
Wombat Posted June 19, 2014 Author Share Posted June 19, 2014 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 More sharing options...
JohnOne Posted June 19, 2014 Share Posted June 19, 2014 And when you are editing a text? 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 More sharing options...
Wombat Posted June 19, 2014 Author Share Posted June 19, 2014 (edited) 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 June 19, 2014 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 More sharing options...
JohnOne Posted June 19, 2014 Share Posted June 19, 2014 I think it's probably based on the blink rate in the registry whether it's blinking or not. 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 More sharing options...
Wombat Posted June 19, 2014 Author Share Posted June 19, 2014 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 More sharing options...
JohnOne Posted June 19, 2014 Share Posted June 19, 2014 If you want to know when a mouse cursor enters a control then I think you need to hook the window. Unfortunately I doubt "any window of any program" messages will be accessible. 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 More sharing options...
Wombat Posted June 19, 2014 Author Share Posted June 19, 2014 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 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 More sharing options...
JohnOne Posted June 19, 2014 Share Posted June 19, 2014 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 More sharing options...
Wombat Posted June 19, 2014 Author Share Posted June 19, 2014 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 More sharing options...
JohnOne Posted June 19, 2014 Share Posted June 19, 2014 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. Wombat 1 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 More sharing options...
Wombat Posted June 20, 2014 Author Share Posted June 20, 2014 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 More sharing options...
LarsJ Posted June 20, 2014 Share Posted June 20, 2014 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. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Wombat Posted June 22, 2014 Author Share Posted June 22, 2014 (edited) 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 June 22, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now