simply put I want my program which runs in the background to check whether the print screen button has been pressed (which mostly triggers a function within another program to generate a screenshot of the current window. eg a game screen).
I have seen lots of possible answers, but most seem overkill for just detecting the print screen button.
I want to have a program in the background check so that it can move the screenshot that has just been made/saved to a certain location. after the button had been pressed.
I hope this question is clear, if not I'll try to explain more clearly.
ps
On a side note, would it be better to try and detect the printscreen button or to simply check the specified folder every 1 or 5 minutes whether a new image has been put in that folder and then move it if true.
EDIT
I decided to use the FileSystemWatch, however it seems to be to fast if i use the on create event as sometimes the file is still being made and it can't move the file yet.
Would the best action be to use a timer to delay ?
You could just watch the folder location for updates using a FileSystemWatcher. There are many examples around the place.
Global keyboard capture in C# application
You should be able to use a global key hook to handle the print screen key press.
Related
I am building this simple game, where a bunch of fellows that I have are supposed to seek a point indicated by a mouse click. The issue is that the Editor does not seem to notice mouse clicks at runtime. I have used the exact Input Action Asset before for detecting presses of "g" button, but it seemed to have stopped working when I played with it some more sometime later. I have since removed the asset and created w new Action Assets (one that I created manually and another that I created through the Input Action component button). Neither of them works. I have no idea what is going on and I have been looking at this for several hours now. Can someone please explain what I might have done wrong?
Different functions I used to try and get the Editor to respond to my code are below. MouseClick() is the original function that I needed to run, but did not work, onFire() is my attempt at running the default one that is given if Actions Asset is isnantiated through the component.
So it turns out that the issue was that the functions are supposed to be capitalized at the start.
Have you tried using the performed event ?
Also your Fire action needs to be a button type
I'm trying to write a program in C# that lets me send a keystroke to another program that's open but is not in the foreground. The purpose of the program is to let me start recording gameplay footage from my Xbox 360 using TotalMedia Extreme while also starting recording in audacity to record from the PC mic. That way I can get both tracks to be synced instead of starting gameplay recording and quickly switching to audacity and clicking record.
Basically all I need this program to do is detect a mouse click while TotalMedia Extreme is in the foreground and when the mouse is clicked, send the hotkey command to Audacity to start recording. Does anyone have an idea for how I could get started with this?
This seems like it might be a good place to start, but I don't think it will do the same thing I need to do:
Send fast textinput to another process (Window)
Check this: http://msdn.microsoft.com/en-us/library/windows/desktop/ms632589(v=vs.85).aspx
I suppose you could do it through Windows Hooks, in particular WH_KEYBOARD_LL
Just use AutoHotKey. The command SendMessage will send keystrokes to a non-active window, but you could also just have AHK activate the right window before sending keystrokes. Once you are done you can wrap it into a handy little hotkey or even compile it into an exe file.
AutoHotKey is definitely the rout I'd go. You can use a function called ControlSend to send keystrokes to specific controls of specific applications, even if they're in the background. Sounds like it would work perfectly for what you're needing. The forums over at AHKScript.org are really helpful too, so you might check them out as well!
I have tried using this code sample:
private void DoShortRunningTask()
{
using (new StWaitCursor())
{
Thread.Sleep(5000); // 5 sec delay.
.. do some work ..
}
}
From: http://www.codeproject.com/KB/cpp/WaitCursor.aspx
But it did not do anything for me, since I did not have a main form. I do not need a main form. My C# project type is Windows Application, but the only GUI it shows if any is error or success messages dialogs. Is there a way for me to fake the existence of a WinForm (so that it exists but is not visible)? Would the mouse cursor have to be over it in order to show up?
I don't think it would be good practice just to change the cursor when it's not in your UI. You wouldn't want another program messing with the cursor in your UI. If you just want to show that your application is running, have you thought of using a tray app. These are relatively simple to create.
Here's an example I just googled:
http://alanbondo.wordpress.com/2008/06/22/creating-a-system-tray-app-with-c/
You can also show speech bubble messages as your run progresses etc, if you want to let the user know things are happening.
I do not need a main form
Yes, you do. Any UI interaction needs a form, sorry.
way for me to fake the existence of a WinForm (so that it exists but is not visible)?
How is that faking?
Make a form, make it invisible (transaprent - check all the properties on the form class and you will find it) and finished ;) Standard approach. Also tell it not to show up in the forms collection in the bottom of the screen and minimize it and you are finished. nothing fake here.
TomTom++
Are you just wanting to change the current cursor?
Try this
http://www.csharp-examples.net/hourglass-wait-cursor/
So, here's a weird question: Is there a way for me to disable the menu you get when pressing the "C:\" button at the top left of the console?
I am making a game, for fun, but it would take away alot of the fun if players were able to paste words into the command-line.
I haven't found any topics about it, so I was wondering if anyone has an idea on how to get this done, or atleast a work-around.
Thanks in advance!
Edit: Would a simple reg-ex for any ^ character work? Or does the console not use ^C and ^V?
a) Use GetConsoleWindow to get window handle; use subclassing and hooks to filter mouse and keyboard events. Though this approach probably has a lot of hidden obstacles, because of Windows console implementation specifics.
b) Use timing analysis. Measure time interval between keystrokes and ignore input if this interval is unreasonably short. You may have to experiment to find the criterion that works best. Maybe it's better to measure input duration of entrie word, not inter-character intervals.
Note that pasting text to Windows console is implemented via keyboard input simulation, i.e. when you paste something to a console, the console application observes a sequence of key-down/key-up events.
I'm not sure if the console supports pasting via a keyboard combo, you can paste either via the menu or just right clicking in the console (this depends on how the console is set up though).
I'd suggest that a better solution would be to create a winforms app instead where you can control the input/output easier than in a console app.
Otherwise, one workaround might be to call Clipboard.Clear every 100ms or so to make sure that they'll never have time to copy and paste anything until you've cleared it out, but this could of course upset and/or confuse the users if they have your application running in the background and are trying to do some work in some other software.
I want to create an alarm app for myself. On certain conditions (i need to poll websites) i want my app to inform me and make it HARD TO MISS. So i can take appropriate action or ignore it if i need to do something else.
I wrote a test app and using a BalloonTip (ShowBalloonTip with notifyIcon) isnt great. One of my previous apps brings the window in front of you and does a MessageBox however that doesnt always work or work well (if i somehow miss it or accidentally forget to click ok no futher messages will occur).
What are your suggestions?
You could also make it a system tray application and change the icon out if there is something which requires attention, a la a messenger application. That may not be "hard to miss" but I am trained (for better or worse) to look down at the icon tray when I see something blinking.
Where I work, we have a TimeTracker application (built in house) with which developers are supposed to log what we worked on and when. I am notorious for not using it. So, I wrote my own (Windows Forms) version for my own use which, every hour opens up and takes over my screen:
It is a frameless dialog which consumes the entire screen.
TopMost = True.
On resize, it sets WindowsState = Normal and resizes to fill the screen.
While it is open, it polls for taskmgr.exe and procexp.exe and kills them if found.
It disables the start menu to prevent cmd.exe commands from the menu in Windows 7.
The only way to close it is to enter a log, only then is the OK button shown!
So far, it's working out well - no one has been able to break it!
My less drastic suggestion would be to have a notification which pops up momentarily above the system tray. After a second or two, fade it out. Keep showing the notification every 30 seconds or so until it is dismissed.
Always-on-top window in the corner of the screen?
You could always set your window to be a top most window, make it full screen, and activate it. It would be very, very hard to miss...
Granted, it would also be very annoying, and not something I'd do to other users...
My "real" suggestion would be to use sound along with standard notification methods if this is going to be used by other people, as that's an easy way to grab attention without necessarily killing their workflow. A modeless window that appears in a corner of the screen, especially if combined with sound and color, can be very effective to grab attention.
The industry has been adopting these ambient orb devices and variations of it when such a hard-to-miss notification is required. It is used for tracking the stock-market and for broken-daily-builds.
http://www.ambientdevices.com/cat/orb/MAN_Ambient%20Orb_3-23-03.pdf
Regards