Click here to Skip to main content
15,906,341 members
Home / Discussions / C#
   

C#

 
GeneralRe: msagent output voice file Pin
Muammar©1-Jan-08 6:11
Muammar©1-Jan-08 6:11 
GeneralNavigating a web form Pin
brsecu31-Dec-07 6:31
brsecu31-Dec-07 6:31 
GeneralRe: Navigating a web form Pin
DotNetXenon31-Dec-07 7:45
DotNetXenon31-Dec-07 7:45 
GeneralDatagrid and combo box or drop down list Pin
Saamir31-Dec-07 5:07
Saamir31-Dec-07 5:07 
GeneralRe: Datagrid and combo box or drop down list Pin
Justin Perez31-Dec-07 5:24
Justin Perez31-Dec-07 5:24 
GeneralRe: Datagrid and combo box or drop down list Pin
Saamir31-Dec-07 6:14
Saamir31-Dec-07 6:14 
GeneralRe: Datagrid and combo box or drop down list [modified] Pin
awiesendanger2-Jan-08 2:23
awiesendanger2-Jan-08 2:23 
QuestionSendKeys Oddity??? Pin
tboydva31-Dec-07 3:56
tboydva31-Dec-07 3:56 
I have a small program to monitor a sensor, detect an error state (sensor value goes over a setpoint), then change focus to a running application and send the {END} key to stop acquisition (before bad things happen!). I am using this code which seems to work fine...:

<br />
methodcall....<br />
{<br />
                Process pr = new Process();<br />
                pr = Process.GetProcessesByName("PeakSimple329")[0];<br />
                IntPtr psHandle = pr.MainWindowHandle;<br />
<br />
                // Try and get process of interest, get main window handle<br />
                // Get a handle to PeakSimple application. The window class<br />
                // and window name were obtained using the Spy++ tool.<br />
                // Verify that PeakSimple is a running process.<br />
                if (psHandle == IntPtr.Zero)<br />
                {<br />
                    MessageBox.Show("Peak Simple is not running.");<br />
                    return;<br />
                }<br />
<br />
                // Make PeakSimple the foreground application and send it <br />
                // the <end> key to stop acquisition.<br />
                SetForegroundWindow(psHandle);<br />
                SendKeys.SendWait("{END}");<br />
                SendKeys.Flush();</end>



}
<br />
<br />
        // Activate an application window.<br />
        [DllImport("USER32.DLL")]<br />
        public static extern bool SetForegroundWindow(IntPtr hWnd);<br />


This works perfectly "the first time." So if I reset the my C# application (to start monitoring again) and restart a run on the PeakSimple program, when triggered, the method call will set focus to PeakSimple, but won't send the {END} key anymore? If I shut down my C# app, then re-run it, the method call will work???? I added the SendKeys.Flush() command, thinking perhaps it would "clean up" any reference to previous key sends, but it doesn't help. I tried to Invalidate() the form, again to no avail.... I can't figure what "state" needs to be flushed, reset or invalidated to make the SendKeys.X command work a second time within a running C# app? I tried just doing a SendKeys.Send("{END}") instead of the SendWait which works, but also only the first time (I have to restart the app to get it to work "again"). If I set breakpoints, it goes through the code and performs the SendKeys.SendWiat or .Send method, but it doesn't actually "send" the key-stroke on subsequent calls to the method??? I must be missing something, but I can't find anything in my searching that explains this behavior??? Any help appreciated...

Thanks!
QuestionTextBox indentation??? Pin
JoZ CaVaLLo31-Dec-07 2:24
JoZ CaVaLLo31-Dec-07 2:24 
GeneralRe: TextBox indentation??? Pin
Justin Perez31-Dec-07 2:25
Justin Perez31-Dec-07 2:25 
GeneralRe: TextBox indentation??? Pin
JoZ CaVaLLo31-Dec-07 2:49
JoZ CaVaLLo31-Dec-07 2:49 
GeneralRe: TextBox indentation??? Pin
Skippums31-Dec-07 7:40
Skippums31-Dec-07 7:40 
QuestionHow to get the values of dynamic fileupload Pin
Elena200631-Dec-07 1:49
Elena200631-Dec-07 1:49 
AnswerRe: How to get the values of dynamic fileupload Pin
Justin Perez31-Dec-07 2:14
Justin Perez31-Dec-07 2:14 
GeneralRe: How to get the values of dynamic fileupload Pin
Elena200631-Dec-07 2:19
Elena200631-Dec-07 2:19 
GeneralRe: How to get the values of dynamic fileupload Pin
Justin Perez31-Dec-07 2:24
Justin Perez31-Dec-07 2:24 
GeneralRe: How to get the values of dynamic fileupload Pin
Elena200631-Dec-07 2:30
Elena200631-Dec-07 2:30 
GeneralRe: How to get the values of dynamic fileupload Pin
Ed.Poore31-Dec-07 7:13
Ed.Poore31-Dec-07 7:13 
Generaldisplay rows in a list box Pin
michael_jhons31-Dec-07 1:22
michael_jhons31-Dec-07 1:22 
GeneralRe: display rows in a list box Pin
WillemM31-Dec-07 1:31
WillemM31-Dec-07 1:31 
GeneralC# - Events not triggering Pin
jgrogan31-Dec-07 1:07
jgrogan31-Dec-07 1:07 
GeneralRe: C# - Events not triggering Pin
WillemM31-Dec-07 1:29
WillemM31-Dec-07 1:29 
GeneralRe: C# - Events not triggering Pin
jgrogan31-Dec-07 1:48
jgrogan31-Dec-07 1:48 
GeneralRe: C# - Events not triggering Pin
PIEBALDconsult31-Dec-07 15:37
mvePIEBALDconsult31-Dec-07 15:37 
GeneralBook of c# Pin
help as an alias31-Dec-07 0:28
help as an alias31-Dec-07 0:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.