Search Results

Search found 5 results on 1 pages for 'gtaborga'.

Page 1/1 | 1 

  • How do I backup and restore the system clipboard in C#?

    - by gtaborga
    Hey everyone, I will do my best to explain in detail what I'm trying to achieve. I'm using C# with IntPtr window handles to perform a CTRL-C copy operation on an external application from my own C# application. I had to do this because there was no way of accessing the text directly using GET_TEXT. I'm then using the text content of that copy within my application. The problem here is that I have now overwritten the clipboard. What I would like to be able to do is: Backup the original contents of the clipboard which could have been set by any application other than my own. Then perform the copy and store the value into my application. Then restore the original contents of the clipboard so that the user still has access to his/her original clipboard data. This is the code I have tried so far: private void GetClipboardText() { text = ""; IDataObject backupClipboad = Clipboard.GetDataObject(); KeyboardInput input = new KeyboardInput(this); input.Copy(dialogHandle); // Performs a CTRL-C (copy) operation IDataObject clipboard = Clipboard.GetDataObject(); if (clipboard.GetDataPresent(DataFormats.Text)) { // Retrieves the text from the clipboard text = clipboard.GetData(DataFormats.Text) as string; } if (backupClipboad != null) { Clipboard.SetDataObject(backupClipboad, true); // throws exception } } I am using the System.Windows.Clipboard and not the System.Windows.Forms.Clipboard. The reason for this was that when I performed the CTRL-C, the Clipboard class from System.Windows.Forms did not return any data, but the system clipboard did. I looked into some of the low level user32 calls like OpenClipboard, EmptyClipboard, and CloseClipboard hoping that they would help my do this but so far I keep getting COM exceptions when trying to restore. I thought perhaps this had to do with the OpenClipboard parameter which is expecting an IntPtr window handle of the application which wants to take control of the clipboard. Since I mentioned that my application does not have a GUI this is a challenge. I wasn't sure what to pass here. Maybe someone can shed some light on that? Am I using the Clipboard class incorrectly? Is there a clear way to obtain the IntPtr window handle of an application with no GUI? Does anyone know of a better way to backup and restore the system clipboard?

    Read the article

  • Automate Google Chrome extension installation

    - by gtaborga
    Hi everyone, I am working on creating a Google Chrome extension. We have it included in an automated build system and since it is constantly being worked on we need a solution to be able to package the extension as a .crx file which according to http://code.google.com/chrome/extensions/packaging.html can easily be scripted. My question is after packaging the extension is there a known method either through the command-line or some other programmatic way, to install the newly packaged extension in an automated manner? If someone knows how or has any reference material that I can be pointed towards I would greatly appreciate any help that is offered. Thank you.

    Read the article

  • Use SendMessage in C# to perform a CTRL-C operation on a given handle

    - by gtaborga
    Hello everyone, I'm trying to perform a (CTRL-C) copy on a window. I've already managed to do this using SendInput but unfortunately that could fail if the window doesn't have focus. I'm trying to perform the same (CTRL-C) operation using SendMessage in C#. So far I haven't been successful in getting the WPARAM and LPARAM combination for this to work. I have also tried using SendMessage with the WM_COPY message but that didn't work for my needs. Please if anyone has done this before successfully using SendMessage I would greatly appreciate your help.

    Read the article

  • Is there a reliable way to activate / set focus to a window using C#?

    - by gtaborga
    Hey everyone, I'm trying to find a reliable way to activate / set focus a window using C#. Currently I'm attempting to achieve this using the following Windows API calls: SetActiveWindow(handle); SwitchToThisWindow(handle, true); Previously I also had ShowWindow(handle, SW_SHOWMAXIMIZED); executing before the other 2, but removed it because it was causing strange behavior. The problem I'm having with my current implementation is that occasionally the focus will not be set correctly. The window will become visible but the top part of it will still appear grayed out as if it wasn't in focus. Is there a way to reliably do this which works 100% of the time, or is the inconsistent behavior a side-effect I can't escape? Please let me know if you have any suggestions or implementations that always work. Thank you for your time.

    Read the article

  • How do I automatically reset a boolean when any method other is called in C#?

    - by gtaborga
    Hey everyone, Using C#, I need to do some extra work if function A() was called right before function C(). If any other function was called in between A() and C() then I don't want to do that extra work. Any ideas that would require the least amount of code duplication? I'm trying to avoid adding lines like "flag = false;" into every function B1..BN. Here is a very basic example: bool flag = false; void A() { flag = true; } void B1() { ... } void B2() { ... } void C() { if (flag) { //do something } } The above example was just using a simple case but I'm open to using something other than booleans. The important thing is that I want to be able to set and reset a flag of sorts so that C() knows how to behave accordingly. Thank you for your help. If you require clarification I will edit my post.

    Read the article

1