Hot key activation for music whilst giving Powerpoint presentation

frassa

New member
Local time
3:05 PM
Messages
1
Hello all,

I perform a comedy set using a Powerpoint presentation.

I would like to have a simple method when I could press a button/combination of buttons to activate a mp3 to play from a media player such as VLC or KMplayer, whilst in the middle of a Powerpoint presentation. Any freeware media player is fine.

Does anyone have any ideas how I could achieve this?

Thanks
 

My Computer My Computer

At a glance

windows 7
Computer type
PC/Desktop
OS
windows 7
I would use AutoIt3. You can assign a hot key that works only while the script is running. That way, the hot key can be a single key like "z". Once you end the script. The letter "z" no longer triggers the mp3.

AutoIt3 will play the MP3 file by calling a Windows API. In other words, it does not need a 3rd party player. Windows can play MP3 files directly.

Below is some code that I threw together to test the idea. You can modify it was you see fit. You can copy/paste/edit the functions to have as many hot keys as you like. Change the path to the mp3 files as needed.

See this post for instructions on how to make use of the code below.

Code:
AutoItSetOption ("TrayIconDebug", 1)  ;0-off

#include <Sound.au3>

$S_running = "comedy-mp3s" ;name the script
If WinExists($S_running) Then
      MsgBox(0, "AutoIt", "This script is already running")
      Exit
EndIf
AutoItWinSetTitle($S_running)

Global $aSozund=""

HotKeySet ("{ESC}", "end_script")
HotKeySet ("{SPACE}", "end_mp3")
HotKeySet ("z", "mp3_1")
HotKeySet ("x", "mp3_2")

While 1
    Sleep(100)
WEnd

Func mp3_1()
    HotKeySet ("z")
    Global $aSound = _SoundOpen("c:\temp\testz.mp3")
    Global $iSoundLen = _SoundLength($aSound , 2)
    _SoundPlay($aSound, 0)
    Sleep($iSoundLen)
    _SoundClose($aSound)
    HotKeySet ("z", "mp3_1")
EndFunc

Func mp3_2()
    HotKeySet ("x")
    Global $aSound = _SoundOpen("c:\temp\testx.mp3")
    Global $iSoundLen = _SoundLength($aSound , 2)
    _SoundPlay($aSound, 0)
    Sleep($iSoundLen)
    _SoundClose($aSound)
    HotKeySet ("x", "mp3_2")
EndFunc

Func end_mp3()
    _SoundClose($aSound)
EndFunc

Func end_script()
    _SoundClose($aSound)
    Exit
EndFunc
Some notes on the code above:

Use the ESC key to end the script.

Use the Space bar to end an mp3 file...
...in case you hit the wrong hot key.

The section that starts with $S_running is there to keep you from accidentally running more that one copy of the script at a time.

The section listing the hot keys...
HotKeySet ("z", "mp3_1")
...is were you would add more keys. The name "mp3_1" can be anything. You might want to use the actual name of the mp3 file or something more meaningful.

The section that starts with While 1 just tells the script to loop (doing nothing) - waiting for you to press a hot key. Once a hot key is pressed, the code goes to the function. Once the function completes, the code returns to the loop and waits for another hot key to be pressed.

Inside each function, I remove the hot key assignment via code like HotKeySet ("z"). Doing this prevents problems that might happen if you were to hold the hot key down so long that the Windows repeat key kicked in (e.g. zzzzzzzzzzzzzzzz)

Within each function, you should change c:\temp\testz.mp3 to the path of the mp3 that you want to play for a given hot key.


As mentioned in the post linked to above the code block, you can right click on the script text file and select Edit Script from the context menu. That should open the SciTE editor that comes with the AutoIt3 install. That editor has several features just for AutoIt3. You can place the edit cursor on a function (e.g. HotKeySet) and press F1. That should open the help file for AutoIt3 directly to the info on HotKeySet.
 
Last edited:

My Computer My Computer

At a glance

W7 Pro SP1 64biti78GBIntel HD Graphics
Computer type
Laptop
Computer Manufacturer/Model Number
Employer provided Dell Latitude
OS
W7 Pro SP1 64bit
CPU
i7
Memory
8GB
Graphics Card(s)
Intel HD Graphics
Hard Drives
crappy SSD
Antivirus
Employer mandated Symantec Endpoint Protection
Browser
Pale Moon 64bit, IE11 64bit & Chrome 64bit
frassa,
The code in post #2 has been changed many times as I thought of things that could go wrong while you use it (e.g. press the wrong hot key). Hopefully, you are not playing around with an earlier version of the script/code.

My edits to the code in post #2 should not cause the forum to send you a notification. This post is intended to get the forum to send you a notice (e-mail).
 

My Computer My Computer

At a glance

W7 Pro SP1 64biti78GBIntel HD Graphics
Computer type
Laptop
Computer Manufacturer/Model Number
Employer provided Dell Latitude
OS
W7 Pro SP1 64bit
CPU
i7
Memory
8GB
Graphics Card(s)
Intel HD Graphics
Hard Drives
crappy SSD
Antivirus
Employer mandated Symantec Endpoint Protection
Browser
Pale Moon 64bit, IE11 64bit & Chrome 64bit
Back
Top