c# - Receiving strangers strings in target window from PostMessage api -
i have remote administration tool, , i'm trouble when receives strings in window postmessage api. strings sent through of textbox
componente in server application.
for example, word coder in stackoverflow window stays this:
and code i'm using this:
server application
private void tenviartexto_click(object sender, eventargs e) { string message = string.format("<|msg|>{0}", tenviarmsg.text); listviewitem item = listview_clients.focuseditem; string clientid = item.name; remoteclient client = this.remoteclientmanager.getclientbyid(clientid); if (client != null) { try { client.mremessage.waitone(); client.queuemessage.addmessage(message); tenviarmsg.text = ""; } catch (exception ex) { messagebox.show(ex.tostring()); } } }
client application
public void enviatextohwnd(string texto) { foreach (char caractere in texto) { int charvalue = caractere; string hexvalue = charvalue.tostring("x"); intptr val = new intptr((int32)caractere); string valor = val.tostring(); if (valor == "66") // letra b no operador { postmessage(windowhandle, wm_keydown, new intptr(vk_back), new intptr(0)); postmessage(windowhandle, wm_keyup, new intptr(vk_back), new intptr(0)); } else if (valor == "83") // letra s no operador { postmessage(windowhandle, wm_keydown, new intptr(vk_space), new intptr(0)); postmessage(windowhandle, wm_keyup, new intptr(vk_space), new intptr(0)); } else { postmessage(windowhandle, wm_keydown, val, new intptr(0)); postmessage(windowhandle, wm_char, val, new intptr(0)); postmessage(windowhandle, wm_keyup, val, new intptr(0)); } } }
and usage:
public void communicationproc() { while (this.connected) { else if (message.indexof("<|msg|>") == 0) { string[] strsplit = value.split(menuremoteclient.separator, stringsplitoptions.none); string msg = strsplit[0]; // content textbox on server application if (this.remotednav) { thread sendtextohwnd = new thread(() => enviatextohwnd(msg)); sendtextohwnd.start(); } } } }
so, how solve it?
any suggestions or guidance here appreciated.
fixed:
// postmessage(windowhandle, wm_keydown, val, new intptr(0)); postmessage(windowhandle, wm_char, val, new intptr(0)); // postmessage(windowhandle, wm_keyup, val, new intptr(0));
Comments
Post a Comment