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 »

I tend to do all of my PCOMM programming in excel vba, as my requirement was to upload and/or download data between the two. I always found it difficult to code within PCOMM, but controlling PCOMM with excel was relatively easy. That would not be suitable in this situation though as the endless loop would tie up both programs until "NEW" was found.

I'll dig out some old macro's tomorrow and see what we can do. I have no idea about the alert / email, I don't think you could generate an email from PCOMM.

Something along the lines of.....

Code: Select all

[PCOMM SCRIPT HEADER]
Language = VBSCRIPT
Description = PCOMM
[PCOMM SCRIPT SOURCE]
Option Explicit
autECLSession.SetConnectionByName (ThisSessionName)

'REM This line calls the macro subroutine
subSub1_

Sub subSub1_()

'Once logged in and at the local queue, with all service call listed.....
    Do While pcommPS.GetText(5, 26, 3) <> "NEW"
        autECLSession.autECLOIA.WaitForAppAvailable
        autECLSession.autECLOIA.WaitForInputReady
        autECLSession.autECLPS.SendKeys "ci"        'Screen coordinates 22/28 (Need the syntax)
        autECLSession.autECLOIA.WaitForInputReady
        autECLSession.autECLPS.SendKeys "[enter]"
        autECLSession.autECLPS.Wait 10000 'milliseconds - adjust as required
    Loop
    
    MsgBox "New call found"

End Sub
I'm not even sure that a message box can be generated, it may be thee best we can do is loop until NEW is found and cease, but you would need to keep an eye on the screen periodically. Is that viable?
: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 »

Are you online right now sir?

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

Btw it told me Error in the script line 14. Variable is undefined: pscommPS.

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

I also found this post of yours, have a look sir

http://windowssecrets.com/forums/showth ... I-think%29" onclick="window.open(this.href);return false;

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:I also found this post of yours, have a look sir

http://windowssecrets.com/forums/showth ... I-think%29" onclick="window.open(this.href);return false;
Yes, but that is excel vba code used to control PCOMM directly from excel. What you are looking for is a PCOMM VB script, examples of which I have at work and will post tomorrow.

Try changing:
Do While pcommPS.GetText(5, 26, 3) <> "NEW"
to:
Do While autECLSession.autECLPS.GetText(5, 26, 3) <> "NEW"

Does that work?
: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 »

Quick question what is (5, 26, 3) ?

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

Vegas I need to send you something that I can't make public, u will understand after I send it for I work...and I am sure I can be handy one day to you ;) Do you have any email, or msn I can contact you directly.

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:Quick question what is (5, 26, 3) ?
You said:
<< The "NEW" should be at line N (05,026) E (05,027), W (05,028)

5, 26, 3 = Row 5, column 26, 3 characters = NEW.

You can email me via the lounge as you did yesterday.
: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 »

It's seem to be working, but I will need to wait for the NEW call in the queue to disappear to see if it will still works. Also how can I also make it look for the string "ST".
The popup appears, is it possible to make it play a sound? .mp3 wav? or an alert ?
Thanks Vegas

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:It's seem to be working, but I will need to wait for the NEW call in the queue to disappear to see if it will still works. Also how can I also make it look for the string "ST".
The popup appears, is it possible to make it play a sound? .mp3 wav? or an alert ?
Thanks Vegas
Thanks for your email, I will respond by DM via the lounge.
I'm glad that it seems to be working. Once "New" is found, the macro will cease, therefore you will need to play the macro again in order to carry out a new search.

Where and when do you want to search for "ST", can you be specific?, including screen coordinates.

I am *amazed* that the msgbox appears, I did not think that it would. I don't know much about the VBSCRIPT language. Hans (or others) may be able to comment on whether a sound could be added. You could try changing:

MsgBox "New call found"
to
MsgBox "New call found", vbExclamation
or:
MsgBox "New call found", vbInformation

If this does work, the associated windows sound should play.
Last edited by VegasNath on 09 Oct 2011, 18:17, edited 1 time in total.
: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 »

Let me try, Btw I need the script to look for both NEW and ST is it possible?

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

vbExclamation = ICON with EXCLAMATION (Sound played but only once)
vbInformation = Normal windows with popup sound that played once
how can we make the sound play until we press OK

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:Let me try, Btw I need the script to look for both NEW and ST is it possible?
Yes, but where?
: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 »

Same position then the "NEW"

NEW and ST (= STATUS FOR NEW CALL BE OPENED)

