Jump to content
Sign in to follow this  
JackDinn

trying to learn GUIRegisterMsg

Recommended Posts

JackDinn

so im just starting out looking properly at windows messages & reading the MSDN, but already questions ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUIRegisterMsg($WM_CLOSE, "MY_WM_CLOSE")
GUIRegisterMsg($WM_MOUSEMOVE, "MY_WM_MOUSEMOVE")
GUICreate("test",200,200)

GUISetState()

While 1
    $msg=GUIGetMsg()
    Switch $msg
        case $GUI_EVENT_CLOSE
        GUIDelete()
    EndSwitch
WEnd

func MY_WM_CLOSE()
MsgBox(0, "", "WM_CLOSE")   
    
EndFunc


func MY_WM_MOUSEMOVE()
MsgBox(0, "", "WM_MOUSEMOVE")   
    
EndFunc

firstly i was hoping that by registering WM's it would capture messages from all windows not just the GUI im using but in the case of GUIRegisterMsg($WM_MOUSEMOVE, "MY_WM_MOUSEMOVE") i found that it only triggers when the mouse moves over the gui i made? how would i capture messages from outside my GUI?

and also why can't i get WM_CLOSE to work at all?

originally was looking to capture notification if any windows window was closed and this is why i started looking more into registering windows messages so how to do this would be great to ^_^


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
Valuater

As a general rule AFAIK

All commands here with "GUI" in the name relates to the User Interface created by Autoit.

Thus, GUIRegisterMsg() is the wrong direction

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
SmOke_N

1. When using GUIRegisterMsg(), the function to receive the data must have 4 parameters. Hwnd, Msg, Wparam, Lparam. If you look at any examples on the forum or the help file you'll see this.

2. To interact or capture other window messages other than ones you have ownership of, you must hook that window. Look for SetWindowsHookEx in the forum search (I'd search Examples Forum ^_^ )

3. You have a lot of learning to do to understand these types of hooks/message registering, in order to properly translate the messages you receive.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Jos

3. You have a lot of learning to do to understand these types of hooks/message registering, in order to properly translate the messages you receive.

... and looking at your awful avatar you are already desperate with not much head left.

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
JackDinn

1. When using GUIRegisterMsg(), the function to receive the data must have 4 parameters. Hwnd, Msg, Wparam, Lparam. If you look at any examples on the forum or the help file you'll see this.

yea im ok with that part & the params when im using it within my owned GUI's

To interact or capture other window messages other than ones you have ownership of, you must hook that window. Look for SetWindowsHookEx in the forum search (I'd search Examples Forum wink.gif )

o crud ^_^ hooks are one for another day along with objects dll & COM's SQLlite etc...... ;)

i'll get on with reading through Microsoft Win32 Programmer's Reference & try to nail WM's for now.

cheers chaps.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
JackDinn

... and looking at your awful avatar you are already desperate with not much head left.

LOL , i'll have you know iv had 2 PM's from peeps who love it ^_^

Yo JackDinn,

Just got to say man your Avatars always put a smile on my face. wink.gif

Respect

XXXXX

kinda thing

looking at my last post, all the head banging going on i kinda agree with ya, maybe i should get my sanity checked out ;)


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
Jos

LOL , i'll have you know iv had 2 PM's from peeps who love it ^_^

kinda thing

looking at my last post, all the head banging going on i kinda agree with ya, maybe i should get my sanity checked out ;)

Well you are the third person on this forum that I say this too for the same stupid avatar: I seriously think its sick.


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
SmOke_N

yea im ok with that part & the params when im using it within my owned GUI's

Your example doesn't show you understand, unless it was just something you threw up there to make others think you were actually trying. ^_^

WM_CLOSE doesn't work with your example (even if you were using the correct params) because you're also using $GUI_EVENT_CLOSE which undoubtedly registers that through the autoit default event.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
JackDinn

