Solved

How to create macro to capture the session screen and beep if condition met?

Posted on 2008-06-12
6
1,697 Views
Last Modified: 2013-12-06
I would like to create the macro the refresh every several mins to monitor the job status, once "MSGW" appears the macro should know "beep" me.. then I can do other things without monitoring the session all the time. The tech points is that I dont know how to compare the strings in the screen and don't know how to trigger beep in the macro..

Sam

 I've coded the sample to prompt message for message wait job, but I do want to "Beep". anyone know it?  the current screen will be on the work job screen, e.g. wrkusrjob xxx *active. then this macro is applied to monitor this screen.. by refreshing every 3 secs, prompts warning ifmessage wait job found.
 
[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=
[PCOMM SCRIPT SOURCE]
OPTION EXPLICIT
autECLSession.SetConnectionByName(ThisSessionName)
 
REM This line calls the macro subroutine
 
subSub1_
 
sub subSub1_()
Dim MsgInd
Dim MsgRow, MsgCol
Dim MsgJob
Dim MsgBody
 
MsgInd = False
MsgRow = 1
MsgCol = 1
 
MsgBody = "prompt message"
 
Do while MsgInd=False
   autECLSession.autECLOIA.WaitForAppAvailable   
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.Wait(3000)
   autECLSession.autECLPS.SendKeys "[pf5]"
   MsgInd = autECLSession.autECLPS.SearchText("MSGW",1,MsgRow,MsgCol)
   If MsgInd Then
	MsgJob = autECLSession.autECLPS.GetText(MsgRow, 7, 10)
	Msgbox MsgBody,,"Batch Monitor" 
   End if
Loop
 
end sub

Open in new window

0
Comment
Question by:Sam80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 21767540
Hi Sam80,

I do a similar trick to get the program name, see Snippet.
The Beep... ? I will check, buy I'm wondering if that isn't a MSGBOX function :s

Regards,
Murph
Function Correct_Program_Window(sProgramName)
  Dim bCP, i
  ' Get 10 characters starting at row 1 col 2
  autECLSession.autECLOIA.WaitForAppAvailable
  autECLSession.autECLOIA.WaitForInputReady
  bCP = False
  For i = 0 To 10 'try 10 times to check if the right programme is reached
    bCP = ((trim(autECLSession.autECLPS.GetText(1, 2, 15))) = sProgramName)
    If bCP then 
      exit For
    Else
      autECLSession.autECLPS.Wait(500)
    End If
  Next
  Correct_Program_Window = bCP
End Function

Open in new window

0
 
LVL 16

Accepted Solution

by:
theo kouwenhoven earned 50 total points
ID: 21768649
Found it :)
The Beep is the standard ASCII 7 character (Bell)
you can use good old dos to echo that by a shell.

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c @echo "
 = CHR$(7)

Good luck,
   
0
 

Author Comment

by:Sam80
ID: 21813925
Thanks murphey2, but can the AS400 session macro support WScript.CreateObject? I've tried before but seems not work, I will try when I back tomorrow.. keep you update..
0
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 21814948
Hi Sam40,

It is already some day's ago, but I think I copied this example from a working script.

Regards,
0
 

Author Comment

by:Sam80
ID: 21819099
I've got the beep statement.. check it out:
Beep = chr(007)
autSystem.shell "cmd.exe", "/c @echo " & Beep,5
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 21820013
Hi Sam,

Good Old Great DOS :)

Have Fun!!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Often we come across situations wherein our batch files would be needing to reboot Windows for a variety of reasons. A few of them would be like: (1) Setup files have been updated whose changes can take effect only after a reboot …
Just about everyone has an old PC laying around.  Ask anyone in the IT industry, whether they are a professional or play in it as a hobby.  From outdated Desktops to cheap "throwaway" laptops, they are all around and not as hard to "fix up" as you m…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question