NEW can be located here = 5, 26, 3 = Row 5, column 26, 3 characters
ST can also be located here = 5, 26, 3 = Row 5, column 26, 3 characters

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:vbExclamation = ICON with EXCLAMATION (Sound played but only once)
vbInformation = Normal windows with popup sound that played once
how can we make the sound play until we press OK
I *think* this is probably possible, but beyond my level of expertise, so I hope others may jump in and comment.
: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 »

look what I found
First off, the 1 is in there which is the constant value of "vbOkCancel". The following is from VB help for msgbox:

Constant Value Description
vbOKOnly 0 Display OK button only.
vbOKCancel 1 Display OK and Cancel buttons.
vbAbortRetryIgnore 2 Display Abort, Retry, and Ignore buttons.
vbYesNoCancel 3 Display Yes, No, and Cancel buttons.
vbYesNo 4 Display Yes and No buttons.
vbRetryCancel 5 Display Retry and Cancel buttons.
vbCritical 16 Display Critical Message icon.
vbQuestion 32 Display Warning Query icon.
vbExclamation 48 Display Warning Message icon.
vbInformation 64 Display Information Message icon.
vbDefaultButton1 0 First button is default.
vbDefaultButton2 256 Second button is default.
vbDefaultButton3 512 Third button is default.
vbDefaultButton4 768 Fourth button is default.
vbApplicationModal 0 Application modal; the user must respond to the message box before continuing work in the current application.
vbSystemModal 4096 System modal; all applications are suspended until the user responds to the message box.
vbMsgBoxHelpButton 16384 Adds Help button to the message box
VbMsgBoxSetForeground 65536 Specifies the message box window as the foreground window
vbMsgBoxRight 524288 Text is right aligned
vbMsgBoxRtlReading 1048576 Specifies text should appear as right-to-left reading on Hebrew and Arabic systems

I don't believe vbs would recognize the constants, so that is why I put the 1 in there originally (I think it was me at least). The responses have the values:

Constant Value Description
vbOK 1 OK
vbCancel 2 Cancel
vbAbort 3 Abort
vbRetry 4 Retry
vbIgnore 5 Ignore
vbYes 6 Yes
vbNo 7 No

So if you have:

If Msgbox("Click ok or cancel",1) = 1 then
msgbox "you clicked ok"
Else
msgbox "you clicked cancel"
end if

If you had the buttons yes/no/cancel on there (value of 3 instead of 1), you should store the return in a variable:

dim resp
resp = Msgbox("Click yes, no, or cancel",3)
If resp = 6 then
msgbox "you clicked yes"
elseif resp = 7 then
msgbox "you clicked no"
else
msgbox "you clicked cancel"
end if

Add up the different values for the "1" in your question to choose which button is default, if you want it a critical msgbox, if you want it a system-wide msgbox, etc. Playing around with it is usually the best way. I told you at one point you can use an MS Office VBA help to see these types of things (which is where I pasted all that from), but you can also use VBA to test these things. VBA and VBS are similar, though VBA always requires a sub/end sub or function/end function. Nonetheless it might help you learn a little more, though you're making great progress as it is.

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

I am starting my script like this

[PCOMM SCRIPT HEADER]
Language = VBSCRIPT
Description =Monitor New Call in Local Queue
[PCOMM SCRIPT SOURCE]
Option Explicit
autECLSession.SetConnectionByName (ThisSessionName)

'REM This line calls the macro subroutine

msgbox"The Queue is been monitored for new call, an Alarm will be triggered when [NEW] or [ST] call are created within the Queue!", vbOKCancel

How can I make the OK go on with the rest of the script and the cancel to abort it?

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:Same position then the "NEW"

NEW and ST (= STATUS FOR NEW CALL BE OPENED)

NEW can be located here = 5, 26, 3 = Row 5, column 26, 3 characters
ST can also be located here = 5, 26, 3 = Row 5, column 26, 3 characters
So you want to look for "NEW" OR "ST", both in the same place?
If so, try changing:

Do While pcommPS.GetText(5, 26, 3) <> "NEW"
to:
Do While pcommPS.GetText(5, 26, 3) <> "NEW" or pcommPS.GetText(5, 26, 2) <> "ST"

:crossfingers:
: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 »

U mean

Do While autECLSession.autECLPS.GetText(5, 26, 3) <> "NEW" or autECLSession.autECLPS.GetText(5, 26, 3) <> "ST"

hehe ;)

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

Re: Help with repeating command on IBM PCOMM

Post by moktarious »

No go, nothing happen...any idea?