Click here to Skip to main content
15,891,607 members
Home / Discussions / C#
   

C#

 
GeneralRe: Issue with Serial Port class Pin
Member 1206160010-Feb-16 1:52
Member 1206160010-Feb-16 1:52 
GeneralRe: Issue with Serial Port class Pin
Eddy Vluggen10-Feb-16 3:00
professionalEddy Vluggen10-Feb-16 3:00 
AnswerRe: Issue with Serial Port class Pin
Gerry Schmitz10-Feb-16 5:39
mveGerry Schmitz10-Feb-16 5:39 
QuestionWeb Services - Error in deserializing body of request message for operation Pin
FabeCode9-Feb-16 18:54
FabeCode9-Feb-16 18:54 
AnswerRe: Web Services - Error in deserializing body of request message for operation Pin
Gerry Schmitz10-Feb-16 5:13
mveGerry Schmitz10-Feb-16 5:13 
Question'ctor design and extra "cost" of using nullable ValueTypes ? Pin
BillWoodruff9-Feb-16 0:31
professionalBillWoodruff9-Feb-16 0:31 
AnswerRe: 'ctor design and extra "cost" of using nullable ValueTypes ? Pin
Pete O'Hanlon9-Feb-16 1:02
mvePete O'Hanlon9-Feb-16 1:02 
GeneralRe: 'ctor design and extra "cost" of using nullable ValueTypes ? Pin
BillWoodruff9-Feb-16 20:08
professionalBillWoodruff9-Feb-16 20:08 
GeneralRe: 'ctor design and extra "cost" of using nullable ValueTypes ? Pin
Pete O'Hanlon9-Feb-16 21:30
mvePete O'Hanlon9-Feb-16 21:30 
SuggestionRe: 'ctor design and extra "cost" of using nullable ValueTypes ? Pin
Richard Deeming9-Feb-16 1:51
mveRichard Deeming9-Feb-16 1:51 
GeneralRe: 'ctor design and extra "cost" of using nullable ValueTypes ? Pin
BillWoodruff9-Feb-16 20:09
professionalBillWoodruff9-Feb-16 20:09 
QuestionLarge terrain problem in main first game Pin
Member 122480289-Feb-16 0:25
Member 122480289-Feb-16 0:25 
AnswerRe: Large terrain problem in main first game Pin
OriginalGriff9-Feb-16 0:45
mveOriginalGriff9-Feb-16 0:45 
GeneralRe: Large terrain problem in main first game Pin
Member 122480289-Feb-16 1:03
Member 122480289-Feb-16 1:03 
QuestionCode or .NET class in C# similar to what inf2cat does ? Pin
Coding4DMasses8-Feb-16 23:07
Coding4DMasses8-Feb-16 23:07 
AnswerRe: Code or .NET class in C# similar to what inf2cat does ? Pin
Garth J Lancaster8-Feb-16 23:45
professionalGarth J Lancaster8-Feb-16 23:45 
GeneralRe: Code or .NET class in C# similar to what inf2cat does ? Pin
Coding4DMasses8-Feb-16 23:50
Coding4DMasses8-Feb-16 23:50 
Question(c#) Detection of encoding imported txt files ? Pin
Member 104109728-Feb-16 21:17
Member 104109728-Feb-16 21:17 
AnswerRe: (c#) Detection of encoding imported txt files ? Pin
Thomas Daniels8-Feb-16 21:34
mentorThomas Daniels8-Feb-16 21:34 
GeneralRe: (c#) Detection of encoding imported txt files ? Pin
Member 104109728-Feb-16 23:31
Member 104109728-Feb-16 23:31 
AnswerRe: (c#) Detection of encoding imported txt files ? Pin
Sascha Lefèvre8-Feb-16 21:54
professionalSascha Lefèvre8-Feb-16 21:54 
QuestionHow can i use instead of Sleep() method? Pin
sugarpasa8-Feb-16 10:11
sugarpasa8-Feb-16 10:11 
Code is as following..I am starting some application and triying to write a username into textbox.Unfortunately,FindWindowEx can not get correct handle because target application takes some time to start.How can wait for the application to get correct handle to textbox? WaitForInputIdle doesn't work since program maintains a login window.

Thanks in advance






C#
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
        static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);

        //include FindWindowEx
        [DllImport("user32.dll")]
        public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

        //include SendMessage
        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, uint uMsg, IntPtr wParam, string lParam);

        //this is a constant indicating the window that we want to send a text message
        const int WM_SETTEXT = 0X000C;

  private void button1_Click(object sender, EventArgs e)
        {
           
            Process p = Process.Start("SomeApp.exe");
            IntPtr AppTextBox = IntPtr.Zero;
            int i = 0;

            do
            {
                AppTextBox = FindWindowByCaption(IntPtr.Zero, "SomeApp");
                i++;
            } while (AppTextBox.ToInt32() == 0);

          
            // I DONT WANT TO USE SLEEP METHOD HERE
            Thread.Sleep(4000);
        
            AppTextBox = FindWindowEx(p.MainWindowHandle, IntPtr.Zero, "Edit", null);

          
            SendMessage(AppTextBox, WM_SETTEXT, IntPtr.Zero , "Success!");
            
        }


modified 8-Feb-16 16:28pm.

AnswerRe: How can i use instead of Sleep() method? Pin
Richard Andrew x648-Feb-16 11:24
professionalRichard Andrew x648-Feb-16 11:24 
GeneralRe: How can i use instead of Sleep() method? Pin
sugarpasa8-Feb-16 11:48
sugarpasa8-Feb-16 11:48 
GeneralRe: How can i use instead of Sleep() method? Pin
Richard Andrew x648-Feb-16 11:50
professionalRichard Andrew x648-Feb-16 11:50 

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.