0

I am currently trying to run a TeXStudio script that calls a Powershell Script that outputs to the Messages Section of TeXStudio the contents of the clipboard. This is the script I have in TeXStudio's Macros, which runs a Powershell script:

// TexStudio Script
cmd = system("cmd /C powershell.exe -File 'C:\\Users\\Dir1\\Dir2\\Dir3\\Dir4\\\jsclipboardtest.ps1'")
cmd.waitForFinished();

And here is the code within the jsclipboardtest.ps1 file:

# Powershell Script
$content = Get-Clipboard
Write-Host $content

So, the TeXStudio script is triggered by typing //t into TeXStudio's Editor, which runs the Powershell script that takes what's in the clipboard and outputs it into the Messages section of TeXStudio. The Messages section is here: enter image description here

Now, the trigger for the TeXStudio script is typing //t. This script executes very fast for any text. However, if I were to copy any text from the TeXStudio Editor's code, say I copy \begin{enumerate} or even a space character from the TeXStudio Editor and then trigger the script with //t, my TeXStudio freezes and then says it's "Not Responding", and after some time TeXStudio unfreezes and starts responding. The Message section either outputs what I copied.

Example: This is what happens when I copy \begin{enumerate} and trigger //t:

Message Section says:

Process started: cmd /C powershell.exe -File 'C:\\Users\\Dir1\\Dir2\\Dir3\\Dir4\\\jsclipboardtest.ps1'

TeXStudio Freezes, and then TeXStudio says "Not Responding": enter image description here

Message outputs what I copied:

enter image description here

The questions that I have

  • What is it about the text from TeXStudio's editor that makes the script(both TeXstudio script and powershell or either) freeze and take so much time to give the clipboard output? Is it perhaps the text encoding that TeXStudio uses(default UTF-8 which I use) and the encoding that powershell uses?
  • Is there a possible solution to this issue?

Notes:

  • I tried copying the TeXStudio Editor text into the clipboard and running the powershell script by itself in the terminal/command line. The output is immediate, so I believe the problem may lie in how powershell interprets the content from the clipboard?
  • The TeXstudio scripting code is JavaScript

0

You must log in to answer this question.

Browse other questions tagged .