Jump to content
Sign in to follow this  
Squirrely1

How do I hook button clicks in Display Properties

Recommended Posts

My hope is that my screensaver will be properly integrated with the Screen Saver tab in the Display Properties applet. I found that the .scr should poll for a click on each of three buttons in that applet, in order that it exit when needed.

It would be nice if something like GUIRegisterMsg() would work. I found the following function on the Forum, but it would probably need modifying, if it even is anything like what I want:

Func MY_WM_NOTIFY($hWnd, $nMsg, $wParam, $lParam)
    Local $nID        = BitAnd($wParam, 0x0000FFFF)
    Local $stNmhdr  = DllStructCreate("dword;int;int", $lParam)
    Local $hWndFrom  = DllStructGetData($stNmhdr, 1)
    Local $nNotifyCode  = DllStructGetData($stNmhdr, 3)
    If Not ($nNotifyCode = $NM_CLICK Or $nNotifyCode = $TVN_KEYDOWN) Then Return $GUI_RUNDEFMSG
    Local $tagPOINT = _WinAPI_GetMousePos(True, $hWndFrom)
    Switch _GUICtrlTreeView_HitTest($nID, DllStructGetData($tagPOINT, 1), DllStructGetData($tagPOINT, 2))
        Case 2
            ConsoleWrite("--------------------------------" & @LF)
            ConsoleWrite("MY_WM_NOTIFY: Treeview Icon clicked" & @LF)
        Case 4
            ConsoleWrite("--------------------------------" & @LF)
            ConsoleWrite("MY_WM_NOTIFY: Treeview Text clicked" & @LF)     
        Case 16
            ConsoleWrite("--------------------------------" & @LF)
            ConsoleWrite("MY_WM_NOTIFY: Treeview Button clicked" & @LF)
        Case 64
            ConsoleWrite("--------------------------------" & @LF)
            ConsoleWrite("MY_WM_NOTIFY: Treeview Checkbox clicked" & @LF)
    EndSwitch     
    Return $GUI_RUNDEFMSG
EndFunc

Does anyone know where there is a good description of the Windows Message Codes, which are only listed in the appendix of the Autoit help file? Or how would I implement the above function?

The class number of the Display Properties window is CLASS:32770

The "Apply" button's controlID=12321, the "Preview" button's controlID=1304, and the "Settings" button's controlID=1303.

Edited by Squirrely1

Share this post


Link to post
Share on other sites

My hope is that my screensaver will be properly integrated with the Screen Saver tab in the Display Properties applet. I found that the .scr should poll for a click on each of three buttons in that applet, in order that it exit when needed.

It would be nice if something like GUIRegisterMsg() would work. I found the following function on the Forum, but it would probably need modifying, if it even is anything like what I want:

Func MY_WM_NOTIFY($hWnd, $nMsg, $wParam, $lParam)
    Local $nID        = BitAnd($wParam, 0x0000FFFF)
    Local $stNmhdr  = DllStructCreate("dword;int;int", $lParam)
    Local $hWndFrom  = DllStructGetData($stNmhdr, 1)
    Local $nNotifyCode  = DllStructGetData($stNmhdr, 3)
    If Not ($nNotifyCode = $NM_CLICK Or $nNotifyCode = $TVN_KEYDOWN) Then Return $GUI_RUNDEFMSG
    Local $tagPOINT = _WinAPI_GetMousePos(True, $hWndFrom)
    Switch _GUICtrlTreeView_HitTest($nID, DllStructGetData($tagPOINT, 1), DllStructGetData($tagPOINT, 2))
        Case 2
            ConsoleWrite("--------------------------------" & @LF)
            ConsoleWrite("MY_WM_NOTIFY: Treeview Icon clicked" & @LF)
        Case 4
            ConsoleWrite("--------------------------------" & @LF)
            ConsoleWrite("MY_WM_NOTIFY: Treeview Text clicked" & @LF)     
        Case 16
            ConsoleWrite("--------------------------------" & @LF)
            ConsoleWrite("MY_WM_NOTIFY: Treeview Button clicked" & @LF)
        Case 64
            ConsoleWrite("--------------------------------" & @LF)
            ConsoleWrite("MY_WM_NOTIFY: Treeview Checkbox clicked" & @LF)
    EndSwitch     
    Return $GUI_RUNDEFMSG
EndFunc

Does anyone know where there is a good description of the Windows Message Codes, which are only listed in the appendix of the Autoit help file? Or how would I implement the above function?

The class number of the Display Properties window is CLASS:32770

The "Apply" button's controlID=12321, the "Preview" button's controlID=1304, and the "Settings" button's controlID=1303.

I don't think you should need to detect the buttons. This thread by MsCreatoR might help.


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

I don't think you should need to detect the buttons. This thread by MsCreatoR might help.

Well I did a lot of research on the subject; I read the contribution of MsCreatoR; but I found the following information on the internet and haven't found anything to disprove it:

"Windows passes command switches to the screen saver to tell it what to do. The following switches are used:

When You: Select a screen saver from the drop down

Windows Passes: /p <hwnd>

Your .scr should have close & begin again to display in the Preview window.

When You: Click the Preview button

Windows Passes: /s

Your .scr should have close & begin again to run fullscreen.

When You: Stop previewing the screen saver

Windows Passes: /p <hwnd>

Your .scr should have close & begin again to display in the Preview window.

When You: Click the Settings button

Windows Passes: /c:<hwnd>

Your .scr should have close & begin again to run the configuration dialog of the .scr.

When You: Close your Configuration form

Windows Passes: /p <hwnd>

Your .scr should have close & begin again to display in the Preview window.

When You: Click the Change Password button

Windows Passes: /a <hwnd>

Your .scr should show the change password screen if it is to be Windows98 compatible.

When You: Click the Apply button

Windows Passes: /p <hwnd>

Your .scr should have close & begin again to display in the Preview window.

When You: Pick a screen saver and leave the PC idle

Windows Passes: /s

Your .scr should run fullscreen.

Where <hwnd> is the handle of the Preview window. The Preview window is the small

window on the Screen Saver tab of the Display Properties applet.

Windows will automatically shut down your program when you close the Display

Properties dialog or select another screen saver."

And from microsoft I found out that <hwnd> is an unsigned decimal representation of a window handle.

:)

I feel certain about the above prescription and I am sure that MSCreatoR was as unfamiliar with all this stuff as I was a week ago when I began my screensaver project.

All that aside, I could think that there is a way to poll for a button click in a window that is non-native to autoit, even though it is probably some code imported to autoit by someone whose first language is VB or C++ or something.

Edit: I take that back about MSCreatorR, who did a great job with YT_Download_Center, and wrote a better screensaver than mine.

Edited by Squirrely1

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  

×
×
  • Create New...