Change the value of a textbox/label/etc from another program with Visual Basic...

I have a program with some controls on it.
I want to make another program that can change the values of a text box, for example in the first one. They will be two exe's.

can this be done via windows api functions?

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

drnickConnect With a Mentor Commented:
i think so.
you need to these steps:

get in your "changer" app a handle to the editbox/lable (which both will be windows)
and then send the new text via SendMessage/PostMessage with WM_SETTEXT.

to get the handle can be messy, got to use stuff like FindWindow or GetForeGroundWindow or EnumWindows,

it could also be that you need to transfere your string into the other processes address space,
if so, you'll need VirtualAllocEx and WriteProcessMemory, however, i'm not sure of that.

to sum up, what you want to do is complicated, unsecure and version-compatibility-horror.
maybe try to work around this problem,
the use of normal IPC, shared memory or DDE or such will be safest.

hope i could helf anyway,
why is there a need to transfer his string into the other process space?
I thought WM_SETTEXT will take care of that?

it would help if there is certain prominent characteristic for you to identify
the textbox you want.
wladq66Author Commented:
is it easier to just simulate clicking somewhere? [that would be alot of help].. to select a menu and click file->others->input [just as an examples].. then use wm_settext to set the text in the window it appears.
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

to wm_settext, you need the handle of the window, so you still have to do it like what drnick says
wladq66Author Commented:
but if i need a button [normal one, not menu] and then click on the menu that apperas? or what about simulating clicking clicking on file->etc ?then what? could u help? i will increase thhe points
in that case it will maybe easier to simulate keystrokes with the
i assume that you can control the program by keyboard-commands,
like the most common programs.
All Courses

From novice to tech pro — start learning today.