What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Basic Questions - LaTeX

Pages: (6): « First « 1 [ 2 ] 3 4 5 6 » Last »
Basic Questions - LaTeX
Author: Message:
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: Basic Questions - LaTeX
i think the following command:

dvipng -T tight -x 1200 -z 9 file.dvi

it requires an input from the user... i think you just need to write a new line in the batfile of "q", this is a silent command as you dont need any text back from it...

hope this works...
06-17-2009 10:51 AM
Profile PM Find Quote Report
Flippy
Junior Member
**


Posts: 29
34 / Male / Flag
Joined: Jun 2009
O.P. RE: Basic Questions - LaTeX
What do you mean? The command doesn't need any input, I just need to run that command as it is. The file.dvi file is created just before that (with the latex command), and the dvipng commands creates a PNG image from the dvi file.

Anyway, I found the following code on another forum and this seems to work. I don't really know what I'm doing here though lol:
JScript code:
// -----------------
        // Create DVI file and PNG file
        // -----------------
        var batFile = fso.CreateTextFile(path + "\\batFile.bat", true);
        batFile.WriteLine("cd " + path);
        batFile.WriteLine("latex file.tex");
        batFile.WriteLine("dvipng -T tight -x 1200 -z 9 file.dvi");
        batFile.Close();
       
        var shell = new ActiveXObject('WScript.Shell');
        var oExec = shell.Exec(path + "\\batFile.bat");
        while (oExec.Status == 0)
        {
            WScript.Sleep(100);
        }
        oExec = null;
        shell = null;


Anyway.. it creates the PNG image :)

All that's left now is displaying it in a window!

Unfortunately, I haven't got a clue how to start lol... Do I need a separate XML editor? I have Visual Studio, maybe I can use that?

I suppose there is no visual editor? Eg, I cannot see the window before compiling the XML code?

Actually all I need is one window, roughly the size of the PNG image created, displaying the PNG image. Perhaps a button to close it, but that's not even a requirement. What controls am I looking at? In C# or VB I would use a picturebox, but there doesn't seem to be one..?

This post was edited on 06-17-2009 at 11:04 AM by Flippy.
06-17-2009 10:59 AM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: Basic Questions - LaTeX
First of all: welcome to our forums! :D
quote:
Originally posted by Flippy
Unfortunately, I haven't got a clue how to start lol... Do I need a separate XML editor? I have Visual Studio, maybe I can use that?
There are some examples in the scripting documentation, but you'll learn the most by looking at other scripts. There are a lot of scripts which display an image in a window, have a look on how the image container is defined in the XML and how an image is assigned to the element.

You don't need a special editor, any text editor will do. It doesn't matter whether you prefer Notepad++ or Visual Studio, as long as you write valid XML and save your files as UTF-16 with BOM, Plus! will happily read your interfaces. If you still run into trouble with your interfaces, the Interface Tester can help you finding errors in your interface files.
quote:
Originally posted by Flippy
I suppose there is no visual editor? Eg, I cannot see the window before compiling the XML code?
No, unfortunately there isn't. Many developers on the forums here have attempted to start up such a project, but it appears none of them succeeded in finishing it. At the moment, all script developers have to write the XML themselves. It sounds difficult at first, but you'll get the hang of it very quickly. :)

