2019-02-26 06:37:20 (edited by grryfindore 2019-02-26 06:39:35)

Hi,
So I have been playing around with jaws scripting for a while now and although the documentation/ manual is a bit lacking, its decent to work with and understand.
I have a few questions issues that I am facing though, and hope someone here can help me out.
The first problem that I have is when I try to use the typekey () function
Its parameter requires us to give it a key name or a scan code, For simple keystrokes like Alt+F you can just write that and it will hopefully catch on, but what about keystrokes that are a bit more complex? I.E ctrl+Alt+Up arrow?

Another question which is a bit unrelated to the previous one is the jaws delay function, perhaps I don't get it, but if I use it, the script either gets performed entirely before the delay function or after the delay all at once.
For example if on a webpage, I wanted it to find a piece of text , go there and click a link, and have it wait til the page loaded or say 3 4 seconds and then go to a specific line number and read it, would such a thing be possible? if yes, could you show me how?

Thanks and cheers
Grryf

Of all sad words of tongue or pen, the saddest are these, ‘It might have been.
Follow me on twitter

2019-02-26 07:08:49

Typekey works fine with multiple key modifiers. You could do ctrl+alt+shift+insert+f12, if you wanted to.

Are you taking into account that the delay function uses milliseconds? If you want it to delay for 3 seconds, for example, you need to write it as:
delay (3000)

It's been ages since I've done scripting, but I think the functions you'll want for your scrip are findString, Delay, and SayLine. There's some more stuff you could do like SaveCursor to remember where the cursor was, then go to the top of the page, do your find and speech, then RestoreCursor so you don't lose your position. If you can't figure it out by the morning, I'll whip up an example for you.

Kai

Spill chuck you spots!

2019-02-26 08:38:09 (edited by grryfindore 2019-02-26 08:39:43)

Hi,
  Thank you Xoren for your reply
I just tried 3000 delay and it crashed my jaws lol
The manual talks about 1 being 10th of a second so perhaps its more like 30 or 300 instead?
Still it doesn't seem to work as I imagine it should
I.E have jaws read a line, press enter on that link, have it wait for 3 seconds,have it do something else such as move to next heading. It does reading lines just fine, but the enter keypress only happens after the delay where as it should be happening before the delay instead?
And As for the typekey event, The trouble I am having is phrasing the keystroke properly that is not knowing what will work and what not.
As I said, for example if I wanted to use ctrll+alt+up arrow, what would I go and write it up for the script to understand that that in fact is the keystroke I am looking for (wanting to use)?
Thanks again
Grryf

Of all sad words of tongue or pen, the saddest are these, ‘It might have been.
Follow me on twitter

2019-02-26 12:37:16 (edited by flackers 2019-02-26 13:31:52)

You know you can type your key commands between braces to save using the typekey function. So you could just do {control+Shift+L} for instance. What is it you're trying to do with the up arrow command? Because I've found just typing uparrow inside braces doesn't cause an up arrowing effect as in moving to the prior line. Control+UpArrow doesn't do anything either, yet Windows+UpArrow does maximize the window, so the uparrow is working that time. There is a sequence you have to arrange combined modifiers in, such as control shift alt windows, but I'm not absolutely sure what it is other than being pretty sure control and shift come first. You can't type shift+control and have it work just like control+shift is what I mean. For just moving the cursor up a line it's best to use the actual PriorLine () function. And for control up arrow, PriorParagraph. As for the delay before enter, it seems to be working okay for me. I've just tried it on this website. If you go to the top of the page and arrow down four times, you should be on a link to the audiogames forum. I ran the following script to check the delay before the EnterKey function, and it worked okay. The delay is 5 seconds. Going down line by line to find a link probably isn't the best way, but it's just a test of the last two functions.

Script Test ()
NextLine ()
NextLine ()
NextLine ()
NextLine ()
Delay (50)
EnterKey ()
EndScript

2019-02-26 14:28:01 (edited by grryfindore 2019-02-26 14:30:25)

Hi,
Thank you flackers.
I did not know you could just type keynames inside braces and they would work, but then again this has the same issue as that of the typekey () function, that is naming keys in a way that the script would understand that its control alt up arrow that I am trying to use when I write {ctrl+alt+up arrow}
Does jaws have a list of keynames or codes that it recognises somewhere?

