[jawsscripts] Re: Testing whether the {ShiftKey} in a function is really being pressed?

  • From: "Donald Marang" <donald.marang@xxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Tue, 24 Mar 2009 10:26:47 -0400

Have you looked at the GetKeyState function?  I have not used this function 
yet,, but I think it will let you check if the Shift key is being held down. 
Holding down the Shift key by itself does not trigger any events that I know 
of.  It seems like the trick here is to create a function to monitor if this 
has happened yet!  If you know about when to expect this event, you can use 
something similar to:
If GetKeyState ("Shift", iDown, iLocked) Then
; I am assuming the Shift needs to be in quotes.  I am sure you are more 
familiar with this value/variable than I am!
; The iDown and the iLocked parameters are passed by reference.
; This means these values are set by the function and can be used 
afterwards.
    If iDown Then
        ; Shift key is down, perform desired action
        HandleSectionRefresh ()
    EndIf
EndIf

If the key can be pressed at any time, you may need to place this type of 
check in a self perpetuating function using the ScheduleFunction capability. 
This would be a function that contains the above code to check the state of 
the Shift key. and then schedule the function again. I do have examples of 
this way of monitoring if you need to go this route.

From the FSDN:
Function: GetKeyState
Description
Returns by reference both the up/down state of the key, and the toggle state 
if applicable. NumLock, ScrollLock, and CapsLock have toggle states.

Returns
Type: Int
Description: TRUE if the keystate was successfully returned.


Parameters
Param 1:
Type: String
Description: The name of the key whose state is to be retrieved. A list of 
key names is referenced in keycodes.ini.
Include: Required


Param 2:
Type: Int
Description: Set to true if the key is in a down state.
Include: Required
* Returns data by reference


Param 3:
Type: Int
Description: Set to true if the toggle state is on. For example, if CapLock 
is in the on state, then this value will be true.
Include: Required
* Returns data by reference


Version
This function is available in the following releases:

PAC Mate 1.10 and later
JAWS 4.51 and later
Magic 10.5 and later


Don Marang


----- Original Message ----- 
From: "Geoff Chapman" <gch@xxxxxxxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Tuesday, March 24, 2009 8:15 AM
Subject: [jawsscripts] Re: Testing whether the {ShiftKey} in a function is 
really being pressed?


