Help with repeating command on IBM PCOMM

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with repeating command on IBM PCOMM

Post by HansV »

That should work, but you can streamline it a bit. You don't have to create the WScript.Shell object and set the variables over and over within the second loop:

Code: Select all

'REM This line calls the macro subroutine

Dim A1, oShell, retCode, strSoundFile, objShell, strCommand

subSub1_

Sub subSub1_()
    If MsgBox("An Alarm will be triggered when [NEW] or [ST] call are created within the Queue!", vbOKCancel, _
        " The Queue will be monitored for new call") = vbCancel Then Exit Sub

    'Once logged in and at the local queue, with all service call listed.....
    Do While autECLSession.autECLPS.GetText(5, 26, 3) <> "NEW" And _
            autECLSession.autECLPS.GetText(5, 26, 2) <> "ST" And _
            autECLSession.autECLPS.GetText(6, 26, 3) <> "NEW" And _
            autECLSession.autECLPS.GetText(6, 26, 2) <> "ST"
        autECLSession.autECLOIA.WaitForAppAvailable
        autECLSession.autECLOIA.WaitForInputReady
        autECLSession.autECLPS.SendKeys "ci", 22, 8
        autECLSession.autECLOIA.WaitForInputReady
        autECLSession.autECLPS.SendKeys "[enter]"
        autECLSession.autECLPS.Wait 5000 ' = 5 seconds - Adjust as required in miliseconds
    Loop

    strSoundFile = "C:\windows\Media\ringin.wav"
    strCommand = "sndrec32 /play /close " & Chr(34) & strSoundFile & Chr(34)
    Set objShell = CreateObject("WScript.Shell")
    Do
        objShell.Run strCommand, 0, False
        autECLSession.autECLPS.Wait 500 ' = 0.5 seconds - Adjust as required in miliseconds
        If objShell.Popup("New Call Found", 5, " ***WARNING***", &H1 + &H30 + &H1000) = &H2 Then Exit Sub
    Loop
End Sub
Best wishes,
Hans

moktarious
StarLounger
Posts: 61
Joined: 08 Oct 2011, 21:25

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

So we got it :) We learn a lot...Big thanks to you and Vegas man!

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with repeating command on IBM PCOMM

Post by HansV »

I've learned some new things too! :thumbup:
Best wishes,
Hans

moktarious
StarLounger
Posts: 61
Joined: 08 Oct 2011, 21:25

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

I had a question that came to my mind and it's important. When it's loop the audio...does it loop the whole process of doing CI then ENTER? It's important that it's loop that part also because let's say a colleague treat that call and it's not new anymore, well my session will still be ringing right?

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with repeating command on IBM PCOMM

Post by HansV »

As it is, you have two separate loops:

The first loop sends CI and Enter until there is neither NEW nor ST in the indicated positions.
Next, the second loop displays the popup repeatedly until the user clicks Cancel. Then, the code ends.
Best wishes,
Hans

moktarious
StarLounger
Posts: 61
Joined: 08 Oct 2011, 21:25

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

hmmmmm we have a problem there let me explain.

moktarious
StarLounger
Posts: 61
Joined: 08 Oct 2011, 21:25

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

Can we loop the whole process in one single loop? It's important that after the popup auto close and no one press cancel it recheck if the new call still exist u follow me?
Let me explain
So after it see the NEW or ST a sound is played then a pop up appears, if no action is taken the pop pup close and reappear by it self, but before reappearing I want that the first loop get rechecked in case the NEW call got already handled. I hope I made myself more clear.


Here is the actual code

Code: Select all

'REM This line calls the macro subroutine

Dim A1, oShell, retCode, strSoundFile, objShell, strCommand

subSub1_

