Jump to content



Photo

Problems while activating window under mouse


  • Please log in to reply
3 replies to this topic

#1 Aktonius

Aktonius

    Prodigy

  • Active Members
  • PipPipPip
  • 182 posts

Posted 15 July 2011 - 10:19 PM

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, 15 July 2011 - 10:21 PM.








#2 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 15 July 2011 - 11:21 PM

This can be done without a DLL and in pure AutoIt using polling. It would simplify things considerably.

#3 Aktonius

Aktonius

    Prodigy

  • Active Members
  • PipPipPip
  • 182 posts

Posted 16 July 2011 - 06:44 AM

nevermind...

i fixed it trough managing activation in dll

Edited by Aktonius, 16 July 2011 - 07:01 AM.


#4 Manadar

Manadar

    Taking a REST.

  • MVPs
  • 10,714 posts

Posted 16 July 2011 - 07:28 AM

Same as http://stackoverflow.com/questions/6713747/activate-windows-under-mouse-through-mouse-hook




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users