> Hi Jackie.
> Thanks for this suggestion!
>
> hmmmm, Well, as it happens, I can't quite recall now! whether I've tried
> that one or not!
> I may have, but maybe not in resolving this particular issue, ... oh, 
> wait,
> yes I have, I remember now why I can't utilize that, because it sends 
> things
> into a loop if I do, for refreshing the window, in this case refreshes the
> whole app, as it's a terminal emulation package with no unique Windows for
> controls as such at all so far as I can see,
> and, I've got stacks of StringContains conditions being watched for in
> NewTextEvent,
> which of course would run heaps when things like refreshWindow were done, 
> to
> run a bunch of checks to see which screen is present, and load the correct
> FrameSet and set the Global variable for each screen that I've set up. 
> So,
> if I put a refreshWindow in any of these LoadFrameSet functions, that'll
> just retrigger the loop and on and on it'll go.
> <grin.>
> So, I don't think th'ats gunna be the magic formula I need for this one.
> I need something that isn't going to reload the frameSet, which I'm pretty
> positive from my testing, is what's breaking the normatively reliable
> OnFocus Frames I've got going for each TabStop, from working properly.
> When I disable FrameSets from Loading, Refreshing does indeed happily
> trigger the OnFocus Frame that I want to fire. But, ... yeah, it's working
> out how I can make it happy and trigger, without doing that.  That's the
> trick.
>
> And what's difficult is, 8 times out of 10, my manually tapping the shift
> key, does bring the joy I want! it's just insuring that I'm realy doing it
> from a Script now, that I want to work out how to do. and/or, to test that
> it really is being pressed from inside my function?
>
>
> Have you got any further ideas Jackie on how I might test for this? when 
> it
> doesn't seem to generate, on it's own, any integer in KeyPressed Event?
>
>
> ----- Original Message ----- 
> From: "Jackie McBride" <abletec@xxxxxxxxx>
> To: <jawsscripts@xxxxxxxxxxxxx>
> Sent: Monday, March 23, 2009 4:18 PM
> Subject: [jawsscripts] Re: Testing whether the {ShiftKey} in a function is
> really being pressed?
>
>
>> U tried a refreshwindow function?
>>
>> On 3/22/09, Geoff personal <gch@xxxxxxxxxxxxxxxx> wrote:
>> > Scripters.
>> > Another queery if I may.
>> > I have a situation where I've loaded a new FrameSet, into the 
>> > jff/jfd's,
>> > with a bunch of OnFocus frames
>> > to handle a particular screen's tab order, but, of course, There's a
> timing
>> > issue going on, such that the frame whose events I want to fire upon 
>> > the
>> > cursor moving/being inside it, is in this new FrameSet, and, of course
> the
>> > screen has to be already loaded, and the cursor moved to that point,
> before
>> > the FrameSet actually loads.
>> > This means that the Current field label on the new Screen, which I've
> got
>> > working via an OnFocus frame in the new FrameSet just loaded, doesn't
> fire
>> > properly.
>> > now what's weird is, pressing the shift key manually, seems to, flush,
>> > something, and make the proper ONFocus frame fire it's events as if the
>> > cursor had just moved into it.
>> > Yet, when I place that shiftKey in a function, either like this:
>> > {Shift}
>> > or
>> > I place that single line in another function and schedule it,
>> > neither one of these approaches, seems to emulate what I can do 
>> > manually
> by
>> > hitting the shift key?
>> > and the annoyance is, that if this isn't flushed and read properly, 
>> > when
> the
>> > user tabs once, instead of reading the next Tab field and just ignoring
> it's
>> > current one, it also performs the "flushing" type function, and fires
> the
>> > data in the frame being left as well.
>> > So, bottom line is, Can anyone tell me how I might test, whether using
>> > leftRight braces to pass the shiftKey in this way,
>> > is actually really activating/pressing it or not?
>> > When placing a
>> >
>> > SayInteger (NKey)
>> > statement , in KeyPressedEvent,
>> > to speak keystrokes as they are pressed, tapping the control or shift
> key
>> > doesn't emit any number, so I'm not even sure if this registers
> properly?
>> >
>> > Is there any other way in a function, to insure that the shift key is
> being
>> > simply tapped by itself, to provide the functionality I'm after?
>> > I can see a function here called TypeKey, but whenI try inserting this,
> it
>> > asks me for a "message constant containing the
>> > Keystroke  Name?
>> > And, well I'm not at all sure yet how I might work out where I might
> find
>> > such a thing, hense my  use of leftRight Braces to simply pass the key
>> > through to the application?
>> > and if KeyPressedEvent doesn't even register it alone as having been
>> > pressed, as it seems is the case, I feel a bit stumped on this one too?
>> >
>> >
>> > thanks so much for any pointers.
>> >
>> >
>> > Geoff c.
>> >
>> > __________
>> > Visit and contribute to The JAWS Script Repository
> http://jawsscripts.com
>> >
>> > View the list's information and change your settings at
>> > http://www.freelists.org/list/jawsscripts
>> >
>> >
>>
>>
>> -- 
>> Change the world--1 deed at a time
>> Jackie McBride
>> Check out my homepage at:
>> www.abletec.serverheaven.net
>> & please join my fight against breast cancer
>> <http://teamacs.acsevents.org/site/TR?px=1790196&pg=personal&fr_id=3489>
>> __________
>> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>>
>> View the list's information and change your settings at
>> http://www.freelists.org/list/jawsscripts
>>
>
> __________
> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
> 

__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

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

Other related posts: