New user wondering if my idea is even possible

If you have a question or need help, this is the place to be.
Post Reply
ksheyman
Posts: 5
Joined: Sat Jun 08, 2019 2:46 am

New user wondering if my idea is even possible

Post by ksheyman » Sat Jun 08, 2019 2:55 am

Hey guys! I'm a long time user of Home Assistant and found out about your cool community when I was trying to figure out a way to trigger an automation in home assistant every time I open Rocket League. To my pleasure I was able to achieve that goal in like 15 minutes! Love eventghost so far (after being a user for like an hour).

So I have an idea and I am uncertain if it is even possible.

I want to get eventghost to automatically switch my sound card output to my headset whenever I join a Discord voice chat, and then switch back to speakers when I leave the discord voice chat.


I know it probably isn't possible to listen for specific events or even button presses in the discord window itself, so here are my two alternate ideas:

1) eventhost generates an event when my computer connects to whatever port/server is used for Discord voice chat
2) (this one seems kinda janky) eventhost generates an event whenever I click in a certain area of my screen (the voice connect button). my discord window is always in the same place.

Are either of these possible with EventGhost? Does anyone know of any other options I haven't thought of? Thanks so much! Really excited about the possibilities with this platform!

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New user wondering if my idea is even possible

Post by kgschlosser » Sat Jun 08, 2019 7:03 am

I would need to do some more investigating into the discord chat program. If they have any kind of an API then you may be surprised at what can be done.

Unfortunately we had a really bad server issue that caused the loss of our forum attachments. While I do have many of the plugins I may not have all of them or even the most recent versions of them.

I do however have an experimental interface into Windows Core Audio. It may still have some glitches in it will accomplish the task of allowing you to switch inputs and output and also the sound card in use. It also generated events for audio playing and stopping. It also provides master volume control as well as adjusting the volume on a specific channel (all 8 channels). you can also change the gains on input devices. this includes microphones as well.

The core audio plugin is attached.

I will take a quick look into the chat program and see what I come up with.
Attachments
CoreAudio-0.1a.egplugin
(135.28 KiB) Downloaded 93 times
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New user wondering if my idea is even possible

Post by kgschlosser » Sat Jun 08, 2019 7:07 am

as it turn out discord chat has a pretty extensive development API.

https://discordapp.com/developers/docs/intro

I am not familiar with the verbage used for the specific components of the application, you would probably be better at determining if the bits needed to accomplish your task are available via the API.
If you like the work I have been doing then feel free to Image

cableghost
Experienced User
Posts: 50
Joined: Thu Oct 10, 2013 9:43 pm

Re: New user wondering if my idea is even possible

Post by cableghost » Sat Nov 23, 2019 2:25 pm

kgschlosser wrote:
Sat Jun 08, 2019 7:07 am
as it turn out discord chat has a pretty extensive development API.
Thanks for looking into this for the OP.

User avatar
Medy
Experienced User
Posts: 178
Joined: Sat Nov 15, 2014 8:33 pm
Location: Germany

Re: New user wondering if my idea is even possible

Post by Medy » Sat Nov 23, 2019 7:15 pm

ksheyman wrote:
Sat Jun 08, 2019 2:55 am
Hey guys! I'm a long time user of Home Assistant and found out about your cool community when I was trying to figure out a way to trigger an automation in home assistant every time I open Rocket League. To my pleasure I was able to achieve that goal in like 15 minutes! Love eventghost so far (after being a user for like an hour).

So I have an idea and I am uncertain if it is even possible.

I want to get eventghost to automatically switch my sound card output to my headset whenever I join a Discord voice chat, and then switch back to speakers when I leave the discord voice chat.


I know it probably isn't possible to listen for specific events or even button presses in the discord window itself, so here are my two alternate ideas:

1) eventhost generates an event when my computer connects to whatever port/server is used for Discord voice chat
2) (this one seems kinda janky) eventhost generates an event whenever I click in a certain area of my screen (the voice connect button). my discord window is always in the same place.

Are either of these possible with EventGhost? Does anyone know of any other options I haven't thought of? Thanks so much! Really excited about the possibilities with this platform!