As for what I am exactly trying to do its something like this.
1. on a webpage find a specific text which falls in a table cell? row colom etc?
2. if the text is found, use the ctrl alt up arrow command to go to and read the cell above that sell area where the line was located
I have many more places such a thing would prove to be useful that's why my atempt at learning what different keystrokes should be written as so as to make jaws understand.

The delay thing if it works correctly could also be very handy, but perhaps its just me that isn't getting it write.
I will write a example script to demenstrate what exactly I am trying to do and where it goes wrong.
Script TestDelay ()
SayLine (); we make jaws say what's on the current line has to be a link
EnterKey ()
Delay (50)
MoveToNextHeading ()
NextLine ()
EnterKey ()
EndScript
What I want to happen with that script.
Go to a link, activate the script.
Jaws says the link name and presses enter
Jaws then gives the page 5 seconds to load.
After which it should move to the next heading and say line again and move to next line.
Press enter again.
If you run it, you will see that that's not what happens.
Thanks again!
Grryf

Of all sad words of tongue or pen, the saddest are these, ‘It might have been.
Follow me on twitter

2019-02-26 15:10:02 (edited by flackers 2019-02-26 17:11:50)

Instead of putting Control+Alt+UpArrow into your script, you would have to put UpCell () as that is the script you're trying to activate. It must just be that if you have a script containing a key command  that normally activates another script, it doesn't activate the script but passes the key command straight to the application. . I wrote a similar script to the one you suggested for testing the delay, and although I think the delay part worked, I think what's happening is that when a new page loads, jaws automatically triggers other scripts that let it interact with the webpage. The fact that you're trying to do stuff on a new page before these automatic scripts have  been performed, is probably the issue. You'd probably have to include in your script these functions that are normally run automatically.

2019-02-26 16:19:12

I don't have JAWS on here to test your script. Can you provide details for those of us who can't run it?

With respect to your typeKey question, yes, JAWS has an understanding of key labels that let you type things like {CTRL+UP}; to execute the CTRL+UP command. They're somewhere in hjconst.jsh but I don't remember where. You can open hjconst.jsh and look for keycode or something like that.

Scripting for web pages is always tricky because the new page has to be loaded into JAWS' memory (called the virtual buffer) before JAWS can interact with it. So a better way to write your script would be to have your script click the link, then code in the onPageLoad event will execute once the new page loads to resume the rest of your script. OnPageLoads isn't the exact name of the event that fires when a new page loads but I think you get the idea. For context switches you should always hook into the event loop that the language provides instead of potentially blocking sync processing.

JAWS developers have done a good job at naming all of their events with "event," so you should be able to easily find the event that fires when a new page loads. Look for code that looks like its speaking the number of headings and things on a page and you should be pretty close to where you want to be.

If I had JAWS I'd give you some code examples, but I hope this helps you a little anyway.

2019-02-27 05:33:57

Hi,
Thank you guys for your inputs.
flackers, possibly but perhaps that can be passed through with the event that Munawar describes, that is if the delay thingy works as I am imagining it does. Try jaws reading some lines, a few keystrokes that don't involve page loads with a delay and a few more keystrokes or activity and you will see it doing the same thing. could be just me not knowing and screwing it up, though.


Munawar, I have found a few functions That may do, but I am not really sure as it is, I am really new to scripting and have a very basic understanding of programming. so I could be missing very obvious things.
one that seems promicing is

fsdn wrote:

Function: DocumentLoadedEvent
Description
When an internet explorer document is loaded it will automatically begin reading.

Returns
Type: Void


Parameters
No Parameters

Version
This function is available in the following releases:

JAWS 4.51 and later
MAGic 10.5 and later

or

fsdn wrote:

DoDefaultDocumentLoadActions
Description
Performs the default sequence of events when DocumentLoadedEvent fires.

And Thank you, I was able to locate the hjconst.jsh file, but it doesn't include keycodes for combos, do I just combine them with the + sign?

As for what this script does, and what I expect it to do is something like this
It reads the first line just fine, But everythhing else in the script happens after the delay at once
What should actually happen or my intent is have it read the link we are on, press enter on it and wait for 5 seconds and then perform rest of the script.
Thank you guys once again!
Grryf

Of all sad words of tongue or pen, the saddest are these, ‘It might have been.
Follow me on twitter