Question: I'm trying to log in to a server through remote desktop using c#. I'm able to initiate the connection using the `AxMSTSCLib` and the code below. However, I'm stuck on our domain's security notice. 

When logging in manually it requires you to click ok on the notice before the log in completes. I have been unable to find anyway to interact with this OK button through my application. I've tried variations of `SendKeys`, sending key events using interop services, finding the cursor position and sending a mouse click event... 

I'm running out of ideas here. 

```
rdp.Server = server;
rdp.Domain = domain;
rdp.UserName = userName;

IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
secured.ClearTextPassword = password;
rdp.StartConnected = 1;

rdp.Connect();

```

Thanks

Answer: 
Well, there is a way to do what you ask.
You will need to download a copy of Windows 7 Embedded Standard (**WES7 wSP1**).
WES7 contains something that other editions of Windows 7 do not - a **Dialog Filter**.
It runs as a service, and allows you to specify certain window events to be performed automatically, without user interaction.

The Dialog Filter Editor is installed with the Windows Embedded Standard 7 tools in the EmbeddedSDK\bin folder.

All you have to do is:

1. Add the service to your Windows, by copying the necessary Dialog Filter files to C:\Windows\System32. There are x86 and x64 versions, so choose the correct architecture.
2. Register the files, and enable the service to run automatically.
3. Add the **ConfigurationList.xml** file created with the editor to **C:\ProgramData\Microsoft\DialogFilter**.
This location is hidden by defeault, so make sure to show hidden files and unhide protected system files in Windows Explorer.

I've actually created the ConfigurationList.xml file already, so you can simply copy the following code and save it as "ConfigurationList.xml":

```
<?xml version="1.0" encoding="utf-8"?> 
<CL:dialogs xmlns:CL="urn:Dialogs"> 
    <dialog> 
    <ProcessImageName>rundll32.exe</ProcessImageName> 
    <Title>Remote Desktop Connection</Title> 
    <Class>#32770</Class> 
    <Buttons> 
      <Button>OK</Button> 
      <Button>Cancel</Button> 
      <Button>Close</Button> 
    </Buttons> 
    <Actions> 
      <Action>OK</Action> 
    </Actions> 
  </dialog> 
</CL:dialogs>

```

As you can see, the action is set to press the **OK button** automatically in the RDP dialog that pops up when making an RDP connection.

More info regarding the Dialog Filter directly from MS:
<https://msdn.microsoft.com/en-US/library/ff794135(v=winembedded.60).aspx>
Just found a much easier way to do this:
There's a free small app called **ClickOff**, which works in a very similar manner to Windows Embedded Standard 7 **DialogFilter**. 

You can download **ClickOff** v1.90 [here](http://www.softpedia.com/get/System/System-Miscellaneous/ClickOff.shtml).

After you install **ClickOff**, you can define which window to capture, and which button inside it to click. Only thing is that you must add it to your startup apps.

I have already created a clickoff.lst file which clicks OK on the 30-sec RDP timeout popup window. The file should be placed in **C:\Users\USERNAME\AppData\Roaming\ClickOff**. Here's the contents of the file:

```
1.900
WINDOWTITLE="Remote Desktop Connection" BUTTONTEXT="OK" MSGTEXT="CompName\\UserName wants to connect to this machine.\r\n\r\nClick OK to disconnect your session immediately or click cancel to stay connected.\r\n\r\nOtherwise, you will be disconnected in 30 seconds." BUTTONID="1" MSGID="65535" DLGID="0" CLKEVENT="17" CLKMETHOD="3" TIMESCLICKED="0" WAIT="0" BPOSX="0" BPOSY="0" ;

```

Cheers.