Jump to content
Macro Express Forums

Terminate Program With/Without User Intervention


tpiper
 Share

Recommended Posts

I have a timer set up that displays a reminder message for a user to close a program if they aren't using it. I have a repeat loop that contantly displays the reminder and a dialog box every few minutes. If they type yes in the dialog box then they are given more time. If they type no or hit cancel then the program closes, which is what I want.

 

My problem is that I also want the program to automatically close if there is no response at all, such as if they are away from their computer for long periods of time and don't respond to the dialog box.

 

I'm new to using Macro Express. I've tried using OR logic to terminate the program after a period of time but can't seem to get that to work. Also tried to control the cancel button in the dialog box with an automated click on the cancel button, but again didn't work. I'm sure there is a simple way to do this but can't seem to find the right way.

 

Any help is appreciated!

 

Tom

Link to comment
Share on other sites

Use the If Message command. It allows you to choose the types of buttons to display, which one is the default and a Default Time Out value.

 

Kevin, I tried it and I can time out the the message box, but I don't see how this will terminate the program that I'm trying to close without clicking on a button. I need the macro to run such that if no button at all is clicked then the program will terminate after a certain period of time. What am I missing?

 

Thanks,

Tom

Link to comment
Share on other sites

Hmmm, I never used this before, but I just tried it. IF MESSAGE appears to return a boolean true/false value.

IF MESSAGE:XXXX

TEXT BOX DISPLAY: YES WAS SELECTED

ELSE

TEXT BOX DISPLAY: NO WAS SELECTED

END IF

 

Whatever you specify as default is the highlighted button on the display, and is also the boolean value returned on timeout. So in your case maybe this would work:

IF MESSAGE:Are you still using the application? [with delay time of x minutes]

[DO NOTHING, LEAVE THE APPLICATION RUNNING]

ELSE

CLOSE THE APPLICATION

TEXT BOX DISPLAY: APPLICATION WAS ENDED BECAUSE YOU DIDN'T REPLY IN x MINUTES, YOU SLUGGARD!

END IF

Link to comment
Share on other sites

Hmmm, I never used this before, but I just tried it. IF MESSAGE appears to return a boolean true/false value.

IF MESSAGE:XXXX

TEXT BOX DISPLAY: YES WAS SELECTED

ELSE

TEXT BOX DISPLAY: NO WAS SELECTED

END IF

 

Whatever you specify as default is the highlighted button on the display, and is also the boolean value returned on timeout. So in your case maybe this would work:

IF MESSAGE:Are you still using the application? [with delay time of x minutes]

[DO NOTHING, LEAVE THE APPLICATION RUNNING]

ELSE

CLOSE THE APPLICATION

TEXT BOX DISPLAY: APPLICATION WAS ENDED BECAUSE YOU DIDN'T REPLY IN x MINUTES, YOU SLUGGARD!

END IF

I had never noticed the built-in time-out on this command. Awesome!

 

My problem is that I also want the program to automatically close if there is no response at all, such as if they are away from their computer for long periods of time and don't respond to the dialog box.

Personally, what I would do in this case (admittedly I don't know the full spectrum of what it is you do, so feel free to completely ignore me) would be to

make the macro as unobtrusive as possible.

 

<Begin Boring Personal Example>:

I work with a Citrix application that times itself out ever 4-8 minutes (it is completely inconsistent). This was a problem when it would time out and then

I'd run a macro that needed to call the app, which had timed out in the mean-time, requiring a sign in. Rather than building a series of commands to

determine if the app had gone to a log-in page or to the page I actually wanted, I built a simple macro that would refresh the application automatically

every 4 minutes. Unfortunately, that got to be a headache when I was using the app regularly or when it would refresh immediately after I reached the

information I was looking for (the refresh takes the app back to the first page of a hundreds-of-pages-long document).

 

I made some modifications so now any time the application is refreshed manually or via another macro accessing the application, the timer starts over.

This way, if I don't use the app for 4 minutes, and neither do any of my other macros, I get a text box that pops up alerting the user that the app is

refreshing and to be patient for a few seconds. Once the refresh is completed, the app is minimized, the text box goes away, and the user can get back to

work.

 

I can go hours without seeing the text box, or I can go an hour and see it 15 times, depending on whether or not and how often I'm using the app.

<End Boring Personal Example>

 

I guess my point is that you could probably build something around your macro, so that when the application in question does get used, the timer on the

macro starts over, and only prompts the user if the application has definitely not been looked at.

 

The code is pretty basic (and relies on a second, separate macro):

The primary macro would look like this (I named the application "This App"):

 

Launches on a schedule: Every 5 minutes

If Window Title "This App" is running
 If Message: "Don't Forget to Close This App"
 Else
Text Box Display: Closing
Window Close: "This App"
Text Box Close: No Response
 End If
End If

If This App is not running, nothing happens. If it is running, the If Message appears every 5 minutes as long as This App is running.

 

---------------------------------------------------------

The secondary code, which blocks the If Message when it's clear that the User is actually using the application, looks like this:

 

Launches whenever window title "This App" comes on top.

Macro Disable: test 1 for tpiper
Macro Enable: test 1 for tpiper

This way, if This App comes to the top, the 5 minute timer for the primary macro gets reset to zero. If the User is clearly using the app, then they won't be

bugged by a constant barrage of "Are you using this?" requests.

 

Anyway, I hope this helps!

Link to comment
Share on other sites

Steve, that's pretty slick! I'll give it try.

 

But does this require two macro's to be running at the same time? I thought this wasn't possible in the non-pro version.

 

Thanks,

Tom

 

I had never noticed the built-in time-out on this command. Awesome!

 

 

Personally, what I would do in this case (admittedly I don't know the full spectrum of what it is you do, so feel free to completely ignore me) would be to

make the macro as unobtrusive as possible.

 

<Begin Boring Personal Example>:

I work with a Citrix application that times itself out ever 4-8 minutes (it is completely inconsistent). This was a problem when it would time out and then

I'd run a macro that needed to call the app, which had timed out in the mean-time, requiring a sign in. Rather than building a series of commands to

determine if the app had gone to a log-in page or to the page I actually wanted, I built a simple macro that would refresh the application automatically

every 4 minutes. Unfortunately, that got to be a headache when I was using the app regularly or when it would refresh immediately after I reached the

information I was looking for (the refresh takes the app back to the first page of a hundreds-of-pages-long document).

 

I made some modifications so now any time the application is refreshed manually or via another macro accessing the application, the timer starts over.

This way, if I don't use the app for 4 minutes, and neither do any of my other macros, I get a text box that pops up alerting the user that the app is

refreshing and to be patient for a few seconds. Once the refresh is completed, the app is minimized, the text box goes away, and the user can get back to

work.

 

I can go hours without seeing the text box, or I can go an hour and see it 15 times, depending on whether or not and how often I'm using the app.

<End Boring Personal Example>

 

I guess my point is that you could probably build something around your macro, so that when the application in question does get used, the timer on the

macro starts over, and only prompts the user if the application has definitely not been looked at.

 

The code is pretty basic (and relies on a second, separate macro):

The primary macro would look like this (I named the application "This App"):

 

Launches on a schedule: Every 5 minutes

If Window Title "This App" is running
 If Message: "Don't Forget to Close This App"
 Else
Text Box Display: Closing
Window Close: "This App"
Text Box Close: No Response
 End If
End If

If This App is not running, nothing happens. If it is running, the If Message appears every 5 minutes as long as This App is running.

 

---------------------------------------------------------

The secondary code, which blocks the If Message when it's clear that the User is actually using the application, looks like this:

 

Launches whenever window title "This App" comes on top.

Macro Disable: test 1 for tpiper
Macro Enable: test 1 for tpiper

This way, if This App comes to the top, the 5 minute timer for the primary macro gets reset to zero. If the User is clearly using the app, then they won't be

bugged by a constant barrage of "Are you using this?" requests.

 

Anyway, I hope this helps!

Link to comment
Share on other sites

Steve, that's pretty slick! I'll give it try.

 

But does this require two macro's to be running at the same time? I thought this wasn't possible in the non-pro version.

 

Thanks,

Tom

Hey Tom,

 

It does not require them both to run at the same time. The primary macro only runs every 5 minutes. The secondary macro only runs when "This App"

comes to the top.

 

If you're using a repeat loop within the primary macro in order to establish the every-5-minutes prompt, then the secondary macro won't be able to run

(ever); however with the primary macro set on a schedule to run every 5 minutes, then you won't need a repeat loop inside it at all to perform this

function. Thus you should only ever see one of 2 situations with this set-up:

  • Situation 1: No macro is running for 5 minutes, then the primary macro runs, does it's thing, then stops running and the 5 minute timer starts over.
  • Situation 2: No macro is running for 3 minutes, then the User brings This App to the top in order to use it. At this point the secondary macro runs very
    quickly disabling, then re-enabling the primary macro - effectively resetting the 5 minute timer.

Link to comment
Share on other sites

Okay, thanks for the explanation.

 

Tom

Hey Tom,

 

It does not require them both to run at the same time. The primary macro only runs every 5 minutes. The secondary macro only runs when "This App"

comes to the top.

 

If you're using a repeat loop within the primary macro in order to establish the every-5-minutes prompt, then the secondary macro won't be able to run

(ever); however with the primary macro set on a schedule to run every 5 minutes, then you won't need a repeat loop inside it at all to perform this

function. Thus you should only ever see one of 2 situations with this set-up:

  • Situation 1: No macro is running for 5 minutes, then the primary macro runs, does it's thing, then stops running and the 5 minute timer starts over.
  • Situation 2: No macro is running for 3 minutes, then the User brings This App to the top in order to use it. At this point the secondary macro runs very
    quickly disabling, then re-enabling the primary macro - effectively resetting the 5 minute timer.

Link to comment
Share on other sites

Steve, after looking at the code and trying to follow the logic of what you're doing I didn't see where the 5 minute timer was set up. What did I miss?

 

Thanks,

Tom

 

Hey Tom,

 

It does not require them both to run at the same time. The primary macro only runs every 5 minutes. The secondary macro only runs when "This App"

comes to the top.

 

If you're using a repeat loop within the primary macro in order to establish the every-5-minutes prompt, then the secondary macro won't be able to run

(ever); however with the primary macro set on a schedule to run every 5 minutes, then you won't need a repeat loop inside it at all to perform this

function. Thus you should only ever see one of 2 situations with this set-up:

  • Situation 1: No macro is running for 5 minutes, then the primary macro runs, does it's thing, then stops running and the 5 minute timer starts over.
  • Situation 2: No macro is running for 3 minutes, then the User brings This App to the top in order to use it. At this point the secondary macro runs very
    quickly disabling, then re-enabling the primary macro - effectively resetting the 5 minute timer.

Link to comment
Share on other sites

Nevermind, I found out what was happening. I overlooked the fact that it was set up as a scheduled macro...duh!

 

Works great now.

 

Thanks again,

Tom

 

Hey Tom,

 

It does not require them both to run at the same time. The primary macro only runs every 5 minutes. The secondary macro only runs when "This App"

comes to the top.

 

If you're using a repeat loop within the primary macro in order to establish the every-5-minutes prompt, then the secondary macro won't be able to run

(ever); however with the primary macro set on a schedule to run every 5 minutes, then you won't need a repeat loop inside it at all to perform this

function. Thus you should only ever see one of 2 situations with this set-up:

  • Situation 1: No macro is running for 5 minutes, then the primary macro runs, does it's thing, then stops running and the 5 minute timer starts over.
  • Situation 2: No macro is running for 3 minutes, then the User brings This App to the top in order to use it. At this point the secondary macro runs very
    quickly disabling, then re-enabling the primary macro - effectively resetting the 5 minute timer.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...