Re: Getting mouse click info form a non Gui4Cli window.
"chris.kevany" <[email protected]> Sun, 07 Apr 2013 09:07:11 -0000
| Newsgroups | gmane.comp.windows.gui4cli |
|---|---|
| Message-ID | <[email protected]> |
Hi Dimitris,
Thanks for the suggestion!
I googled a bit on about this function to get some source code examples.
There's a low level (WH_MOUSE_LL) and a high level (WH_MOUSE) variant
for it.
These two are a bit controversal in the sense that the low level variant
has a noticable delay on overal performance of the gui. It acts system
wide
so I can call up a quickmenu on the external window. It supports all
mouse
button clicks except double-click.
The high level variant also supports double click but unfortunately it
is
only seen by the calling thread (Gui4Cli). Useless as you can guess
because
Gui4Cli already has much better support built-in for this.
I used this ...
BOOL _export WINAPI DLL_Init (struct GCMain *gcmain)
{
GCM = gcmain; // store the pointer to Gui4Cli's main structure..
gcAddCommands(DLL_COMMANDS); // add commands to GUI dll list
SetWindowsHookEx(WH_MOUSE_LL,MouseHookProc,GetModuleHandle("dll_name.dll\
"),0);
return TRUE;
}
void WINAPI DLL_Free (void)
{
UnhookWindowsHookEx(MouseHook);
}
and the callback ...
HHOOK MouseHook;
LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
PKBDLLHOOKSTRUCT k = (PKBDLLHOOKSTRUCT)(lParam);
POINT p;
struct Event * bt;
int retval;
if(wParam == WM_RBUTTONDOWN)
{
GetCursorPos(&p);
bt = gcFindEvent("gui_name","right_click", retval);
gcTriggerEventWait(bt);
}
return 0;
}
and in the gui ...
xRoutine right_click
use win 'External Window title'
if $$win.active = 1
quickmenu -1 -1 'First Item/Second Item/#sepa/Cancel'
if $$choice = 0
say 'Item 1 selected'
elseif $$choice = 1
say 'Item 2 selected'
endif
endif
The "GetAsyncKeyState(0x02)" function could also be used from within
a timer, polling for a mouse button press.
Chris
--- In [email protected], Dimitris Keletsekis <gui4cli@...> wrote:
>
> I googled and found this function:
>
> SetWindowsHookEx (using the WH_MOUSE_LL flag)
>
> Looks like the one to use.
> Dimitris
>
>
>
> On Sat, Apr 6, 2013 at 7:55 PM, chris.kevany chris.kevany@... wrote:
>
> > **
> >
> >
> > Hi Dimitris,
> >
> > I'm currently controlling a non Gui4Cli window on its title with
> > the "use" command which works great.
> >
> > This is a one direction control from Gui4Cli to the external window.
> > I now would like to retrieve mouse click info from the external
window
> > in Gui4Cli.
> >
> > My basic idea is to create a ddl function that catches mouse clicks
> > at the external window and triggers a Gui4cli event.
> >
> > Do you have any suggestions?
> >
> > Chris
> >