Jump to content

How to trigger a system-wide hotkey?


Go to solution Solved by somdcomputerguy,

Recommended Posts

I've got a third-party video recording app idling away in the system tray (as it should be), just waiting for a hotkey command sequence (e.g., "CTRL+R") to begin recording.  When I'm recording manually, I simply press the command sequence on the keyboard to get it going, without having to manually activate/raise the idling process/window.

Using ControlSend() doesn't work, because there's no way to identify any specific control to use as a target.  Using Send() doesn't work, because activating the video recording app changes the mode such that it ignores the hotkey.

Instead, it's a hotkey situation with universal (system-wide) scope.  The third-party app must do something like register a hotkey system-wide in Windows and wait in the system tray until some part of the operating system recognizes that the hotkey has been pressed and triggers the app to start recording.

But, how do I submit the control sequence such that it activates the universal hotkey?  My googling has only found AutoIt posts relating to setting up and working with internal hotkeys within a given AutoIt script, and nothing about how to trigger an external, system-wide hotkey.

Or perhaps there's some way of making it look to the OS as a whole that the sequence was actually typed on the keyboard?

I'm stumped!  Please advise.

Link to comment
Share on other sites

Thanks.  I may do it that way if all else fails, but I'd still like to know a more general answer.

is there menu when you click on the tray item? If yes, then simply use the tray commands to send the command you need. Look in the helpfile

Link to comment
Share on other sites

Is possible to know the name, a link of the "third-party video recording app idling away in the system tray"?

Send() work in many scenario but if "we" need to find an alternative how can test it if it really work for that "third-party video recording app"?

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

Thanks for your reply, Terenz.  But as I said above, I do not want a highly-specific answer for this particular app.  I definitely want to know how to trigger a system-wide hotkey, not just for this particular instance.  Because I already know of other system-wide hotkeys I want to trigger for other apps, apps that will not be in the system tray, as well as hotkeys that will not be associated with any specific app at all.

During my googling, I've seen references to code in other languages that claims that there's some way to send keys directly to the keyboard driver such that the system absolutely cannot tell the difference between getting the key string programmatically versus having the user actually type the keys into the keyboard.  That sounds like the most promising approach of all.

 

Is possible to know the name, a link of the "third-party video recording app idling away in the system tray"?
Send() work in many scenario but if "we" need to find an alternative how can test it if it really work for that "third-party video recording app"?

Edited by Mbee
Link to comment
Share on other sites

  • Moderators

Mbee,

A simple Send command triggers system hotkeys on my system. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks for your reply, Terenz.  But as I said above, I do not want a highly-specific answer for this particular app.  I definitely want to know how to trigger a system-wide hotkey, not just for this particular instance.

 

I have already say ( and Melba23 confirm it ) Send() work in many scenario and i don't have nothing on my system that "avoid" or "ignore" the Send() command so for me ( i don't know for other ) without test with something that don't accept-ignore the Send() command is impossible to give an answer. Good Luck

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

I'm honored by your visit, Melba23:sorcerer:  Please accept my tremendous thanks for all the spectacular work you've gifted us with!

Back on point, as soon as I understood the nature of my problems with using SendControl(), I then immediately tried Send(), as you suggest.  The hotkey sequence is Control-R, and this is the very trivial code I tried:

Send("^R")

But nothing whatsoever happens!  If I actually type that in on the keyboard, it works perfectly however.

Perhaps it has something to do with the fact that the help file states that Send() "Sends simulated keystrokes to the active window", which in my case is the Explorer desktop (or some other app)?  Note that I cannot make the video recording app the active window, since doing that changes the mode of the app into not-ready-to-record.

[ETA: It doesn't work with some other system-wide hotkeys I've set either, such as those I created with QuicKeys.  FYI, I'm running 64-bit Windows 7 Pro/SP1]

 

Mbee,

A simple Send command triggers system hotkeys on my system. :)

M23

Edited by Mbee
Link to comment
Share on other sites

Aach!  I didn't think of that, yet it worked perfectly!!  I will now count you too, kind somdcomputerguy, as another :sorcerer:

The reason I didn't consider using lower-case is that, since AutoIt uses the "+" character to indicate that the hotkey sequence includes pressing the Shift key -- and the desired sequence does not include a Shift keypress -- the case wouldn't matter.  That's what I get for abstract reasoning!  :oops:

Try it with a lowercase r, in the Send.

Link to comment
Share on other sites

Using uppercase vs. lowercase to resolve an issue is something I've seen mentioned more than once by others in this forum. Whenever I've seen a post like that, and it did resolve whatever the issue was, I've always thought to myself, "something like that is so logical, but I wouldn't of thought of it".. I just made that post before one of the real AutoIt gurus did.. I'm glad you got it working! :)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

Not only do I want to thank you for providing the answer I so desperately needed, friend somdcomputerguy, but I want to also thank you for your persistence in helping me out both here and in that previous thread!  :thumbsup:

(p.s., I also fixed the "correct answer" to point at your post, instead of mine!  oops)

Using uppercase vs. lowercase to resolve an issue is something I've seen mentioned more than once by others in this forum. Whenever I've seen a post like that, and it did resolve whatever the issue was, I've always thought to myself, "something like that is so logical, but I wouldn't of thought of it".. I just made that post before one of the real AutoIt gurus did.. I'm glad you got it working! :)

Edited by Mbee
Link to comment
Share on other sites

Oh I've been using AutoIt for almost 10 years now, and I have 3 or 4 or 5 scripts that I use quite a bit for myself, use 1 or 2 or 3 written by others here, and have 1 or 2 that I have compiled and distributed to a small handful of people. My AutoIt knowledge is very basic and when I can help somebody out on this forum, I get a warm, fuzzy feeling in my gut! :dance:

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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...