Jump to content

Recommended Posts

Posted

First off, the project I'm working on revolves around AS/400 "Client Access software", it's foundation is directly influenced by the thread linked at the bottom of this post. Moving on, to explain the problem I'm facing; my project utilizes an infinite While loop and automatically performs semi-hard coded monotonous tasks to save users time and effort, the problem is, occasionally and unexpectedly "Display Messages" will popup and the core script will continue executing instead of dismissing said message and the script "breaks". As a countermeasure I've added some code to the While loop in an effort to intervene and dismiss these display messages before the core script has a chance to do anything... however it doesn't work. I hope I didn't do too bad of a job explaining that. 

So I think my question is: How can I temporarily "pause" the core script when these messages spontaneously appear?

The only other solution I thought of would be to check if a display message has appeared before executing every line of code but that obviously isn't very practical.

Any and all help is greatly appreciated!

Thanks

 

;Loop to keep script running and handle display messages
While 1
   dismiss_display_messages()
   Sleep(50)
WEnd

;Function to dismiss display messages
Func dismiss_display_messages()
   If $ps.SearchText("Display Messages") Then
      $ps.SendKeys("[enter]", 8, 1)
      ;This while loop waits until the display message has disappeared to resume the core script
      While $ps.SearchText("Display Messages")
         Sleep(100)
      WEnd
   EndIf
EndFunc

 

 

Posted
1 hour ago, faustf said:

messagbox with answer , the script stay in pause till you press yes or not

If your recommending I put the MsgBox in the dismiss_display_messages()  function it won't help because the While loop seems to stop while the core script is running.

To further explain this, I put ConsoleWrites in the While loop to debug and noticed they stopped firing when the core script starts.

Posted
Just now, FrancescoDiMuro said:

@Rhidlor
Post your entire script.

I don't believe that's entirely necessary, its over 1000 lines across multiple files. What is it you'd like to know?

Posted (edited)
3 minutes ago, FrancescoDiMuro said:

@Rhidlor
The definition/declaration/initialization of $ps.

It's virtually identical to the declaration of $Ps in the topic I linked above.

Edit: I may as well post it here
 

$window = WinGetTitle("Session A - [24 x 80]")
$emulator_handle = WinGetHandle($window)
$session = StringMid(WinGetTitle($emulator_handle), 9, 1)
$obj_emul_session = ObjCreate("PCOMM.autECLSession")
$obj_emul_session.SetConnectionByName($session)
$ps = $obj_emul_session.autECLPS

 

Edited by Rhidlor

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...