Jump to content

Using HotKeySet


Recommended Posts

Hello All,

I am trying to use Hotkeyset to detect when a user presses ALT + SHIFT + Backspace + DEL

When this key combination is pressed simultaneously I will call my function. Here is what I have so far:

;This calls my function as soon as ALT + SHIFT + DEL is pressed (doesn't wait for backspace)

HotKeySet("!+{DEL}{BS}", "Escape")

Can anyone tell me what i am doing wrong?

Link to comment
Share on other sites

  • Moderators

Re-read the HotKeySet page in the help file, specifically those keys that cannot be set.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I read it and I see (it appears to me) no reason why you can't do it. This is what is said on it (from the help file)

Ctrl+Alt+Delete

It is reserved by Windows

F12

It is also reserved by Windows, according to its API.

NumPad's Enter Key

Instead, use {Enter} which captures both Enter keys on the keyboard.

Win+B,D,E,F,L,M,R,U; and Win+Shift+M

These are built-in Windows shortcuts. Note: Win+B and Win+L might only be reserved on Windows XP and above.

Alt, Ctrl, Shift, Win

These are the modifier keys themselves!

Other

Any global hotkeys a user has defined using third-party software, any combos of two or more "base keys" such as '{F1}{F2}', and any keys of the form '{LALT}' or '{ALTDOWN}'.

Link to comment
Share on other sites

Oh wait -

Other

Any global hotkeys a user has defined using third-party software, any combos of two or more "base keys" such as '{F1}{F2}', and any keys of the form '{LALT}' or '{ALTDOWN}'.

Is this the reason? I'm not quite understanding it but I think this is what you are getting at.

Link to comment
Share on other sites

Re-read the HotKeySet page in the help file, specifically those keys that cannot be set.

Its interesting because I do see that it says you can't do Ctrl, Alt and Shift because they are modifiers, but I figure there is still some way to do it because Alt + Shift + Del works fine. So that part about the keys that you can't do does not seem to be completely accurate.

Edited by althurm
Link to comment
Share on other sites

What it's saying is that you can't map a hotkey directly to just the CTRL/ALT/Shift key, you have to use one of them in combination with another key, such as CTRL-C. Other than that, I don't know what he's referring you to in the help file.

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

  • Moderators

I have always taken it, as Yogi pointed out, that two or more base keys would not work - sorry if I was being vague. I know that you can set a hotkey for "!s", for example. But setting it for "!+" would not, or at least has never done so for me. I'm happy to be proven wrong though :) Perhaps it is simply a limit of the number of inputs it will take.

Example, this works fine:

HotKeySet("!s", "test")

While 1
Sleep(1000)
WEnd

Func test()
MsgBox(0, "", "Entered Test")
EndFunc

Whereas this does not:

HotKeySet("{DEL}{BS}", "test")
While 1
Sleep(1000)
WEnd

Func test()
MsgBox(0, "", "Entered Test")
EndFunc

Edit: horrible spelling

Edit2: Realized my non-working example was done wrong, sorry for the confusion.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

What it's saying is that you can't map a hotkey directly to just the CTRL/ALT/Shift key, you have to use one of them in combination with another key, such as CTRL-C. Other than that, I don't know what he's referring you to in the help file.

OK then, How would I do what I said above? Alt + Shift + DEL + Backspace ?

Link to comment
Share on other sites

I have always taken it, as Yogi pointed out, that two or more base keys would not work - sorry if I was being vague. I know that you can set a hotkey for "!s", for example. But setting it for "!+" would not, or at least has never done so for me. I'm happy to be proven wrong though :) Perhaps it is simply a limit of the number of inputs it will take.

Example, this works fine:

HotKeySet("!s", "test")

While 1
Sleep(1000)
WEnd

Func test()
MsgBox(0, "", "Entered Test")
EndFunc

Whereas this does not:

HotKeySet("!+", "test")
While 1
Sleep(1000)
WEnd

Func test()
MsgBox(0, "", "Entered Test")
EndFunc

Edit: horrible spelling

This works for me:(Alt +Shift+DEL)

HotKeySet("!+{DEL}")
Edited by althurm
Link to comment
Share on other sites

  • Moderators

But not when you combine "base" keys, those surrounded by {}. Try this out, it should enter the test function as soon as you it Del.

HotKeySet("{DEL}{BS}", "test")
While 1
Sleep(1000)
WEnd

Func test()
MsgBox(0, "", "Entered Test")
EndFunc
Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

But not when you combine "base" keys, those surrounded by {}. Try this out, it should enter the test function as soon as you it Del.

HotKeySet("{DEL}{BS}", "test")
While 1
Sleep(1000)
WEnd

Func test()
MsgBox(0, "", "Entered Test")
EndFunc

Not sure what you are getting at?

That code doesn't have any of the base keys or the modifier keys. From what it says I think the base keys are the F1 - F12.

But yes this code enters the function as soon as you hit DEL.

I want to enter after hitting ALT + SHIFT + DEL + Backspace

Link to comment
Share on other sites

I have always taken it, as Yogi pointed out, that two or more base keys would not work - sorry if I was being vague. I know that you can set a hotkey for "!s", for example. But setting it for "!+" would not, or at least has never done so for me. I'm happy to be proven wrong though :) Perhaps it is simply a limit of the number of inputs it will take.

Matter of fact the help file uses two modifier keys in the example

HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d
Edited by althurm
Link to comment
Share on other sites

  • Moderators

Ok, I think this is partly my fault for a poor explanation, and for that I apologize. The help file states that you cannot use two "base keys" - which would be any key you surround with {}. Any time you use two base keys, AutoIt will ignore the second one completely. For example:

{DEL}{BS} will react as soon as you hit {DEL}

{F1}{F2} will react as soon as you hit {F1}

{BS}{HOME} will react as soon as you hit {BS}

You can do a combination of base keys and normal modifiers, such as:

!{DEL}

+{BS}

^{HOME}

Thus, having {DEL}{BS} in your code is not going to work. Hope this clears things up for you.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Ok, I think this is partly my fault for a poor explanation, and for that I apologize. The help file states that you cannot use two "base keys" - which would be any key you surround with {}. Any time you use two base keys, AutoIt will ignore the second one completely. For example:

{DEL}{BS} will react as soon as you hit {DEL}

{F1}{F2} will react as soon as you hit {F1}

{BS}{HOME} will react as soon as you hit {BS}

You can do a combination of base keys and normal modifiers, such as:

!{DEL}

+{BS}

^{HOME}

Thus, having {DEL}{BS} in your code is not going to work. Hope this clears things up for you.

yup thanks

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