[jawsscripts] Re: Schedule function

  • From: "Paul Magill" <magills@xxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Wed, 15 Sep 2010 22:51:14 +1000

Hi Utin,

Below is the description from the Freedom Scientific scripting FSDN for 
ScheduleFunction, followed by a list of some of the FS scripts files in the 
version 11 shared folder that contain examples of ScheduleFunction. Below 
that is an extracts from a previous post on the topic, but first, some 
general comments in no particular order.

There are a wide range of uses for this function. Some of these are:
*. if you want to monitor a particular window, or location on the screen for 
changes, & have something happen on any change, or on particular changes.
For example, an application may display a warning message at a particular 
location on the screen, but there is no normal way of monitoring that 
location, so you could schedule a function to check that location regularly 
by having the scheduled function, schedule itself, perhaps every 2 seconds, 
to route the invisible cursor to the location & ...

*. to prevent repetitive speaking of the same text, where it is repeated 
because the application, either rewrites the same text to the screen a 
number of times very quickly, or writes different portions of the text at 
slightly different times.
ScheduleFunction is used to delay the speaking of that text until all those 
screen writes have happened.
For example,  in NewTextEvent it might be identified that a particular 
window's text  is suffering from the above problem, so the general approach 
inside NewTextEvent is:
if (window = window with the problem) then
ScheduleFunction ("SpeakRepeatingWindow",2)
EndIf
The function SpeakRepeatingWindow then might use something like SayWindow to 
speak the text.
- the reason it works, is that there is a delay of 2 from when the text was 
first written to screen, till when it is to be spoken.
if that same window has the text rewritten within the delay of 2, then the 
schedule starts over, and the first call never happens. The effect is that 
the only text that gets spoken, is that which does not get rewritten within 
a delay of 2.
- it works quite well

*. you can not pass in parameters to functions that are scheduled. If the 
function that is scheduled needs values from where it is called, then you 
need to place those values in global variables, and use those globals in the 
scheduled function.

Description from FSDN:
Runs a user defined function in a set period of time. Useful when you want 
to perform a task and then check on the results at a later time. Once this 
function is used, you can call UnScheduleFunction to cause the user-defined 
event not to run.

Returns
Type: Int
Description: An ID that can be used to call UnScheduleFunction. If 0 is 
returned, then the timer was not successfully set.


Parameters
Param 1:
Type: String
Description: Name of function to be executed.
Include: Required


Param 2:
Type: Int
Description: Amount of time to elapse before the function is executed. Time 
is measured in tenths of a second. A value of 10 is one second.
Include: Required


FS files  containing examples of ScheduleFunction:

Default.JSS,
triton_im.JSS,
Microsoft Outlook 2000.JSS,
TaxAct 2006.JSS,
Microsoft Outlook XP.JSS,
Windows Mobile Device Center.JSS,
Windows Live Messenger 8.JSS,
MSN Messenger.JSS,
Microsoft Outlook 2003.JSS,
Windows Messenger.JSS,
winamp.JSS,
Microsoft Word.JSS,




A previous post on the topic:

----- Original Message ----- 
From: Sepke, Glen
Subject: RE: Schedule function 101?


Here is a primer on the schedule function.

Why would I use it?
If I wanted to delay the execution of a function, while other work continues
to carry on in the application.
With ScheduleFunction you supply a function name, and a delay, I.E. how long
will it wait until it executes.

Example:
I have some error message which had better be heard by my user.
Unfortunately, with typing and reading interrupt on, there is a chance the
error message could be missed by the user if they start to type, just as it
starts to speak.
Here's what I would do ...

include "hjconst.jsh"

globals
; stores the users original interrupt choices
int gblTypingInterrupt,
int gblReadingInterrupt


Void Function ResetInterrupts ()
; this function simply resets the interuptable options
; back to the user selected values
SetJcfOption (OPT_READING_INTERRUPT, gblReadingInterrupt)
SetJcfOption (OPT_TYPING_INTERRUPT, gblTypingInterrupt)
Say ("Scheduled function finally ran, and reset original interruptable
options", OT_STATUS)
EndFunction

Script TestScheduleFunction ()
; store the original user interupt choices
Let gblReadingInterrupt = GetJcfOption (OPT_READING_INTERRUPT)
Let gblTypingInterrupt = GetJcfOption (OPT_TYPING_INTERRUPT)
; set interuptable to off
SetJcfOption (OPT_READING_INTERRUPT, OFF)
SetJcfOption (OPT_TYPING_INTERRUPT, OFF)
; schedule reset function in 4 seconds
ScheduleFunction ("ResetInterrupts", 40)
Say ("This message will be spoken and will not be interrupted even if you
hit keys while it is speaking", OT_STATUS)
EndScript

How to test it?
Assign the script to a key.
If you execute the script, the long winded message will speak even if you
hit keys to read or type.

The one draw back of this example is that you must adjust the timing so that
the reset of the options occurs as soon as possible after the important
message is spoken, otherwise the user could be hitting keys and not getting
the expected interrupt speech.
Of course, speeding up the speech will vary what time you should allow for
the message to speak.

Hope this helps.
Glen Sepke


Regards,

Paul from Aust



----- Original Message ----- 
From: "udin rambo" <rambo.udin@xxxxxxxxx>


Hi,
i've been trying to use the schedule function. Actually, what is it
for? Can anyone give me an example of it?

THANKS!

__________�

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: