How to detect the key sent by AHK in a C# program - autohotkey

I am using AHK to send keys. Then I want to use a C# program to detect this key.
In AHK, I am using Send {f} and In the C# program, I am using the GetKeyState(vk_f) function from user32.dll.
But the GetKeyState cannot get the f key press.
Is it because GetKeyState() from user32.dll only can capture physical key press?

Related

How do Bind a key or mouse click to the fn key (autohotkey)

So I am working with an old windows vista and to decrease the volume you need to press fn + the up or down arrow key. I'm stuck trying to figure out how to find the key for the fn key but some of the methods I try don't work. I want to bind it to the mouse scroll, the normal soundset doesn't work for some reason the computer is an acser extenssa 5220. Anymore questions I will answer down bellow. I'm thinking about downloading a program to remap the keys on the vista, but then I still don't if that and autohotkey will work.
You don't send the FN key because Windows doesn't actually even know of such a key. The FN key is processed by your keyboard. So what's sent to Windows is actually just the multimedia key, in your case volume up/down.
In AHK you can send the keys like this: SendInput, {Volume_Up}.
Alternatively you could use SoundSet.

AutoHotKey function to perform File-Rename without relying on sending F2 key code

I want define a custom hotkey to rename a selected file in File Explorer. So my new hotkey should behave exactly like the F2 key does by default. That is, when I press the hotkeys, the file name should be editable, allowing me to type a new name. However, I can't use the F2 key to cause windows to do this.
The reason is that I'm using the default hotkeys for something else. I am often running an application (unrelated to AutoHotKey) where the buttons in the UI are triggered using keyhooking for all of the F keys. The only suggestions that I can find on this are to have my custom hotkey use 'send' to raise the default key codes that would be associated with the action. This won't work, because I am using those hotkeys for something else. What I need is a solution that causes a file to be renameable without sending the F2 keycode.
^+!R::
Send {F2} ;This won't work for me
return
Actually the original hotkey can be used, just add $ before the hotkey that you don't want to be fired by the send command. Also using app-specific hotkeys a good idea to minimize possible conflicts.
Try this:
#If winActive("ahk_exe Explorer.EXE")
^+!R::
send {F2}
return
$F2::
send {down}
return
In case you have an application which scans the F2 key globally and unconditionally, and you cannot redefine it, there is not much you can do from within AHK. So ideally you should get rid of that application, and use e.g. AHK for same functionality, or find some workaround.
In this particular case the easiest workaround is alternative way to rename the file:
^+!R::
send {AppsKey}
sleep 100
send {m}
return

Sending keys from ahk so ahk registers them

Is it possible to Send key strokes (e.g., ctrl+alt+b xyz) using ahk and have activated corresponding hotkey ?
E.g., I have ^!b:: that shows MsgBox. I have ^!c:: from which I'd like to Send, ^!b and I want ^!b:: code to be activated.
My goal: I have various hotkeys in combination with Input. I want to have a hotkey to repeat last command.
Thank you

AutoHotkey SendInput Problems

[Key Mappings of New Media Remote]
http://i.stack.imgur.com/ivMSK.png
Using AutoHotkey I want to interrupt Keyboard Keys sent like AppsKey and Browser_Home and send another key instead. Unfortanately the best I can manage is to send a key as well as the key function.
F3::SendInput {a}
Browser_Home::SendInput {a}
Browser_Home::SendInput a
Browser_Home:: a
The first line 'F3 to a' works as intended; the F3 Key outputs the letter a.
The 2nd and 3rd line Browser_Home only launches Browser to Home.
The 4rd line launches the Browser_Home as well as outputting the letter a.
Anyone know what I'm doing wrong / know how to fix my script to output a without launching browser to home?
According to documentation under Hotkey:
$ is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise
cause it to trigger itself. The $ prefix forces the keyboard hook to
be used to implement this hotkey, which as a side-effect prevents the
Send command from triggering it. The $ prefix is equivalent to having
specified #UseHook somewhere above the definition of this hotkey
Try this and report back: $Browser_Home::SendInput {a}

What is the key scan code of the Fn key for use in AutoHotkey (AHK)?

I want to use Fn+S to emulate Ctrl+S, and so far this is my code:
#InstallKeybdHook
#Persistent
SC126 & s::
Send ^{s}
return
My problem is that I don't know the Fn key's scan code.
How can I find it?
The Fn key does not have a scan code.
The keyboard driver does not expose the Fn key to the operating system, so basically your operating system (and therefore AutoHotkey) does not know that it exists.
When you press the Fn key in combination with a supported key, the keyboard driver reports a single key press to the operating system with a different scan code. Basically, it tells the operating system that a different key was pressed.
When you press the Fn key in combination with a supported key, the keyboard driver reports the presses to the operating system (Windows in this case).
You can find the Fn key scan code by:
Go to the tray icon
Right-click Script
Click Open
Click View and then Key History and Script Info (alternatively Ctrl + K)
Once you press the key, you can refresh (F5) and scroll to the bottom to see the codes
If you're trying to use a Mac keyboard and would like to map the Fn key to Insert (and also get other standard Windows keys, like PrintScreen), then you might want to try the 'hidfalum' driver. It's available here: http://www.bimoid.com/download/utils/hidfalum.zip