protected SpyConsole installSpyConsole() {
		final PluginTool tool = plugin.getTool();
		runSwing(() -> {
			ConsoleService defaultConsole = tool.getService(ConsoleService.class);

			//@formatter:off
			invokeInstanceMethod(
				"removeService",
				tool,
				new Class[] { Class.class, Object.class },
				new Object[] { ConsoleService.class, defaultConsole });
			//@formatter:on
		});

		final AtomicReference<SpyConsole> ref = new AtomicReference<>();

		runSwing(() -> {
			final SpyConsole spyConsole = new SpyConsole();

			//@formatter:off
			invokeInstanceMethod(
				"addService",
				tool,
				new Class[] { Class.class, Object.class },
				new Object[] { ConsoleService.class, spyConsole });
			//@formatter:on

			ref.set(spyConsole);
		});

		return ref.get();
	}
Run the last script by pressing the last script button and return output.

@param taskName name for the task listener
@return script output written to the console
@throws Exception on failure, e.g. timeout
Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/script/AbstractGhidraScriptMgrPluginTest.java