How to get the hotkey definition if a shortcut is pressed? - keyboard

For example, if I press Ctrl+Shift+Alt+C in this order, how I do get the corresponding hotkey definition?
I expect something like the following:
; pseudo code
*::MsgBox %A_ThisHotkey% was pressed

I don't really get what you mean, this
^+!c::MsgBox, % A_ThisHotkey
works just fine?
Or do you mean something like this?
Gui, Add, Hotkey, vHotkeyName
Gui, Add, Button, gPrintHotkey, % "Print Hotkey"
Gui, Show
return
PrintHotkey()
{
global HotkeyName
Gui, Submit, NoHide
MsgBox, % HotkeyName
}
GuiClose()
{
ExitApp
}
See the hotkey gui control.

Related

How do I bind Function keys to Buttons in tkinter?

I want to bind a function key to menu button like when i click F5 program ends, I used root.bind("<Function-5>", quit) but its wrong. Is there any other way of doing it, such that I can use commands when ever I click on F5 ?
Extracted from #TheLizzard comment,
You should use this to bind F5 in root :
root.bind("<F5>",quit)
You can learn about these for from here and here

What is the hotkey to navigate back to the line where a method is used?

When I left click the method in Android Studio with control button
_setInterval(_sliderValue);
it opens the method definition
Future<void> _setInterval(double foo) async {
...
print('interval saved');
}
Now, what is the hotkey to navigate back to the line where the method is used?
I think you can press ALT + F7 to see the method usage.
Or right click on the method and you will see a menu with the Find usage option.
Shortcut from here
Also, there is an option called Inlay hints that displays a few useful tips like usages, inheritors, problems
As I found out, to navigate back to the line where the method is using - use Ctrl+B shortcut or control click the method definition name.

How can I get a real-time input via keyboard module?

import keyboard
def printPressedKey(e):
print("key pressed : {}".format(e.name))
keyboard.hook(printPressedKey)
keyboard.wait('esc')
this code prints pressed keys when I press esc. I want to print pressed keys as I press keys. How can I do this?
EDIT
This happens only when you execute python via nppexec in notepad++ so you just execute it on the console. Sorry for everyone ;(
Use pyinput package, it works well for both mouse and keyboard
https://pypi.org/project/pynput/

How to simulate keyboard button in Bash

I have to simulate button press in my script.
I have a big application running in which I have to put some values in some fields and press enter so proceed to next panel and so on.
I got idea about simulating ENTER using echo "\n", but unable to find out how to simulate buttons like Function keys, arrow keys and pressing alphanumeric characters.
Any idea will be helpful
You can use expect to do this.

Changing focus with Autohotkey, what is going on?

I just want my script to select the right Window to input key storkes. To do this I think I use WinActivate. I ran the example from their site but found some strange results in Windows 10
IfWinExist, Untitled - Notepad
WinActivate ; use the window found above
else
WinActivate, Calculator;
If Notepad is minimized, it gets the focus
If Notepad is open but is not have the focus (i.e. another window is on top of it), Notepad gets the focus
If Notepad is not open and the calculator is minimized, for some strange reason it doesn't get the focus.
If Notepad is not open and the calculator is open but not have the focus, it gets the focus.
What is causing the inconsistency?
It happens because of the implementation of the WinActivate function on the language. WinActivate tries to open an window, but it might not be able to.
From the documentation
Six attempts will be made to activate the target window over the
course of 60ms. Thus, it is usually unnecessary to follow WinActivate
with WinWaitActive or IfWinNotActive.
Usually you can try the #WinActivateForce directive in combination with WinWaitActive or IfWinNotActive.
Sometimes you can use an ahk_exe parameter to match the window. It may work in cases where the window title doesn't. In this case you would use
Also it's useful to try restoring the window with WinRestore.
SetTitleMatchMode, 2
IfWinExist, Bloco de notas
{
WinActivate ; use the window found above
}
else
{
WinRestore, ahk_exe calc.exe
WinActivate, ahk_exe calc.exe
}
I'm on Win7, but the above worked for me.
Here is an example of a good and complete implementation of a function that tries to activate a window.
Semicolons introduce comments in AHK. There has to be a white space before it, otherwise it's seen as part of the string (alias winactivate "Calculator;")
so, use
WinActivate, Calculator ;
or just omit the ;, for it doesn't contribute anything

Resources