Thread: int to parameter anyway? casting?

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

    int to parameter anyway? casting?

    Code:
    void CProcess::SendText(char input[])
    {
    	HWND hWnd;
    	int count, number_of_output = sizeof(input);
    	hWnd = FindWindow(0, "Nexus");
    	
    	ShowWindow(hWnd, SW_SHOW);
    	SetForegroundWindow(hWnd);
    	Delay(20000);
    
    	for(count=0;count<number_of_output;count++)
    	{
    		if(input[count] == (char)"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9")
    		{
    			keybd_event("VK_"+input[count],0,0,0);
    		}
    		if(input[count] == (char)"/0")
    		{
    			keybd_event(VK_SPACE,0,0,0);
    		}
    	}
    
    	return;
    }
    Code:
    --------------------Configuration: Macro - Win32 Debug--------------------
    Compiling...
    Main.cpp
    c:\program files\microsoft visual studio\myprojects\macro\apis.h(144) : error C2664: 'keybd_event' : cannot convert parameter 1 from 'char [4]' to 'unsigned char'
            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

  2. #2
    Registered User
    Join Date
    Nov 2005
    Posts
    52
    You're trying to pass the literal string "VK_A" (or b, or whatever) - what the function wants is the symbolic constant VK_A

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    20
    Quote Originally Posted by Stuka
    You're trying to pass the literal string "VK_A" (or b, or whatever) - what the function wants is the symbolic constant VK_A
    How can I get this to work?

    how do I add VK_+value to equal a(n) parameter?

    Thanks

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Take a look at the virtual keycode list There is no VK_A (AFAIK). Also, the comma operator

    Just because it doesn't flag an error doesn't mean it does what you want it to do.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  5. #5
    Registered User
    Join Date
    Feb 2005
    Posts
    20
    Quote Originally Posted by JaWiB
    Take a look at the virtual keycode list There is no VK_A (AFAIK). Also, the comma operator

    Just because it doesn't flag an error doesn't mean it does what you want it to do.
    http://mech.math.msu.su/~vfnik/WinAp...lkeycodes.html

    my bad... for thinking there was VK_A.... =( crap I think in VB you can use VK_A...

    I know what you guys mean now.. thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. NEED HELP READING FILE and PRINTING
    By geoffr0 in forum C Programming
    Replies: 4
    Last Post: 04-16-2009, 05:26 PM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  4. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 09:16 PM
  5. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM