How can I animate the tray icon while the main application is processing? I already tried the suggestion here, but the icon does not animate during process. I also tried putting the animation in a separate thread but still no luck.
There's a very good example of an SystemTrayNotifyIcon with Event Generator over at the CodeProject .
I've looked at this project before but didn't end up using it, due to my artistic inabilities, but the example given does the job quite well.
Take a look at http://www.codeproject.com/KB/shell/IconAnimation.aspx and http://www.c-sharpcorner.com/UploadFile/nkumar/AnimateSysteminCSharp11292005235157PM/AnimateSysteminCSharp.aspx for a more recent example.
Related
I have the following problem:
I have to Buttons.
After a click on the first button the program start a while loop.
I like to leave this while loop after click on the second button.
How I can do this?
Have anyone an idea?
Thank enter image description here
You need to use multiple threads to accomplish this. I suggest reading up on the subject and looking at some examples.
There are a number of different classes/systems that can do this, because newer, better ones were developed over time. BackgroundWorker is an example of an old system that I wouldn't recommend for new development. I believe the current best practices (at the time of writing) are to use the Dispatcher (in WPF) as well as async/await.
Here is some documentation:
MSDN - Threading Model
Building Responsive UI using Async Await in C#
I have developed an application that needs to read an extensive list of files (loading images) before it starts running. With UWP, the user has to wait with the window in the foreground until everything is loaded because it is in suspended state when not in the foreground.
After much reading, I'm trying to decide which route to take. I could use the "Extended Execution" approach or start a background task.
Anyone could point me on the plus and minuses of each approach, or any other recommendation?
Just show a wait message as the window content. Show a nice company logo and 'Please wait, initialising' as a message. Even better, show a percentage indicator so the user gets a feel for how long it will take to complete. When finished you replace the window content with the real content of the application.
I found a very good explanation here:
https://msdn.microsoft.com/en-us/magazine/mt590969.aspx
Very useful. Thanks Phil for pointing me in the right direction. It's working great.
spent the whole day looking up for a solution, but I couldn't find it
I'm not talking about borderless windowed fullscreen, but those exclusive fullscreen mode that usually games use
is this possible?
I think you can get list of the process independently from your mode using System.Diagnostics.Process. Than you can just find any process by name or other properties.
UPDATED
So I have tried some solutions, but for now found one that works if process if full-screen right now, not minimized. Pretty much that:
Is there a way to check to see if another program is running full screen
My code Snippet (Runs in loop and checks if the process with specific name is fullsreen)
https://pastebin.com/qwE7ZXVt
Another possible solution based on window into style flags
https://www.reddit.com/r/AutoHotkey/comments/6maqdd/detecting_if_window_in_the_foreground_is/
But I was unable to make it work. You can try to PM folks there.
Also this site was very handy
https://www.pinvoke.net/index.aspx
I make some tests with C# and Windows Forms.
At the moment I am trying to implement some animations, for example display the current time or display a loading animation.
I looked around the internet but some solutions I found looked a bit ugly.
For example the most people create a Timer and refresh the animation at a specific frequency.
But I don't think thats the purpose of a timer...
So I found a second solution.
Simply register for the Application Idle event so I can update some animations and other processing stuff as part of the main application loop.
This sounds like a better solution.
Also I am wondering how I should request a redraw of some custom animated controls.
Simply call Invalidate() or Update() whats the recommend way?
Whats the professional way of update and redraw such things like a timer or other animations of custom controls?
There is a background worker, you can read more about it here: https://msdn.microsoft.com/en-us/library/cc221403%28v=vs.95%29.aspx?f=255&MSPPError=-2147217396
Or you can use async/await - a Task based asynchronous approach
https://msdn.microsoft.com/en-us/library/hh191443.aspx
I wrote a small autohotkey script that removes the border, titlebar, and resize handles of a window, and centers it on the first monitor. This works for most applications and games, but some (bioshock 2, APB, etc) replace their window style instantly after removing it. Is there a way to block window style changes?
I would prefer to keep this in AHK, but the title has c# in it because I would like to convert my application to that down the road, and if it's only possible in c#/c++ then now would be a good time to start conversion.
I could be missing something, but I doubt this is going to be easy. The behavior you describe is one of an application which is either monitoring for changes in its window style, or just constantly redrawing them nonstop to prevent these changes. Of course you could just Loop through and fight against it where you remove, it replaces, you remove, it replaces, but that won't solve anything.
One way you could try is to create a .dll and inject it into the app's process, and then hook some API calls and simply return before anything gets redrawn. Google for 'detours hooking' for some examples. That might work, but would be out of the scope of AHK. And your simple 15 minute AHK script would turn into a much bigger project. =(