Hi all, I build a scrolling text that starts running when I start up my Computer. I can stop it by clicking on it, no problem. Is it also possible to stop it when I start up another programm ?
Ur calling the another application within ur application?
Assuming you're using WinForms, you could try handling the GotFocus and LostFocus events. Detecting whether a new program has been opened could cause issues, especially during startup, since you can't be sure your program is opened last, and Windows could be starting up a bunch of programs.
Is it also possible to stop it when I start up another programm ?
A particular program? Is it one that you have the source code for? You could always create a cmd file to start that particular program then create a shortcut to the cmd file and always start it from that. The cmd file could have a line to kill your program and another to start the requested program.
I have a scroling text that starts running at the bottom of my desktop when I start up my computer. I would like to know if it is possible to have it detect when any other program starts and have itself shutdown. Just curious if it can be done.
Assuming that your program doesn't start until after all other startup programs have run then you can have a class variable such as
Private tasks As New Dictionary(Of Integer, String)
And you can populate it with the current list of process IDs and names by
For Each proc As System.Diagnostics.Process In System.Diagnostics.Process.GetProcesses tasks.Add(proc.Id, proc.ProcessName) Next
You need to use the process ID as the key because it is guaranteed to be unique. In your timer handler you can do
For Each proc As System.Diagnostics.Process In System.Diagnostics.Process.GetProcesses If Not tasks.ContainsKey(proc.Id) Then MsgBox("closing on task " & proc.ProcessName) Me.Close() End If Next
But in production you would remove the MsgBox.
Thanks for the help, the code works. The link to the article helped me to get an idea of what it does.