Page 1 of 1

Simulating mouse clicks

Posted: 09 Jul 2020, 05:50
by Ian
Hi Everyone

I'm not much of a programmer and I'm visually impaired – double whammy :-)

I'm part of a group of visually impaired musicians who use, among others, software called Kontakt.

You load the Previous and Next instruments by clicking on tiny back and forwards arrows which is obviously very difficult for us and impossible for the totally blind. Unbelievably, there are no shortcut keys for this.

I trawled the web and found a script on a forum but the poster failed to respond to questions so has probably disappeared.

I've tried to get it to work by messing with various settings but failed.

One thing – he was using an earlier version of Kontakt which had "Kontakt 5" in the window header. The current version only has "Kontakt".

I am also not sure where the coordinates are measured from or how to find them.

Would really appreciate any help.

I'm just copying one bit of the script. If this works I hope I can amend the rest.

Thank you,


Code: Select all

;Press F9 to click PREVIOUS MULTI in Kontakt Window.

IfWinExist, Kontakt 5 (x86 bridged)
WinActivate ; Automatically uses the window found above.
MouseClick, left, 708, 152

Re: Simulating mouse clicks

Posted: 09 Jul 2020, 06:13
by gregster
Welcome to the AHK forums!

Just quick a guess: Try to shorten the line IfWinExist, Kontakt 5 (x86 bridged) to IfWinExist, Kontakt

Re: Simulating mouse clicks

Posted: 09 Jul 2020, 06:15
by BoBo
Hi Ian,

a) simply change the IfWinExist-command WindowTitle parameter (that is its first parameter) to match with your current setting, means "Kontakt" as you've mentioned before.
b) coordinate settings could vary, based on the default that can be changed using AHK's CoordMode-command which says:

"Sets coordinate mode for various commands [like the coords of your MouseClick] to be relative to either the active window or the screen"
"If this command is not used, all commands except those documented otherwise (e.g. WinMove and InputBox) use coordinates that are relative to the active window."

Hope that helps. Btw, my handicap is the English language. So I leave more detailed explanations for the native speakers. Good luck :)

PS. AHK member @gerard is writing scripts that seem quite similar to your challenge. It might make sense to get in touch with him.

PPS. for those who are interested I've found the full script Ian mentioned above. To update the script it might make sense to replace the deprecated IfWinExist-command with its successor, the WinExist() function:

I'm sure Ian is aware of that, so it's for whom it may concern AKA for the records:

Code: Select all

Welcome to Access4Music.

This website is built with visually impaired people in mind: in fact, here you can find little scripts and utilities that will help in producing music using a daw (Digital audio workstation) and other professional mainstream products.

About us
We are two Italian visually impaired computer science students with a passion for music and we believe that any software should be able to be used by anyone who wishes to do so, even though this might require some extra work in regards to accessing its controls or navigating its interface. That is why we decided to build some tools that try to help to achieve this goal.

Our access solution
Blind and visually impaired people use screen reading software to read the information software provides, but a screen reader alone unfortunately is not enough especially when it comes to vsts, or software which makes use of bitmap/non-standard controls for its interfaces. Therefore we thought of an external access solution that will function as a bridge between the inaccessible software and the screen reader; in fact, we developed some scripts that allow you to access those controls a screen reader can't intercept properly by using AutoHotkey, a custom scripting language for Microsoft Windows, initially aimed at providing easy keyboard shortcuts or hotkeys, fast macro-creation and software automation that allows users to automate repetitive tasks in any Windows application. Thanks to its automation ability we could create functions and macros that allow us to move to buttons on the screen and click them.
Another very cool and handy feature [b]AutoHotkey[/b] gives us is the fact that the programs we create are screen reader independent; this means that you can use whichever screen reader you have, as long as your daw is supported.
Visit our scripts page to find out more about the scripts we created and how to get them.

Re: Simulating mouse clicks

Posted: 09 Jul 2020, 07:30
by Ian
Hi BoBo - your English is better than mine :-)

It's nice to know that the script SHOULD work :-)

The commands should be relative to the active window so no changes required there.

I've removed a " 5" from the title but can't tell if anything is working or trying to 'click' when I press a key.

I've found references to 'relative' coordinates but how do you find the coordinates of a specific area of the screen?

PS: I looked at Access4Music. There are two scripts which might have been useful but neither worked. They are old, too, I think. They run via .exe so I couldn't see what they were doing.

Re: Simulating mouse clicks

Posted: 10 Jul 2020, 10:59
by Ian
Ok Guys - I've sussed it :-)

The original used some older functions and it just didn't seem to click at all.

Updated with new functions. Needs a few tweaks but it works! :-)

Re: Simulating mouse clicks

Posted: 10 Jul 2020, 11:36
by BoBo
Sharing your script could help others too, and tweaking/squeezing (your) code is some forum members' favorite thing. So, where is it? ;)

Re: Simulating mouse clicks

Posted: 10 Jul 2020, 13:58
by Ian
BoBo wrote:
10 Jul 2020, 11:36
Sharing your script could help others too, and tweaking/squeezing (your) code is some forum members' favorite thing. So, where is it? ;)
All run of the mill stuff to users but it took me 3 days to get this far.

I used this to find the coordinates:

Code: Select all

MouseGetPos, xpos, ypos 
MsgBox, The cursor is at X%xpos% Y%ypos%.

And then this:

Code: Select all

SetTitleMatchMode 2

;Press F11 to click PREVIOUS INSTRUMENT in Kontakt Window.

if WinActive("Kontakt")
Click, 871, 154


;Press F12 to click NEXT INSTRUMENT in Kontakt Window.

if WinActive("Kontakt")
Click, 889, 154

This works in the standalone version of Kontakt but only if the library doesn't eexpand the window. I guess this could be catered for.

However, it doesn't work when Konttakt runs in Komplete Kontrol as it them uses a different way to change instruments.

It also doesn't work when running as an instrument in Cubase as, for whatever reason, it changes the window size and also the window name. Both could be compensated for.

I'm sure some clever person could cater for everything in one script but I'm happy to be able to do this.

I might try to cater for the expanded window but I'll check how many libraries do that first.

It would also be useful to be able to step through instruments in Kontakt/Komplete in Cubase but one thing at a time... :-)