So weird. Coming from a primarily C++/Java background, trusting in my
ability to just throw different datatypes around willie-nillie in
VBScript takes some getting used to. Even PHP is more picky, and I'd
always thought of it as lenient.
On 3/30/2011 5:12 PM, Aaron Smith wrote:
Ah, you figured it out. Yes, you can pass anything you want in an array,
including other objects (as you've noted) and arrays.
Aaron
On 3/30/2011 5:06 PM, Jared Wright wrote:
And you can in fact mix objects and strings in the array, which
confirms what I was really after. For instance:
dim oMyHotkey : set oMyHotkey =
Keyboard.RegisterHotkey("Control-shift-Z", "mySub", nothing,
Array("Aaron", ActiveWindow))
sub mySub(aParms)
dim sName : sName = aParms(0)
dim oWindow : set oWindow = aParms(1)
speak "Hi, " & sName & "! When this script launched, the active window
was " & oWindow.Name
end sub
Jared happy now. Thanks guys.
On 3/30/2011 4:58 PM, Jared Wright wrote:
The problem was that in my haste to pound out the example I wasn't
giving RegisterHotkey a variable to put its result in, as it's a
function not a sub. I'm an idiot either way. Should've been.
dim oMyHotkey : set oMyHotkey =
Keyboard.RegisterHotkey("Control-shift-Z", "mySub", nothing,
Array("see", "dog", "run"))
On 3/30/2011 4:43 PM, bT wrote:
Yes, just do not use the parens.
Standard VB calling method. You can use the parens if you place the
word call in front of the procedure or sub.
Bruce
Sent: Wednesday, March 30, 2011 4:35 PM
Subject: Re: Multiple Parameters to Hotkey Routines
If I load:
Keyboard.RegisterHotkey("Control-shift-Z", "mySub", nothing,
Array("see", "dog", "run"))
sub mySub(aParms)
speak aParms(0)& aParms(1)& aParms(2)
End Sub
I get:
hotkeypassing.vbs - Microsoft VBScript compilation error
Line 1 Column 89
Keyboard.RegisterHotkey("Control-shift-Z", "mySub", nothing,
Array("see", "dog",
"run"))ยท
Cannot use parentheses when calling a Sub
< 0x800A0414>
On 3/30/2011 3:49 PM, Aaron Smith wrote:
I will often do something like:
Keyboard.RegisterHotkey("Control-Blah", "MySub", SomeWindow, Array(x,
y, z))
and then
Sub MySub(parmArray)
firstParm : parmArray(0)
secondParm : parmArray(1)
thirdParm : parmArray(2)
End Sub
Aaron
On 3/30/2011 3:28 PM, Jared Wright wrote:
Just wanted some clarification on passing parameters to hotkey
routines, and I'm sort of hoping someone on here will know already
and
save me some trial and error work. Sorry, cheating a bit I guess.
If I
want to pass more than one parameter to my hotkey routine, is the
best
practice to wrap them all up in a collection of some sort? For
instance, I want to pass the XML Key ID so I can have its description
spoken by key describer, as shown in the WE Script Framework's setup
of hotkeys. But I also want to pass a second variable to the routine
for actual use in the execution of the hotkey. If it matters, I
presently want to pass either another string or a key object, I
haven't yet decided, but I'm sure this'll come up for me in future
plenty of times with a variety of datatypes. Ideally I could just
overload registerHotkey with six parameters instead of five, but
somehow I doubt it'll be that easy. Thanks in advance for the
knowledge.
--
Aaron Smith
Web Development * App Development * Product Support Specialist
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com
To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.
--
Aaron Smith
Web Development * App Development * Product Support Specialist
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com
To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.