Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
SendMessage 0x41 doesnt work
Results 1 to 7 of 7

Thread: SendMessage 0x41 doesnt work

  1. #1

    SendMessage 0x41 doesnt work

    why does all of this work:
    Code:
    					if(GetAsyncKeyState(VK_RIGHT)) {
    						SendMessage(tibiaWindow, WM_KEYUP, VK_RIGHT, 0);
    						SendMessage(tibiaWindow, WM_KEYDOWN, VK_RIGHT, 0);
    					}
    					else if(GetAsyncKeyState(VK_UP)) {
    						SendMessage(tibiaWindow, WM_KEYUP, VK_UP, 0);
    						SendMessage(tibiaWindow, WM_KEYDOWN, VK_UP, 0);
    					}
    					else if(GetAsyncKeyState(VK_DOWN)) {
    						SendMessage(tibiaWindow, WM_KEYUP, VK_DOWN, 0);
    						SendMessage(tibiaWindow, WM_KEYDOWN, VK_DOWN, 0);
    					}
    					else if(GetAsyncKeyState(VK_LEFT)) {
    						SendMessage(tibiaWindow, WM_KEYUP, VK_LEFT, 0);
    						SendMessage(tibiaWindow, WM_KEYDOWN, VK_LEFT, 0);
    					}
    but not this:
    Code:
    					else if(GetAsyncKeyState(0x41)) {
    						SendMessage(tibiaWindow, WM_KEYUP, 0x41, 0);
    						SendMessage(tibiaWindow, WM_KEYDOWN, 0x41, 0);
    					}
    ?

  2. #2
    You also need to send WM_CHAR if you want to write letters and such.
    Use Spy++ or so in the future to see what messages is sent when you press a button.

    PS. You can write 'A' instead of 0x41, easier to read just so you know.

  3. #3
    I dont like spy++, it never gives concrete WM keycodes.
    anything wrong here?

    Code:
    						SendMessage(tibiaWindow, WM_CHAR, 0x41, 0);

  4. #4
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Just to make you aware, because you'll probably face this issue soon, the use of SendMessage is disrupted by TeamViewer, so if your keyboard controller isn't working, that'll be why. I didn't find a workaround yet, not looked so hard.

    Here is my method for sending strings, if you wanted it:

    Code:
           public void SendKeys(string message)
            {
                foreach (char c in message)
                {
                    int charValue = c;
                    IntPtr val = new IntPtr((Int32)c);
                    SendMessage(Util.Handle, Constants.WM_CHAR, val, new IntPtr(0));
                }
                IntPtr rtn = new IntPtr((Int32)'\0');
                SendMessage(Util.Handle, Constants.WM_CHAR, rtn, new IntPtr(0));
            }
    So you know, Util.Handle is the handle, and Constants.WM_CHAR is defined like so:

    public const Int32 WM_CHAR = 0x0102;

    In a seperate class named Constants. I think the \0 I'm sending at the end was supposed to be a carriage return but I may have modified it by mistake when I was trying something.

  5. #5
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723
    Quote Originally Posted by Xleniz View Post
    I dont like spy++, it never gives concrete WM keycodes.
    anything wrong here?

    Code:
                            SendMessage(tibiaWindow, WM_CHAR, 0x41, 0);
    Then you're not using Spy++ correctly.

  6. #6
    Quote Originally Posted by Xleniz View Post
    I dont like spy++, it never gives concrete WM keycodes.
    anything wrong here?

    Code:
    						SendMessage(tibiaWindow, WM_CHAR, 0x41, 0);
    It can't be much clearer than it already is in Spy++.

  7. #7
    ok THNX.
    i was using wininspector or whatever it was called, it showed too many messages,
    Spy++ came with VSSTUDIO (i will use it in future)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •