Jump to content

How to obtain the owner of a Hotkey?


Exit
 Share

Recommended Posts

After searching the forum and MSDN, I believe that is it not possible to obtain the owner of a hotkey.

To enhance my _Hotkey() function (see >here), I would like to show the owner of a hotkey, if Hotkeyset() fails.

I believe to the power of the developers to make the impossible possible. 

I prepared a skeleton script to start with.

Just the last function _HotkeyOwner() needs some tweaks.

;~ Hotkey checker
#include <WinAPI.au3>

_HotKey("{ESC}")
_HotKey("{F12}")
Func _HotKey($hotkey = "")
    Switch @HotKeyPressed
        Case "{ESC}"
            Exit MsgBox(64 + 262144, Default, "Exit", 1)
        Case "{F12}"
            Beep()
        Case Else
            If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed)
            If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application." & @LF & "Error: " & @error & " Extented: " & @extended & @LF & "Lasterror: " & _WinAPI_GetLastErrorMessage() & @LF & _HotkeyOwner($hotkey))
    EndSwitch
EndFunc   ;==>_HotKey

While Sleep(100) ; here should be your application.
WEnd ; meanwhile, here is a dummy loop.

Func _HotkeyOwner($hotkey)
    Return "No Hotkeyowner detected for hotkey " & $hotkey
EndFunc   ;==>_HotkeyOwner

Please confirm, that there is no solution   :  or better, ... show me the impossible. :thumbsup:

Thanks Exit

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

Explain what you mean by the owner of a hotkey. Some so-called "hotkeys" aren't really hotkeys at all, their just windows messages that the application intercepts and processes, such as CTRL-P and CTRL-S.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

As you already pointed out, so-called "hotkeys" aren't really hotkeys, but application accelerators. See GUISetAccelerators() in the help file.

Real hotkeys are those who are set by Hotkeyset(). And only those are subject of my thread.

I want to detect, which process prevents Hotkeyset() to acquire the hotkey.

This might be a system process (like F12), but in most cases, it is another script or executable.

And it would be a good information for the user, to know this other process.

Please excuse my wording, my native language is German.

But anyway, please  show me the impossible. :thumbsup:

Edited by Exit

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

It's not possible from everything I've read to find out what application might have a certain hotkey assigned to it. Windows doesn't give you that information.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Well I guess if you really wanted to, you could use a global hook for all windows on the desktop, hooking their message loops to check if they are receiving a hotkey while you send it. You could even remove it from the queue so that the window didn't process it.

There has to be a list somewhere in memory, though it is buried deep, and this is windows so nothing is going to be easy to find.

Link to comment
Share on other sites

As I stated in my first post:  "After searching the forum and MSDN, I believe that is it not possible to obtain the owner of a hotkey." , I hoped that one of you would prove me the contrary and amend the last function in my code _HotkeyOwner() . But the guru didn't turned up till now. :x

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

That's a shame that this info isn't available.  I did a quick search on sysinternals and nirsoft to see if they had anything of the sort, but nothing came up.  There's an old utility Ethervane ActiveHotkeys that can look to see if a hotkey is used by other programs, but it too doesn't locate what implemented it.  The global Atom table sometimes is linked to the hotkeys, but that too doesn't seem to have any information on ownership.  I suppose what Mat suggests could be one approach, though its quite brute-force.

Link to comment
Share on other sites

Why do you need/want to know the "owner" of a certain hotkey? Just because you want to know, or is there a real reason for knowing it? If you're creating hotkeys, you're overwriting the ones that already exist anyways, and you can't reassign them once you're done.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Why do you need/want to know the "owner" of a certain hotkey? Just because you want to know, or is there a real reason for knowing it? If you're creating hotkeys, you're overwriting the ones that already exist anyways, and you can't reassign them once you're done.

 

 "If you're creating hotkeys, you're overwriting the ones that already exist."  Partially wrong!

You can overwrite them, if you created them. If they where created by another process, your creation fails.

And when the creation fails, I want to inform the user, which process is involved. Then he can close this process and try again.

Btw, I pointed this out in post #1 and #3.

"anyways, and you can't reassign them once you're done". Also wrong!

You can reassign them, if you created them.

But ,perhaps another user has the inspiration. :thumbsup:

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

Google, or Bing translate the page, Bing did a far better job when I translated it than Google did.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

That russian page discusses device-level kernel operations, which is a little insane.  And who knows what the 64-bit equivalent code would be and if that stuff is even portable to other O/S versions.  I also found another page where someone tried to tackle the same problem, but it all winds up being guesswork in the end..

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...