Hi Bruce:

I am getting a feel for the methods.

One question about the hot key you define to download a webpage though.

Here is your call:

    Set myAlertAltDown =

Keyboard.RegisterHotkey("Alt-Down Arrow", "AlertWebPage", dObj.Window,

"pd")

In the above you filter the keypress messages based on a window object I
think.

That means, if I get it, that no matter what app is running or wherever
focus is that your app will only download the page so long as the window in
that object is active.

But, it will interrogate the keyboard message que or whatever holds keyboard
intputs and just skip that message in this case.

Now, what if a nube does not specify a filter parameter?

If I run your app and the hot key is created and later in the day hit the
hotkey while in say a program like word or something would your page still
try and download some webpage?

Rick USA

From: LBX [mailto:lab...@fltg.net] 
Sent: Monday, September 15, 2014 2:02 PM
To: gw-scripting@gwmicro.com
Subject: Re: Global Scripts and HotKeys

 

Hi Rick,

 

    Note this is what I do for all my hotkeys inside the Breaking News app,
or any app I write. If nothing was in the third parm you would have a
global, or kind of unpredictable event with the hotkey.

    I pass in the code for the command wanted from the select list as the
fourth parm and don't bother with the fifth, so I leave it blank.

    Below I also added the manual object list explanation for both hotkey
types, cursor and hotkey..

 

Format:

object.RegisterHotkey(Key, FunctionName, FilterBy, Parameter, FirstPress)


Download and make a list of the web page:

    Set myAlertAltDown = Keyboard.RegisterHotkey("Alt-Down Arrow",
"AlertWebPage", dObj.Window, "pd")

 

Download and read the page:

    Set myAlertCtrlDown = Keyboard.RegisterHotkey("Control-Down Arrow",
"AlertWebPage", dObj.Window, "rp")

 

Make a copy of the URL link in the Clipboard:
    Set myAlertAltUp = Keyboard.RegisterHotkey("Alt-Up Arrow",
"AlertWebPage", dObj.Window, "cp")

 

Just display the URL link:
    Set myAlertCtrlUp = Keyboard.RegisterHotkey("Control-Up Arrow",
"AlertWebPage", dObj.Window, "p")

 

The Register Hotkey explanation

RegisterHotkey
Registers a hot key, and returns a
RegisteredKey
 object. Hot keys are discarded (or "eaten"), and not passed through to an
underlying
application (just like Window-Eyes hot keys). The return value must be
stored in
order for the hot key to continue functioning until it is released (either
manually
using the
Unregister
 method of the
RegisteredKey
 object, or automatically when the script exits). Hot keys are designed to
add new
functionality. If you are adding functionality to an existing key press, you
should
use
RegisterCursorKey
.
Syntax
object.RegisterHotkey(Key, FunctionName, FilterBy, Parameter, FirstPress)
where object is a
Keyboard
 object.
Parameters
Name
Data Type
Required/Optional
Description
Key
Object/String
Required
Can either be a
Key
 object, or a quoted string containing the name of a hot key (i.e.
"Control-Shift-Q").
Modifiers are spelled out completely, not abbreviated. You can use the
Window-Eyes
hot key dialog to verify the exact spelling of a hot key to use as a string.
FunctionName
String
Required
Name of the user defined function to call when the hot key is pressed. Refer
to the
RegisteredKeyProc
 callback for function for more information.
FilterBy
Object
Optional
Window
 object or
Process
 object to filter the hot key by. If the hot key should work globally
(across all
applications), use Nothing as the FilterBy parameter, or leave it empty.
Note that
the FilterBy parameter will overwrite any filtering applied to a
Key
 object if a
Key
 object is passed as the Key parameter. Also note that if you supply any
additional
parameters, you must include the FilterBy parameter, again passing Nothing
(or leaving
the parameter empty) if you do not plan on using it.
Parameter
Variant
Optional
Additional parameter to be passed to the FunctionName. If you want to use
this parameter
as a return value, you will need to pass it as an object. Note that if you
supply
any additional parameters, you must include this parameter. If you do not
plan on
using it, leave the parameter empty. If this parameter is supplied, the
value will
be passed as the first parameter to the
hot key callback function
 (specified by the FunctionName parameter).
FirstPress
Boolean
Optional
Indicates whether a key has been pressed for the first time (True) or has
been pressed
more than one time in succession (False). If this parameter is True, a value
of True
will be passed as the last parameter to the
hot key callback function
 (specified by the FunctionName parameter) for the first press of the