(By the way: you don't compile XML, it is being read as-is. Saving it and re-opening the window works just fine.)
quote:
Originally posted by Flippy
Actually all I need is one window, roughly the size of the PNG image created, displaying the PNG image. Perhaps a button to close it, but that's not even a requirement. What controls am I looking at? In C# or VB I would use a picturebox, but there doesn't seem to be one..?
You're going to need a window with an ImageElement and a ButtonControl.

You'll want to set the image on the ImageElement in the interface XML to some kind of place-holder image ("Loading" or something alike) and then change the image dynamically with PlusWnd::ImageElmt_SetImageFile.

Another interesting thing you might want to use: if you simply give your button "BtnCancel" as Id, Plus! will automatically recognise it as a close button (unless you override this behaviour and add your own event handling for the button of course).

As for resizing the window according to the size of the loaded image, you're going to need a Win32 API call using Interop.Call() to SetWindowPos (in user32.dll) and set the width and height of the window. This will require some calculations to retrieve the size needed to display the image correctly but I'm sure that with a little creativity and some help from these forums, you'll be able to get this right!

If you have any question, search the forums first to make sure whether it has already been answered and if it's not, feel free to ask here! ;)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
06-17-2009 12:07 PM
Profile E-Mail PM Web Find Quote Report
Flippy
Junior Member
**


Posts: 29
34 / Male / Flag
Joined: Jun 2009
O.P. RE: Basic Questions - LaTeX
Thanks.

At the moment, I'm just following the example in the documentation. I have been able to show the window in the Initialize event, but it won't show up in any other event...

I need it to show up after the latex is done converting to a png file, so I used this code:
JScript code:
// -------------
        // Show LaTeX in separate window
        // -------------
        var pngFile = folder + "\\file1.png";
        if (fso.FileExists(pngFile))
        {
            var wnd = MsgPlus.CreateWnd("Windows.xml", "WndTest");
        }

(This is in the OnEvent_ChatWndReceiveMessage event btw)

Nothing shows up.

I figured there might be something wrong with my file check (is there?), so I tried it without that... Still nothing. No window shows up.

What am I doing wrong? I can't see any mention of this in the documentation...?

This post was edited on 06-17-2009 at 12:23 PM by Flippy.
06-17-2009 12:23 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: Basic Questions - LaTeX
First of all, make sure that the FileExists block really works the way it should. Try to place a Debug.Trace() call inside it and see if you get the message in the debug window. Also make sure that the Interface Tester (link in previous post) gives you no errors about your interfaces.

Other than that, I see no reason why it shouldn't work if you have a valid window. :S
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
06-17-2009 01:49 PM
Profile E-Mail PM Web Find Quote Report
Flippy
Junior Member
**


Posts: 29
34 / Male / Flag
Joined: Jun 2009
O.P. RE: Basic Questions - LaTeX
I've tried it without the FileExists block too, but still no window. When I place the wnd = MsgPlus.CreateWnd line in the Initialize event it shows up fine :S


EDIT
Nevermind, I got it. Apparently an error occured a few lines before this part, so anything after that stopped. I got the window now... All it does is say "hello" though, so now on to the ImageElement stuff... Can you recommend me any script that uses this, so I can see an example?

This post was edited on 06-17-2009 at 02:47 PM by Flippy.
06-17-2009 02:41 PM
Profile E-Mail PM Find Quote Report
Flippy
Junior Member
**


Posts: 29
34 / Male / Flag
Joined: Jun 2009
O.P. RE: Basic Questions - LaTeX
EDIT
Nevermind, got it :p



Another question: can I use an outside editor to edit the jscript files? This one is starting to piss me off, sorry :p It's really good for a 'simple' editor embedded into Plus!, but the one in Visual Studio for example is much better... I just spent 10 minutes figuring out why my code was wrong, and it was just a forgotten capital letter lol...

However, this works pretty good where I can just save the file and it will restart, so I can immediately try it again... How does that work if I use Visual Studio?

This post was edited on 06-17-2009 at 03:14 PM by Flippy.
06-17-2009 03:07 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Basic Questions - LaTeX
1) You don't need any batchfile.

You already use the Shell.Exec function so you know how to use it. With that same function you can simply perform your 2 steps needed to create a PNG right from the scripting language. So instead of executing a batch file which executes some other command line tools on its turn, why not simply execute the two command line tools directly with the proper parameters using the Shell object?

However, you can also use the Shell.Run for that. The reason it didn't worked at first is because you didn't used the function properly (you used it asyncroniously and thus it returned immediatly, thus before the PNG was created). For more information see the Windows Script Documentation > Index > 'Run method'.

Also remember to always add the proper path strings to the filenames (and enclose them in quotes if you use those files as parameters).

2) Don't use the WScript.Sleep() function!!!! This function will actually halt execution and will stop Messenger for a few milliseconds which can cause all sorts of bad things. WScript.Sleep() is acceptable in standalone scripts which you run in Windows, but certainly not in an integrated scripting language.

Instead learn to use timers (see the Plus! Scripting documentation).

Or, use Shell.Run as I said in previous point. In that way you don't need to wait for the function to finish since the Run method has that build in by using a boolean parameter (see Windows Script Documention). However, I do recommend using Shell.Exec, but as you have noticed it requires more programming and the proper use of timers.

But if you don't know how to use timers at this point, it is better to stick to the syncronious Shell.Run method.

-----

3) About the inline editor;
Yes, you can use any editor you like since the scripts are simply open-source text files. But the integrated editor is not as limited as you think. There are a few options which will greatly help you. When you use an external editor you wont have those options or you need to constantly switch between windows.

a) Show the debug window below the editor. In that way you immediatly see if everything is ok and if there is an error you'll see immediatly on which line and what the error is.

b) Intellisense: Just like in the Visual Studio editor there is a IntelliSense option which shows you possible function names.

c) Collapsable functions (outlining), line numbering

d) When you save a script from the inline editor it is immediatly restarted. However, there is a registry option for Messenger Plus! which will also restart the script whenever something has changed in its source. In that way you could edit your script in an external editor and whenever you save the source the script is restarted in Messenger Plus!.
See http://www.msgpluslive.net/help/registry/ and look for the ScriptDebugReloadOnChange setting.

So, first turn on debugging mode:
Plus! > Preferences & Options > General > Scripts > Enable debugging options

Then in the inline scripting editor go to the Options menu and turn on all the available options.

All in all I do recommend learning to use the inline editor though. Because especially debugging will be a lot easier and you don't need to switch between windows all the time.

