[Mono-dev] AppActivate and System.Windows.Forms.SendKeys on Ubuntu 10.10

Bojan Rajkovic severedcross at gmail.com
Wed Mar 16 15:07:35 EDT 2011


On Mar 16, 2011, at 8:37 AM, Quandary wrote:

> Hi,
> 
> Question: 
> Is System.Windows.Forms.SendKeys implemented and working on Ubuntu Linux ?
> 
> I try to control JD-GUI with it, but the keys don't arrive, neither do they arrive in gedit.
> They do arrive in Notepad on Windows using the same program, and they work with JD-GUI on Windows, using the same program. 
> 
> Or does it need any library installed, such as XTest/XFakeEvent ?
> 
> 
> And BTW, Microsoft.VisualBasic.Interaction.AppActivate("Window Title") throws not implemented...
> 
> You can use the functions:
>      static Window FindWindow(Window top, char *name)
>      static void GetFocusedWindow(void)
> From xvkbd -> in file xvkbd.c
> Basically, all you need to do is save the mouse position, find the target window position & rectangle, and press the left mousebutton somewhere on it with mousedown & mouseup via xsendevent, then restore the mouse position.
> 
> I can supply left + right mousedown + mouseup,
> I have appended cMouse.cs and the dependencies: XorgAPI + XorgStructs.
> 
> And when I loop through all processes, as shown below, I don't get a WindowTitle anywhere...
> (using mono 2.10.1 on Ubuntu)
> --------------------------------------------
> 
>         public void GetProcesses()
>         { 
>             System.Diagnostics.Process[] processlist = System.Diagnostics.Process.GetProcesses();
> 
>             string str = "";
>             foreach(System.Diagnostics.Process theprocess in processlist)
>             {
>                 Console.WriteLine("Process: {0} ID: {1} WindowTitle: {2}", theprocess.ProcessName, theprocess.Id, theprocess.MainWindowTitle);
>                 str += string.Format("Process: {0} ID: {1} WindowTitle: {2}", theprocess.ProcessName, theprocess.Id, theprocess.MainWindowTitle);
>                 str += Environment.NewLine;
>             }
>             MessageBox.Show(str);
>         }
> 
> --------------------------------------------
> 
> <cMouse.cs><cXorgAPI.cs><Structs.cs>_______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

Erm, I don't think SendKeys for WinForms is going to work against !WinForms apps on Linux. gEdit is GTK+, so the mainloops don't match at all, and gEdit likely isn't expecting any keys from Mono.

—Bojan


More information about the Mono-devel-list mailing list