Click here to Skip to main content
15,896,557 members

Comments by dsnlkc (Top 25 by date)

dsnlkc 1-Jul-11 3:13am View    
SendInput function does the trick. A little walkthrough for using it is in order, though. It might be of some help for future readers.

First of all, as BobJanova said, it is a Win API function, not .net method. On this link

http://pinvoke.net/default.aspx/user32.SendInput

you can find detail description (tutorial) about using it. You can find open source C# wrapper for this function here:

http://inputsimulator.codeplex.com/

Just add this project to your solution and you will be able to simulate keyboard entries. However, I experienced some problems with simulation of mouse clicks, so I had to implement that myself, but data types defined in the project offered me great help. I just had to add one more method to the InputSimulator class.

Thank you BobJanova for the suggestion and your time. Happy coding.
dsnlkc 1-Jul-11 3:10am View    
Deleted
No comment
dsnlkc 22-Jun-11 12:20pm View    
Thank you for your suggestion. I read about SendInput at MSDN and it seams like nice solution to my problem. However, I couldn't find instruction how to call it in my C# code, which class and namespace does it belong to, whether it is static method or not, and which reference and using directive should I add to my C# project.

Can you please answer these questions for me?
Also, if it's not much trouble, small example would be nice.

Thanks again
dsnlkc 6-Apr-11 3:21am View    
OK, you being so sure casts some new light on the TextBox/ListBox pair approach. As I already said, I tried it and failed (which isn't big surprise because I'm new to WPF). To describe the problem depicted above, I created WPF project as simple as I could. Beside files created by Expression Blend automatically I created one user control: TextListPair. The content of MainWindow.xaml file is:

<pre lang="xml"><window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:clippingIsue2" x:class="clippingIsue2.MainWindow" x:name="Window" title="MainWindow" width="640" height="480">
<grid x:name="LayoutRoot">
<scrollviewer height="70" margin="135,121,244,0" verticalalignment="Top" removed="DarkGray" width="250">
<stackpanel verticalalignment="Top" removed="#FF07C81B">
<local:textlistpair></local:textlistpair>
</stackpanel>
</scrollviewer>
</grid>
</window></pre>

and the content of TextListPair.xaml file is:

<pre lang="xml"><usercontrol xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d" x:class="clippingIsue2.TextListPair" x:name="UserControl">
<grid x:name="LayoutRoot" removed="#FFBA0000">
<textbox margin="8" textwrapping="Wrap" text="TextBox"></textbox>
&lt;ListBox Height="100" Margin="8,0,8,-91.723" VerticalAlignment="Bottom" Background="#FF7C00C6"/&gt;
</grid>
</usercontrol></pre>

I did not make any changes to code-behind files. As you can see part of the Listbox is clipped by Scrollviewer. If there was ComboBox instead of TextListPair, its popup wouldn't be clipped. It would exceed dimensions of the Scrollviewer.

So, how can I do that with Listbox?
Alternatively, solution where the Listbox doesn't exceed dimensions of Scrollviewer, but the Scrollviewer allows scrolling so that user can scroll down to see the rest of the Listbox, would be satisfactory, too.

Thanks in advance.
dsnlkc 6-Apr-11 3:17am View    
Deleted