Jump to content

Recommended Posts

Posted (edited)

Hi all,

I use the usual code around
 

$hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0)

Func _Mouse_Proc($nCode, $wParam, $lParam)  ;function called for mouse events..

to hook mouse clicks and route them through my own code. Works well.

$wParam and $lParam pass infos about which button was pressed, and some additional infos like the position and some flags.

Now I wanted to process only clicks which do appear withgin a certain program (i.e. Excel):

Func ActionIsFiltered($time,$action,$ptx,$pty)

    ; -------- debug code ---------
    local $t = WinGetTitle("[ACTIVE]", "")
    ConsoleWrite($t & @CRLF)
    ; -----------------------------
    If WinActive("Excel") then return False
    return true
EndFunc

Problem is, that certain mouse clicks (Right mouse click) open a dropdown menu, and the menu seems to have a window of its own, and WInActive doesn't return true any more (though, of course, the Excel window is active all the time), and WinGetTitle returns an empty string.

I tried to check the x and y position of a click against the window boundaries of the monitored application, but unfortunately dropdown menus don't get clipped and may reach outside a program's window, so this approach didn't work either.

Has anyone found a more reliable solution to find out in which program window a mouse event has appeared, WinActive abnd WinGetTitle don't seem to be reliable.

Thx,

Armin.

 

 

Edited by ArminLinder
Posted

See if you can make something out of this.

#include <WinAPISysWin.au3>
ConsoleWrite('Active Title: '&WinGetTitle("[ACTIVE]") &@CRLF)
Local $WHdl = WinGetHandle("[ACTIVE]")
ConsoleWrite('Active Handle: '&$WHdl &@CRLF)
Local $Win = _WinAPI_GetWindow($WHdl, $GW_HWNDNEXT)
ConsoleWrite('ZOrder Next: '&$Win&' - '&WinGetTitle($Win)&@CRLF)
Local $Win2 = _WinAPI_GetWindow($WHdl, $GW_HWNDPREV)
ConsoleWrite('ZOrder Prev: '&$Win2&' - '&WinGetTitle($Win2)&@CRLF)

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted (edited)

careca,

thanks for your reply. It didn't solve my problem, but showed me the way to go. i can check the owner of the active window. If it is 0, I have the application main wndow itself, if not, I can get the owner and check it against the handle of the application main window.

This code works for me with modal windows as well as context menus etc.:

 

#include <WinAPISysWin.au3>
; Filter only specific application
Global $FILTERWINHANDLE = 0
$FILTERWINHANDLE = WinGetHandle("Excel", "")
Func ActionIsFiltered($time,$action,$ptx,$pty)

    ; -- true, if the action is filtered out --

    local $return = false;
    if $FILTERWINHANDLE <> 0 then
        local $haw = WinGetHandle("[ACTIVE]", "")
        local $how = _WinAPI_GetWindow($haw, $GW_OWNER)
        if $how = 0 then ; main application window
            $return = ($haw <> $FILTERWINHANDLE)
        Else
            $return = ($how <> $FILTERWINHANDLE)    ; sub-window -- check the owner
        EndIf
        ; -- debugging --
        ConsoleWrite("Filter:" & $FILTERWINHANDLE & " Active:" & $haw & " Owner:" & $how & ": " & $return & @CR)
    endif
    return $return
EndFunc

Greetz, Armin.

Edited by ArminLinder
Posted

Nice it was of some use.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...