Send keys from Icewind Dale 2 to a background program

Ask gaming related questions (AHK v1.1 and older)
Aquinax
Posts: 13
Joined: 18 Jun 2016, 08:16

Send keys from Icewind Dale 2 to a background program

18 Jun 2016, 08:26

Need to send simple commands to a media player, an inactive program, from Icewind Dale 2. ControlSend does not send through the keyboard commands to the player, although disables the remapped keys in IWD 2. The code I tried is:

Code: Select all

#IfWinActive, ahk_class ChitinClass
Right::ControlSend, , {Right}, ahk_class COWON Jet-Audio MainWnd Class
Left::ControlSendRaw, , {Left}, ahk_class COWON Jet-Audio MainWnd Class
#IfWinActive
return
All I need is to be able to fast forward/rewind an audio track as I listen to some radio programs, when playing.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Send keys from Icewind Dale 2 to a background program

20 Jun 2016, 06:31

I assume ahk_class ChitinClass is IWD?

What you need to establish is:

1) When you hit the hotkey in IWD, does AHK see the hotkey being pressed?
To verify this, replace the controlsend with a msgbox.
If no for (1), run the script as Administrator.

2) When you hit the hotkey while notepad is the active application, does the controlsend to the inactive media player work?
If (2) is not true, the problem is nothing to do with IWD. Running as admin may also fix this.

3) Do these hotkeys work if you change the controlsend to a regular send, and have the media player active?
If not, try adding SetKeyDelay, 0, 50 to the start of the script.

So work out what part is not working, then let us know and we can maybe figure out what the problem is.
Aquinax
Posts: 13
Joined: 18 Jun 2016, 08:16

Re: Send keys from Icewind Dale 2 to a background program

22 Jun 2016, 04:22

Thanks, evilC,

I've tried what you advised and these are the results:

1) All tests have been run with AH script launched "as Admin". The Msgbox command is being successfully sent through - the game window is minimized and the message box is displayed.

2) No, the commands aren't executed when the notepad is active. Although the specified commands are still being executed after the "Ok" button of the message box has been pressed and while no other window is active.

3) Having put "Send" instead of "ControlSend", the command is being sent through and executed in the player.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Send keys from Icewind Dale 2 to a background program

22 Jun 2016, 05:40

So it sounds like the problem is not the game but the ControlSend not being directed to the correct place. I would suggest forgetting about the game for the moment and try to get the code working while notepad is the active application.

Bear in mind also, that if using code like this:

Code: Select all

#IfWinActive, ahk_class ChitinClass
Right::ControlSend, , {Right}, ahk_class COWON Jet-Audio MainWnd Class
Left::ControlSendRaw, , {Left}, ahk_class COWON Jet-Audio MainWnd Class
#IfWinActive
... the hotkeys will not trigger while in notepad.

Are you 100% sure your window titles are correctly formed? Try using the same window title with a winactivate or similar command to make sure it is operating on the correct window.
Aquinax
Posts: 13
Joined: 18 Jun 2016, 08:16

Re: Send keys from Icewind Dale 2 to a background program

20 Jul 2016, 13:55

evilC wrote: ... the hotkeys will not trigger while in notepad.
evilC, sorry for being away ... , I'm still interested in getting 'ControlSend' work. Why are you saying the hotkeys will not trigger?
evilC wrote: Are you 100% sure your window titles are correctly formed? Try using the same window title with a winactivate or similar command to make sure it is operating on the correct window.
The program, which should receive the key commands, is Jet-Audio, its ahk_class is: COWON Jet-Audio MainWnd Class and WinActivate does activate it, when sent from Notepad:

Code: Select all

#IfWinActive, ahk_class Notepad++
!Right::
WinActivate, ahk_class COWON Jet-Audio MainWnd Class
#IfWinActive
return
but ControlSend does NOT work. Any idea why?
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Send keys from Icewind Dale 2 to a background program

20 Jul 2016, 15:27

Aquinax wrote:evilC, sorry for being away ... , I'm still interested in getting 'ControlSend' work. Why are you saying the hotkeys will not trigger?
I think I was referring to the hotkeys wrapped in #IfWinActive, ahk_class ChitinClass - obviously, Notepad is not of class ChitinClass
Aquinax wrote: The program, which should receive the key commands, is Jet-Audio, its ahk_class is: COWON Jet-Audio MainWnd Class and WinActivate does activate it, when sent from Notepad:

Code: Select all

#IfWinActive, ahk_class Notepad++
!Right::
WinActivate, ahk_class COWON Jet-Audio MainWnd Class
#IfWinActive
return
but ControlSend does NOT work. Any idea why?
Yeah, I had a similar problem myself today with a browser window, couldn't work it out either. In the end, I just got the hwnd of the active window, activated the window to send to, sent the keys, then switched back to the window that I stored the hwnd of at the beginning.

Did you try using ahk_parent in the Control param (That's currently blank) of ControlSend?

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: DianeWREWS and 67 guests