Hi all,
Thanks Steve, Aaron and Jamal, Excellent advise from all of you. Yep your right 
Aaron, it was line one that the problem was accurring, and I should have noted 
this when asking for help.  Yes, it is what I want this script to do for now, 
as I am writing this just to get to grips with these particular objects and 
properties.  If I had not included the sleep and disconnect method I could be 
locked out of window-eyes in a most undesirable manner, I just don't know 
whether this script will stop me from being able to access the window-eyes 
control panel, so this is why this routine was written, in this way,  as a test 
routine so I thuroughly understand what it can do for me before writing this in 
to my script.  Thanks again to you guys.
Warm regards.
Martin Webster.



--- On Sat, 8/30/08, Aaron Smith <[EMAIL PROTECTED]> wrote:

> From: Aaron Smith <[EMAIL PROTECTED]>
> Subject: Re: can somebody help me with this?
> To: [email protected]
> Date: Saturday, August 30, 2008, 3:41 PM
> Martin,
> 
> As Steve suggested, make sure each line of the code is on
> the correct 
> line. In this case, however, it looks correct to me. He
> probably had 
> some weird email line wrap. Remember that when you get an
> error, you 
> will also get a line number, which will tell you exactly
> what line the 
> error is occurring on.
> 
> You didn't say which line number you got back in the
> error, but I'm 
> willing to bet that the error is occurring on the line:
> 
> ConnectEvent(DesktopWindow, "OnChildActivate",
> "MyOnChildActivate")
> 
> You're getting this error exactly for the reason the
> error says: "Cannot 
> use parentheses when calling a Sub." In VBScript, when
> you call a method 
> that does not return a value, or if you're not
> interested in the return 
> value, you do not need the parenthesis. In fact, if you
> include them, 
> you'll get the error that you got. If you look in the
> documentation for 
> the Script.ConnectEvent method, you'll see that it does
> return a value. 
> Whether or not you care about that return value is up to
> you, but the 
> correct syntax is required.
> 
> If you don't care about the return value, then you call
> the method 
> without parenthesis:
> 
> ConnectEvent DesktopWindow, "OnChildActivate",
> "MyOnChildActivate"
> 
> If you do care about the return value, then you call the
> method with 
> parenthesis:
> 
> retval = ConnectEvent(DesktopWindow,
> "OnChildActivate", "MyOnChildActivate")
> 
> I see one other error in the script below:
> 
> Disconnect(Desktop.Window)
> 
> There are two issues with this line. The first is the same
> as the error 
> above. You're can't use parenthesis when calling a
> method that does not 
> have a return value, or you don't care what the return
> value is. 
> According to the documentation, Script.Disconnect does not
> return a 
> value, so you can't use the parenthesis. So your line
> would look like:
> 
> Disconnect Desktop.Window
> 
> 2. Although the syntax of your line is now correct,
> you'll get another 
> error because of the parameter you are passing. You'll
> note from the 
> documentation that the Disconnect method takes a
> ConnectionHandle 
> parameter, which according to the description, is a handle
> obtained from 
> a ConnectEvent method. The parameter you're passing
> (Desktop.Window) 
> doesn't exist. There's no Desktop object that has a
> Window parameter. I 
> assume you're thinking of the object DesktopWindow
> (note there's no dot 
> in the name). Even that, however, is still incorrect
> because the 
> parameter that Disconnect requires is a ConnectionHandle,
> not a window 
> object. If you need to use the Disconnect method, then you
> need to have 
> a connection to actually disconnect from. And that would be
> the return 
> value of a ConnectEvent method (as the docs state).
> 
> So with all of that knowledge, your script would end up
> looking like this:
> 
> retVal = ConnectEvent(DesktopWindow,
> "OnChildActivate", "MyOnChildActivate")
> Sub MyOnChildActivate(win)
>       win.Overlap.Settings.General.Hotkeys = FALSE
>       Sleep 5000
>       Disconnect retval
>       Playsound, "c:\whistle wake.wav"
> End Sub
> 
> There's one quirk to this script, though. When the
> OnChildActivate event 
> fires, MyOnChildActivate will get called, the hotkeys will
> get set to 
> false, a 5 second pause will happen, then OnChildActivate
> event will get 
> disconnected, and a sound will play.
> 
> But what happens then next time a child window gets
> activated? Because 
> the OnChildActivate event was disconnected the first time 
> MyOnChildActivate ran, you're no longer watching the
> OnChildActivated 
> event. So MyOnChildActivate will only happen once, and
> never again.
> 
> Is that the behavior you're after?
> 
> Aaron
> 
> martin webster wrote:
> > Hi all,
> > I got an example from Doug which disables most hotkeys
> globally, but I can't seem to get this routine to work
> in VB script.  I get the error, "cannot call a sub with
> parentheses when calling a sub".  I've looked at
> some other examples I have and this looks correct to me. 
> This script should disable most hotkeys for 5 seconds, and
> then disconnect this event, in other words, I want this
> action only to accur for 5 seconds, and then I want the
> hotkeys to be enabled again.
> > Begin VB script.
> > 
> > ConnectEvent(DesktopWindow,
> "OnChildActivate", "MyOnChildActivate")
> > Sub MyOnChildActivate(win)
> >     win.Overlap.Settings.General.Hotkeys = FALSE
> > Sleep 5000
> > Disconnect(Desktop.Window)
> > Playsound, "c:\whistle wake.wav"
> > End Sub 
> > 
> > Warm regards.
> > Martin Webster.
> > 
> > 
> > 
> > 
> >       
> > 
> 
> -- 
> 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
> GW Micro
> Phone: 260/489-3671
> Fax: 260/489-2608
> WWW: http://www.gwmicro.com
> FTP: ftp://ftp.gwmicro.com
> Technical Support & Web Development


      

Reply via email to