decrypt Posted January 24, 2004 Posted January 24, 2004 Hi, me and my brother were wondering if it was possible to put text into another program. I'll use netmeeting as an example: The person types in an ip on your form. They click a button and it transmits data to netmeeting and puts it into the box were the ip is supposed to go. Is this possible? (in vb.net) Quote
NK2000 Posted January 25, 2004 Posted January 25, 2004 yes it is possible but you need the handle for this object i used such a thing at a tool for a game named Ultima Online you can find handles with Spy++ but i dont know if they change at each startup but normally the window name doesnt change so you just have to know how many times you have to send the TAB key (switch to next control in the form) and then just send the string you want to enter UPDATE: But you definitly have to use the Win32 lib good luck :) The code is from my first days in windows coding so maybe you find performance improvements..but worked very well at those times :) Code used at my tool: using System; using System.Runtime.InteropServices; namespace UO_Build_World_Builder { /// <summary> /// Zusammendfassende Beschreibung für UO. /// </summary> public class UO { [DllImport("user32.dll",EntryPoint="FindWindow")] public static extern int FindWindow(string _ClassName, string _WindowName); [DllImport("user32.dll",EntryPoint="SendMessage")] public static extern int SendMessage(int _WindowHandler, int _WM_USER, int _data, int _id); [DllImport("User32.dll")] public static extern bool SetForegroundWindow(int hWnd); public static int Handle = 0; public static void GetClientHandle() { if (UO.FindWindow("Ultima Online",null) > 0) UO.Handle = UO.FindWindow("Ultima Online",null); else if (UO.FindWindow("Ultima Online Third Dawn",null) > 0) UO.Handle = UO.FindWindow("Ultima Online Third Dawn",null); else UO.Handle = 0; } public static void SendToUO(string text, bool command) { UO.GetClientHandle(); if (UO.Handle > 0) { if (command == true) text = Core.CommandPrefix + text; for(int i = 0; i < text.Length; i++) { UO.SendMessage(UO.Handle, (int) Message.KeyDown, 69, 1); UO.SendMessage(UO.Handle, (int) Message.Char, text, 1); UO.SendMessage(UO.Handle, (int) Message.KeyUp, 69, 1); } UO.SendMessage(UO.Handle, (int) Message.Char, (int) Key.Return, 0); UO.SetForegroundWindow(UO.Handle); } else { System.Windows.Forms.MessageBox.Show("Ultima Online is NOT started","Error",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error); } /* if (Core.Parent.Visible == false) { Core.Parent.Show(); Core.Parent.TrayMenuMinimize.Text="Minimize"; } */ } } enum Key { Back = 0x08, Tab = 0x09, Clear = 0x0C, Return = 0x0D, Shift = 0x10, Control = 0x11, Menu = 0x12, Pause = 0x13, Capital = 0x14 } enum Message { KeyDown = 0x0100, KeyUp = 0x0101, Char = 0x0102 } } /* #define VK_LBUTTON 0x01 #define VK_RBUTTON 0x02 #define VK_CANCEL 0x03 #define VK_MBUTTON 0x04 #define VK_BACK 0x08 #define VK_TAB 0x09 #define VK_CLEAR 0x0C #define VK_RETURN 0x0D #define VK_SHIFT 0x10 #define VK_CONTROL 0x11 #define VK_MENU 0x12 #define VK_PAUSE 0x13 #define VK_CAPITAL 0x14 #define VK_KANA 0x15 #define VK_HANGEUL 0x15 #define VK_HANGUL 0x15 #define VK_JUNJA 0x17 #define VK_FINAL 0x18 #define VK_HANJA 0x19 #define VK_KANJI 0x19 #define VK_ESCAPE 0x1B #define VK_CONVERT 0x1C #define VK_NONCONVERT 0x1D #define VK_ACCEPT 0x1E #define VK_MODECHANGE 0x1F #define VK_SPACE 0x20 #define VK_PRIOR 0x21 #define VK_NEXT 0x22 #define VK_END 0x23 #define VK_HOME 0x24 #define VK_LEFT 0x25 #define VK_UP 0x26 #define VK_RIGHT 0x27 #define VK_DOWN 0x28 #define VK_SELECT 0x29 #define VK_PRINT 0x2A #define VK_EXECUTE 0x2B #define VK_SNAPSHOT 0x2C #define VK_INSERT 0x2D #define VK_DELETE 0x2E #define VK_HELP 0x2F #define VK_LWIN 0x5B #define VK_RWIN 0x5C #define VK_APPS 0x5D #define VK_NUMPAD0 0x60 #define VK_NUMPAD1 0x61 #define VK_NUMPAD2 0x62 #define VK_NUMPAD3 0x63 #define VK_NUMPAD4 0x64 #define VK_NUMPAD5 0x65 #define VK_NUMPAD6 0x66 #define VK_NUMPAD7 0x67 #define VK_NUMPAD8 0x68 #define VK_NUMPAD9 0x69 #define VK_MULTIPLY 0x6A #define VK_ADD 0x6B #define VK_SEPARATOR 0x6C #define VK_SUBTRACT 0x6D #define VK_DECIMAL 0x6E #define VK_DIVIDE 0x6F #define VK_F1 0x70 #define VK_F2 0x71 #define VK_F3 0x72 #define VK_F4 0x73 #define VK_F5 0x74 #define VK_F6 0x75 #define VK_F7 0x76 #define VK_F8 0x77 #define VK_F9 0x78 #define VK_F10 0x79 #define VK_F11 0x7A #define VK_F12 0x7B #define VK_F13 0x7C #define VK_F14 0x7D #define VK_F15 0x7E #define VK_F16 0x7F #define VK_F17 0x80 #define VK_F18 0x81 #define VK_F19 0x82 #define VK_F20 0x83 #define VK_F21 0x84 #define VK_F22 0x85 #define VK_F23 0x86 #define VK_F24 0x87 #define VK_NUMLOCK 0x90 #define VK_SCROLL 0x91 #define VK_LSHIFT 0xA0 #define VK_RSHIFT 0xA1 #define VK_LCONTROL 0xA2 #define VK_RCONTROL 0xA3 #define VK_LMENU 0xA4 #define VK_RMENU 0xA5 #define VK_PROCESSKEY 0xE5 #define VK_ATTN 0xF6 #define VK_CRSEL 0xF7 #define VK_EXSEL 0xF8 #define VK_EREOF 0xF9 #define VK_PLAY 0xFA #define VK_ZOOM 0xFB #define VK_NONAME 0xFC #define VK_PA1 0xFD #define VK_OEM_CLEAR 0xFE #define WM_KEYFIRST 0x0100 #define WM_KEYDOWN 0x0100 #define WM_KEYUP 0x0101 #define WM_CHAR 0x0102 #define WM_DEADCHAR 0x0103 #define WM_SYSKEYDOWN 0x0104 #define WM_SYSKEYUP 0x0105 #define WM_SYSCHAR 0x0106 #define WM_SYSDEADCHAR 0x0107 #define WM_KEYLAST 0x0108 #define WM_MOUSEFIRST 0x0200 #define WM_MOUSEMOVE 0x0200 #define WM_LBUTTONDOWN 0x0201 #define WM_LBUTTONUP 0x0202 #define WM_LBUTTONDBLCLK 0x0203 #define WM_RBUTTONDOWN 0x0204 #define WM_RBUTTONUP 0x0205 #define WM_RBUTTONDBLCLK 0x0206 #define WM_MBUTTONDOWN 0x0207 #define WM_MBUTTONUP 0x0208 #define WM_MBUTTONDBLCLK 0x0209 */ Quote
NK2000 Posted January 25, 2004 Posted January 25, 2004 one way to open is to start Visual Studio and at the menu Extras you find spy++ with spy++ you can get window handles for example and more important is that you get the windowclass if not then you have to find your window by the titlename of the window Quote
decrypt Posted January 25, 2004 Author Posted January 25, 2004 i can't find the windows extras in v.s... all i can find is external tools in the menu, and that doesn't even contain it... Quote
samsmithnz Posted January 26, 2004 Posted January 26, 2004 Try using the Start menu, find Visual Studio .NET, and theres a folder called Visual Studio .NET Tools Quote Thanks Sam http://www.samsmith.co.nz
*Experts* mutant Posted January 26, 2004 *Experts* Posted January 26, 2004 Decrypt, if you have VB.NET Standard, it does not come with Spy++. Quote
decrypt Posted January 26, 2004 Author Posted January 26, 2004 yeah that would explain a bit... Quote
NK2000 Posted January 26, 2004 Posted January 26, 2004 oh i am sorry didnt know that, but if you need any spy++ output data just tell me what to "spy out" and i will provide you with txt and jpg :) Quote
decrypt Posted January 26, 2004 Author Posted January 26, 2004 (edited) I found something called "Control Inspector" @ Control Inspector Do you think it's like spy++? Edit: ah ha i found something even better called WinSpy here Edit2: I see how your code works. Do you think that this is possible in vb.net? i think your code is in c#? Edited January 27, 2004 by decrypt Quote
NK2000 Posted January 27, 2004 Posted January 27, 2004 I see how your code works. Do you think that this is possible in vb.net? i think your code is in c#? it doesnt matter what in c# work it matter what in .net work and since we use same framework.... :D good luck, just look at DllImportAttribute i think it is the same keyword at vb.net it should be also in InteropServices namespace Quote
NK2000 Posted January 27, 2004 Posted January 27, 2004 this winspy tool looks in some aspects better than spy++ Quote
decrypt Posted January 27, 2004 Author Posted January 27, 2004 i found a c# complier... can you tell me how the code works? (comment it perhaps...) Quote
decrypt Posted February 29, 2004 Author Posted February 29, 2004 (edited) What part of the code tells the location of the textbox? Also what part defines the message? Edited February 29, 2004 by decrypt Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.