Hey
I'm trying to tell a remote process to run a command using (the other processes) command line (like cin).
currently i use createremotethread and inject some asm into the process, but the thread sometimes conflicts with other threads and crashes the program.
so now i am trying to use sendmessage or keybd_event to send keys to the normal command line (i tried using writeprocessmemory and it didnt work) to get it to run the command. however i am a bit skeptical because if i use keybd_event it has to be set as the foreground window, and i am running 8+ instances of this program, so i think they will conflict
i tried using sendmessage as follows:

char *tmp="sv_say \"hi\"";
					
			for(int i=0;i<strlen(tmp);i++){
				cout<<(int)tmp[i];
				SendMessage(hWnd, WM_KEYDOWN, (int)tmp[i], 1);
				SendMessage(hWnd, WM_KEYUP, (int)tmp[i], 1);
			}
			SendMessage(hWnd, WM_KEYDOWN, 13, 1);
			SendMessage(hWnd, WM_KEYUP, 13, 1);

but it doesnt seem to work (it only works if i do just the enter key)
does anyone have any input on what i should do or how to fix the above code?

(int)tmp[i]

Shouldn't it be VkKeyScan(tmp[i]) ?

Yea, I think that was it. thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.