Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

Switch Audio Device and Launch a Game

Description
This function switches the default playback device (headphones in this example), then launches a game (DinoHordeGame.exe in this example). The function then waits for the game to exit, and switches the default playback device again (speakers in this example). To select an audio device, remove the name from the BFS.Audio.SetDefaultPlaybackSounds function, so that it shows BFS.Audio.SetDefaultPlaybackSounds( and then press Ctrl + Space. A window will pop-up allowing you to select which device you want to use in the function.
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Sep 30, 2014
Date Last Modified
Oct 3, 2014

Scripted Function (Macro) Code

using System;
using System.Drawing;

// The 'windowHandle' parameter will contain the window handle for the:
//   - Active window when run by hotkey
//   - Window Location target when run by a Window Location rule
//   - TitleBar Button owner when run by a TitleBar Button
//   - Jump List owner when run from a Taskbar Jump List
//   - Currently focused window if none of these match
public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
		//sets the audio device to use (replace with the name of your audio device of choice)
		BFS.Audio.SetDefaultPlaybackSounds("Headphones (2- High Definition Audio Device)");
		
		//launches the game
		BFS.Application.Start("C:\\Program Files (x86)\\Steam\\SteamApps\\common\\Orion Dino Beatdown\\Binaries\\Win32\\DinoHordeGame.exe", "");
		
		//waits in case the game relaunches itself (happens with some Steam games)
		BFS.General.Sleep(5000);
		
		//waits for the game to exit
		BFS.Application.WaitForExitByFile("*DinoHordeGame.exe", 0);
		
		//set the audio device again (replace with the name of your audio device of choice)
		BFS.Audio.SetDefaultPlaybackSounds("Speakers (2- High Definition Audio Device)");
	}
}