Forum

Results 1 to 3 of 3
  1. #1
    Join Date
    November 2015
    Location
    Florida, USA
    Posts
    2

    User Hotkey Capture / Registration

    I am attempting to write a teamspeak plugin using the SDK using C# and Visual Studio.

    The first part of the process was to develop the user interface, which is nearly complete. I am sure the next part, integration with ts, will be harder, but am nonetheless stuck with the UI.

    My user is to register three hotkeys with windows using the windows api user32.dll as set out below.

    [DllImport("user32.dll")]
    private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);

    I have tried to replicate the ui in the ts client Setting/Options/Push to Talk button, with a button that when pressed launches a gray box and a listener, which stores the keys pressed and then repeats inside the button.text.

    To achieve this I am using the KeyPress event which delivers KeyPressEventArgs. This looks first for the modifiers (SHF/ALT/CTRL/WIN) and then the key.

    THIS ALL WORKS FINE WITH SHF, BUT GIVES NO KEY WITH THE OTHER MODIFIERS.

    I wonder if someone familiar with the ts client source could tell me which of the windows procedures they use for hotkey capture. I am currently just logging away with protected override bool ProcessCmdKey(ref Message msg, Keys keyData) and protected override void WndProc(ref Message keyPressed) to see from the log files if I can identify the logic to use to achieve the goal. As I perform this mindless work, it occurred to me to ask you all for a pointer. It cannot be that hard!!

    Many thanks

    Durham

  2. #2
    Join Date
    September 2012
    Posts
    6,076
    Why not just let TeamSpeak handle your hotkeys?

    You simply tell TeamSpeak which Hotkeys are available from your plugin in the ts3plugin_initHotkeys function that will get called by the client when your plugin is loaded. You can specify a description and an internal name for the hotkey that will be used to identify the hotkey within your plugin. The name should be unique.

    When your user clicks the button to assign a hotkey in your UI (or does whatever else is required to assign a hotkey in your UI), you simply call ts3plugin_requestHotkeyInputDialog with the internal name of the hotkey you want to have the user enter a key (combination) for, which will open up the gray box, where the user can then press buttons for the action you specified by the parameters to the function call. It will then automatically get entered into the TeamSpeak clients' hotkey list in the options dialog. Once the user pressed a hotkey there and it was accepted and entered, the client will call ts3plugin_onHotkeyRecordedEvent with the name of the hotkey and the key sequence the user chose, so you can use this to store it internally (if needed) or display it in your UI.
    The client will also call the callback function ts3plugin_onHotkeyEvent whenever the user pressed the hotkey, giving you your internal name of the hotkey as a parameter. You can then execute the desired functionality of that hotkey.

    It should be far easier and much more compatible than messing with the clients' GUI and doing all the hijacking.

    It is to note though that, since TeamSpeak handles your Hotkey things and integrates your plugin into its own UI (in terms of hotkeys), your plugin hotkeys can also be set and changed from the clients' option dialog without your code being informed about that. However this isn't much of a problem as all the technicalities will be handled from the client itself, the only issue is that if you're displaying the Sequence for the hotkey in your own UI as well. In that case it won't be up 2 date unless you call getHotkeyFromKeyword, which will let you query the current key assignments for your hotkeys from the client.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  3. #3
    Join Date
    November 2015
    Location
    Florida, USA
    Posts
    2
    Chris.

    Thank you for your kind reply. What an idiot I am! Unfortunately, by the time I read your response I had invested my Thanksgiving holiday in replicating your register hotkey module. For reference, I used the following:

    [DllImport("user32.dll")]
    public static extern short GetAsyncKeyState(int vKey);

    and looped through the 255 keys to return and ascii code and a key for each of the hotkeys. This was then registered with Windows and unregisted on form close, as well as displayed back to the user. All seems "good enough for government work" although it is still not quite as smooth as your implementation!

    I am now moving onto the Teamspeak SDK and learning all about C++ wrapper classes, so that I can call the functions from C#. Oh what fun!

    Thanks again.

    Durham

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Resolved] Hotkey registration
    By Pixinger in forum Client Plugins / Lua Scripts
    Replies: 7
    Last Post: February 4th, 2014, 10:55 AM
  2. [Resolved] Is it possible to assign a hotkey to switch voice capture modes?
    By Pellit in forum General Questions
    Replies: 8
    Last Post: June 18th, 2013, 06:08 PM
  3. Replies: 2
    Last Post: June 2nd, 2010, 09:18 AM
  4. Unable to add Capture-Playback-Hotkey Profiles as buttons on Toolbar
    By drivetheory in forum Bug Reports [EN/DE]
    Replies: 2
    Last Post: June 2nd, 2010, 09:18 AM

Tags for this Thread

Posting Permissions

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