Two scripts

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Samc
Posts: 5
Joined: 29 Aug 2017, 12:30

Two scripts

29 Aug 2017, 12:38

Hi,
I am using the neo 2 keyboard layout which is implemented as autohotkey script.
The problem i am facing now: other ahk scripts don't see the modified keycodes from the script, means they don't see the layout i am using.

Is there a way to bind other scripts to the output of another script? So that the second script sees the"correct" keycodes?

Thanks,
Simon
User avatar
Cuadrix
Posts: 236
Joined: 07 May 2017, 08:26

Re: Two scripts

29 Aug 2017, 17:31

See Include

Have your "Keyboard layout" script included in your other scripts. That way your scripts will recognize your layout..

Example "Keyboard layout" script:

Code: Select all

Your code...
Now include the "Keyboard layout" script in your other script.

Code: Select all

#Include, Keyboard_Layout_Script.ahk ;Just place your includes at the top of the script

Some code here... ; Your code/script should now recognize the layout
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Two scripts

29 Aug 2017, 17:53

You may need to make your Keyboard_Layout_Script use SendLevel higher than the default, so that it can trigger other hotkeys.
Samc
Posts: 5
Joined: 29 Aug 2017, 12:30

Re: Two scripts

18 Sep 2017, 08:19

Hi,
finally I was able to dig into that further.
The issues isnt that the keys dont get detected, that works as it should.

But very odd to me, the problem is the #IfWinExists at the top.

#IfWinActive ahk_exe test.exe

This works perfectly if the other script is not running in the backgroud. But as soon as it is running, the condition seems to be never true.

What can I do about this?

Thanks,
Simon
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Two scripts

18 Sep 2017, 09:22

If you can share your code, that would be helpful. I'm not seeing how the #IfWinActive stops being true because another script has been launched, 'less that script is the active window (such as with a GUI).
Samc
Posts: 5
Joined: 29 Aug 2017, 12:30

Re: Two scripts

20 Sep 2017, 10:41

Hi,

my script can be broken down to this:

Code: Select all

#IfWinActive, ahk_exe dxp.exe

; single layer mode
ä::Send S
The keyboard layout is a pretty complex project, it can be found here:https://wiki.neo-layout.org/browser/windows/neo-vars

I certainly checked with the "Windows Syp", it reports what I expect. As soon as I unload the layout script, the "ä" key works again. It also does if the layout IS loaded but the #IfWinActive is commented out...

Thanks,
Simon
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Two scripts

20 Sep 2017, 15:04

What program is dxp.exe? I've never heard of it.

But if it has an active window, like you would see a Notepad or a Google Chrome or Mozilla Firefox or a Microsoft Word window, then does the ä key produce the S? Because I'm thinking what you really want is #IfWinExist, ahk_exe dxp.exe and you may need to use DetectHiddenWindows, On in your auto-execute section.

Now, you're mentioning multiple scripts here, which is getting me confused since only one was provided -- I'll assume that neo-vars layout is made into the second AHK script. But I'm kind of suspecting if you launch your new Keyboard Layout script after you launch this other AHK script, it should work, since the layout script would take priority in intercepting keys. But again, SendLevel needs to be involved.
Samc
Posts: 5
Joined: 29 Aug 2017, 12:30

Re: Two scripts

21 Sep 2017, 08:59

Hi,

dxp is circuit studio, a PCB layouter software.

But there is nothing wrong with the ahk_exe dxp.exe, because as long as the keyboard layout is NOT loaded, it works as expected.

About #ifwinexists: my goal is that the ä key is only mapped when the dxp.exe is currently active. And again, this works nicely without the keyboard layout loaded.

The weired thing is, that is soon as the layout IS loaded, the condition does not come true again, while it did before.
Its not about the keymapping: if I comment out the condition, than it works, but surel in all windows (which is not very desirable)

The keyboard layout is a big project, consisting of many files. Way beyound my knowledge about ahk.

Oh, and it doesnt matter in what order I launch the scripts: the condition does not come true if both are loaded.

So I would be happy for any clue on how to proceed from here...

Thanks,
Simon
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Two scripts

21 Sep 2017, 09:04

my goal is that the ä key is only mapped when the dxp.exe is currently active.
So, what about to check for its Process instead?
Samc
Posts: 5
Joined: 29 Aug 2017, 12:30

Re: Two scripts

22 Sep 2017, 11:07

Hi,

Code: Select all

Process, exist, dxp.exe
NewPID = %ErrorLevel%
saves the PID correctly.
But that does not tell me if the program is currently in foreground...

Is there another command than IfWinActive to check for this?

Thanks,
Simon

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jollyjoe and 324 guests