Jump to content
Sign in to follow this  
astronicy

GUIRegisterMsg parameters unknown

Recommended Posts

astronicy

I have some trouble understanding the parameters $WM_NCHITTEST and $ HTCAPTION

Though they are not declared, AutoIt uses them nonetheless.

Also, I cannot rename them to make it all work.

Has anyone an idea where I can find these parameters in the help file, so that I can understand what is going on?

My goal is however not to drag and drop, but to create a clickable picture (PNG) on a transparent window:

Everything is working (GDI and such), except the click function.

Please advice, and thanks.

; Register notification messages
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
; ====================================================================================================
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
If ($hWnd = $win03) And ($iMsg = $WM_NCHITTEST) Then 
Return $HTCAPTION 
EndIf
EndFunc   ;==>WM_NCHITTEST
Edited by astronicy

Share this post


Link to post
Share on other sites
martin

I have some trouble understanding the parameters $WM_NCHITTEST and $ HTCAPTION

Though they are not declared, AutoIt uses them nonetheless.

Also, I cannot rename them to make it all work.

Has anyone an idea where I can find these parameters in the help file, so that I can understand what is going on?

My goal is however not to drag and drop, but to create a clickable picture (PNG) on a transparent window:

Everything is working (GDI and such), except the click function.

Please advice, and thanks.

; Register notification messages
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
; ====================================================================================================
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
If ($hWnd = $win03) And ($iMsg = $WM_NCHITTEST) Then 
Return $HTCAPTION 
EndIf
EndFunc   ;==>WM_NCHITTEST

If you use SciTE then add this line to the top of your script then run it

#AutoIt3Wrapper_Add_Constants=y

That will get the required include files added for the constants you have used.

To find out about $WM_NCHITTEST or any window message just Google for it without the leading $ and follow the link to msdn.

I don't think that's what you want though as you will see when you look it up. In the help for GuiCtrlCreatePic and read the remarks and you will see how to drag a window by a picture, although that won't work for what you are trying to do with a png.

I think you need to check for the left mouse button down, check to see if it's over your picture and if it is send it a message something like the example below.

#include <windowsconstants.au3>
#include <guiconstantsex.au3>
#include <sendmessage.au3>


Const $WM_ENTERSIZEMOVE = 0x231

$form1 = GUICreate("Form1",300,300,340,200)
GUISetState()
$Form2 = GUICreate("Form2",240,500,100,200)
GUISetState()
;GUIRegisterMsg($WM_ENTERSIZEMOVE,"Follow");doesn't work
While 1
    
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_PRIMARYDOWN
            _SendMessage($Form1, $WM_SYSCOMMAND, 0xF012, 0)
        Case -3
            exit
    EndSwitch

WEnd

Func Follow()
    ConsoleWrite("start" & @CRLF)
    _SendMessage($Form2, $WM_SYSCOMMAND, 0xF012, 0)
EndFunc

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
astronicy

Thanks Martin,

Well, I did get the drag and drop to work, I just did not understand these names.

Mouse down...interesting.

The snippet you added does not work? or does it? I will look into it.

Anyway, thank you.

Share this post


Link to post
Share on other sites
astronicy

Well, it seems new unknown names and codes appear in my script.

I still don't understand what is going on.

edit: that 'While 1'- 'WEnd' thing I cannot use.

All the windows in the GUI are, and need to be, in full motion.

Even escape doesn't exit the GUI - yet.

2nd edit:

I have come up with a new GUIregisterMsg function, as stated in the message codes in the help file, but it is rejected by AutoIt because now it says, unlike WM_NCHITTEST, that WM_MBUTTONDOWN must be declared.

here's the code:

; Register notification messages
GUIRegisterMsg($WM_MBUTTONDOWN, "WM_MBUTTONDOWN")

;<<< And >>>

; ========================================================================
; Handle the WM_MBUTTONDOWN for the layered window so it can be clicked
; ========================================================================
Func WM_MBUTTONDOWN($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $win03) And ($iMsg = $WM_MBUTTONDOWN) And ($iwParam = $MK_LBUTTON) Then 
    MouseCoor()
    EndIf   
EndFunc   ;==>WM_MBUTTONDOWN

3rd edit:

just to let you know I figured it out:

Local $msg = GUIGetMsg()

Local $pos = MouseGetPos()

if $msg = $GUI_EVENT_PRIMARYDOWN Then

ExitLoop

EndIf

Too much to explain fully, because I had to put this in the big For Next loop with

the repeating Winmove commands

Edited by astronicy

Share this post


Link to post
Share on other sites
martin

Well, it seems new unknown names and codes appear in my script.

I still don't understand what is going on.

edit: that 'While 1'- 'WEnd' thing I cannot use.

All the windows in the GUI are, and need to be, in full motion.

Even escape doesn't exit the GUI - yet.

2nd edit:

I have come up with a new GUIregisterMsg function, as stated in the message codes in the help file, but it is rejected by AutoIt because now it says, unlike WM_NCHITTEST, that WM_MBUTTONDOWN must be declared.

here's the code:

; Register notification messages
GUIRegisterMsg($WM_MBUTTONDOWN, "WM_MBUTTONDOWN")

;<<< And >>>

; ========================================================================
; Handle the WM_MBUTTONDOWN for the layered window so it can be clicked
; ========================================================================
Func WM_MBUTTONDOWN($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $win03) And ($iMsg = $WM_MBUTTONDOWN) And ($iwParam = $MK_LBUTTON) Then 
    MouseCoor()
    EndIf   
EndFunc   ;==>WM_MBUTTONDOWN

3rd edit:

just to let you know I figured it out:

Local $msg = GUIGetMsg()

Local $pos = MouseGetPos()

if $msg = $GUI_EVENT_PRIMARYDOWN Then

ExitLoop

EndIf

Too much to explain fully, because I had to put this in the big For Next loop with

the repeating Winmove commands

That makes no sense to me, carry on the good work >_<

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
astronicy

Well, I can describe it for you:

I have one mother window with a gradent background, which is static.

Four other windows, namely a large sphere, a small sphere, and two ellipses that form the shadows on the ground.

Both spheres move in an elliptical motion, the small one like a moon around a planet and 1.5x as fast.

Therefore I need the loop: For $Angle = 120 to 840, switching WinSetOnTop, WinMove Commands, Next (if angle 840 then 120 again, eternal loop).

Then the clicking on the small sphere is not done by a command for this specific window, but in fact independent of any window, thus on the screen, where the cursor coordinates must match the (WinMove) position of the small sphere. And this works.

Also found a snippet that determines if the cursor/pointer is within an ellipse/sphere as well, so that clicking will only be picked up if the cursor is on the sphere itself.

Next phase will be a new For Next loop, where the small sphere slowly accelerates to a high speed, while gradually disappearing totally.

Edited by astronicy

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  

×