Bring your karma
Join the waitlist today
HUMBLECAT.ORG

Blind and Visually Impaired Community

Full History - 2017 - 01 - 06 - ID#5mg6d8
3
Automating a video stream for my mom. (self.Blind)
submitted by Myntrith
I'm sighted, but I'm here for my mom. I'm recently unemployed, so I'm exploring ways to cut costs. We currently have cable TV for one reason and one reason only. Mom likes to tune in to EWTN (A Catholic channel).

I got her a computer a while back (when I was still working) to help with keeping track of her doctor's appointments and so I can instantly bring up the weather when she wanted to know the temperature or if it was going to snow soon, things like that.

The other day, I got a programmable mouse. I wrote two PowerShell scripts. I wrote one to start EWTN's Internet stream, and I wrote a second to close the stream. I created a shortcut for each script, assigned a hotkey to each shortcut, and assigned each hotkey to one of the mouse buttons.

Mind you, mom is not at all computer savvy. She wouldn't know how to manage with a screen reader and voice commands, and she's not inclined to learn. So I had to make this as easy as possible. One mouse button to start, one to stop.

If anyone is interested in the nitty gritty details, I'll post them. If not, I figured I'd spare you the indignity of having your screen readers spew out Powershell script commands and symbols.
fastfinge 1 points 6y ago
Yes, I'm slightly interested. Powershell is one of those things I've been meaning to learn. My old keyboard broke over Christmas, and now I actually type on one of those crazy gamer keyboards, with like 8 macro keys intended for games, that aren't doing anything for me. Getting some use out of them might be nice. I just got it because I insist on having a mechanical keyboard, and this one was on sale for super cheap. So...now I have programmable multicoloured backlit LEDs and buttons I can't use for anything. Yay?
Myntrith [OP] 1 points 6y ago
OK ...

Step 1, of course, was to get the URL for the stream. In my case, this was: http://ewtn.com/live/ewtnplayer/jwplayer.asp?bottom=false&feed=domeng

I had two problems with that. First, it loaded the stream, but wouldn't automatically play it. A friend helped me figure out that the HTML source on the page included an "autoplay" parameter that was set to false. So I copied the HTML source to a local HTML file on my local drive, and changed the autoplay parameter to TRUE.

Now, instead of invoking the remote URL, I invoked the local file path ... which brought me to the second problem. Internet Explorer would pop-up a notification that content was blocked, and did I want to allow it? To get around this, I had to add a line at the beginning of the local HTML file.

<!-- saved from url=(0016)http://localhost -->

Step 2: The Powershell script to start the stream:

$isrunning = Get-Process | where {$_.name -eq 'iexplore'}
if (-not $isrunning) {
$ie = new-object -ComObject "InternetExplorer.Application"
$ie.visible = $true
$ie.silent = $true
$ie.navigate('file:///C:/Users/Myntrith/Desktop/ewtn.html')
}

The first line sets up a test for the if block to see if Internet Explorer is currently running. It only executes the rest of the script if it is NOT running. This avoids starting multiple video streams.

No one uses this computer except to check things for her, so Internet Explorer should not normally be running unless she's activating this stream.

Step 3: The Powershell script to close the stream.

$isrunning = Get-Process | where {$_.name -eq 'iexplore'}
if ($isrunning) {
Stop-Process -processname iexplore
}

Again, all this does is it checks to see if Internet Explorer is running, and if so, it stops it. If multiple instances are running, it stops all instances.

Step 4: Create shortcuts for each of the scripts. Creating a shortcut allows you to assign a hotkey. Don't assign the hotkey yet, just create a shortcut.

Step 5: Make sure you have your keyboard or mouse software installed. For Logitech, this software is called SetPoint.

I open Setpoint, and I select the mouse's forward button, and select "Keystroke Assignment". I assigned CTRL-ALT-E as the keystroke.

I select the mouse's back button, and select "Keystroke Assignment." I assigned CTRL-ALT-N.

Now, for the shortcut to the start script, I right-click and select Properties. There's an entry in there for "Shortcut Key". I select that entry and press E. (It assumes the CTRL-ALT, so you only have to press E.)

Likewise for the shortcut to the stop script, except I select N instead of E.

And that's it. Now, pressing the forward mouse button should invoke the CTRL-ALT-E hotkey, which should invoke the shortcut to the start script, which invokes the start script itself, which invokes the local HTML file which invokes the video stream.

Likewise with the back mouse button and CTRL-ALT-N and the stop script.

If things don't work, you troubleshoot step by step to see where the problem is. Invoke the script directly to see if that works.
If it does, invoke the shortcut directly to see if that works.
If it does, invoke the shortcut through the hotkey to see if that works.
If it does, try the mouse button again.

Wherever it fails should tell you where the problem is.

It does seem like the shortcuts to the scripts have to be on the desktop in order for the hotkey to work properly. I haven't tested this extensively, but with what I have tested so far that seems to be an important bit.
fastfinge 1 points 6y ago
Clever! Thanks for all the detail. Unfortunately, the software for programming the buttons on my keyboard is totally inaccessible. I'd hoped it was your script that took care of listening for the keyboard presses, rather than just depending on the keyboard software. Oh well, it's still a nice powershell example!
Myntrith [OP] 1 points 6y ago
Oh, no, sorry. To do that, I think I would have to write something equivalent to a key logger (intercepting every key stroke) in order to be able to detect a given hotkey.

I'm not sure how to write a key logger in Powershell, or even if it would be possible, but I think it would also be considered a security risk. Key loggers are one of the tools that people use to steal login information and banking information.
fastfinge 1 points 6y ago
Well, most screen-readers intercept keypresses; they have to, to define the thousands of shortcuts they use. Plus, media players seem to be able to intercept the media keys on keyboards, to skip tracks and so-on, when the media player is open. Media keys work no matter what media player is used, without reprogramming or anything. So I had rather hoped there was some kind of API for assigning actions to non-standard keyboard keys in Windows somewhere.

Edit: Autoit can do this, as long as I close and uninstall the software that came with my keyboard. If the software is running, autoit doesn't see the keypress. Odd and irritating.
This nonprofit website is run by volunteers.
Please contribute if you can. Thank you!
Our mission is to provide everyone with access to large-
scale community websites for the good of humanity.
Without ads, without tracking, without greed.
©2023 HumbleCat Inc   •   HumbleCat is a 501(c)3 nonprofit based in Michigan, USA.