|
Hello Every Body
How can I handle a system event that is not exposed by the SystemEvents class using c# ? I read somthing about "InvokeOnEventsThread" method in MSDN :
public static void InvokeOnEventsThread(Delegate method);
But I don't undrestand how I can use it.Please Help Me.
Thanx
|
|
|
|
|
What are you calling a "system event"? What "event" are you looking to a notification of?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi...
I want to handle system events such as mouse clicks,mouse move and any action that happens out side of my application(When my application is not focused.Such as clicks on desktop or on any other application). Like babylone dictionary and keyloggers.I read an article in code project about system hooks(Global System Hooks in .NET) But hooking is very heavy action.The CPU usage of this sample is 80% to 100% when application is running ! I want a way to trap this events when they happen.
Please Guide me !
|
|
|
|
|
The only way to grab the mouse and keyboard events are global system hooks. If written properly, the hooks will not consume any measurable CPU time for days, maybe even weeks. But, of course, this all depends on what your doing with the captured messages.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanx For Your Attention Dave. Your Guid was very useful for me.
Good Luck !
|
|
|
|
|
Hi folks,
I've written a custom installer / uninstaller for my application and everything works fine
But...
How do i delete my uninstal.exe??
I can't tell it to delete itself but i have been told there is a way to get windows to delete a file next time it starts up. Anyone got any ideas on how to do this?
Kev
|
|
|
|
|
|
Very close but not quite.
Assume i have installed my application and there is a file called
c:\uninstall.exe
Uninstall.exe is registered with the windows add / remove programs.
The user tries to remove my application and all files and registry
entries are deleted without any problems. All except one, Uninstall.exe.
I can't tell it to delete itself as it is currently running and would
obviously crash.
Anyone know the answer or able to point me in the direction of an article?
Kev
|
|
|
|
|
|
I wasn't aware that i could put commands into the registry.
Could you show me how ot do it using the c:\Uninstall.exe as an example?
Thanks for your help
Kev
|
|
|
|
|
Colin pointed out the link to help. Here's the pertinent line:
The data value for a key is a command line.
Use a command line command, like "del", as in "del c:\uninstall.exe"
Remember good ol' DOS?
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Marc,
Thanks for clearing that up, that's the "Idiot Proof" answer i was after but...
When i create my key with the value of del c:\uninstaller.exe i just get a message saying Cannot find del... when i restart my PC.
I assume i am missing something very trivial and i'll probably kick myself when i get it sorted but can you tell me what i'm doing wrong. Does the registry entry's name have to be anything specific? oir is that irrelevant in this case?
Cheers
Kev
|
|
|
|
|
exhaulted wrote:
Cannot find del... when i restart my PC.
Ew. I had assumed that it would be able to run DOS commands. You might need to do something like c:\uninstaller /u, where you pass a command line parameter to itself. BTW, it won't crash if you tell it to delete itself--why would it? The running version is in memory. There is the potential, though, of a locking issue--a running app might have its file locked by the OS, but I'm not sure.
Strange stuff!
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Lol, after all that you are right, you can just tell it to delete itself!!
I just assumed there woudl be file locking issues but there's not.
Thanks to you all for your help.
Kev
|
|
|
|
|
exhaulted wrote:
How do i delete my uninstal.exe?
Check out: Win32 Q&A (MSJ 01/1996)[^]. It's an older article but I think it's an interesting approach (at least if you're not afraid of P/Invoking ). Now, I haven't checked out if you can use this technique in managed code, but if not you can at least create a helper executable to take care of the final deleting.
Best regards
Dennis
|
|
|
|
|
Thanks for your reply Dennis, i'm gonna see if i can get anything working with the registry entries first.
Cheers
Kev
|
|
|
|
|
I have a cosole application always running in background and checking if is it 10h5 or 11h15 now. If it is, the console app will print out a message. How can i do that
Thanks a lot!
|
|
|
|
|
use System.Timers.Timer
see here for example - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtimerstimerclasstopic.asp
|
|
|
|
|
Thanks a lot for your help
|
|
|
|
|
Look into the System.Threading namespace on msdn.
Simply create a thread and do something like
while (escape condition)
{
thread.Sleep(60000)
if (DateTime.Now.Minute == 15)
{
}
}
The thread.Sleep command simply stops the thread eating system resources by
making the thread wait for 60 seconds between checks.
Kev
|
|
|
|
|
Thanks! It really works
|
|
|
|
|
You're Welcome
Kev
|
|
|
|
|
|
Override the onDrawItem event:
protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
{
// Your menu drawing code
}
and set the OwnerDraw property of the menu items to "True"
--Aditya
|
|
|
|
|
Thanks for your help but there is no OwnerDraw property to the main form ( no this.OwnerDraw )and no OnDrawItem() to override from......
What have I missed ?
Udi
|
|
|
|