Thread: WinAble.h help

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    20

    WinAble.h help

    OK..! I know I use WinAble.h to send text to a target window, but how? With which function?

    My best guess is SendMessage(); , but I dont get it... You have to pass the handle, then 3 unsigned ints? (Or Null/0) How do I use this to send text to a target process/window?

    I am trying to use this in a macro type program for a game.

    Thanks!

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Code:
    SendMessage(hWindow, WM_SETTEXT,  0, szText);
    Where szText is a text string such as
    Code:
    char szText[]="hello world";

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    20
    Quote Originally Posted by Quantum1024
    Code:
    SendMessage(hWindow, WM_SETTEXT,  0, szText);
    Where szText is a text string such as
    Code:
    char szText[]="hello world";
    Thanks a lot..!

    Umm so what would WM_SETTEXT be? Can I just pass null in there? Also, to send like the tab key or shift or left error ect..ect.. Would I just type TAB without quotes ect.. ect..? Is there a reference guide somewhere?

    Thanks again

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    WM_SETTEXT is the name of the message, type it as it is. You can send atab by putting a \t in the string. To do a new line use \r\n.
    If you want to send arrow keys to a control then you can use the WM_KEYUP/KEY_DOWN message, there is also a simulate keys api function but I don't remember it's name.
    Look up edit controls on http://msdn.microsoft.com

  5. #5
    Registered User
    Join Date
    Feb 2005
    Posts
    20
    Another problem arises =(

    Code:
    void CProcess::SendText()
    {
    	HWND hWnd;
    
    	hWnd = FindWindow(0, "Nexus");
    	
    	ShowWindow(hWnd, SW_SHOW);
    	SetForegroundWindow(hWnd);
    	
    	Delay(10000); //in milliseconds
    	char szText[]="hello world";
    	SendMessage(hWnd, WM_SETTEXT, 0, szText);
    
    	return;
    }
    It's telling me I have to cast szText.. When I do that I get no errors, but nothing displays in hWnd (Nexus)...

    Code:
    --------------------Configuration: Macro - Win32 Debug--------------------
    Compiling...
    Main.cpp
    c:\program files\microsoft visual studio\myprojects\macro\apis.h(141) : error C2664: 'SendMessageA' : cannot convert parameter 4 from 'char [12]' to 'long'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    Error executing cl.exe.
    
    Main.obj - 1 error(s), 0 warning(s)
    Thanks for all your help. You've been my idol for the past few hours hehe.

  6. #6
    Registered User
    Join Date
    Feb 2005
    Posts
    20
    NvM I need to use sendinput function, thanks! Like you said above

Popular pages Recent additions subscribe to a feed