Help with repeating command on IBM PCOMM

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Help with repeating command on IBM PCOMM

Post by VegasNath »

moktarious wrote:Thanks yes now this work, so now let figure out how to make the MsgBox "New Call Found", vbExclamation, " ***WARNING***" loop till the ok is pressed (it will keep beeping, like an alert or alarm u follow me sir?
Great stuff, I'm pleased that we got there!
I'm not sure on this bit though, hopefully someone else may comment. Good luck.
:wales: Nathan :uk:
There's no place like home.....

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

Or can we call an outside file (mp3,wav) that will be played when the msg box appear?

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Help with repeating command on IBM PCOMM

Post by VegasNath »

moktarious wrote:Or can we call an outside file (mp3,wav) that will be played when the msg box appear?
Beyond my level of expertise I'm afraid. I'm hopeful that somebody will know of a bit of trickery....
:wales: Nathan :uk:
There's no place like home.....

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 »

When a message box is displayed, all code execution pauses until it is closed, so you can't loop while the message box is open.

I have no idea whether you can play media files from within PCOMM.
Best wishes,
Hans

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

Any suggestion for a workaround?

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

Got an idea, will an outside shell do the job?

Dim wsh
Set wsh=CreateObject("WScript.Shell")
wsh.Run("%windir%\AppScript.cmd")
wsh.Popup "Done"


or adding a timer to the msg box, if nothing pressed the box close then we will do a while routine, till the OK is press then the script will stop. is that a good ideA?
http://vb.mvps.org/samples/TimedMsg/" onclick="window.open(this.href);return false;

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

Or check this, I think this is what we need...

How can we configure it on PComm

http://blogs.technet.com/b/heyscripting ... cript.aspx" onclick="window.open(this.href);return false;

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

I think I got it. Now i can play an outside sound without any problem. The only thing missing is a timer to the last MsgBox so when no one press cancel, it will reloop the whole script, meaning the sound will play again. This is the best approach to the problem I guess.

Code: Select all

[PCOMM SCRIPT HEADER]
Language = VBSCRIPT
Description =Monitor New Call in Local Queue - Made by Me MySelf And I (need to remain private, but people who are using this script know who I am hehe)- Version 1.0
[PCOMM SCRIPT SOURCE]
Option Explicit
autECLSession.SetConnectionByName (ThisSessionName)

'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, 008 
            autECLSession.autECLOIA.WaitForInputReady
            autECLSession.autECLPS.SendKeys "[enter]"
            autECLSession.autECLPS.Wait 500 ' = 5 seconds - Adjust as required in miliseconds
    Loop
Do

strSoundFile = "C:\windows\Media\Notify.wav"
Set objShell = CreateObject("Wscript.Shell")
strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34)
objShell.Run strCommand, 0, False
autECLSession.autECLPS.Wait 500
If MsgBox("New Call Found", vbSystemModal + vbExclamation + vbOKCancel,  "    ***WARNING***") = vbCancel Then Exit Sub
Loop

End Sub
Last edited by moktarious on 09 Oct 2011, 22:32, edited 1 time in total.

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 »

Thanks for sharing your solution!
Best wishes,
Hans

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

Np sir, you have any idea how I can set a timer to that MsgBox if no action taken it will close?

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

I am so almost there :( but can't figure out :( :(

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 »

Not easily - as I mentioned before, code execution pauses when you display a message box. If you're running the code from Excel, you could use Application.OnTime to send a command to the message box, but I don't know of a way to do this from script.
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 set a countdown to the msgbox when no action is taken, do you know how to do that?

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 »

Again, code execution is halted as long as the message box is open, until the user closes it, so you can't run a countdown while the message box is displayed.
Best wishes,
Hans

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

What about a Wscript.Shell's popup ?

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 don't think that would help, sorry.
Best wishes,
Hans

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

createobject("wscript.shell").popup "New Call Found", 5, " ***WARNING***", &H1 + &H30 + &H1000

Got it awesome, now it's playing my sound and looping after 5 second if no key pressed . Now how I make it stop the loop if cancel is pressed?

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

Got it

If createobject("wscript.shell").popup("New Call Found", 5, " ***WARNING***", &H1 + &H30 + &H1000) = &H2 Then Exit Sub

U see sir

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 »

Perhaps something like this?

Code: Select all

Do
    intResult = CreateObject("wscript.shell").Popup("New Call Found", 5, " ***WARNING***", &H1 + &H30 + &H1000)
Loop Until intResult = 2
(2 = vbCancel, this value is returned by the Popup method if the user clicks the Cancel button)
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 me show u my whole script and tell me if it's ok
Mine also worked the one I pasted before

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, 008 
            autECLSession.autECLOIA.WaitForInputReady
            autECLSession.autECLPS.SendKeys "[enter]"
            autECLSession.autECLPS.Wait 5000  ' = 5 seconds - Adjust as required in miliseconds
    Loop
Do

strSoundFile = "C:\windows\Media\ringin.wav"
Set objShell = CreateObject("Wscript.Shell")
strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34)
objShell.Run strCommand, 0, False
autECLSession.autECLPS.Wait 500  ' = 0.5 seconds - Adjust as required in miliseconds

If createobject("wscript.shell").popup("New Call Found", 5, "    ***WARNING***", &H1 + &H30 + &H1000) = &H2 Then Exit Sub
Loop

End Sub