Is it possible to create a countdown to a specific date and time inside imacros? I know that this can be done by scheduling in windows to run the .bat file but this is not helpfull because it first launches firefox and then runs the macro and this can take a few seconds. I want this to be integrated inside the imacro and running all the way until the specific date and time and then continue executing the remaining script. Can anybody write an example script to use it in imacros?
Just as an example, you can try something like this code:
' ... '
SET specificTime "2018-02-14T12:00:00"
SET countdownTime EVAL("var ct = parseInt((new Date('{{specificTime}}') - new Date()) / 1000); Math.max(0, ct);")
WAIT SECONDS={{countdownTime}}
' Happy Valentine’s Day! '
Related
I have a script which has some commands that takes time to complete like 30 sec to 1 minute to get completed.
What I am trying to achieve is that till the time command is doing it works in the background we should get some counter or timer or anything getting displayed till the command is running.
When command gets completed, the counter gets stopped.
The user running the script should be aware that yes something is running.
For example like when we open any site and it takes time to load, we get the sand timer or something else as in the display.
I have a job in autosys and I need to update it to remove the starting time completely.
Currently the start time is set to run at 10pm every night.
update_job: myjobname
start_times:
Do I leave the start_times blank as above or do I change it to start_times: " "
Any help would be greatly appreciated.
Yes, you have to keep it as blank. However, along with this you have to remove the days_of_week or run_calendar as applicable:
update_job: myjobname
start_times:
days_of_week:
If you are looking to remove this from schedule, another way is to just update the boolean value of date_condition
update_job: myjobname
date_conditions: n
here "n" would mean not to follow the timings. It can be mentioned as 0 or 1. The user has to force start the job on need basis.
I have a scheduled task that wakes up the computer to run a batch file. However the computer turns back off after some time. I have my computer set to (never sleep) so after waking up from the task it should stay on.
However after doing some reading I found out this was because the computer did not wake up from user input.
What I am looking for is a simple script (batch or vb file maybe) I can run via task scheduler that will simulate user input. Maybe hitting the space bar once or moving the mouse.
Running windows 8.1
I tried the following .vbs script without success
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.SendKeys("+{F10}")
You can try this application:
http://mousejiggler.codeplex.com/
It'll simulate mouse movement to keep your computer awake.
If you really want a script try this:
https://gallery.technet.microsoft.com/scriptcenter/Keep-Alive-Simulates-a-key-9b05f980
You can simulate the [F5] key to refresh windows every 2 minutes like this :
Option Explicit
Dim Ws
set Ws = createobject("Wscript.Shell")
Do
Ws.Sendkeys "{F5}"
Call Pause(2)'To sleep for 2 minutes
Loop
'***************************************
Sub Pause(min)
Wscript.Sleep(min*1000*60)
End sub
'***************************************
on Windows 7, how do I trigger on first occurance of an event each day to run a small batch file?
I'm trying to kick off a small batch script that runs only for a few seconds when I unlock my PC, but I only want it to run the first time I unlock my PC and never again until the I unlock my PC after 12AM of the next day. I can't tigger on specific time because the time at which I unlock my PC is random. I have been playing with task scheduler for days without success.
You could have the script set a state on first run, which keeps it from running again, for example by exiting immediately instead of doing anything when the state is set.
Then set up a task that triggers on log on to execute said script and another task that runs each day at 12AM to unset/remove the state set by the script. This should give you the effect you want.
A better solution, would be to have the script deactivate (f.e. via schtasks) the task triggered by logging on that called it and have the 12AM task restart the logon triggered task once each day.
I just faced the same problem, so here is my workaround without knowing to much scripting:
I created 4 .bat-files containing basically the following.
start application, afterwards replace bat-file1 with bat-file2
do nothing
replace bat-file1 with bat-file4
start application, afterwards replace bat-file1 with bat-file2
Now I created to scheduled tasks:
The first one runs every day at 12am and runs batch-file 3. Hence, it replaces bat-file1 with bat-file4.
The second one runs after every unlocking of the computer and runs batch-file1.
As you can see in total it does exactly what you want, although it might be a little bit complicated...
On your first unlock it starts your desired script and replaces itself with a dummyfile (the batch file only contains the word exit). After every following unlocking nothing but a hardly noticable cmd popup happens.
At 12am the dummyfile is replaced by the initial batch-file again, to provide your task in the next morning.
I'm writing a JScript program which is run in cscript.exe. Is it possible to run a commnad line command from within the script. It would really make the job easy, as I can run certain commands instead of writing more code in jscript to do the same thing.
For example:
In order to wait for a keypress for 10 seconds, I could straight away use the timeout command
timeout /t 10
Implementing this in jscript means more work.
btw, I'm on Vista and WSH v5.7
any ideas? thanx!
You can execute DOS commands using the WshShell.Run method:
var oShell = WScript.CreateObject("WScript.Shell");
oShell.Run("timeout /t 10", 1 /* SW_SHOWNORMAL */, true /* bWaitOnReturn */);
If you specifically need to pause the script execution until a key is pressed or a timeout elapsed, you could accomplish this using the WshShell.Popup method (a dialog box with a timeout option):
var oShell = WScript.CreateObject("WScript.Shell");
oShell.Popup("Click OK to continue.", 10);
However, this method displays a message box when running under cscript as well.
Another possible approach is described in this article: How Can I Pause a Script and Then Resume It When a User Presses a Key on the Keyboard? In short, you can use the WScript.StdIn property to read directly from input stream and this way wait for input. However, reading from the input stream doesn't support timeout and only returns upon the ENTER key press (not any key). Anyway, here's an example, just in case:
WScript.Echo("Press the ENTER key to continue...");
while (! WScript.StdIn.AtEndOfLine) {
WScript.StdIn.Read(1);
}
thanx for the help ppl, this was my first post and stackoverflow is awesome!
Also, I figured out another way to do this thing, using the oShell.SendKeys() method.
Here's How:
var oShell = WScript.CreateObject("WScript.Shell");
oShell.SendKeys("cls{enter}timeout /t 10{enter}");
This way you can run almost every dos command without spawning a new process or window
EDIT: Although it seems to solve the problem, this code is not very reliable. See the comments below
Yes, with the WScript.Shell object.
See the docs and samples