slloyd has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to query the mouse status to see if a button is depressed on Win32 using perl?

I am aware of Win32::Gui and the _Onclick event but what if you want to see if the mouse was clicked in an object that does not support the onclick event.

adding -onclick to an AxWindow does not seem to work so I am looking for an alternate solution to determining is the mouse was clicked.

Any help is greatly appreciated.

#!perl use strict; use Win32::GUI; use Win32::GUI::AxWindow; require 'subs_common.pl'; ################ MAIN WINDOW ############# my $FormWindow = new Win32::GUI::Window( -name => "FormWindow", -text => "Test", -pos => [600,50], -size => [400,300], ); sub FormWindow_Resize{return 0;} sub FormWindow_Minimize {return 0;} sub FormWindow_Maximize {return 0;} sub FormWindow_Terminate {return -1;} ########################## # Add a WebBrowser AxtiveX my $Control = new Win32::GUI::AxWindow ( -parent => $FormWindow, -name => "Control", -control => "Shell.Explorer.2", #-control => "InternetExplorer.Application", #-control => "{8856F961-340A-11D0-A96B-00C04FD705A2}", -pos => [0, 0], -size => [400, 300], -onClick => \&clickEvent, );

Replies are listed 'Best First'.
Re: Is Mouse Down
by halley (Prior) on Jun 17, 2004 at 13:55 UTC
    I don't know if the Perl bindings can reach it, but the Win32 API for determining this is (GetKeyState(VK_LBUTTON) < 0) (or GetAsyncKeyState()). Mouse buttons are just seen as more Shift-like keyboard elements in this regard.

    The difference between the two APIs is esoteric and you need to know a little how message loops are implemented to fully grok it; typically, you want to just use the first one.

    --
    [ e d @ h a l l e y . c c ]

Re: Is Mouse Down
by hossman (Prior) on Jun 18, 2004 at 05:27 UTC

    I've never used Win32::GUI::AxWindow, but the POD mentions...

    RegisterEvent (ID_or_Name, Callback)
    
      Associate a Callback for an ActiveX Event.
    

    Now i don't know much about ActiveX, but on a hunch i googled for "ActiveX Event Mouse" and found this.

    I'm not saying that that will work, I'm jsut saying I would try it.