i had tried without it previously but it didn't work so i put in the $GUI_EVENT_CLOSE to see if it was the actual closing of the window that sent the WM_CLOSE message.

i didn't put in the prams because it was just a test to capture the WM i wasn't looking to gather any other info like the handle of the window generating the message etc,

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUIRegisterMsg($WM_CLOSE, "MY_WM_CLOSE")
GUICreate("test", 200, 200)

GUISetState()

While 1
    $msg = GUIGetMsg()
WEnd

Func MY_WM_CLOSE($hWndGUI, $MsgID, $WParam, $LParam)
    MsgBox(0, "", "WM_CLOSE")
EndFunc  ;==>MY_WM_CLOSE

i do appreciate the help, thx.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
JackDinn

found it,

$WM_SYSCOMMAND, for the messages like minimise or close.

as i said im just started looking at GUIRegisterMsg(), i admit i have many assumptions based on having used it many times form others scripts but can only gain a better understanding by focusing on one thing at a time.

Your example doesn't show you understand, unless it was just something you threw up there to make others think you were actually trying.

no i probably don't understand completely and most of what i think i know is assumption but i am trying , honestly ^_^.

does leave me wondering how $WM_CLOSE is used

thx.

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
martin

1. When using GUIRegisterMsg(), the function to receive the data must have 4 parameters. Hwnd, Msg, Wparam, Lparam.

I think the function doesn't have to have any parameters for most messages although it could make the function useless. If you have registered WM_ENTERSIZEMOVE for example and you don't care about the parameters then there is no requirement to specify any. Some, like callback functions, do require all 4 but that might be because 4 are defined in the callback. _Timer_SetTimer callback functions will not get executed unless there are 4 parameters for the function even though they might never get used.

So in general it is better to include the paramters, but I just wanted to point out that it's not always essential.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
JackDinn

aye thx, i had noticed in the help file that in a lot of cases if you didn't want to gather these param's that you didn't need to use them and i was just looking to test out some of the messages actually getting to there func so i didn't, but i shall use them in future even if i dont want them (just in case).

also in my own defence the fact that i had a $GUI_EVENT_CLOSE being polled shouldn't have affected the testing of the messages as a quote from the help file on GUIRegisterMsg:-

Case $nButton

; Normally should not run through cause of our MY_WM_COMMAND function

MsgBox(0, "Info", "Button pressed")

would seem to imply that the registered message would take precedence over GUIGetMsg()

but it's all by the by as im just tinkering about atm.

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites
WideBoyDixon

As per another help topic recently, please note that you can't hook windows messages for other applications unless you install a hook procedure that resides in a separate DLL because the hook code needs to be injected in to the call space of the other application. It's not something that's possible with AutoIt but I did sort of commit to looking at a possible solution in a C/C++ DLL.

WBD

Share this post


Link to post
Share on other sites
SmOke_N

As per another help topic recently, please note that you can't hook windows messages for other applications unless you install a hook procedure that resides in a separate DLL because the hook code needs to be injected in to the call space of the other application. It's not something that's possible with AutoIt but I did sort of commit to looking at a possible solution in a C/C++ DLL.

WBD

That's not entirely true for everything.

http://www.autoitscript.com/forum/index.ph...c=56536&hl=


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
JackDinn

wow just goes to show how much there is for me yet to even be aware of let alone learn. Ok so it pretty difficult to test for windows messages from other that AI created GUI's.

I'll pop all this in the back of my memory and maybe one day when im looking at hooks i'll read again and actually understand what was just said, a lot of studying then.

pity i dont have years of C, C++ behind me as i might understand some of the stuff im now looking into a bit better but i found AutoIt the best script language to start out with. i did try starting with C but just couldn't quite get going also had a reasonable look at java and VB but once i found AI i started getting somewhere, prob will revisit the others some time but im quite happy atm and im sure learning about object creation with dll methods, COM objects and all that in AutoIt will help when i do go back to have another look at C, java & VB.

cheers chaps.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
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
Sign in to follow this  

×