Thread: Getting window Handel

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    110

    Getting window Handel

    Hello, I did do a search, but I searched badly.
    BTW this is in C not C++

    This is what I want to do.

    I have a program

    its Task name (using ctrl alt delet) is.
    "SwgClient"

    its proccess name is.
    "SwgClient_r.exe"

    Are any of those its handel? Im not sure how to get a windows handle or even use it if I do. Does anyone know how?

    My overall goal! so u dont think im some guy sending viruses or who knows what.

    Is to create a macro program to prevent injury to my wrist in the future!

    I was using keybd_event but that is annoying having to keep the swgclient as ontop So im hoping to switch to a sendkeys LIKE command.

    BOT

  2. #2
    Registered User MicroFiend's Avatar
    Join Date
    Nov 2002
    Posts
    80
    easy man as long as u know the window caption, just use the api call FindWindow(class,caption); i havent used it 4 a while but i think u can set the class propertie as null. this will then return the hWnd value (i have used this for getting the sytrays handle and blitted junk 2 it ^^) of course the call requires the include file windows.h but hey uv prbly already got this included ^^ hope it helps

  3. #3
    Registered User KurtSurge's Avatar
    Join Date
    Aug 2003
    Posts
    25
    If you don't know the caption or class of the window to put in the FindWindow function, you should use an api spy program to obtain it. Spy++ is a good one that comes with VC++.
    It's too bad that stupidity isn't painful
    --Anton Szandor LaVey

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    Hello, and thnx for the info, it seems to be running fine.

    Now part 2:

    What is the best ways to send keys to a specific program, like a macro program would work.

    Without using hooks...

    ?


    Coder

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    If you can ensure the program you want the keystrokes to go to will have focus, then use SendInput, else use SendMessage to the window you want.

  6. #6
    Registered User MicroFiend's Avatar
    Join Date
    Nov 2002
    Posts
    80
    I agree however i would go with send message, very flexible

  7. #7
    Registered User
    Join Date
    Jul 2003
    Posts
    110

    Thnx

    I got spy++ from

    http://www.catch22.org.uk/software/winspy.asp


    AND WOW!!!!!!!!!!!!!


    This program RULES...

    Are handels static?

  8. #8
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    No, they can change per process and each time the program with the handle runs. Use FindWindow to get a handle for your process.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  2. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  3. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  4. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM