Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Hot key activation for music whilst giving Powerpoint presentation

26 Jul 2015   #1
frassa

windows 7
 
 
Hot key activation for music whilst giving Powerpoint presentation

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 System SpecsSystem Spec
.
26 Jul 2015   #2
UsernameIssues

W7 Pro SP1 64bit
 
 

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.
My System SpecsSystem Spec
26 Jul 2015   #3
UsernameIssues

W7 Pro SP1 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 System SpecsSystem Spec
.

Reply

 Hot key activation for music whilst giving Powerpoint presentation




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Trenton Computer Festival Powerpoint Presentation
Here is a bit about what I did at the Trenton Computer Festival Saturday Seminars Scroll down till you see the power point presentation
Chillout Room
cannot extract music file from a powerpoint presentation
When I was using Vista and MS Home and Student 2007, I was able to extract music file from any pps ( provided it was not password protected ) by ..... right click existing pps > New > Office button > save as > at save as type, select web page (*html) > save. Now I am using Win 7 Home Premium...
Microsoft Office
PowerPoint Help - Music Track
I'm compiling about a 15-min PowerPoint slide presentation for a person at our company who is retiring in the next few days. Does anyone have a clue as to how I can get a custom-length audio (music) track to span the entire PowerPoint presentation, from start to finish without interruption . . ....
Music, Pictures & Video
Sound not working in PowerPoint Presentation
I am running Office 2010, on Win 7 64-bit. I have inserted a sound file to play accross all the slides in my presentation. It plays just fine from the PowerPoint program when I test the slideshow. However, when I save the presentation as a PowerPoint 2003 .pps file, and play that show back, there...
Microsoft Office
Powerpoint - How do I check how long is my presentation?
I have just created a presentation and I'd like to know how long is it to add some music and to know where should I fate the song out. Thank's ahead :)
Microsoft Office
Powerpoint presentation to video?
hello, i have finished my power point from 2010 beta version and i was wondering what software is great to convert it to video format? more likely an HD format? i finished my intro for my call of duty mw2 gameplay so i need something to convert it. other softwares seems to only support...
Music, Pictures & Video


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:07.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App