eyalyaari
asked on
VBScript and event handling under WSH
hi,
I would like to write a VBScript program using WSH that waits for incoming calls and then processes them as they come in. I found the ActiveX controls that can deal with the telephony side of the application, but since it's a completely event driven application, what does the main part of the VBScript do while waiting for a call to come in and trigger an event? I imagine that if there was a way to ping/query for an incoming call, then I could write a while loop that sleeps for one second and then pings, although that seems so wasteful and inefficient. But I don't think I have that functionality anyway, which raises the question of how do I get VBScript to twiddle its thumbs (while waiting for an event to be triggered) until a call comes in? and if I do discover a function that can tell me if a call is coming in, is the while loop I described above the best way to handle that?
Thanks,
Eyal Yaari
I would like to write a VBScript program using WSH that waits for incoming calls and then processes them as they come in. I found the ActiveX controls that can deal with the telephony side of the application, but since it's a completely event driven application, what does the main part of the VBScript do while waiting for a call to come in and trigger an event? I imagine that if there was a way to ping/query for an incoming call, then I could write a while loop that sleeps for one second and then pings, although that seems so wasteful and inefficient. But I don't think I have that functionality anyway, which raises the question of how do I get VBScript to twiddle its thumbs (while waiting for an event to be triggered) until a call comes in? and if I do discover a function that can tell me if a call is coming in, is the while loop I described above the best way to handle that?
Thanks,
Eyal Yaari
ASKER
I tried running a tight loop like that and it used up 25 to 30% of my CPU. Is there a way to put it in sleep commands or something to that effect which won't eat up so much computer resources? what would happen if I put in a sleep command in the body of the loop, would it miss the events that happened during that time or would the events get queued up? is there a kind of "sit idle and listen" method?
Secondly, I don't have a property or method that can access the event trigger. for example, while I am given the event, X_OnIncomingCall, I am not given any property or method that can tell me if there is any incoming call.
Also, if I had a long "if" statement inside the loop that was checking for the event trigger and then triggering the corresponding subroutine, then aren't I copying the functionality of events in the first place? I wouldn't need to use the built-in event handler since I would be doing the exact same thing manually, right? Or have I missed the point...
Thanks,
Eyal
you could use task manager to kick off the job at a particular time..infinite loop will likely cause the CPU to over process...if you know when the trigger will launch then the task manger can scehedule to run the script right after a trigger launches...
ASKER
unfortunately, since the application is processing incoming phone calls it needs to be running all the time :-(
Maybe this can't be done in VBScript? Would I have the same problem if it was done in regular Visual Basic?
Eyal Yaari
Maybe this can't be done in VBScript? Would I have the same problem if it was done in regular Visual Basic?
Eyal Yaari
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
excellent, that makes sense. I'll try it in Outlook VBA. Thanks.
Eyal Yaari
Eyal Yaari
Do
'Add your Event Trigger here probably in an If statement or Select Case
Loop