Determining whether an application has been entered or exited

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TNT
    New Member
    • Feb 2007
    • 48

    Determining whether an application has been entered or exited

    My sister is notorious at leaving game CD-ROMs in the computer.
    I want to create an application that detects when she enters the game, then detects when you exit it. When you exit it, I want it toshow a message box with a reminder.

    How do I get my programme to detect when she enters and then exits the game?
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Try searching (see the search box at top-right) for information about enumerating executing processes, or open windows. You should be able to set a flag when you see a particular process or window appear, then show a popup when it disappears.

    Comment

    • willakawill
      Top Contributor
      • Oct 2006
      • 1646

      #3
      Originally posted by TNT
      My sister is notorious at leaving game CD-ROMs in the computer.
      I want to create an application that detects when she enters the game, then detects when you exit it. When you exit it, I want it toshow a message box with a reminder.

      How do I get my programme to detect when she enters and then exits the game?
      This would be a TSR (terminate and stay resident) program which remains running in the background in memory using up clicks and space. Usually computer games take over the entire environment and then restore it when exited. I think it might be extremely tricky to get this working especially in vb. Why don't you buy her a piece of candy every time she remembers to remove the dvd?

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by willakawill
        This would be a TSR (terminate and stay resident) program which remains running in the background in memory using up clicks and space. Usually computer games take over the entire environment and them restore it when exited. I think it might be extremely tricky to get this working especially in vb. Why don't you buy her a piece of candy every time she remembers to remove the dvd?
        Smart move. :) Good example of lateral thinking, that.

        As for the rest, that would really depend on whether it's a Window-aware game, wouldn't it? My guess is that most are, these days. It has been some time since I saw one that had to reboot to DOS mode to run.

        Comment

        • willakawill
          Top Contributor
          • Oct 2006
          • 1646

          #5
          Originally posted by Killer42
          Smart move. :) Good example of lateral thinking, that.

          As for the rest, that would really depend on whether it's a Window-aware game, wouldn't it? My guess is that most are, these days. It has been some time since I saw one that had to reboot to DOS mode to run.
          Yup I remember running space commander on 1mb ram. It came on one floppy disk. I had a 33mhz olivetti with 30mb disk. I had to locate all of the TSRs and stop them from running because they did not leave me enough memory for the game. Never forgot that lesson cause it took a whole week to work it out.

          good old compuserve was just about all there was back then with a half hour download for one jpg but it was all adventure.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by willakawill
            ...good old compuserve was just about all there was back then with a half hour download for one jpg but it was all adventure.
            Those were the days, huh? :D

            (Not really...)

            Comment

            • TNT
              New Member
              • Feb 2007
              • 48

              #7
              Originally posted by Killer42
              Smart move. :) Good example of lateral thinking, that.

              As for the rest, that would really depend on whether it's a Window-aware game, wouldn't it? My guess is that most are, these days. It has been some time since I saw one that had to reboot to DOS mode to run.
              What is "Window-aware"? Is there any simple code to detect the closure of the game? Would the application affect the speed of the game?

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Originally posted by TNT
                What is "Window-aware"?
                That was a typo. I meant "Windows-aware, meaning that it is designed to run under Windows. A lot of old MSDOS games would force you to reboot to a clean copy of DOS with various memory management software loaded, then restart Windows again afterward, which might make things much more complicated for you. If the game somehow takes total control of Windows as someone else here implied, not allowing your program to do anything until the game finishes, it seems to me that would actually be a good thing for you.

                Originally posted by TNT
                Is there any simple code to detect the closure of the game?
                I'm not aware of anything readily available - after all, as far as Windows is concerned a game is usually just a program like any other. So you'll want to monitor what processes are running, and watch for a specific name.

                Originally posted by TNT
                Would the application affect the speed of the game?
                That would depend how you code it. I'm sure you could use up lots of CPU and slow things down, but presumably you will design your software to minimise any such impact.

                Try searching TheScripts for keywords such as VB and sleep and you'll find plenty of info on how to make Windows effectively ignore your program for a while, so it doesn't interfere.

                You may also want to liberally sprinkle your code with DoEvents statements, to minimise the impact each time your application "wakes up and takes a look around". (This applies to VB6 - don't know about later versions).

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  Alternatively, start hiding the CDROM every time it's left in the drive. A bit of wasted time searching for it might help it stick in the memory.

                  Comment

                  • TNT
                    New Member
                    • Feb 2007
                    • 48

                    #10
                    Originally posted by Killer42
                    ...I'm not aware of anything readily available - after all, as far as Windows is concerned a game is usually just a program like any other. So you'll want to monitor what processes are running, and watch for a specific name...

                    ...You may also want to liberally sprinkle your code with DoEvents statements, to minimise the impact each time your application "wakes up and takes a look around". (This applies to VB6 - don't know about later versions).
                    How would I detect processes? What is the DoEvents statement?

                    Comment

                    • Killer42
                      Recognized Expert Expert
                      • Oct 2006
                      • 8429

                      #11
                      Originally posted by TNT
                      How would I detect processes? What is the DoEvents statement?
                      As for detecting processes, I'd suggest searching TheScripts (there's a search box at the top-right) for things like "vb enumerate processes".

                      As for the DoEvents statement, check the manual. But basically it just allows Windows to take time out from your code to go do whatever else needs doing.

                      Comment

                      Working...