Skip to content

codegallivant/sample-scriptcaster-scripts

Repository files navigation

sample-scriptcaster-scripts


Sample scripts for script-caster app.
Copy of Exterior.


Script descriptions

  • GET_LOCATION.pyw
    Gets IP location of target machine and writes information to Exterior.

  • UPLOAD_SCREENSHOT.pyw
    Takes a screenshot of the target machine and uploads it to a Google Drive folder.

  • STAY_AWAKE.pyw
    Forces computer to not go to sleep by pressing the F15 key every 60 seconds.

  • PIP_PACKAGE.pyw
    Installs/updates/uninstalls pip packages. Useful if you're creating a python script using pip modules which are currently not installed on the target computer. The package name is inputted in Exterior.

  • AlERT_BOX.pyw
    Creates an alert box. You can input the title and text in Exterior.

  • EXECUTE_LINE.pyw
    Executes a line of code. You can input the line in Exterior.

  • NEXT_VIRTUAL_DESKTOP.pyw & PREVIOUS_VIRTUAL_DESKTOP.pyw
    Moves to subsequent/previous virtual desktop.


Tools to deal with Exterior and Google Drive

Scripts often need to interact with Exterior and Google Drive. To do so, the files lib/exterior_connection.py and lib/gdrive_pyinteract.py can be imported. Examples of their usage can be found in UPLOAD_SCREENSHOT.pyw, GET_LOCATION.pyw and a few others. You can also find more details on lib/gdrive_pyinteract.py in this repository.


How script-caster runs the scripts

  1. It downloads the all the files in this repository into a folder of your choice. You can set the folder path in Settings (Visible in app GUI).
  2. It checks Exterior for the switch for the script.
  3. If the switch is enabled, the script is run. Upon completion of execution of the script, it's switch in Exterior is turned off automatically. If you turn the script's switch off while the script is running, the script will be terminated without it's execution completing.

Accessing user variables from the script

User variables such as the sheet name, app path, script folder path, GitHub credentials etc are available in the environment variables.

import os


print(os.environ["SC_COMPUTER_NAME"]) #Prints the name of sheet in Exterior connected to the ScriptCaster on the machine
print(os.environ["SC_APP_FOLDER_PATH"]) # Prints path to ScriptCaster app directory
print(os.environ["SC_USERSCRIPTS_FOLDER_PATH"]) # Prints path to folder containing the scripts
print(os.environ["SC_GITHUB_USERNAME"]) # Prints username of GitHub account containing the scripts 
print(os.environ["SC_GITHUB_REPO_NAME"]) # Prints name of GitHub repository containing the scripts 
print(os.environ["SC_GITHUB_ACCESS_TOKEN"]) # Prints personal access token

# To obtain the path to the credentials folder -
print(os.path.join(os.environ["SC_APP_FOLDER_PATH"],"creds/"))

About

Sample scripts for https://github.com/codegallivant/script-caster

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages