AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Basic OnMessage() Question

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Rhys



Joined: 17 Apr 2007
Posts: 736
Location: Florida

PostPosted: Wed Apr 09, 2008 3:44 pm    Post subject: Basic OnMessage() Question Reply with quote

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
View user's profile Send private message
dncarac



Joined: 31 Aug 2006
Posts: 64

PostPosted: Wed Apr 09, 2008 4:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 666
Location: MN, USA

PostPosted: Thu Apr 10, 2008 12:12 am    Post subject: Reply with quote

Maybe you already know this; Question 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
View user's profile Send private message Visit poster's website
Rhys



Joined: 17 Apr 2007
Posts: 736
Location: Florida

PostPosted: Thu Apr 10, 2008 1:59 am    Post subject: Reply with quote

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
View user's profile Send private message
dncarac



Joined: 31 Aug 2006
Posts: 64

PostPosted: Thu Apr 10, 2008 11:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group