how to cancel incoming message sound on Symbian PyS60 - symbian

I am writing a parental control app using PyS60 ( on Nokia E72)
The app is operated via sms's.
Every sms that operates the app is deleted when entering the inbox listener's callback, and by using a blank audio file, I manage to cancel the "new message" sound alert.
However,
this only works when the focus in on Python Script Shell.
Meanning - when I switch to desktop, or any other app that is open, the new message alert sound is playing.
My guess is - I'm losing the race with the messaging module (or process race condition),
Does anyone know how to make this work while running in background?
Or even cancel the process that handles incoming sms's and deal with it myself?
Or lower the priority of the process ??
any other suggestions are also welcome..
thank in advance,
Amitos80

Related

How to detect when an app is launched on macOS?

I have a background process running on the user’s macOS machine. Its job is to detect whenever any app is launched on the machine. Currently, I am detecting the NSNotificationCenter’s NSWorkspaceDidLaunchApplicationNotification event. This works perfectly for detecting when an app is freshly launched (i.e. the app had no instance already running at that time).
But, on macOS, if we click the red cross button at the top-left corner, it generally closes the app window and the app continues to run in the background. This is also evident by the app icon visible on the dock with the dot indicator below it. If I click the app icon on the dock and then launch it, the NSWorkspaceDidLaunchApplicationNotification event won’t be triggered.
To track such events, I tried using the NSWorkspaceDidActivateApplicationNotification event. Using this event, I was able to detect all the app launch scenarios. The problem is that this event gets triggered whenever the app comes into focus such as switching windows using command+tab, clicking on its dock icon, changing between two apps, …
Is there a way to filter out these triggers or identify which action led to the trigger? Or is there some other event/ method I can listen to which gives the required filtered triggers? I only want to detect scenarios where a new window of the app is created.
What you seems to want is two different things, as was mentioned in comments, which should be processed separately to be reached.
To detect app launch, when the new process is started. You could use the NSWorkspaceDidLaunchApplicationNotification if it is enough (usually for visual user apps), or kqueue if it is not, or even EndpointSecurity framework to rule them all.
To track the window(s) in the already launched app. Visually, if the white dot under app dock icon is there, the app is still launched.
There is an Accessibility framework for this task, you could track the event of window creation, window destruction, get count of windows from target process id, visibility state and etc.
It is a bit abandoned and has no updates since maybe release, but it will work for you in most cases.

Program to respond to Keycodes while minimized

I need a program to respond while not active/not selected by user or minimized to KeyCodes.
Anyone got ideas? In VB.NET.
This won't work out of the box as key messages are only sent to the active window. A minimized window is never active.
What you could try is register system-wide hotkeys. You could also try to install a keyboard hook, however, this would affect the entire system and your application would receive all the keystrokes performed. This would require efficient filtering.

Detect screen shutdown in vb.net

I'm building an application using vb.net that should record some specific user actions, one of these actions is the screen shutdown, is there a way to do that? Maybe a system event or something that i can check periodically to know if the screen is active or not.
I've already found some code to check if the screensaver is running but i want to know if there's a way to detect if the screen is phisically turned off.

StatusItem menu blocks main thread when it's opened. Workaround?

I've written an app for the Mac that is designed as a status bar item. However, when a user opens its menu from the status bar, the main run loop is blocked until it's closed. Since this app responds to messages on a socket, it's a problem that it can't do anything while the menu is open.
I've tried setting the status item from a separate thread and scheduling the socket on a different thread, but no dice. Is there a good way to deal with this?
UPDATE:
I've resolved this now. I was using the NetSocket socket wrapper and its asynchronous nature made it very difficult to open and watch on a different thread. I switched to SmallSockets (another Objective-C socket wrapper) and because it is synchronous, I was able to open a socket and just watch it directly on a separate thread.
While the user is interacting with a menu the run loop runs in the event tracking mode. Attach your sockets to the NSEventTrackingRunLoopMode mode too and they continue to run while the user interacts with the menu.
But putting the sockets on another thread should work too. If this did not work for you, you probably did something wrong, but without seeing the code I can't say.

Track system activity

Is there a neat/easy way in objective-c/cocoa to track if a user is at their computer, ie I assume by detecting key presses and mouse movement?
(ie I want to fill out my timesheet automatically by detecting when I am at work and not at work)
You can detect mouse events across the entire log-in session using an event tap.
I'm pretty sure there's a way to do this for key events as well, but I don't remember what it was and it requires that the user have access for assistive devices turned on. Catching key events across the session is hard on purpose, in order to make Mac OS X unattractive for key-logger authors.
You should also use NSWorkspace's notifications to detect when the machine is about to go to sleep, and when it has just woken up from sleep.
Much more on Event Taps and handling global activity in Mac OS X 10.6 is here:
Mouse tracking daemon