| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
philips Capt

Registrado: 16 Nov 2005Mensajes: 154
|
Publicado: Mie 08 Jul, 2009 9:43 am Asunto: Hacer click en boton de aplicación externa |
|
|
Necesito arrancar una aplicación externa desde mi código en builder, hacer click en un botón de esta aplicación y por último cerrarla
He buscado en el foro, pero no he encontrado nada acerca de como hacer click en el botón.
Alguna idea por favor
Phil |
|
| Volver arriba |
|
 |
escafandra Master

Registrado: 29 Nov 2007Mensajes: 625Ubicación: Madrid - España
|
Publicado: Mie 08 Jul, 2009 11:53 pm Asunto: |
|
|
Para conseguir realizar un click de ratón deberás utilizar la API SendInput. Analiza este ejemplo:
| Código: | int MouseClick(int x, int y)
{
TPoint P;
GetCursorPos(&P);
SetCursorPos(x, y);
INPUT Input[2];
::ZeroMemory(Input, sizeof(Input));
Input[0].type = INPUT_MOUSE;
Input[0].mi.dx = x;
Input[0].mi.dy = y;
Input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
Input[1].type = INPUT_MOUSE;
Input[1].mi.dx = x;
Input[1].mi.dy = y;
Input[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
int a = SendInput(2, Input, sizeof(INPUT));
SetCursorPos(P.x, P.y);
return a;
}
|
Saludos. |
|
| Volver arriba |
|
 |
philips Capt

Registrado: 16 Nov 2005Mensajes: 154
|
Publicado: Mar 14 Jul, 2009 10:26 am Asunto: |
|
|
Muchas gracias escafandra por tu respuesta
Abusando un poco de tu amabilidad si me permites un último detalle ue tampoco he encontrado en los foros
Cuando abro una aplicación con winExec o ShellExecute, es posible definir la posición que ocupe en el escritorio de windows y fijarla ?
Me refiero a que no se mueva de esa posición
Gracias de nuevo
phil |
|
| Volver arriba |
|
 |
Angel Master


Registrado: 15 Abr 2003Mensajes: 2311Ubicación: Toledo (España)
|
Publicado: Mar 14 Jul, 2009 11:30 am Asunto: |
|
|
| philips escribió: | Cuando abro una aplicación con winExec o ShellExecute, es posible definir la posición que ocupe en el escritorio de windows y fijarla ?
Me refiero a que no se mueva de esa posición |
Con WinExec, no; con ShellExecute tienes un parámetro que te permite hasta cierto punto algo de esto; en la ayuda del comando cita:
| Cita: | ShellExecute( HWND hwnd, // handle to parent window
LPCTSTR lpOperation, // pointer to string that specifies operation to perform
LPCTSTR lpFile, // pointer to filename or folder name string
LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
LPCTSTR lpDirectory, // pointer to string that specifies default directory
INT nShowCmd // whether file is shown when opened
); |
Y para este último:
| Cita: | SW_HIDE Hides the window and activates another window.
SW_MAXIMIZE Maximizes the specified window.
SW_MINIMIZE Minimizes the specified window and activates the next top-level window in the Z order.
SW_RESTORE Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window.
SW_SHOW Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. An application should call ShowWindow with this flag to set the initial show state of its main window.
SW_SHOWMAXIMIZED Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE Displays the window as a minimized window. The active window remains active.
SW_SHOWNA Displays the window in its current state. The active window remains active.
SW_SHOWNOACTIVATE Displays a window in its most recent size and position. The active window remains active.
SW_SHOWNORMAL Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time. |
_________________ Un saludo
Necesitamos tu ayuda: Envía AI al 27595 (Coste 1,20 euros + IVA) |
|
| Volver arriba |
|
 |
escafandra Master

Registrado: 29 Nov 2007Mensajes: 625Ubicación: Madrid - España
|
Publicado: Mar 14 Jul, 2009 10:05 pm Asunto: |
|
|
Angel te da la solución para colocar tu aplicación en la pantalla, pero nada impide a un usuario modificara después.
Sin embargo puedes localizar la posición de tu aplicación. Para ello debes encontrar el Handle de la ventana principal y luego encontrar su posición en la pantalla. tienes varias APIs que te servirán: FindWindow, GetWindowRect, WindowFromPoint
También puedes relocalizar tu aplicación con SetWindowPos
Tras tener localizada la ventana haces tu click calculando la posición donde pulsarás tu botón.
Saludos. |
|
| Volver arriba |
|
 |
|