Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: How can i use instead of Sleep() method? Pin
sugarpasa8-Feb-16 12:41
sugarpasa8-Feb-16 12:41 
GeneralRe: How can i use instead of Sleep() method? Pin
Richard Andrew x648-Feb-16 12:15
professionalRichard Andrew x648-Feb-16 12:15 
GeneralRe: How can i use instead of Sleep() method? Pin
sugarpasa8-Feb-16 12:44
sugarpasa8-Feb-16 12:44 
GeneralRe: How can i use instead of Sleep() method? Pin
Richard Andrew x648-Feb-16 12:49
professionalRichard Andrew x648-Feb-16 12:49 
GeneralRe: How can i use instead of Sleep() method? Pin
sugarpasa9-Feb-16 6:12
sugarpasa9-Feb-16 6:12 
GeneralRe: How can i use instead of Sleep() method? Pin
Richard Andrew x649-Feb-16 6:19
professionalRichard Andrew x649-Feb-16 6:19 
QuestionScanning QR code Pin
Member 123142768-Feb-16 7:13
Member 123142768-Feb-16 7:13 
AnswerRe: Scanning QR code Pin
OriginalGriff8-Feb-16 8:09
mveOriginalGriff8-Feb-16 8:09 
AnswerRe: Scanning QR code Pin
Sascha Lefèvre8-Feb-16 8:15
professionalSascha Lefèvre8-Feb-16 8:15 
QuestionC# iTexSharp How to put PDF page number during creation PDF File Pin
Zefir18-Feb-16 2:38
Zefir18-Feb-16 2:38 
AnswerRe: C# iTexSharp How to put PDF page number during creation PDF File Pin
Richard MacCutchan8-Feb-16 3:17
mveRichard MacCutchan8-Feb-16 3:17 
GeneralRe: C# iTexSharp How to put PDF page number during creation PDF File Pin
Zefir18-Feb-16 3:27
Zefir18-Feb-16 3:27 
GeneralRe: C# iTexSharp How to put PDF page number during creation PDF File Pin
Richard MacCutchan8-Feb-16 3:50
mveRichard MacCutchan8-Feb-16 3:50 
QuestionIs this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 21:07
Member 120616007-Feb-16 21:07 

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.