Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
JuicyT
Posts: 18
Joined: 21 May 2023, 06:20

Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Post by JuicyT » 27 May 2023, 00:05

( this is only one of many, and this seems to be a thing in music production programs )

It does not seem to respond to any commands https://vmpk.sourceforge.io/#Download

I am assuming after figuring this one out, the other ones start to work as well

All your help is much appreciated

Descolada
Posts: 1105
Joined: 23 Dec 2021, 02:30

Re: Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Post by Descolada » 27 May 2023, 01:30

It's a Qt app, so regular AHK methods won't work with it. One way would be to use ImageSearch, FindText, or other image-finding methods to locate elements and click.

Another way would be to use UIAutomation. For example, download UIA_Interface.ahk from the provided link and put it in the same folder as the following script:

Code: Select all

#include UIA_Interface.ahk

WinActivate Virtual MIDI Piano Keyboard

UIA := UIA_Interface()
vmpk := UIA.ElementFromHandle("Virtual MIDI Piano Keyboard")

channelRange := vmpk.FindFirstByName("Channel:").FindByPath("+1") ; Finds the label named "Channel" and then gets the next element which is the actual range element
channelRange.Highlight()
channelRange.Value := 2

vmpk.FindFirstByName("Reset All").Highlight().Click() ; click the Reset All button
ExitApp

JuicyT
Posts: 18
Joined: 21 May 2023, 06:20

Re: Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Post by JuicyT » 29 May 2023, 09:28

Descolada wrote:
27 May 2023, 01:30
It's a Qt app, so regular AHK methods won't work with it. One way would be to use ImageSearch, FindText, or other image-finding methods to locate elements and click.

Another way would be to use UIAutomation. For example, download UIA_Interface.ahk from the provided link and put it in the same folder as the following script:

Code: Select all

#include UIA_Interface.ahk

WinActivate Virtual MIDI Piano Keyboard

UIA := UIA_Interface()
vmpk := UIA.ElementFromHandle("Virtual MIDI Piano Keyboard")

channelRange := vmpk.FindFirstByName("Channel:").FindByPath("+1") ; Finds the label named "Channel" and then gets the next element which is the actual range element
channelRange.Highlight()
channelRange.Value := 2

vmpk.FindFirstByName("Reset All").Highlight().Click() ; click the Reset All button
ExitApp
thank you, did not understand how to make it work though

LAPIII
Posts: 667
Joined: 01 Aug 2021, 06:01

Re: Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Post by LAPIII » 31 May 2023, 06:26

JuicyT wrote:
29 May 2023, 09:28
did not understand how to make it work though
You need UIAViewer.ahk. With this tool you can get the Path, property, or value of any element in an app, just press F1 and move your cursor over an element
I suggest you read the wiki on how to use the library.

JuicyT
Posts: 18
Joined: 21 May 2023, 06:20

Re: Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Post by JuicyT » 01 Jun 2023, 01:23

LAPIII wrote:
31 May 2023, 06:26
JuicyT wrote:
29 May 2023, 09:28
did not understand how to make it work though
You need UIAViewer.ahk. With this tool you can get the Path, property, or value of any element in an app, just press F1 and move your cursor over an element
I suggest you read the wiki on how to use the library.
thank you, one thing about github... um, is there any instructions how and where to place a file anywhere on github ?

JuicyT
Posts: 18
Joined: 21 May 2023, 06:20

Re: Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Post by JuicyT » 01 Jun 2023, 04:24

JuicyT wrote:
01 Jun 2023, 01:23
LAPIII wrote:
31 May 2023, 06:26
JuicyT wrote:
29 May 2023, 09:28
did not understand how to make it work though
You need UIAViewer.ahk. With this tool you can get the Path, property, or value of any element in an app, just press F1 and move your cursor over an element
I suggest you read the wiki on how to use the library.
thank you, one thing about github... um, is there any instructions how and where to place a file anywhere on github ?
and thanks again, checking the wiki

LAPIII
Posts: 667
Joined: 01 Aug 2021, 06:01

Re: Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Post by LAPIII » 01 Jun 2023, 04:26

Installing Autohotkey created a folder in "C:\Documents". In that folder I have two other folders called Lib and Scripts. UIA is in Lib and UIAViewer in Scripts. In a script, I can call the library using #Include <UIA_Interface>.

Does this answer your question?

JuicyT
Posts: 18
Joined: 21 May 2023, 06:20

Re: Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Post by JuicyT » 01 Jun 2023, 04:55

LAPIII wrote:
01 Jun 2023, 04:26
Installing Autohotkey created a folder in "C:\Documents". In that folder I have two other folders called Lib and Scripts. UIA is in Lib and UIAViewer in Scripts. In a script, I can call the library using #Include <UIA_Interface>.

Does this answer your question?
Hi there, yeas it does thank you

I am wondering what am i doing, or not doing, when as soon as i press f1, this message comes up ( running the UIAVieiwer in the folder )


uia.png
uia.png (52.32 KiB) Viewed 627 times

LAPIII
Posts: 667
Joined: 01 Aug 2021, 06:01

Re: Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Post by LAPIII » 01 Jun 2023, 06:29

I've got no idea. It works fine for me. Are you sure if you have both complete scripts? If you do then I guess you just have to ask @Descolada.

JuicyT
Posts: 18
Joined: 21 May 2023, 06:20

Re: Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Post by JuicyT » 17 Jun 2023, 04:00

LAPIII wrote:
01 Jun 2023, 06:29
I've got no idea. It works fine for me. Are you sure if you have both complete scripts? If you do then I guess you just have to ask @Descolada.
Thank you, yes they are in the same directory

or just to double check, what scripts do you mean are in the same directory or not ?

LAPIII
Posts: 667
Joined: 01 Aug 2021, 06:01

Re: Can somebody tell me how could i automate anything on this program ( virtual midi keyboard ) ?

Post by LAPIII » 17 Jun 2023, 12:32

I'll give you an example of a library is scripted the same directory:

C:\Users\LPIII\OneDrive\Documents\Autohotkey\Lib\UIA.ahk
C:\Users\LPIII\OneDrive\Documents\Autohotkey\AHK Scripts\Apps\YouTube.ahk


When you have the library in this directory, called the User library, you can include the library in scripts with #Include <UIA_Interface>.

Post Reply

Return to “Ask for Help (v1)”