how to assign specific time pop up message in uipath with message box - uipath

I want to use message box as good morning message at 8:00 everyday but I couldnt assign the time interval. Can anyone help me to assign specicif time in uipath for message box

A couple of options:
While Loop
Rather than a delay you could use a while loop to check the time.
So your sequence would be
While Date.Now.Hour <> 8
End While
Message Box "Good Morning"
Obviously doing this you won't be able to do anything while the loop is running so isn't really going to work properly
While Loop in Parallel
The benefit this has over the above solution is that it can run while something else is running too
Parallel
While True
If Date.Now.Hour = 8
Message Box "Good Morning"
End If
End While
End Parallel

Related

how can I run ruby script for n-occurrences every X-minutes

I am looking at https://github.com/jmettraux/rufus-scheduler which nicely allows me to schedule and chain events.
But I want the events to stop after, say, the 10th occurrence or after the 24 days.
How do I do this?
My case would be:
run a script which creates the recurring jobs based on intervals and then stops after a given date or occurrence.
This is what I have done.
def run_schedule(url, count, method, interval)
puts "running scheduler"
scheduler = Rufus::Scheduler.new
scheduler.every interval do
binding.pry
attack_loop(url, count, method)
end
end
I am testing my site and want the attack_loop to be scheduled in memory to run against the interval.
But it appears it never hits the binding.pry line.
Normally these schedulers are running via cron jobs. Then the problem with your requirement is cron job doesn't know whether you hit the 10th occurrence or the 24 days as it doesnt keep a track. One possible solution would be to create a separate table to update the cron job details.
I'm thinking a table like,
scheduler_details
- id
- occurrence_count
- created_date
- updated_date
_ scheduler_type
So, now when you run a script, you can create or update the details. (You can search the script by scheduler_type, that way
you can check the number of occurrences
with created date, you can calculate the 24 days
HTH
Good day, you can specify the number of times a job should run:
https://github.com/jmettraux/rufus-scheduler/#times--nb-of-times-before-auto-unscheduling
If you need a more elaborate stop condition, you could do:
scheduler.every interval do |job|
if Time.now > some_max_date
job.unschedule
else
attack_loop(url, count, method)
end
end
But it appears it never hits the binding.pry line.
What has it to do with your issue title? Are you mixing issues?

Ruby -- How to require user input while simultaneously showing a countdown

(Warning: I'm relatively new to Ruby.)
I'm writing a simple math script that will help my kids learn their addition facts. I want to show a countdown that they need to beat with their answers. So, for instance, while they're watching a countdown go from 5 to 0, they need to press '6 + enter' in order to correctly answer 3 + 3 = ?. The '6 + enter' should stop the countdown and advance them to the next question.
Currently, this is the code for my countdown:
5.downto(0) do |i|
print "\r00:00:#{'%02d' % i}"
sleep 1
end
This works, as far as it goes. It gives me the countdown that I want. The problem is that I need to solicit an answer from the user that will interrupt this countdown -- while the countdown process is still running. As it stands, I could put a
answer = gets.chomp
after the countdown, but that's obviously not going to help me very much.
Any ideas? I've tried to read up on how to run simultaneous processes, but the explanations have been a bit difficult to follow, and none of the ones that I read about seemed to allow the kind of user interaction I'm after.
Thanks in advance for your help.!
Threading is the answer. Here's what I did. It isn't perfect, but it gets the job done.
student_answer = nil
timer = Thread.new do
5.downto(0) do |i|
puts "\r00:00:#{'%02d' % i}"
sleep 1
end
puts 'Time is up'
end
answer = Thread.new do
puts 'What is your answer?'
student_answer = gets.chomp
end
answer.join(5)
timer.join
if $answer.nil?
puts 'No Answer'
else
puts "Your answer is #{student_answer }"
end
This code will produce the following output
What is your answer?
00:00:05
00:00:04
00:00:03
00:00:02
00:00:01
00:00:00
Time is up
No Answer
Of course, you can enter your answer at anytime, but the answer thread is killed about 5 seconds, and you can no longer enter any answer.
Unfortunately, I can not figure out how to kill the timer thread once an answer is inputted. If anyone have any ideas, please let me know.

Howto know that I do not block Ruby eventmachine with a mongodb operation

I am working on a eventmachine based application that periodically polls for changes of MongoDB stored documents.
A simplified code snippet could look like:
require 'rubygems'
require 'eventmachine'
require 'em-mongo'
require 'bson'
EM.run {
#db = EM::Mongo::Connection.new('localhost').db('foo_development')
#posts = #db.collection('posts')
#comments = #db.collection('comments')
def handle_changed_posts
EM.next_tick do
cursor = #posts.find(state: 'changed')
resp = cursor.defer_as_a
resp.callback do |documents|
handle_comments documents.map{|h| h["comment_id"]}.map(&:to_s) unless documents.length == 0
end
resp.errback do |err|
raise *err
end
end
end
def handle_comments comment_ids
meta_product_ids.each do |id|
cursor = #comments.find({_id: BSON::ObjectId(id)})
resp = cursor.defer_as_a
resp.callback do |documents|
magic_value = documents.first['weight'].to_i * documents.first['importance'].to_i
end
resp.errback do |err|
raise *err
end
end
end
EM.add_periodic_timer(1) do
puts "alive: #{Time.now.to_i}"
end
EM.add_periodic_timer(5) do
handle_changed_posts
end
}
So every 5 seconds EM iterates over all posts, and selects the changed ones. For each changed post it stores the comment_id in an array. When done that array is passed to a handle_comments which loads every comment and does some calculation.
Now I have some difficulties in understanding:
I know, that this load_posts->load_comments->calculate cycle takes 3 seconds in a Rails console with 20000 posts, so it will not be much faster in EM. I schedule the handle_changed_posts method every 5 seconds which is fine unless the number of posts raises and the calculation takes longer than the 5 seconds after which the same run is scheduled again. In that case I'd have a problem soon. How to avoid that?
I trust em-mongo but I do not trust my EM knowledge. To monitor EM is still running I puts a timestamp every second. This seems to be working fine but gets a bit bumpy every 5 seconds when my calculation runs. Is that a sign, that I block the loop?
Is there any general way to find out if I block the loop?
Should I nice my eventmachine process with -19 to give it top OS prio always?
I have been reluctant to answer here since I've got no mongo experience so far, but considering no one is answering and some of the stuff here is general EM stuff I may be able to help:
schedule next scan on first scan's end (resp.callback and resp.errback in handle_changed_posts seem like good candidates to chain next scan), either with add_timer or with next_tick
probably, try handling your mongo trips more often so they handle smaller chunks of data, any cpu cycle hog inside your reactor would make your reactor loop too busy to accept events such as periodic timer ticks
no simple way, no. One idea would be to measure diff of Time.now to next_tick{Time.now}, do benchmark and then trace possible culprits when the diff crosses a threshold. Simulating slow queries (Simulate slow query in mongodb? ?) and many parallel connections is a good idea
I honestly don't know, I've never encountered people who do that, I expect it depends on other things running on that server
To expand upon bbozo's answer, specifically in relation to your second question, there is no time when you run code that you do not block the loop. In my experience, when we talk about 'non-blocking' code what we really mean is 'code that doesn't block very long'. Typically, these are very short periods of time (less than a millisecond), but they still block while executing.
Further, the only thing next_tick really does is to say 'do this, but not right now'. What you really want to do, as bbozo mentioned, is split up your processing over multiple ticks such that each iteration blocks for as little time as possible.
To use your own benchmarks, if 20,000 records takes about 3 seconds to process, 4,000 records should take about 0.6 seconds. This would be short enough to not usually affect your 1 second heartbeat. You could split it up even farther to reduce the amount of blockage and make the reactor run smoother, but it really depends on how much concurrency you need from the reactor.

VBScript: Reminder for office workers and personal use

My program asks the user for any events that he will be having later on (eg. meeting/special lunch event/submit report/pay bills/birthday) and will remind the user when the time comes.
Here is my code:
Dim remind
re=MsgBox("Do you want me to remind you anything later on?", vbYesNo, "Reminder")
If re=6 then call main
Sub main
' Ask for the time that the user wanted to be reminded
remind=InputBox("At what time?" & vbNewLine &
"Please use this format {H:MM:SS AM/PM}" & vbNewLine &
"Note: H is in 12h format")
' Description eg. "Lunch with boss"
reminder=InputBox("Any discription you want to add in?")
Do Until check=remind
check=Time
If check=remind Then MsgBox reminder
Loop
End Sub
For example, I put in 12:30:00 PM and Lunch with boss. Even when the time comes nothing happens, no popup. And when I check my TaskManager it is still running.
I'm using wscript.exe to run this script. It's the do until check=remind part that doesn't work. If I put do until check="12:30:00 PM" then it will work.
PS: I know we can use the Microsoft Outlook for the reminder or even use our phones. But this is well suited for workers that are 24h infront of the computer and lazy to use their phones and update their outlook.
Convert to Date data type
The issue seems to be that the remind variable is a String data type, and the check variable is a Date data type. When you try to compare them, they'll always fail to be equal, even if the actual date inside both types is the same.
You can solve the problem by using the CDate function to convert remind to a Date before entering the loop.
remind = CDate(remind)
Validation
Because you're now using CDate to convert the user's input, if they make a typo and enter an invalid date, its going to bring up an error box and end the program. You may want to use IsDate to ensure it is a valid time before converting it, then gracefully ask the user to enter the time again if they made a typo.
CPU Usage
Your loop will sit there taking up 100% CPU usage of one core of the machine its running on. This can slow down your user's computer, among other side effects.
To fix this issue, you want to slow down the loop, such that its only checking a few times a second, rather than a few hundred times a second. Insert this statement inside the loop to have it sleep for 500 milliseconds before trying again.
WScript.Sleep 500

how to delay 'say' actions in siri proxy plugin

I've started to play with Ruby on Rails to make some plugins for Siri Proxy Server.
I am inexperienced with Ruby but have manage the basics.
what I have done:
################ Commands
listen_for (/show a demo to (.*)/i) do |name|
show_demo
request_completed
end
################ Actions
def show_demo(name)
say "Hi #{name}, let me do a quick demo for You."
say "For example if You tell me 'Turn on sidelight' I will turn the sidelights in Living room like now..."
system "/usr/local/bin/tdtool --on 2"
say "That was the sidelights, and now if like I can turn on the gallery for You, just tell me 'turn on gallery' like so... "
system "/usr/local/bin/tdtool --on 3"
say "This only part of things I can do after mod."
say "Now I will turn all devices off..."
system "/usr/local/bin/tdtool --off 3"
system "/usr/local/bin/tdtool --off 2"
say " Thank You #{name}, and goodbye."
end
The problem is when I'll start the demo all the actionssystem "..." are executed before Siri start to say anything .
How can I delay above action to put them in right place in time to execute them right after words I want?
Thank You in advance.
The problem is that say won't wait for Siri to actually say the words, it just sends a packet over to your iDevice and then goes on. The simplest approach i can think of would be to wait a few seconds, depending on how long the text is. So first we need a method that gives us the duration to wait (in seconds). I tried with the OSX built-in say command and got the following results:
$ time say "For example if You tell me 'Turn on sidelight' I will turn the sidelights in Living room like now..."
say 0,17s user 0,05s system 3% cpu 6,290 total
$ time say "That was the sidelights, and now if like I can turn on the gallery for You, just tell me 'turn on gallery' like so... "
say 0,17s user 0,06s system 2% cpu 8,055 total
$ time say "This only part of things I can do after mod."
say 0,13s user 0,04s system 5% cpu 2,996 total
So this means we have the following data:
# Characters w/o whitespace | Seconds to execute
------------------------------+---------------------
77 | 6.290
87 | 8.055
34 | 2.996
This leaves us with an average of about 0.0875 seconds per character. You may need to evaluate the average time for your scenario yourself and with more samples. This function will wrap say and then wait until the text was spoken out by Siri:
def say_and_wait text, seconds_per_char=0.0875
say text
num_speakable_chars = text.gsub(/[^\w]/,'').size
sleep num_speakable_chars * seconds_per_char
end
where gsub(/[^\w]/,'') will remove any non-word characters from the string. Now you can use this to simply say something and wait for it to be spoken out:
say_and_wait "This is a test, just checking if 0.875 seconds per character are a good fit."
Or you can also override the duration in special cases:
say_and_wait "I will wait for ten seconds here...", 10
Let me know if it works for you.

Resources