Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
GeneralRe: cant send key stroke only to Word Through my program that use KeyboardHook Pin
goldsoft4-Sep-15 6:16
goldsoft4-Sep-15 6:16 
GeneralRe: cant send key stroke only to Word Through my program that use KeyboardHook Pin
Eddy Vluggen4-Sep-15 7:00
professionalEddy Vluggen4-Sep-15 7:00 
GeneralRe: cant send key stroke only to Word Through my program that use KeyboardHook Pin
goldsoft4-Sep-15 21:35
goldsoft4-Sep-15 21:35 
GeneralRe: cant send key stroke only to Word Through my program that use KeyboardHook Pin
Eddy Vluggen5-Sep-15 0:45
professionalEddy Vluggen5-Sep-15 0:45 
QuestionC# Active Directory Pin
Vuyo884-Sep-15 0:47
Vuyo884-Sep-15 0:47 
AnswerRe: C# Active Directory Pin
Pete O'Hanlon4-Sep-15 0:58
mvePete O'Hanlon4-Sep-15 0:58 
AnswerRe: C# Active Directory Pin
Ravi Bhavnani4-Sep-15 7:25
professionalRavi Bhavnani4-Sep-15 7:25 
QuestionReceives a question mark when trying to see active window open in my program Pin
goldsoft3-Sep-15 21:59
goldsoft3-Sep-15 21:59 
hi
I built Software that grabbing weight and throw into open window where the cursor is. Everything worked out well - I only have one problem annoying
Receives a question mark (?) when I open Word. and Then the software hangs not recognize the window properly.

when i open Word i see Word? - 123.docx for example. And even if I remove the question mark, the software is still stuck in this case.

my code:
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);

private string GetActiveWindowTitle()
{
    const int nChars = 256;
    StringBuilder Buff = new StringBuilder(nChars);
    IntPtr handle = GetForegroundWindow();
    if (GetWindowText(handle, Buff, nChars) > 0)
    {
        return Buff.ToString();
    }
    return null;
}

[DllImport("user32.dll")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);

public void Start(string NAME)
{
    MSG = lblMSG.Text.Trim();
    IntPtr zero = IntPtr.Zero;
    for (int i = 0; (i < 60) && (zero == IntPtr.Zero); i++)
    {
        Thread.Sleep(500);
        zero = FindWindow(null, NAME);
    }
    if (zero != IntPtr.Zero)
    {
       .
       .
       .
    }
}

what is the problem ? how to fix it ?

thanks

modified 4-Sep-15 4:06am.

AnswerRe: Receives a question mark when trying to see active window open in my program Pin
Eddy Vluggen3-Sep-15 23:15
professionalEddy Vluggen3-Sep-15 23:15 
QuestionReturn an image from database sql server management studio 2012 Pin
Member 119583513-Sep-15 17:54
Member 119583513-Sep-15 17:54 
AnswerRe: Return an image from database sql server management studio 2012 Pin
Wendelius3-Sep-15 18:20
mentorWendelius3-Sep-15 18:20 
AnswerRe: Return an image from database sql server management studio 2012 Pin
OriginalGriff3-Sep-15 22:07
mveOriginalGriff3-Sep-15 22:07 
QuestionFAXCOMEXLib need fax modem? Pin
Member 118422883-Sep-15 6:44
Member 118422883-Sep-15 6:44 
AnswerRe: FAXCOMEXLib need fax modem? Pin
OriginalGriff3-Sep-15 8:07
mveOriginalGriff3-Sep-15 8:07 
GeneralRe: FAXCOMEXLib need fax modem? Pin
Member 118422883-Sep-15 9:10
Member 118422883-Sep-15 9:10 
GeneralRe: FAXCOMEXLib need fax modem? Pin
Dave Kreskowiak3-Sep-15 9:45
mveDave Kreskowiak3-Sep-15 9:45 
GeneralRe: FAXCOMEXLib need fax modem? Pin
Member 118422883-Sep-15 9:48
Member 118422883-Sep-15 9:48 
GeneralRe: FAXCOMEXLib need fax modem? Pin
Dave Kreskowiak3-Sep-15 9:49
mveDave Kreskowiak3-Sep-15 9:49 
GeneralRe: FAXCOMEXLib need fax modem? Pin
Member 118422883-Sep-15 9:52
Member 118422883-Sep-15 9:52 
GeneralRe: FAXCOMEXLib need fax modem? Pin
OriginalGriff3-Sep-15 9:52
mveOriginalGriff3-Sep-15 9:52 
GeneralRe: FAXCOMEXLib need fax modem? Pin
Dave Kreskowiak3-Sep-15 9:55
mveDave Kreskowiak3-Sep-15 9:55 
GeneralRe: FAXCOMEXLib need fax modem? Pin
OriginalGriff3-Sep-15 11:16
mveOriginalGriff3-Sep-15 11:16 
GeneralRe: FAXCOMEXLib need fax modem? Pin
Dave Kreskowiak4-Sep-15 5:10
mveDave Kreskowiak4-Sep-15 5:10 
AnswerRe: FAXCOMEXLib need fax modem? Pin
OriginalGriff5-Sep-15 2:30
mveOriginalGriff5-Sep-15 2:30 
GeneralRe: FAXCOMEXLib need fax modem? Pin
Member 118422885-Sep-15 2:40
Member 118422885-Sep-15 2:40 

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.