| View previous topic :: View next topic |
| Author |
Message |
Rhys
Joined: 17 Apr 2007 Posts: 736 Location: Florida
|
Posted: Wed Apr 09, 2008 3:44 pm Post subject: Basic OnMessage() Question |
|
|
| Code: | ;WM_CUT = 0x300
OnMessage(0x300,"FUN")
Return
FUN()
{
MsgBox, FUN!
} |
I'm just testing the waters here, trying to pop a msgbox whenever I cut something. What am I doing wrong? _________________ [Join IRC!]
http://www.codeforcure.org/ |
|
| Back to top |
|
 |
dncarac
Joined: 31 Aug 2006 Posts: 64
|
Posted: Wed Apr 09, 2008 4:49 pm Post subject: |
|
|
The problem is that the WM_CUT message is sent to a control, but your OnMessage statement listens at the window level. I don't think you can use OnMessage to listen to a particular edit control.
On the other hand, I'd bet that a notification (something like EN_CUT maybe) is sent to the window by a WM_COMMAND message when a cut is made in an edit control. You can trap this message using an OnMessage command, determine what the notification message and associated control is
I hope this is not completely incoherent and somewhat helpful.
DNC
EDIT-- I checked and I was wrong. There is no CUT notification. There is a change notification which is sent anytime there is a change, but not a CUT. Sorry
DNC |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 666 Location: MN, USA
|
Posted: Thu Apr 10, 2008 12:12 am Post subject: |
|
|
Maybe you already know this; but OnMessage is only for monitoring messages sent to the AHK script, so you would have to be cutting something from an AHK GUI (assuming that would generate a 0x300 message, which dncarac says is not the case).
| AHK Help File wrote: | OnMessage()
Specifies a function to call automatically when the script receives the specified message. |
_________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 736 Location: Florida
|
Posted: Thu Apr 10, 2008 1:59 am Post subject: |
|
|
I actually didn't know that - As I said I'm just testing the waters, and really don't know a whole lot about how it works. I don't even care about cutting per se, but I thought that message looked pretty friendly compared to some of the others.
I need to RTFM more, I was just trying to hack together a small example of it working. I thought OnMessage() could do more stuff like be aware of when hardware has changed (USB / Monitor / etc...) but I may have confused it with something else. Thanks DNC and Jaco for the help so far! _________________ [Join IRC!]
http://www.codeforcure.org/ |
|
| Back to top |
|
 |
dncarac
Joined: 31 Aug 2006 Posts: 64
|
Posted: Thu Apr 10, 2008 11:36 pm Post subject: |
|
|
| Rhys wrote: | | I actually didn't know that - As I said I'm just testing the waters, and really don't know a whole lot about how it works. I don't even care about cutting per se, but I thought that message looked pretty friendly compared to some of the others. |
Ahhhhh. Well, if you're just playing around, you can look at what I did:
http://www.autohotkey.com/forum/viewtopic.php?t=28520
It deals with detecting getting and losing focus among edit controls. That, combined with the MSDN site can give you insight.
And keep in touch. We're all interested.
DNC |
|
| Back to top |
|
 |
|