Remember last open Desktop/App and return to it after all actions completed

Hi all!

I have a script that runs through all desktops and changes walls and after that I want to return to desktop where I called this function.
So I need to remember desktop or app.

Havn't found a way to remember desktop, but this script can return me ID of active app

**tell** *application* "BetterTouchTool"

**return** **get_string_variable** "BTTActiveAppBundleIdentifier"

**end** **tell**

After that I can set_persistent_string_variable and save it to my variable.

So the questions are

  1. How can I use this BTTActiveAppBundleIdentifier to show this app?
  2. Maybe I can somehow get display number and use it ?
  3. Maybe there is a better approach ?