How to start a program using a hotkey in C#? - c#

I'm making a program using C#, the user should be blind person. I've done everything but I remembered that the blind user can't start the application like any person.
So is it possible in C# to add the program to the startup programs list and send it to the tray, and when the user presses Esc key for example, the program starts.
Thanks..

It's can be done without any connection to c#, follow this instructions:
http://windows.microsoft.com/en-US/windows-vista/Create-keyboard-shortcuts-to-open-programs?SignedIn=1
or tutorial:
http://www.butterscotch.com/tutorial/Launch-A-Program-With-Windows-Hotkeys

Related

C# How to send a hotkey globally (needed for a background process, running in system tray)

I am writing a program to automate some work for me.
I have another program (OBS Studio) installed, which I use to capture video. OBS Studio is minimized to the system tray and listens to my configured hotkey CTRL + 1.
When I press CTRL + 1 anywhere, the software starts recording. It does not matter which application is in the foreground.
I am trying to do the same thing from my application, send a "global" hotkey. I have spend hours trying to achieve this, but without any result. SendKeys only works for the current open window (which does not exist), no results with PostMessage either and I tried the wrapper "InputSimulator"
So, to summarize:
Is it possible to send a hotkey/keystroke globally (for every application?)
If not, how would I send a hotkey to a program that is running in the background, without a window? I don't want to bring the app to the foreground.
Hopefully someone with a deeper understanding of these concepts can guide me...
I've found similar questions, but they remain unanswered:
Send global keystroke / fake a global hotkey from a Winforms application
Sources I studied (among others):
https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys(v=vs.110).aspx
https://dailyoverdose.wordpress.com/2009/10/28/postmessage-and-sendmessage/
https://ourcodeworld.com/articles/read/520/simulating-keypress-in-the-right-way-using-inputsimulator-with-csharp-in-winforms

C# how to get key input in background?

I want to get key input in c#.net in console application but the console will be invisible like freeconsole in c# and it will get what you type and set it to a string named like idk input then messagebox.show(input); then everytime you type a key it messagees it in the background,
i want to learn to make games so yeah and i want it to work in background.
The way Windows works is that when a key on the keyboard is hit, Windows sends a message (actually, several) to the Window which currently has the focus. If your Console app is in the background, then by definition it will not have the focus.
All is not lost, though. You can setup what's called a global keyboard hook. This does mean that you'll get ALL keyboard hits, though.
And as #AaronM.Eshbach says, this is a keylogger and generally not a good thing...

How can i make program press button for me C#

How can I make console program in C# press and hold numlock7 key for me. So that can run in background even if console app is not selected. Can you please tell me method to do that, or atleast class that can I look into.
Thanks
System.Windows.Forms.SendKeys.Send()

How to detect a process start & end using c# in windows?

I have a good working experience with C# but now I want to develop a simple(may be a console app) software which just detects the name and time of the process started or ended on my computer.
For example (I am assuming that my small app is already running) if a user opens Firefox then it should just insert firefox.exe into a database with time and if a user close it then it also do the same.
And same as above if a user open notepad then it should insert notepad.exe with time and so on.
I know how to insert values in database but I just need your help in identifying when the process/program starts or ends on my system.
Honestly saying I never developed this kind of application before so i have no idea that it can be possible using console app or i need to make a windows service app etc.
So please provide your answer just considering me as a beginner.
In the part of C# I am able to understand it so need to worry about that.
I am using visual studio 2010 with .net 4.0.
To do this without polling requires WMI. This is well supported in .net and you can use the ManagementEventWatcher class to subscribe to WMI notifications.
This Code Project article illustrates how it is done. Here's an extract showing how straightforward it is.
notePad = new ProcessInfo("notepad.exe");
notePad.Started +=
new Win32Process.ProcessInfo.StartedEventHandler(this.NotepadStarted);
notePad.Terminated +=
new Win32Process.ProcessInfo.TerminatedEventHandler(this.NotepadTerminated);
Note that ProcessInfo is a class implemented in the code attached to that article.

How to get/set data of(into) visual components (of windows programs) programmatically?

I am talking about windows GUI programs. Say a program-window has a dialog box (or a confirm button) asking user input. How can I provide input to that program using my program (written in say C#, Java or Python). Or say, a program window is showing some image in one of its panels. How can I grab that from other(my) program. It is a kind of impersonating (or inter-win-program messaging?). Someone told me it can be done using spy++. But how? Can you explain? What code to write? What to do with spy++?
spy++ is listening for all win32 messages. It is very useful for debugging an application but I don't think that it is a good idea to use it as an inter-process communication mechanism.
You can use win32 apis to send input to your program. As an example, You can modify the content of an edit text by using the SetWindowText function.
You need to get the handle of the window. You can use the FindWindow and the GetDlgItem to get it.
It will work for c++ and python thanks to win32 python extension. I don't know if there it is possible to use win32 api from java.
To programmatically generate key presses, see Key Presses in Python, and search for "generate", "key", "emulate", "fake".
To programmatically capture the screen, see Capture screenshot of active window?, and search for terms like "capture", "window", "screen".
If you want to write win32 code to do it, start here:
http://msdn.microsoft.com/en-us/library/ms632589(VS.85).aspx
If you just want to hook the gui as easily as possible, investigate:
http://www.winbatch.com/
http://www.autoitscript.com/
http://www.autohotkey.com/

Categories

Resources