Usuário com melhor resposta
Interagindo software

Pergunta
-
Olá,
como fasso um programa interage com outro tipo ja vi o negocio de macro que grava o q o mouse fez e teclado e repete mas nao quero isso tipo tem um software que tem um login eu quero automatizar isso tipo um programa que escreve a senha e login sozinho para min isso quer dizer que gravar passos nao adianta pq a caixa de login pode esta em qualquer posição da tela o jeito e identificar o textbox e escrever mas como faz isso se nao qual outra ideia aceito sugestoes o software e vai ser feito em c# e nao tenho api para o programa que tem login existe algum modo de olhar na memoria sei la que identifica o textbox de login e de senha assembly sei la
att,nt10k
Respostas
-
Olá nt10k segue um exemplo de como fazer um programa que interage com a calculadora. Neste exemplo o aplicativo procura pela calculadora aberta e envia alguns comandos para ela, tente adaptar para sua necessidade.
[]s,
Elton
using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;
namespace SimulateKeyPress
{
class Form1 : Form
{
private Button button1 = new Button();
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
public Form1()
{
button1.Location = new Point(10, 10);
button1.TabIndex = 0;
button1.Text = "Click to automate Calculator";
button1.AutoSize = true;
button1.Click += new EventHandler(button1_Click);
this.Controls.Add(button1);
}
// Get a handle to an application window.
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
// Activate an application window.
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
// Send a series of key presses to the Calculator application.
private void button1_Click(object sender, EventArgs e)
{
// Get a handle to the Calculator application. The window class
// and window name were obtained using the Spy++ tool.
IntPtr calculatorHandle = FindWindow("SciCalc", "Calculadora");
// Verify that Calculator is a running process.
if (calculatorHandle == IntPtr.Zero)
{
MessageBox.Show("Calculator is not running.");
return;
}
// Make Calculator the foreground application and send it
// a set of calculations.
SetForegroundWindow(calculatorHandle);
SendKeys.SendWait("111");
SendKeys.SendWait("*");
SendKeys.SendWait("11");
SendKeys.SendWait("=");
SendKeys.Send("{ENTER}");
}
}
}
Todas as Respostas
-
Olá nt10k segue um exemplo de como fazer um programa que interage com a calculadora. Neste exemplo o aplicativo procura pela calculadora aberta e envia alguns comandos para ela, tente adaptar para sua necessidade.
[]s,
Elton
using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;
namespace SimulateKeyPress
{
class Form1 : Form
{
private Button button1 = new Button();
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
public Form1()
{
button1.Location = new Point(10, 10);
button1.TabIndex = 0;
button1.Text = "Click to automate Calculator";
button1.AutoSize = true;
button1.Click += new EventHandler(button1_Click);
this.Controls.Add(button1);
}
// Get a handle to an application window.
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
// Activate an application window.
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
// Send a series of key presses to the Calculator application.
private void button1_Click(object sender, EventArgs e)
{
// Get a handle to the Calculator application. The window class
// and window name were obtained using the Spy++ tool.
IntPtr calculatorHandle = FindWindow("SciCalc", "Calculadora");
// Verify that Calculator is a running process.
if (calculatorHandle == IntPtr.Zero)
{
MessageBox.Show("Calculator is not running.");
return;
}
// Make Calculator the foreground application and send it
// a set of calculations.
SetForegroundWindow(calculatorHandle);
SendKeys.SendWait("111");
SendKeys.SendWait("*");
SendKeys.SendWait("11");
SendKeys.SendWait("=");
SendKeys.Send("{ENTER}");
}
}
} -