3)4) There is an Interface Tester application, also made by Patchou. Using that tool you can immediatly see how your own created window will look like. You can download the Interface Tester here: http://www.msgpluslive.net/scripts/browse/9/Tools...Script-Developers/

;)

This post was edited on 06-17-2009 at 06:21 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-17-2009 05:54 PM
Profile PM Find Quote Report
Flippy
Junior Member
**


Posts: 29
34 / Male / Flag
Joined: Jun 2009
O.P. RE: Basic Questions - LaTeX
1) I've tried running the commands directly, but it won't work. The reason is that the commands I'm using ("latex <file>" for example) don't work if the <file> is any full path (such as "C:\Test\file.tex"). The file needs to be relative (such as "file.tex").

Of course, for that to work, the current directory needs to be the directory in which the file is located. So I need to use the "cd <dir>" command to set this directory.

If I run the latex command separately, I cannot use the cd command (as far as I know), and hence it won't work.

Unless you can see another way?



2) Yeah, I realized that. It doesn't even do anything actually since WScript wasn't even any defined object. It gave me an error about that but I didn't notice it before. I removed it now.



3) I agree that the editor is not limited, especially not for an embedded editor. In fact, I know these types of editors pretty well, as I've used a few of them to make other applications. I am assuming it is a third party editor (it looks alot like the Quantum Whale editor, or the ActiPro (or something) editor), or did Patchou write it completely from scratch? If so, he should look into selling it lol. The editors I mentioned sell for about $500.

I know about the Outlining and Intellisense too, but the Intellisense seems to be pretty rare. It only shows up when I use objects such as 'MsgPlus. ...'. It doesn't show up when I try to call a function or something like that.
For example, the following script does not show Intellisense at the ___ location:
JScript code:
function someFunction(name, age)
{
    return "Your name is " + name + " and you are " + age + " years old.";
}
 
function someRandomFunction()
{
    var x = someFunction( ___ )
}

If I load this code in Visual Studio, as soon as I type "s", it shows me "someFunction()" in the list. I press "(" and it completes it to "someFunction(" and then tells me it is expecting the "name" variable. It also shows me clearly that it expects two arguments.

If I type this in the Plus! editor, Intellisense doesn't show up at all...

Maybe I'm just too used to C# or VB.NET, where Intellisense pretty much lets you write the code without touching the keys, but it doens't seem very helpful here.

Of course, Visual Studio has all the same features too, except for the debugging thing... That does seem helpful, although I suppose I could just keep the debugging window open (I don't have a dual monitor setup for nothing ;) ), that won't be much of a problem.


3) You already had a nr 3 ;)
Thanks for mentioning it though :p I'll check it out.


This post was edited on 06-17-2009 at 06:21 PM by Flippy.
06-17-2009 06:14 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Basic Questions - LaTeX
1) You're sure it doesn't allow absolute file names? In some cases it might be needed to use short path names instead of long path names. Or sometimes it requires you to enclose the file in quotes, and other times it explicitly doesn't.... Or maybe use a better converter :p

And you sure you didn't made the easy to make mistake of not doubling up the slashes? This is required in JScript. eg:
wrong: someFunction("C:\mydir\mycommand.exe")
correct: someFunction("C:\\mydir\\mycommand.exe")

If it indeed doesn't work with absolute file names, you could still execute the stuff in one go since the command line in Windows allows you to enter multiple commands on one line (using the & character). So you could still use the CD command before the LATEX command. eg: oShell.Run("CD c:\\blahblah & LATEX -someparameter")

Another possebility is using piping. This is where (simulated human) input is redirected to the command. This might even also safe you from first creating an input file.
eg: oShell.Run("echo $blahblah | C:\\mydir\\latex.exe")
(The $blahblah stuff will of course be the wrong syntax as it should be the same thing as when you manually type the stuff, but it's just an example of the principle using the echo command and piping (|) the output)

Then there is also maybe the possebility to use redirecting (using the < or > symbols) on the command line (though this does require a tex file).

Anyways, I'm sure it is possible to do everything in one go by using the proper DOS command line, without the use of any external files and batch files. The only question is how this LATEX tool exactly works and finding the proper syntax.

Therefor, can you provide a download link from where you got this LATEX command line tool? Then we can look into it and maybe give you the best solution. Or maybe even zip this latex command together with an example tex file and attach it to a post.

2) If you keep on using oShell.Exec, you do need to use timers (in order to check if the process has finished - oExec.Status != 0). Otherwise the function is executed asyncroniously and further code will run before the function has finished.

3) - Patchou writes all his stuff himself from scratch.
- Yes, IntelliSense in the inline editor only works for the build in Plus! functions and events (unfortunatly).

3) oops 4)

This post was edited on 06-17-2009 at 07:08 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-17-2009 06:36 PM
Profile PM Find Quote Report
Pages: (6): « First « 1 [ 2 ] 3 4 5 6 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On