 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
rh
Joined: 19 Jan 2006 Posts: 15 Location: Heidelberg
|
Posted: Fri Feb 10, 2006 12:54 pm Post subject: how to determine if mouse is hovering over text edit ctrl? |
|
|
hi! i have the following question:
i want to know whether the mouse is currently hovering over a text edit field, and if yes, send input to that field on pressing a mouse button.
i know that i can get a handle on the control using
| Code: | | MouseGetPos, , , , control |
but i dont see how then to determine the TYPE of this control. i had a look at the "GuiControlGet" function, but if this offers a solution then i don't understand how...
any ideas? thanks a lot! |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Fri Feb 10, 2006 12:56 pm Post subject: |
|
|
what does the "control" var in the MouseGetPos command contain when you move the mouse over the control you want to check? _________________ Ciao
toralf  |
|
| Back to top |
|
 |
rh
Joined: 19 Jan 2006 Posts: 15 Location: Heidelberg
|
Posted: Fri Feb 10, 2006 1:04 pm Post subject: |
|
|
| that depends on the program. in some it says "Edit1", but for example in firefox it says "MozillaWindowClass1". |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6836 Location: France (near Paris)
|
Posted: Fri Feb 10, 2006 3:25 pm Post subject: |
|
|
Bad example, Firefox is like Java programs, its interface is hand-made to ease the portability between systems.
You can still have the problem with Visual Basic or Delphi applications, which can name their control ThunderRT6TextBox1 or TEdit1...
A way to see if a control is an edit one is to send it some specific Windows message and see if the answer is consistent. A ListBox will ignore a EM_GETLINECOUNT.
Actually, you can do this with ControlGet:
| Code: | MouseGetPos, , , id, control
ControlGet lc, LineCount, , %control%, ahk_id %id%
|
lc will be 0 for non-edit control, 1 or more for edit controls (including RichEdit ones).
I could have used: | Code: | EM_GETLINECOUNT = 0xBA
SendMessage EM_GETLINECOUNT, 0, 0, %control%, ahk_id %id%
lc := ErrorLevel
| with similar result. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
evl
Joined: 24 Aug 2005 Posts: 1237
|
Posted: Fri Feb 10, 2006 3:41 pm Post subject: |
|
|
You can also check what type (shape) the mouse pointer is which may be an alternative.additional check you could make. When over text the mouse changes to an IBeam - this unfortunately doesn't differentiate between edit controls and ordinary text on a web page, for example.
From the manual:
| Quote: |
A_Cursor:
The type of mouse cursor currently being displayed. It will be one of the following words: AppStarting, Arrow, Cross, Help, IBeam, Icon, No, Size, SizeAll, SizeNESW, SizeNS, SizeNWSE, SizeWE, UpArrow, Wait, Unknown. The acronyms used with the size-type cursors are compass directions, e.g. NESW = NorthEast+SouthWest. The hand-shaped cursors (pointing and grabbing) are classfied as Unknown.
If this variable's contents are fetched repeatedly at a high frequency (i.e. every 500 ms or faster), it will probably disrupt the user's ability to double-click. There is no known workaround.
|
|
|
| Back to top |
|
 |
rh
Joined: 19 Jan 2006 Posts: 15 Location: Heidelberg
|
Posted: Fri Feb 10, 2006 4:40 pm Post subject: |
|
|
thanks Philho, that is a nice solution. unfortunately, for firefox it does not work, but well, i have to handle that case individually.
so here's my code:
| Code: | F13::
MouseGetPos, , , id, control
ControlGet lc, LineCount, , %control%, ahk_id %id%
if (lc!=0 or control="MozillaWindowClass1")
{
MouseClick
Send, {End}+{Home}{Del}
}
return |
as you can see, it is useful for emptying e.g. the adress bar of a browser when wanting to visit another webpage. |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6836 Location: France (near Paris)
|
Posted: Fri Feb 10, 2006 5:26 pm Post subject: |
|
|
So, if you run this on an hotkey, why do you want to check the kind of control? One could suppose you would only hit this key on purpose, when mouse is at the right location.
Is it a kind of foolproof control, to avoid errors?
Anyway, I am happy it works for you. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
rh
Joined: 19 Jan 2006 Posts: 15 Location: Heidelberg
|
Posted: Fri Feb 10, 2006 7:14 pm Post subject: |
|
|
| PhiLho wrote: | | Is it a kind of foolproof control, to avoid errors? |
well, when i asked, my code was still a bit different:
i was sending CTRL-A,DEL. when doing this by hazard on the desktop for example, then this would result in deleting all files (well there was always the confirmation question, but you never know...). therefore i wanted to add some safety, especially since the concerning button on my mouse is placed in a location where from time to time one hit's it accidently.
now after i changed the code, it should be safer in any case, but "del" is always a potentially evil key...  |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sat Feb 11, 2006 4:52 am Post subject: |
|
|
Try this Solution by Shimanov _________________ URLGet - Internet Explorer based Downloader |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|