Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I'm looking for a way to make the WaitForIdle (or equivalent function, even a custom one) work on a JScript macro.
What I'm trying to achieve is to pause the application (not make it "sleep", as I've already done with custom code) in order to select a value on a field and give time to the application to "update the layout" with the selection before taking a screenshot.
Currently with the lone sleep the screenshot is taken before I can see the layout update.
Do you have any hint about how to do this in JScript?
Sorry for the very late answer, I had literally no time
Anyway, this is what I discovered:
Thanks to everyone for the help!
It has been a while I didn't code in JScript, but I think you can use if you haven't already tried it:
setTimeout(function() {alert("take your screenshot");}, 1000);
You can also look into using WinJS libraries:
https://msdn.microsoft.com/en-us/library/windows/apps/br229706.aspx
Hi Sinan, thanks for your reply
I've already tried that (only difference is the Application.Msgbox instead of the alert) but it's not working... When I use it opens the Edit Module and does nothing at all!
I'm not sure about how to use them, using directly
WinJS.Application.stop();
won't work...
Do I need to import anything? If not, could you make a working example, please?
thanks
I believe you need to download WinJS from this link WinJS: Windows Library for JavaScript - Windows app development
Apart from this, the only way is to use setTimeout() as far as I know.
Tried that, but including it in the module gave me many errors: on the WinJS base/ui file there are many strings that ends with a ",", which I'm not sure about... Of course the parser gives me error, and I think they are wrong too... but I hope they left them there for a purpose
Still no luck with setTimeout, but thanks for trying
Let's see if anybody else has an idea/workaround for my problem
Here is how you can use InputBox and MsgBox from JScript:
// JScript
function Test()
{
personName = qvlib.InputBox("What is you name?")
msg = "Hello " + personName + " !"
qvlib.MsgBox(msg)
}
Try this:
function Test()
{
qvlib.MsgBox('Started.');
app = ActiveDocument.GetApplication();
qvlib.MsgBox( '[' + app.OSName() + ']' );
app.WaitForIdle();
qvlib.MsgBox('Ended.');
}
Hi Petter, thanks for your reply,
I've tried it and it works, but I don't think this example is the best one... When you use a MsgBox or something else where you need the user to execute an action (in this situation click the "ok" button to proceed with the execution of the macro) you stop the execution, so it's not like having it scheduled...
Anyway I found the solution to my problem, I'll post it later