Windows application is not accepting keypresses sent from Autohotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mahaju
Posts: 1
Joined: 15 Apr 2021, 10:24

Windows application is not accepting keypresses sent from Autohotkey

15 Apr 2021, 10:54

I am trying to play a virtual piano program (https://www.everyonepiano.com/Software.html) by sending keystrokes from AHK. It is the type of program where piano keys can be played by pressing key on the keyboard. Each keyboard key is mapped to some particular key on the virtual piano.

When the window is in focus, pressing the k, l, or ; key on the keyboard (standard USB windows English keyboard) should play specific keys on the piano

I am trying to send these keypresses through AHK

Here is the code I am using for reference:

Code: Select all

$z::
	KeyWait, z, T0.1
	
	if (ErrorLevel)
		Send long

	else {
		KeyWait, z, D T0.1

		if (ErrorLevel)
			; Send kl;
			SendRaw kl;
			; SendInput kl;
			; SendPlay kl;
			
		
		else
			Send double
	}

	KeyWait, z
return
In notepad, if I short press the z key on the keyboard, it prints out kl;, so the autohotkey installation seems to have worked correctly. But if I bring focus on the virtual piano software window and short press z, it just plays the piano key corresponding to the z key on the keyboard. It seems the app is completely ignoring AHK.

What could be the issue here? Do I need to use a different function than Send? I am a beginner to Autohot key.
I am using AutoHotkey_1.1.33.05 (portable zip file version), I use AutoHotkeyU64.exe to start AHK, Windows 10 Pro ver 1909 Build 18363.1440

Edit:
I have been looking around and it seems this could be related to some Windows permission issues (not sure about it)
I have tried running a cmd window as Administrator and I start Autohotkey from command line as
D:\ahk_folder\AutoHotkeyA32.exe D:\path_to_script_file\myscript.ahk
However, this doesn't fix the problem. What else can I do? Will doing a full install of Autohotkey fix this?
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: Windows application is not accepting keypresses sent from Autohotkey

15 Apr 2021, 12:46

The way to run your script as administrator is to right-click on the script file in File Explorer and select "Run as administrator." If that works, then there are ways to have your script run itself as administrator every time.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: makdc96, RandomBoy, Rohwedder and 175 guests