hotkey, and
False for all subsequent presses of the hotkey.
Examples
' Create a hot key using a Key object
Set myKey = Keyboard.Keys(vk_R)
myKey.RequireModifiers kmControl Or kmShift Or kmWindows
Set registeredKey = Keyboard.RegisterHotKey(myKey, "SpeakHelloWorld")
Sub SpeakHelloWorld()
Speak "Hello world!"
End Sub
' Create a hot key using a string
Set registeredKey = Keyboard.RegisterHotKey("Control-Shift-Windows-R",
"SpeakHelloWorld")
Sub SpeakHelloWorld()
Speak "Hello world!"
End Sub
' Detect if a key has been pressed twice in succession
Set registeredKey = Keyboard.RegisterHotKey("Control-Shift-Windows-R",
"SpeakHelloWorld",
, , True)
Sub SpeakHelloWorld(firstPress)
If Not firstPress Then
          Speak "Key pressed twice in succession"
End If
End Sub

RegisterCursorKey
Previous page
Return to chapter overview
Next page
Registers a cursor key, and returns a
RegisteredKey
 object. Unlike hot keys, cursor keys are not discarded (or "eaten") so that
they
may be used in conjunction with an application, just like Window-Eyes cursor
keys.
The return value must be stored in order for the cursor key to continue
functioning
until it is released (either manually using the
Unregister
 method of the
RegisteredKey
 object, or automatically when the script exits). Cursor keys are designed
to add
additional functionality to an existing application key press. If you are
creating
new functionality, you should use
RegisterHotKey
.
Syntax
object.RegisterCursorKey(Key, FunctionName, FilterBy, Parameter)
where object is a
Keyboard
 object.
Parameters
Name
Data Type
Required/Optional
Description
Key
Object/String
Required
Can either be a
Key
 object, or a quoted string containing the name of a key (i.e.
"Control-Shift-Q").
Modifiers are spelled out completely, not abbreviated. You can use the
Window-Eyes
hot key dialog to verify the exact spelling of a key to use as a string.
FunctionName
String
Required
Name of the user defined function to call when the key is pressed. Refer to
the
RegisteredKeyProc
 callback for function for more information.
FilterBy
Object
Optional
Window
 object or
Process
 object to filter the cursor key by. If the cursor key should work globally
(across
all applications), use Nothing as the FilterBy parameter, or leave it empty.
Note
that the FilterBy parameter will overwrite any filtering applied to a
Key
 object if a
Key
 object is passed as the Key parameter. Also note that if you supply any
additional
parameters, you must include the FilterBy parameter, again passing Nothing
(or leaving
the parameter empty) if you do not plan on using it.
Parameter
Variant
Optional
Additional parameter to be passed to the FunctionName. If you want to use
this parameter
as a return value, you will need to pass it as an object. Note that if you
supply
any additional parameters, you must include this parameter. If you do not
plan on
using it, leave the parameter empty. If this parameter is supplied, the
value will
be passed as the single parameter to the
hot key callback function
 (specified by the FunctionName parameter).

Sent: Monday, September 15, 2014 8:37 AM

Subject: RE: Global Scripts and HotKeys

 

Hi Bruce:

Do you create the hot keys only when you create and activate a dialog and
then verify that dialog has focus?

Even if that is the case could that impact some other scripts global hot key
with the same key combo if something is to be done by that script even if
your app is running or do you turn off all the hot keys you use then turn on
yours and turn them off when your dialog closes somehow?

In other words, Is there any chance your hot keys can step on other scripts
hot keys making them not work if they are running active and use the same
hot keys?

I am just curious what type of global isolation exists between global
scripts like the jaws keyboard script and the insert key script and the
several other global scripts.

There are also the standard Windows HotKeys not to mention the many
dedicated to third party programs like Visual Studio, hundreds I think, and
others.

Since global scripts I think are active all the time once created and active
I was wondering if some problems might be related to some conflicts along
these lines.

Not specifically with your app but I used it as an example since you and
others are familiar with it for thinking about this question of global use
of hot keys over other global scripts and then over third party software
like your app.

Rick USA

 

  _____  


 <http://www.avast.com/> 

This email is free from viruses and malware because avast! Antivirus
<http://www.avast.com/>  protection is active. 

 

Reply via email to