I've been having this problem for the last few years, that after using TXC normally for a long while, suddenly I get the infamous "Cannot execute the command." error message when attempting to ForwardSearch. I then have to restart TXC to get it to work again.
I've searched the forums for this but I haven't found a post where the DDE command works at the start of a session but then suddenly stops working mid-session without anything else having changed. I guess it's not a big deal, but I'd be interested in hearing whether this has been observed before, whether you can reproduce it, and whether there is a fix.
Here's a minimalistic way to reproduce the problem on my system (TeXnicCenter 1.0 RC 1, MiKTeX 2.9, pdfTeX 3.1415926-1.40.11, SumatraPDF 2.0.1):
1. Make a minimal document, e.g.
Code: Select all
\documentclass{article}\begin{document}a\end{document}
3. Repeat: {Press F5 in TXC to view output with SumatraPDF. Switch back to TXC.} 127 times
4. Press F5 for the 128th time. "[Open("%sbm.pdf",0,1,1)] Cannot execute the command."
This works with a variety of settings, e.g.
Path of executable: C:\Program Files\SumatraPDF\SumatraPDF.exe
View project's output: [Open("%sbm.pdf",0,1,1)]//SUMATRA//control
No Forward search
(For completeness, basic compilation options "C:\Program Files\MiKTeX 2.9\miktex\bin\pdflatex.exe", "-interaction=nonstopmode "%pm"", no bibtex/makeindex)
After the error occurs, that instance of TXC can no longer execute any DDE commands, even if I close all TXC tabs and open a new file, recompile, close SumatraPDF, or change to another output profile. (I haven't tried changing to a profile with a different viewer, because Adobe Reader crashes on me.) The only "solution" I've found is to close that instance of TXC and open a new one / use another that's already open.
Here's an Autohotkey script I wrote to test the behaviour automatically:
Code: Select all
; Repeatedly presses F5 in TeXnicCenter until SumatraPDF no longer pops up within a second.
; Displays the number of successful F5's in a MsgBox.
; Preparation: Make a test file called test.tex and compile it to test.pdf . Run the script and switch to the TXC window.
; Make sure not to have any other windows open with title beginning with "TeXnicCenter" or "test.pdf"
n := 0
WinWaitActive, TeXnicCenter
Sleep, 1000
Loop 1000 ; Make max 1000 attempts
{
WinActivate, TeXnicCenter
Send, {F5}
WinWaitActive, test.pdf, ,1 ; Wait for max 1 second
If ErrorLevel
Break
n := n + 1
}
MsgBox, %n%
Exit
#space:: ; Emergency pause -- Win+space
Pause
Return