Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor
Scripting
Scripting
Scripting

Scripts designed for the software servers used by the Polyglot system each carry out a particular function (e.g. open, save, kill) and depending on the operation the script takes 0, 1, or 2 arguments indicating the input/output files. Each script starts with a four line header that indicates the pretty name of the program, the domain of the file that it is designed for, and depending on the operation type the valid input and output formats.  Three example scripts written in the AutoHotKey scripting language are provided below.  The purpose of these scripts is to convert a .pdf file.  Open, save, and kill operations are given as examples.


  • Anchor
    AutoHotKey
    AutoHotKey
    AutoHotKey
    • Code Block
      titleOpen
      ;Adobe Acrobat (v9.3.0 Pro Extended)
      ;document
      ;pdf
      
      ;Parse input filename
      arg1 = %1%
      StringGetPos, index, arg1, \, R
      ifLess, index, 0, ExitApp
      index += 2
      input_filename := SubStr(arg1, index)
      
      ;Run program if not already running
      IfWinNotExist, Adobe 3D Reviewer
      {
        Run, C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe
        WinWait, Adobe Acrobat Pro Extended
      }
      
      ;Activate the window
      WinActivate, Adobe Acrobat Pro Extended
      WinWaitActive, Adobe Acrobat Pro Extended
      
      ;Open document
      Send, ^o
      WinWait, Open
      ControlSetText, Edit1, %1%
      ControlSend, Edit1, {Enter}
      
      ;Make sure model is loaded before exiting
      Loop
      {
        IfWinExist, %input_filename% - Adobe Acrobat Pro Extended
        {
          break
        }
      
        Sleep, 500
      }
      Code Block
      titleSave
      ;Adobe Acrobat (v9.3.0 Pro Extended)
      ;document
      ;doc, html, jpg, pdf, ps, rtf, txt
      
      ;Parse output format
      arg1 = %1%
      StringGetPos, index, arg1, ., R
      ifLess, index, 0, ExitApp
      index += 2
      out := SubStr(arg1, index)
      
      ;Parse filename root
      StringGetPos, index, arg1, \, R
      ifLess, index, 0, ExitApp
      index += 2
      name := SubStr(arg1, index)
      StringGetPos, index, name, ., R
      ifLess, index, 0, ExitApp
      name := SubStr(name, 1, index)
      
      ;Activate the window
      WinActivate, %name%.pdf - Adobe Acrobat Pro Extended
      WinWaitActive, %name%.pdf - Adobe Acrobat Pro Extended
      
      ;Save document
      Send, ^S
      WinWait, Save As
      
      if(out = "doc"){
        ControlSend, ComboBox3, m
      }else if(out = "html"){
        controlSend, ComboBox3, h
      }else if(out = "jpg"){
        controlSend, ComboBox3, j
      }else if(out = "pdf"){
        controlSend, ComboBox3, a
      }else if(out = "ps"){
        controlSend, ComboBox3, p
        controlSend, ComboBox3, p
        controlSend, ComboBox3, p
        controlSend, ComboBox3, p
        controlSend, ComboBox3, p
      }else if(out = "rtf"){
        controlSend, ComboBox3, r
      }else if(out = "txt"){
        controlSend, ComboBox3, t
        controlSend, ComboBox3, t
      }
      
      ControlSetText, Edit1, %1%
      ControlSend, Edit1, {Enter}
      
      ;Return to main window before exiting
      Loop
      {
        ;Continue on if main window is active
        IfWinActive, %name%.pdf - Adobe Acrobat Pro Extended
        { 
          break
        }
      
        ;Click "Yes" if asked to overwrite files
        IfWinExist, Save As
        {
          ControlGetText, tmp, Button1, Save As
      
          if(tmp = "&Yes")
          {
            ControlClick, Button1, Save As
          }
        }
      
        Sleep, 500
      }
      
      ;Wait a lit bit more just in case
      Sleep, 1000
      
      ;Close whatever document is currently open
      Send, ^w
      
      ;Make sure it actually closed before exiting
      Loop
      {
        ;Continue on if main window is active
        IfWinActive, Adobe Acrobat Pro Extended
        { 
          break
        }
      
        Sleep, 500
      }
      Code Block
      titleKill
      ;Adobe Acrobat (v9.3.0 Pro Extended)
      
      ;Kill any scripts that could be using this application first
      RunWait, taskkill /f /im Acrobat_open.exe
      RunWait, taskkill /f /im Acrobat_save.exe
      
      ;Kill the application
      RunWait, taskkill /f /im Acrobat.exe
  • Anchor
    AppleScript
    AppleScript
    AppleScript
    • Applescript is also supported by Polyglot.  An example script will be provided in the future.
  • Anchor
    Python
    Python
    Python
    • Python is also supported by Polyglot.  An example script will be provided in the future.
  • Anchor
    Bash
    Bash
    Bash
    • Bash is also supported by Polyglot.  An example script will be provided in the future.

...