Sub subSub1_()
    If MsgBox("An Alarm will be triggered when [NEW] or [ST] call are created within the Queue!", vbOKCancel, _
        " The Queue will be monitored for new call") = vbCancel Then Exit Sub

    'Once logged in and at the local queue, with all service call listed.....
    Do While autECLSession.autECLPS.GetText(5, 26, 3) <> "NEW" And _
            autECLSession.autECLPS.GetText(5, 26, 2) <> "ST" And _
            autECLSession.autECLPS.GetText(6, 26, 3) <> "NEW" And _
            autECLSession.autECLPS.GetText(6, 26, 2) <> "ST"
        autECLSession.autECLOIA.WaitForAppAvailable
        autECLSession.autECLOIA.WaitForInputReady
        autECLSession.autECLPS.SendKeys "ci", 22, 8
        autECLSession.autECLOIA.WaitForInputReady
        autECLSession.autECLPS.SendKeys "[enter]"
        autECLSession.autECLPS.Wait 5000 ' = 5 seconds - Adjust as required in miliseconds
    Loop

    strSoundFile = "C:\windows\Media\ringin.wav"
    strCommand = "sndrec32 /play /close " & Chr(34) & strSoundFile & Chr(34)
    Set objShell = CreateObject("WScript.Shell")

    Do
        objShell.Run strCommand, 0, False
        autECLSession.autECLPS.Wait 500 ' = 0.5 seconds - Adjust as required in miliseconds
        If objShell.Popup("New Call Found", 5, " ***WARNING***", &H1 + &H30 + &H1000) = &H2 Then Exit Sub
Loop

End Sub
Thanks

PJ_in_FL
5StarLounger
Posts: 1100
Joined: 21 Jan 2011, 16:51
Location: Florida

Re: Help with repeating command on IBM PCOMM

Post by PJ_in_FL »

Try to integrate this code in your script to beep until ENTER or SPACEBAR is pressed:

Code: Select all

' Function to beep until user presses ENTER (or spacebar)
'
Dim WshShell, beep, btn

  set WshShell = Wscript.CreateObject("Wscript.Shell")
  beep = chr(007)
  do
    WshShell.Run "cmd /c @echo " & beep, 0
    btn = WshShell.Popup("Press Enter", 2, "Looping ... ", &H20 + &H0)
  loop until btn > 0
PJ in (usually sunny) FL

moktarious
StarLounger
Posts: 61
Joined: 08 Oct 2011, 21:25

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

But that will only make the beep loop. I need to make the sequence CI then Enter loop again after NEW and ST is found and the POPUP is ran, so it like rescan the queue after the popup appear. So most likely something that restart the script from the top when the pop appear.

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with repeating command on IBM PCOMM

Post by HansV »

Does this do what you want? It wraps the two loops in an outer (infinite) loop:

Code: Select all

'REM This line calls the macro subroutine

Dim A1, oShell, retCode, strSoundFile, objShell, strCommand

subSub1_

Sub subSub1_()
    If MsgBox("An Alarm will be triggered when [NEW] or [ST] call are created within the Queue!", vbOKCancel, _
        " The Queue will be monitored for new call") = vbCancel Then Exit Sub

    strSoundFile = "C:\windows\Media\ringin.wav"
    strCommand = "sndrec32 /play /close " & Chr(34) & strSoundFile & Chr(34)
    Set objShell = CreateObject("WScript.Shell")

    Do
        'Once logged in and at the local queue, with all service call listed.....
        Do While autECLSession.autECLPS.GetText(5, 26, 3) <> "NEW" And _
                autECLSession.autECLPS.GetText(5, 26, 2) <> "ST" And _
                autECLSession.autECLPS.GetText(6, 26, 3) <> "NEW" And _
                autECLSession.autECLPS.GetText(6, 26, 2) <> "ST"
            autECLSession.autECLOIA.WaitForAppAvailable
            autECLSession.autECLOIA.WaitForInputReady
            autECLSession.autECLPS.SendKeys "ci", 22, 8
            autECLSession.autECLOIA.WaitForInputReady
            autECLSession.autECLPS.SendKeys "[enter]"
            autECLSession.autECLPS.Wait 5000 ' = 5 seconds - Adjust as required in miliseconds
        Loop

        Do
            objShell.Run strCommand, 0, False
            autECLSession.autECLPS.Wait 500 ' = 0.5 seconds - Adjust as required in miliseconds
        Loop Until objShell.Popup("New Call Found", 5, " ***WARNING***", &H1 + &H30 + &H1000) = &H2
    Loop
End Sub
Best wishes,
Hans

moktarious
StarLounger
Posts: 61
Joined: 08 Oct 2011, 21:25

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

But when I press CANCEL it doesn't stop it RELOOP the popup and I don't see the CI been retyped when the popup disappear and reappear if nothing is selected, it's seem only the POPUP is been looped.

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with repeating command on IBM PCOMM

Post by HansV »

Sorry, that must be due to my lack of knowledge of PCOMM. I hope that someone else will be able to solve this for you.
Best wishes,
Hans

moktarious
StarLounger
Posts: 61
Joined: 08 Oct 2011, 21:25

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

Let wait and see, thanks bro