Results 1 to 7 of 7

Thread: SendKeys not working using Midi Data to HotKeys conversion

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    SendKeys not working using Midi Data to HotKeys conversion

    Greetings,

    I am currently developing a program called Midi2Logix. Its primary intent is to capture Midi data, assign that data a "Key" value that is sent to a program that has HotKeys enabled. Here's the workflow:

    1. Midi Output (ProPresenter or DAW)
    2. LoopMidi + RTPMidi on two machines allowing for Virtual Instruments and connecting the two PCs.
    3. Midi2Logix - converts, from PC1, the midi data into preset HotKey values to PC2.
    4. OBS - receives the HotKeys.

    A. Midi Output - Success
    B. Midi connection over IP - Success
    C. Midi2Logix receiving and converting data - Success
    D. OBS has HotKeys configured, is Always on Top but has less than a 30% success rate in actually firing the HotKey.

    Things I've noticed:
    I've tried almost every method in getting this to work. I bring focus to the OBS App by filename, title, and mouse-click. When the midi signal is received it reads a very small (less than 30 entries) xml file to verify the <presets> node and then display the value when the initial midi code is received. I immediately see the OBS window get focus but the SendKeys event has to be fired multiple times and randomly in order to work. I've tried wait times thinking it was firing the sendkey prior to finding focus. I've used not only sendkeys but the AutoItv3 reference. Neither work well. I've used the same methods against notepad and word and it works flawlessly firing the sendkeys perfectly. There's just something in OBS that's causing an issue.

    OBS doesn't require it to have focus to receive physical keyboard input to fire hotkeys.

    One thing that was very interesting. The only thing I am doing is using midi notes to change the scenes I've setup in OBS. When I first start the OBS app and I TAB 17 times and then fire the HotKey to change the scene it works every time.

    AutoItV3 has an app that allows you to get information on an app using a tool finder. It gives basic information like the app title and such. One of the interesting things is it shows different classes. Almost like it's able to tell the difference between the windows/controls. I wonder if there's a way to bring focus specifically to the scenes window and it fire the HotKeys properly. It's just so strange that it works for all other apps but this one.

    I've tried running both My App and the OBS app as administrator wondering if it was a UAC issue. No luck.

    There's been some chatter online regarding Windows 64 bit handing app focus differently but it's not very clear, to me, the issue or solution.


    So, here's my final, is there anyone who would be interested in seeing the entire solution to help me resolve my issue?
    If there's someone willing to help look at the project I have no issues posting the specific code(s) needed for the desired result for educational purposes should anyone need similar help. Just don't want to post incorrect code if no one is very interested.

    A couple of disclaimers: I'm not a developer. I do this as a hobby and passion with utmost respect for those who truly know what they're doing. Also, I'm not doing this program for financial gain. This will only be used by me to make my life easier, hopefully, at work.

    If you've made it this far, thank you.

    Name:  screenshot.jpg
Views: 253
Size:  20.9 KB

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: SendKeys not working using Midi Data to HotKeys conversion

    Are you clicking a button remotely? Try using Spy++ to identify the button if so. You'll need FindWindow, FindWindowEx, and SendMessage for this method

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Re: SendKeys not working using Midi Data to HotKeys conversion

    Under the "Run Presets" column on the right, the Multi-line text box receives the MIDI values. Once this is done it checks the local XML file for the same value in a child node. If found, the second child node sends the associated converted value to the SendKeys function.

    Code:
    Imports Imports AutoItX3Lib
    
    Dim au as New AutiItV3
    au.send("converted value typed here")
    au.send("{ENTER}")
    or I've tried

    Code:
    SendKeys.Send("converted value typed here")
    SendKeys.Send("{Enter}")
    I can use the below code to activate a particular .exe using appactivate and it works in apps like Word, Notepad, Webpages, etc. Except OBS. Only sometimes.

    Code:
    AppActivate("appname.exe")

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: SendKeys not working using Midi Data to HotKeys conversion

    You're using AppActivate wrong...

    Code:
    AppActivate("your app titlebar text")

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: SendKeys not working using Midi Data to HotKeys conversion

    Alternatively...

    Code:
    AppActivate(your app mainWindowHandle)

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Re: SendKeys not working using Midi Data to HotKeys conversion

    Actually, I'm not using it wrong. I posted it here wrong by mistake. I'm aware of the app title. I've used the title, class, instance, current process id. The issue isn't bringing focus to the app window.

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: SendKeys not working using Midi Data to HotKeys conversion

    So where in the app do you want to sendkeys to? It would be better with FindWindow, FindWindowEx, and SendMessage, assuming it’s a textbox you’re trying to put data into...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width