1

Is there a way to catch event like user opening certain app in Windows?

I have a requirement where , if user opens any app specifically windows store app then my app should be able to catch that event.

I have not yet started with it yet. I just want to know whether is it even possible?

Will it be possibble with C# development or JavaScript development?

I am more comfortable with JavaScript.

rene
  • 41,474
  • 78
  • 114
  • 152
UzUmAkI_NaRuTo
  • 565
  • 3
  • 8
  • 20
  • Unless both your apps- the one being opened and the one catching the event are both published by same developer. You wont be able to catch those events. other than that you can use third party tracking events api to catch those events after implementing them in your app. – Jerin Apr 23 '16 at 09:44
  • Do you know of any such api ? Framing it the other way , On system level can I catch Single click/Double click event ? And then checking if system is launching desired app – UzUmAkI_NaRuTo Apr 23 '16 at 09:57
  • 1
    Again these api's need to be added to your app that need to be tracked. you cant install your app and track every app that user clicks opens thats similar to adware or malware. – Jerin Apr 23 '16 at 10:00
  • @Jerin are you sure that there is nothing available in Windows? How is a third-party tracking events API able to do something that we cannot do directly? – Sam Hobbs Apr 23 '16 at 19:21
  • @SumeetDarade as you said windows App i am expecting you wanted to write Windows Store app not an exe. Windows app runs in their own sandbox so they cant interact with other installed application. The solution provided by user34660 is mainly for exe apps and mostly can't be used by Windows app if you try to do that 2 things will occur-1 your app will constantly crash, 2 your app wont certify. Also you would need to implement a user consent popup that you ae tracking this data. The third party api tracks these data based on each event that you raise. you need to specify add those event in code – Jerin Apr 24 '16 at 06:34

1 Answers1

1

The most reliable solution will be to write a Windows Service. You can write a Windows Service in C# but I doubt you can do it using JavaScript. The advantage of a Windows Service (also called a driver) is that it is not visible as an application and therefore less likely to be get in the way or be stopped. Hooking the native API and controlling process creation on a system-wide basis - CodeProject is an example in C++. Also see Detecting Windows NT/2K process execution - CodeProject that also uses C++; apparently it uses an existing service (driver) so you don't need to write the driver part.

If not using a Windows Service then C# would still be a better solution than JavaScript. The easiest way is to use Windows Management Instrumentation (WMI). See Wes' Puzzling Blog - Using WMI to monitor process creation, deletion and modification in .NET for an example using C# outside of a Windows Service. Also see Constantly monitor processes. For JavaScript you will need to use a Permanent Event Consumer as described in Monitoring Events (Windows). For an example of that see Creating WMI Permanent Event Subscriptions Using MOF - CodeProject.

Community
  • 1
  • 1
Sam Hobbs
  • 2,594
  • 3
  • 21
  • 32
  • wow thats a lot of documentation. thanks. since this is the best i can get on this topic and was not expecting perfect solution ,I am marking this as answer. – UzUmAkI_NaRuTo Apr 24 '16 at 03:48