Created
April 21, 2020 18:07
-
-
Save windyweather/5df56eebc60e70c38328dfda03e2500f to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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