Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample code shows how to launch an Impress slide show and stop it. Uses Timer routines in another gist. Works on Windows 10 and Linux Mint 19.
public void startShowPlaying( String sImpress, String sOptions, String sShowPath ) {
if ( bShowRunning ) {
System.out.println("startShowPlaying already running");
return;
}
String cmdString = sImpress +" "+sOptions+" "+sShowPath;
try {
pShowProcess = Runtime.getRuntime().exec( cmdString );
System.out.println("startShowPlaying show started");
bShowRunning = true;
if ( bTimerRunning ) {
stopTimer();
}
startTimer( 5000 );
} catch (Exception ex ) {
System.out.println("startShowPlaying exception");
}
}
public void stopShow() {
if ( !bShowRunning ) {
System.out.println("stopShow show not running");
return;
}
// we cannot use destroy() since that would leave the Impress show
// in a bad state. So all we can do is wait on the user to stop the
// show and then clean up.
try {
// stop the mouse clicks
stopTimer();
System.out.println("stopShow waiting for you to stop the show");
pShowProcess.waitFor();
System.out.println("stopShow show not running");
bShowRunning = false;
} catch (Exception ex ) {
System.out.println("stopShow exception");
bShowRunning = false; // try to clean up
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment