Pause an application that has NOT been closed / quit

Silly question, and probably very simple for you good folks.

I am running a program, and I wish it so that when the user moves the mouse the program pauses and after some set time, restarts.

Is that possible?

I’m thinking it is timer.CallLater or timer.TimerCallLaterWithValue.

Regards

Do you mean the app gets suspended (i.e. not responding), quitting, idling? Pausing can mean a lot of different things.

Hi Arnaud

To explain, when I have a program running and when the user moves the mouse, the program should “restart” i.e. the program restarts as if it was just opened. I have tried resetting everything, but to get it to restart I have to close and reopen it.

Hints are appreciated.

I haven’t a clue what you want to do. Please explain with more detail. If you don’t do anything in an app the app is “paused” on its own.

I am imagining the OP has something like the Game of Life, or a monitoring software.
While it runs, it does things, displays things, draws things, based on an initial condition.

The initial condition will be ‘whatever the variables are set to’ when the app starts.
Often people have default variable values set in the IDE.

Instead, they should all be initialised in a method - call it Init perhaps?
When the app starts, call Init to set things up and start running.
If the mouse moves over the window, call Init again and refresh the screen.

do you track the users presence somehow?

open means it start with a fresh window.
something like

var w as new SpecialWindow
w.Show

store your properties in objects/classes not in a module
because a object is created by new it have the default values.

In this case, the OP should have a button labelled “Restart calculations from initial conditions” or similar.

Ah.

That is brilliant, Jeff. This never entered my ideas.

I will give it a go and advise.

Thank you very much for your help and everyone else’s

Regards

1 Like