Unable to take activation away from LibreOffice window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Theo
Posts: 7
Joined: 06 Aug 2023, 02:31

Unable to take activation away from LibreOffice window

06 Aug 2023, 02:42

I have this code which activates the window the cursor is over.

Code: Select all

~WheelDown::
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
return
It works for every application except LibreOffice. With LibreOffice apps the WheelDown event continues to go to LibreOffice when I hover over other applications. How can I overcome this?

[Mod edit: Mpved topic to AHK v1 help, since this is not v2 code.]
Master_X
Posts: 33
Joined: 04 Aug 2023, 13:59

Re: Unable to take activation away from LibreOffice window

06 Aug 2023, 05:21

Basically you mean it's stuck opening the last Libre window you activated with mousewheel even though mouse is over another program? You can double click the ahk icon in taskbar to see the executed lines also you can use strg+v there or choose view-variables to see what they currently are and if something changes or is really stuck. After each action you have to press F5 to get the current information
User avatar
mikeyww
Posts: 27370
Joined: 09 Sep 2014, 18:38

Re: Unable to take activation away from LibreOffice window

06 Aug 2023, 05:34

Hello,

Including the tilde means that the hotkey's native function will not be blocked. The result is that the key or button is "activated" before the subroutine executes. To change that, you can remove the tilde, and send (or Click) the key or button when you need that to happen in the subroutine.

For keyboard keys being sent via Send, the $ prefix is often needed for the hotkey if the same key is being sent and the hook is not already being used.
The $ prefix has no effect for mouse hotkeys, since they always use the mouse hook. It also has no effect for hotkeys which already require the keyboard hook, including any keyboard hotkeys with the tilde (~) or wildcard (*) modifiers, key-up hotkeys and custom combinations. To determine whether a particular hotkey uses the keyboard hook, use ListHotkeys.
Theo
Posts: 7
Joined: 06 Aug 2023, 02:31

Re: Unable to take activation away from LibreOffice window

06 Aug 2023, 15:28

I removed the tilde, but scrolling in other Windows still cannot deactivate the LibreOffice window.

Code: Select all

WheelDown::
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
Send, {WheelDown}
return
[Mod edit: [code][/code] tags added. Please use them yourself going forward.]
User avatar
mikeyww
Posts: 27370
Joined: 09 Sep 2014, 18:38

Re: Unable to take activation away from LibreOffice window

06 Aug 2023, 18:54

It worked here. If you have other code in your script, other scripts running, other keyboard or mouse utilities running, or other software with the same hotkey, you may be experiencing a software conflict of some kind.

Microsoft already wrote this script and made a Windows setting from it. See the Mouse control panel setting, "Scroll inactive windows when I hover over them".
Theo
Posts: 7
Joined: 06 Aug 2023, 02:31

Re: Unable to take activation away from LibreOffice window

06 Aug 2023, 21:37

You were right! I forgot about this code I needed in order to work around a scrolling problem (https://ask.libreoffice.org/t/mousewheel-scrolling-not-correct/81304). Sorry!

Code: Select all

#ifWinActive ahk_exe soffice.bin
WheelDown::
Send, {PgDn}
return


Is there a way I can keep the Libre workaround and also activate other windows when I scroll over them?

I'm customizing the scrolling in AutoHotkey because the built-in Mouse control panel setting doesn't bring the scrolled window to the foreground. Thanks!
User avatar
mikeyww
Posts: 27370
Joined: 09 Sep 2014, 18:38

Re: Unable to take activation away from LibreOffice window

07 Aug 2023, 05:01

The beep is just for testing.

Code: Select all

#Requires AutoHotkey v1.1.33

WheelDown::                          ; Not LibreOffice
MouseGetPos,,, hWnd
WinActivate % "ahk_id" hWnd
Send {WheelDown}
SoundBeep 1500
Return

#If WinActive("ahk_exe soffice.bin") ; LibreOffice
WheelDown::Send {PgDn}
#If
Theo
Posts: 7
Joined: 06 Aug 2023, 02:31

Re: Unable to take activation away from LibreOffice window

08 Aug 2023, 03:37

I copied and pasted this into its own script. But once a LibreOffice window is activated, scrolling in any other window still sends the WheelDown event to LibreOffice.

Code: Select all

#Requires AutoHotkey v1.1.33

WheelDown::                          ; Not LibreOffice
MouseGetPos,,, hWnd
WinActivate % "ahk_id" hWnd
Send {WheelDown}
SoundBeep 1500
Return

#If WinActive("ahk_exe soffice.bin") ; LibreOffice
WheelDown::Send {PgDn}
#If
User avatar
boiler
Posts: 17392
Joined: 21 Dec 2014, 02:44

Re: Unable to take activation away from LibreOffice window

08 Aug 2023, 03:54

If I understand the problem, this might work:

Code: Select all

#Requires AutoHotkey v1.1.33

#If MouseIsOver("ahk_exe soffice.bin") ; LibreOffice
WheelDown::Send {PgDn}
#If

WheelDown::                          ; Not LibreOffice
MouseGetPos,,, hWnd
WinActivate % "ahk_id" hWnd
Send {WheelDown}
SoundBeep 1500
Return

MouseIsOver(WinTitle) {
    MouseGetPos,,, Win
    return WinExist(WinTitle . " ahk_id " . Win)
}
just me
Posts: 9575
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Unable to take activation away from LibreOffice window

08 Aug 2023, 04:27

... or maybe:

Code: Select all

#Requires AutoHotkey v1.1.33

WheelDown::
   MouseGetPos,,, hWnd
   If !WinActive("ahk_id " hWnd)       ; if the window under the cursor isn`t active ...
      WinActivate, ahk_id %hWnd%       ; ... activate
   WinGet, ProcName, ProcessName, A    ; get the process name of the active window
   If (ProcName = "soffice.bin")       ; if it is a LibreOffice window
      Send {PgDn}
   Else {                              ; otherwise
      Send {WheelDown}
      SoundBeep 1500
   }
Return
Theo
Posts: 7
Joined: 06 Aug 2023, 02:31

Re: Unable to take activation away from LibreOffice window

18 Aug 2023, 03:35

This works great in all windows except Firefox if an extension pop-up is open.

Code: Select all

WheelDown::
   MouseGetPos,,, hWnd
   If !WinActive("ahk_id " hWnd)       ; if the window under the cursor isn`t active ...
      WinActivate, ahk_id %hWnd%       ; ... activate
   WinGet, ProcName, ProcessName, A    ; get the process name of the active window
   If (ProcName = "soffice.bin")       ; if it is a LibreOffice window
      Send {PgDn}
   Else {                              ; otherwise
      Send {WheelDown}
      SoundBeep 1500
   }
Return
If the cursor is over extension pop-ups like this Image the pop-up closes and the Main menu opens with File selected and I can see in Key History that 2 Alt events are sent. Sometimes this happens on the first WheelDown, sometimes on the second or third.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Mateusz53, Rohwedder and 166 guests