Jump to content
Sign in to follow this  
AndreyS

How to ignore click on the the window title and change its size?

Recommended Posts

AndreyS
All developers hello!
The guys tell me, please, who knows.
I have a function GUISetOnEvent ($ $ GUI_EVENT_PRIMARYVDOWN, "Func1", $ Form1). How to make sure that it does not start when I click on the title bar or resize the window when Form1?

Share this post


Link to post
Share on other sites
FireFox

Hi,

Try this :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Global $hGUI = GUICreate("MyGUI", Default, Default, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
GUISetState(@SW_SHOW, $hGUI)

While 1
    Sleep(1000)
WEnd

Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("left button clicked" & @CrLf)

    Return $GUI_RUNDEFMSG
EndFunc

Func _Exit()
    GUIDelete($hGUI)
    Exit
EndFunc
Edit: Added indents.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
AndreyS

Oh! An interesting solution! Thank you! :)

Now it only works when you click on an empty spot without controls. How to make so that when you click on all the controls on the form and the function work?

Share this post


Link to post
Share on other sites
FireFox

What is the final purpose of this? There must be a more reliable way to do what you want ;)

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
AndreyS

The purpose of the easiest! I want my function to start when you click on the form, or by any of its controls. But when I move the window of the form that it did not fire. That's it.

Share this post


Link to post
Share on other sites
FireFox

So what are the purpose of your controls?


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
AndreyS

I do not understand what you explain more?
We need to do so on any control function worked. In your example, on the Edit control as well. And for all that, I would add.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
 
Opt("GUIOnEventMode", 1)
 
Global $hGUI = GUICreate("MyGUI", Default, Default, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
GUICtrlCreateEdit("", 10, 10, 300,300)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
 
GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
GUISetState(@SW_SHOW, $hGUI)
 
While 1
    Sleep(1000)
WEnd
 
Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("left button clicked" & @CrLf)
 
    Return $GUI_RUNDEFMSG
EndFunc
 
Func _Exit()
    GUIDelete($hGUI)
    Exit
EndFunc

Share this post


Link to post
Share on other sites
FireFox

I mean why the target function needs to be fired for a click on any control?


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
AndreyS
:huh: Click on the window to any location should change the contents of the controls.
I do not want false positives when I drag a window. How else to explain it?  :ermm:

Share this post


Link to post
Share on other sites
FireFox

Apart from a design thing, I don't see why you want to do this.

Anyway, you will have to set an event on all your controls (GUICtrlSetOnEvent function).

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
AndreyS

Since the mouse control is very convenient in my case. For each element, it is inconvenient. Elements and functions may vary as well. It is necessary to find a general solution.

Share this post


Link to post
Share on other sites
FireFox

Try this :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode", 1)

Global Const $SM_CXSIZEFRAME = 32
Global $iSM_CXDLGFRAME = _WinAPI_GetSystemMetrics($SM_CXSIZEFRAME)
Global $iSM_CYCAPTION = _WinAPI_GetSystemMetrics($SM_CYCAPTION)

Global $hGUI = GUICreate("MyGUI", Default, Default, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

GUICtrlCreateButton("button", 10, 10)

GUICtrlCreateInput("input", 10, 40)

GUICtrlCreateCheckbox("checkbox", 10, 70, 80)

GUISetState(@SW_SHOW, $hGUI)

Global $hMouseHook = DllCallbackRegister("_MouseProc", "long", "int;ptr;ptr")
Global $hMouseProc = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hMouseHook), _WinAPI_GetModuleHandle(0), 0)

OnAutoItExitRegister("OnAutoItExit")

While 1
    Sleep(1000)
WEnd

Func _MouseProc($iCode, $wParam, $lParam)
    If $iCode < 0 Then Return _WinAPI_CallNextHookEx($hMouseHook, $iCode, $wParam, $lParam)

    Switch BitAND($wParam, 0xFFFF)
        Case $WM_LBUTTONDOWN
            If WinActive($hGUI) > 0 Then
                Local $aWgp = WinGetPos($hGUI)
                Local $aMgp = MouseGetPos()

                If ($aMgp[0] > ($aWgp[0] + $iSM_CXDLGFRAME)) And ($aMgp[0] < ($aWgp[0] + $aWgp[2] - $iSM_CXDLGFRAME)) _
                        And ($aMgp[1] > $aWgp[1] + $iSM_CYCAPTION) And ($aMgp[1] < ($aWgp[1] + $aWgp[3] - $iSM_CXDLGFRAME)) Then
                    _LeftClick()
                EndIf
            EndIf
    EndSwitch

    Return _WinAPI_CallNextHookEx($hMouseHook, $iCode, $wParam, $lParam)
EndFunc

Func _LeftClick()
    ConsoleWrite("left button clicked" & @CrLf)
EndFunc

Func OnAutoItExit()
    _WinAPI_UnhookWindowsHookEx($hMouseHook)
    DllCallbackFree($hMouseProc)
EndFunc

Func _Exit()
    GUIDelete($hGUI)
    Exit
EndFunc
Edit: Added indents.

Br, FireFox.

Edited by FireFox
  • Like 1

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
AndreyS
Wow solution! :o  Not simple, but it works.
Thanks for the help, FireFox!

Share this post


Link to post
Share on other sites
FireFox

You're welcome :)

Note that the script must be adjusted (at least for me) for the bottom corner of the GUI when you want to resize it (a -2 should do the trick at the end of the last expression ;))

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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  

×