Jump to content

Problems while activating window under mouse


Recommended Posts

Basically i make mousestruct in the hook which is in dll

MOUSEHOOKSTRUCT* str;

THen make it from lparam,

LRESULT CALLBACK MouseProc( int nCode, WPARAM wParam, LPARAM lParam )
{


    str = (MOUSEHOOKSTRUCT *) lParam;

...

Then i catch mousemovements

case WM_MOUSEMOVE:

            wParm = AU3_WM_MOUSEMOVE;
            fromp = WindowFromPoint(str->pt);

Then validate and try not to send to many messages...

if (fromp != currentwindow) 
            {
                
                    currentwindow= fromp;
                    PostMessage(m_hHwndMouse, wParm,(WPARAM)( (MOUSEHOOKSTRUCT*) lParam )->hwnd, LPARAM(fromp));

                
            
            }
            break;

This sends the mousemove message along with hwnd to my autoit app which inspects hwnd and if that hwnd is not active it activates it.

Func mouse_func($hWndGUI, $MsgID, $wParam, $lParam)

    Select


        Case $MsgID = $WM_AUTOITMOUSEMOVE

            If GUICtrlRead($activateundermouse) = 1 And $sitting = 0 Then
                ;Local $starttime = _Timer_Init()
                If StringInStr(WinGetTitle($lParam), "ID=") Then
                    If Not WinActive($lParam) Then
                        ;ConsoleWrite("HOVERING NEW, Activate It: " & WinGetTitle($lParam) & @LF)
                        WinActivate($lParam)
                    EndIf
                    ;ConsoleWrite("diff is > " & _Timer_Diff($starttime) & @LF)
                EndIf
            EndIf

This is how i am activating window that is hovered by the mouse but the problem is that rarely autoit wont read the message that should signal new window being hovered(or the dll with hook didnt send it, i dont know)

Also if the window is overlapping another window and both of them are valid windows that should be activate once hovered i get flickering as autoit is constantly trying to activate the current window and the overlapped one, in a loop

Is there something that perhaps i missed or could be doing wrong here?

Also i am using Opt("WinWaitDelay", 100)

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

    No registered users viewing this page.

×
×
  • Create New...