gtkmm and the system clipboard - gtk

I am wondering if there is a signal anywhere in gtkmm that is emitted when the system clipboard contents change/someone copies text. I looked into the gtk docs and it seems the only signal emitted by the Gtk::Clipboard object is the owner_changed signal. To be more specific, I don't care who changes the system clipboard whether it be my app (which it wont be) or the user.
My only other option to implement this is to loop and keep checking the clipboard for a change. Was hoping there was a more efficient means of accomplishing this.
Anyone know of a signal?
Thanks.

I'd take a look at this example. I did not compile and run it, but I think it is indicating that the "owner_changed" signal will do what you want.

Related

Unity C#: How to rebind buttons via script while game is running?

Title says it all, I'd like to implement a controls menu so the player can rebind controls, which changes the positive input key of a button in the Input Manager. But I can't find anything about it online.
How would I go about changing the positive key for a button while ingame?
Unfortunately, I believe you can't set Input Manager values via code at all. That's probably why you didn't find anything about it.
You've got two alternatives:
Use the "Input System" aka. the new input system that is available as a package. It is not as easy to use as the legacy input system, but you should check it out. It's also open source.
Use an asset store package. I've tested Rewired in the past and found it extremely powerful, especially compared to the legacy input system.
Personally, I'd first go with option 1 and see if you are happy with it. It's an official package and not 3rd party. Option 2 is still there, if you have issues with option 1, but it'll probably cost you money.

There's no way to undo memory changes in windbg?

I'm trying to undo changes in Memory window:
But CTRL-Z does not work and there's no such menu item too:
Is this function supported?
When doing live debugging, there's not much use of an undo functionality in general. If a thread ends, you can't simply recreate it. If you step over a line, you can't easily go back to the state before. If you close a file handle, you can't easily reopen it.
If you changed memory, when should WinDbg disable the ability to undo that? Once that memory was written to by the process? Or do you want to be able to undo even if the memory was written to after your edit?
To what memory content should be undone then? To the values you entered (i.e. undo the action done by the process) or to the values before you entered them (i.e. undo the edits made by you, including the changes made by the process) or undo only those values which were edited by you and not changed by the process yet?
As you see, implementing an undo functionality in a debugging scenario can become really difficult. IMHO, WinDbg was never designed to have undo functionality.
I would even say people do not use the memory window to edit memory content. Why that?
When you do a debugging session, you want your steps to be recorded so that you yourself or someone else can verify and reproduce your actions. In such a scenario, you use .logopen and log everything you do. Actions done outside the command window will not be recorded and thus break the verification workflow.
What do you do instead? You use one of the display commands (db, dd, dp or similar) to show the memory contents before the edit. You then use an edit command (eb, ed, ...) to change the memory. Whenever you want the old values back, you look at the previous output of the d command and e those values again.

How can I know whether process has a windows or not?

Sometimes my program is finished incorrectly. GUI is gone but processes still present in the system. So I need to verify whether the program finishes correctly or not by checking GUI presence. Could anyone help me with it?
It looks like what you need is WASP.
You can use WASP's Select-Window to list all window handles.
You can then use Select-Window Myapp* to set focus on the window, if required.

Using NPAPI to detect browser minimize

Is there a way to use NPAPI to determine whether the browser is minimized.
Not directly. Depending on which platform you want (you should really specify things like that) there might be a way.
For example, on windows you might be able to get the browser HWND (NPN_GetValue with NPNVnetscapeWindow) and then check the state of that window with windows API calls.
On mac you're going to have a harder time of it; you could possibly intuit from the clipping information passed into NPP_SetWindow, but that doesn't tell you if the browser is minimized or if the plugin (or even the tab) is just not visible. Again, you'd need to try to figure out a way to use system calls to find your way back to the real window, but on Mac that's going to be very non-trivial.
Linux I'm not sure; you get a GtkSocket if you use XEmbed (only thing Chromium supports) and I haven't a clue if you can use that to get back to where you'd need to be to check minimized state.
So the short answer is no; NPAPI doesn't provide anything like that. You'd just have to try to find something that it does provide that gives you enough info to hack it.
Since I was using Core animation layer. I put in a timer which checks how often the candraw call back is called. If the time difference between the two callbacks are greater than a second I assume that either my plug-in is minimized or hidden.

How can I intercept and correct keypresses at a low level?

I keep typing "t eh" instead of " the" which is, of course, annoying in the amount of time it takes me to correct myself.
The obvious answer is "Learn to type, noob!" or at least to type more slowly and/or more correctly. This error is frighteningly consistent so it appears I've trained my muscle memory for that pattern already.
But I'm wondering if it's possible to write a small, windows portable script or application that, when it detects the incorrect sequence, backspaces and corrects it automatically at a layer where it would apply to any keyboard input.
Does C# have access to that layer of the OS that intercepts keypresses systemwide?
Will I run into UAC issues with Vista?
Am I re-inventing the wheel (ie, are there open source tools I can modify or use out of the box)?
In DOS this sort of thing was quite easy and one could make TSRs (Terminate and Stay Resident) programs that would, for instance, give you a calculator onscreen with a special keypress. Not to mention the many, many practical joke programs based on this concept (dial "M" for monster!)...
I would, of course, never suggest such a utility could be used that way for co-workers...
-Adam
On windows you could use AutoHotKey. That allows you to create little scripts or macros to automate and correct things like mistypes.
One use was posted on lifehacker which took the common mistyped words and corrected them. It is at http://lifehacker.com/192506/download-of-the-day-universal-autocorrect
UPDATE Per Comment: This is Free software and windows only as far as I know.
The above script is just an example of what it can do. There are a slew of scripts available at AutoHotkeys Site
I suggest AutoHotKey. If you've never used it before, have a quick read of the tutorial: http://www.autohotkey.com/docs/Tutorial.htm
The feature you are looking for is called "hotstrings." http://www.autohotkey.com/docs/Hotstrings.htm
In your case, your script would look something like:
::teh::the
That's it! Add other things you want corrected on additional lines. AutoHotkey scripts can be compiled so you don't have to install AutoHotKey on all of your machines.
It's a very cool program. It's primary use (for making custom hotkeys) rocks! These scripts are system wide so you'll also probably want to make a hotkey to be able to turn them off too!
EDIT: In a comment, it was mentioned that he actually types "t eh" (with a space in it) and I wondered if something additional would be needed for it to work. I just tested it and it works fine. Just install autohotkey, and create a file with the .AHK extension. In that file put in the following line
::t eh::the
and save the file. Then double-click on the AHK file to load AutoHotKey with your script (you'll see a green square in your system tray to let you know it is running). It should work fine!
Yes, you can use pinvoke commands from C# to intercept the low-level os commands. I recommend you take a look at http://www.pinvoke.net. The coding isn't easy but it does work.
I suggest learning to type more slowly. I also suffer from "teh" and "ahve" in part due to autocorrect giving me the leniency. If you forced yourself to retrain then you would not be at a disadvantage when using someone else's machine.
Not to mention the unfortunate event when you need to write "t eh" and are being prevented by an overzealous 'corrector'.