I have experience with the discord API as well as your problem described.



Changing Speaker to Headset is what I have solved in 2 ways.

1- Hotkeys for changing Output (via Audioendpoint plugin) or you could "core audio"
2. Usually as long as im in discord I also playing a game or having a specifc program open.
So to automatically switch outputs, I use "Task terminated" and "Task Created" Events
of these programs to AUtomatically switch output.




But If you are in fact in need of a solution that goes as far as detect wheter you are connected to Voice
Chat / Channel , or are currently Online


1. You would need to use the API
2. You would need to be Owner of the discord server you are on
3. You need a bot to query

Solutions :
You can only check if user is connected to a channel : https://www.reddit.com/r/discordapp/com ... e_enter_a/

You can check if user is online . Online meaning that they are members of the server , simply have discord open which makes them online ... but they could also be online & have a different status as idle...



You can use all these variables to determine if you are currently in voice chat.

For the first Aproach without Api .. you can do it llike me :D


Or if you go all in you need to built a discord bot that supplies that information to Eventghost.
You could set it up with Autoremote plugin for Eventghost ... Also Autoremote plugin for chrome which has option to forward events to eventghost (im using these 2 recently .. since the plugin itself became unstable at some point , but chrome extension autoremote forwardign to Eventhgost plugin works quite realiably. Maybe you dont both though.


You could also skip autoremote and create a websocket connection with your discord bot and eventghost ...

I would advice you to do it with hotkeys or task created / Task detroyed events .. probably easiest .. The other route will take some work

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New user wondering if my idea is even possible

Post by kgschlosser » Sat Nov 23, 2019 8:00 pm

This can be done. And EG is able to listen to keyboard input as well.

You will need the Keyboard plug-in (comes with eg).
The Task Monitor Plus plug-in gotten here https://github.com/Boolean263/EventGhos ... onitorPlus
As well as the core audio located here http://eventghost.net/forum/viewtopic.php?f=9&t=10351

The Task Monitor Plus will generate events letting you know when you have the Discord application in focus (you are using it) set up a macro with that event and the enable action. The enable action you are going to point to a macro that contains the keyboard event to watch for and the EventGhost/sound/set default endpoint action setting the endpoint to your headphones.

Ya know it is going to be easier for me to paste a tree example. In a few hours when I get home I will do that.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New user wondering if my idea is even possible

Post by kgschlosser » Sat Nov 23, 2019 8:03 pm

Oh man this is an old thread.... Blah! Browsing from my phone is my excuse.
If you like the work I have been doing then feel free to Image

ksheyman
Posts: 5
Joined: Sat Jun 08, 2019 2:46 am

Re: New user wondering if my idea is even possible

Post by ksheyman » Tue Dec 03, 2019 9:36 pm

It may be an old thread but I still haven't been able to achieve what I was asking about. As a matter of fact I forgot that I had posted this and found it via google search lol.

So I tried to install those plugins and neither one works. When I try to install core audio it says there is a syntax error. When I try to download TaskMonitorPlus from the download links in the thread, it says the attachment doesn't exist...

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New user wondering if my idea is even possible

Post by kgschlosser » Tue Dec 03, 2019 11:36 pm

download core_audio from here

viewtopic.php?f=9&t=10351

and download the task monitor plus plugin from here
https://github.com/Boolean263/EventGhos ... onitorPlus


there are a few versions is you are getting a syntax error with the latest version of core_audio then use the version before it.

as far as the task monitor plus plugin goes. you need to download it from github. then decompress only the TaskMonitorPlus folder to %programdata%\eventghost\plugins.
once you have done that then restart EG.

when you have EG started back up again you need to right click on your Configuration tree and click on add a plugin.. select the TaskMonitorPlus plugin.. it will install.

then do the same for the CoreAudio plugin..
If you like the work I have been doing then feel free to Image

ksheyman
Posts: 5
Joined: Sat Jun 08, 2019 2:46 am

Re: New user wondering if my idea is even possible

Post by ksheyman » Wed Dec 04, 2019 1:52 am

all right, I've done what you said. When I enable the taskmonitorplus plugin and an event happens, this is what shows up in the log:

Code: Select all

Unhandled exception in WorkerThread <ActionThread>:
Callers stack:
  File "threading.pyc", line 504, in __bootstrap
  File "threading.pyc", line 532, in __bootstrap_inner
  File "threading.pyc", line 484, in run
  File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 354, in __MainLoop
    self.__DoOneEvent()
  File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 342, in __DoOneEvent
    eg.PrintTraceback()
  File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 289, in HandleAction
    action()
  File "C:\Program Files (x86)\EventGhost\eg\Classes\EventThread.py", line 85, in Transfer
    event.SetShouldEnd()
Traceback (most recent call last) (1722):
  File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 326, in __DoOneEvent
    self.HandleAction(action)
  File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionThread.py", line 87, in HandleAction
    action()
  File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 62, in __call__
    self.returnValue = self.func(*self.args, **self.kwargs)
  File "C:\Program Files (x86)\EventGhost\eg\Classes\EventGhostEvent.py", line 166, in Execute
    LogEvent(self)
  File "C:\Program Files (x86)\EventGhost\eg\Classes\Log.py", line 253, in LogEvent
    mesg = eventstring + ' ' + repr(payload)
  File "C:\ProgramData\EventGhost\plugins\TaskMonitorPlus\WindowInfo.py", line 77, in __repr__
    return "<title={}, window_class={},...>".format(repr(self.title), repr(self.window_class))
ValueError: zero length field name in format
As for coreaudio, I tried every version and get the same result. Syntax error:

Code: Select all

Compiling C:\ProgramData\EventGhost\plugins\CoreAudio\__init__.py ...
SyntaxError: ('invalid syntax', ('UserPlugin\\__init__.py', 310, 27, '                        for i in range(channels.count)\n'))

Compiling C:\ProgramData\EventGhost\plugins\CoreAudio\slider_ctrl.py ...
SyntaxError: ('invalid syntax', ('UserPlugin\\slider_ctrl.py', 238, 34, 'NUMBER_CODES.update({i + 48: i for i in range(10)})\n'))

ksheyman
Posts: 5
Joined: Sat Jun 08, 2019 2:46 am

Re: New user wondering if my idea is even possible

Post by ksheyman » Wed Dec 04, 2019 2:02 am

Code: Select all

            try:
                volume = endpoint.volume
                channels = volume.channels
                v_callback = volume.register_notification_callback(self)
                self.__volume_callbacks[endpoint] = v_callback

                self.__endpoints[endpoint] = dict(
                    vol=volume.master_scalar,
                    mute=volume.mute,
                    channels={
                        i: channels[i].level_scalar
                        for i in range(channels.count)
                    }
                )
if it helps at all, this is the section the error points to with coreaudio. I'm not very good with python so I can't see what is wrong. it points to the line that starts "for i in range"

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New user wondering if my idea is even possible

Post by kgschlosser » Wed Dec 04, 2019 3:28 am

Ohhh are you running EG 0.4??

you need to change to EG 0.5 if you are. it can be gotten from here
https://github.com/EventGhost/EventGhost/releases

both problems will be solved when you do the upgrade.
If you like the work I have been doing then feel free to Image

ksheyman
Posts: 5
Joined: Sat Jun 08, 2019 2:46 am

Re: New user wondering if my idea is even possible

Post by ksheyman » Wed Dec 04, 2019 4:02 am

Unbelievable. Yep that was it lol. Both are working now. Thanks for everything I appreciate your help!!

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New user wondering if my idea is even possible

Post by kgschlosser » Wed Dec 04, 2019 6:22 pm

so now you should be able to use the event from Task monitor plus to know when you have the discord application in focus or not...

then you can use the Core Audio plugin to tell if you have a microphone plugged in or not. because the core audio plugin is an extension of of the sound plugin included with eventghost all of the actions for the core audio plugin are located in system\sounds.

There is an extra special bonus (if it works right) you should get events in EG if there is audio detected on the microphone and you can also use an action to ask if there is currently input as well with a user settable threshold to filter out background noise.
If you like the work I have been doing then feel free to Image

Post Reply