|
I have succeeded in getting my code to successfully do mouse clicks on a commercial program, running at a specific screen location, using this code:
SetForegroundWindow(targetWindowHandle);
input.type = INPUT_MOUSE;
input.mi.dx = 900;
input.mi.dy = 50;
input.mi.mouseData = 0;
input.mi.time = 0;
input.mi.dwFlags = 0;
input.mi.dwExtraInfo = 0;
SetCursorPos(input.mi.dx, input.mi.dy);
input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE+MOUSEEVENTF_LEFTDOWN);
resSendInput = SendInput(1, ref input, Marshal.SizeOf(input));
input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTUP);
resSendInput = SendInput(1, ref input, Marshal.SizeOf(input));
The problem is, of course, if the window is moved, the clicks miss. I would love to be able to do the clicks relative to position 0,0 of the window pointed at by targetWindowHandle instead of relative to position 0,0 of the screen.
(I hope that statement makes sense to you guys.)
Any suggestions?
Thanks.
-- modified at 20:11 Wednesday 22nd February, 2006
|
|
|
|
|
for those interested ...
The solution was rather trivial after i found "GetWindowRect" in User32:
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32.dll")]
public static extern int GetWindowRect(int hwnd, ref RECT rc);
// Get the target window's screen coordinates
RECT rect = new RECT();
int hwnd = GetWindowRect((int)targetWindowHandle, ref rect);
Persistence pays ...
---
-- modified at 15:34 Thursday 23rd February, 2006
|
|
|
|
|
I need to make a calcualtor (must be able to add, subtract, divide, and multiply). Two text boxes allow you to enter numbers which in turn does the math and prints to a seperate
|
|
|
|
|
Homework question?
jessica gelina wrote: and prints to a seperate
Missing end of sentence, the adjective should be followed by a noun.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
|
jessica gelina wrote: the only reference we got was that it is similar to the C++ method
Which is what?
You've got to be more specific about what your problem is in order for us to help. For example, I commented that in your first post the sentence ended midstream. So we can only guess or assume what you want.
You have two text boxes.
I'm assuming you have a bunch of buttons. +, -, /, *
I'm assuming you have a textbox or label for the result.
What part isn't working? What have you tried already?
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
i have two text boxes, and four buttons. Each text box allows for numbers, the buttons are teh math function. They then print the answer onclick to a seperate label.
I have tries adding the strings which simply put the two numbers in the box next to one another. I have tries sending the text.tostring function to the label.......
|
|
|
|
|
You need to convert it to an int before you can add them. Use this method:
<br />
int x = Convert.ToInt32(
int y = Convert.ToInt32(
<br />
Wacky waving inflateable arm flailing tube man!
- Family Guy
|
|
|
|
|
int x;
int y;
private void btnAdd_Click(object sender, System.EventArgs e)
{
int x = Convert.ToInt32.txtFirstNum;
int y = Convert.ToInt32.txtSecondNum;
x + y;
}
It doesn't recoginze the ToInt32! Is this supposed to be my answer label name?
|
|
|
|
|
jessica gelina wrote: int x = Convert.ToInt32.txtFirstNum;
int y = Convert.ToInt32.txtSecondNum;
Can't you at least copy/paste correctly????
Regards,
Nish
|
|
|
|
|
|
In addition to my previous post.
jessica gelina wrote: x + y;
Needs to assign the result to something in order for you to use it. e.g.
int result = x + y; Then you can take the result and assign it to the Text property of your Label . (Remember to convert it to a string when you do that)
Does this help?
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
He is referring to the fact that you coded:
Convert.ToInt32.txtFirstNum; When the example clearly used brackets and specified you needed to pass in a string .
Convert.ToInt32(txtFirstNum.Text);
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Just need to make a few changes:
<br />
private void btnAdd_Click(object sender, System.EventArgs e)<br />
{<br />
int x = Convert.ToInt32(txtFirstNum.Text);<br />
int y = Convert.ToInt32(txtSecondNum.Text);<br />
x + y;<br />
}
That should fix it
Wacky waving inflateable arm flailing tube man!
- Family Guy
|
|
|
|
|
Sean89 wrote: int x;
int y;
What's this bit for ? ( outside the click event handler )
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ohh lol oops.
private void btnAdd_Click(object sender, System.EventArgs e)<br />
{<br />
<br />
int x = Convert.ToInt32(txtFirstNum.Text);<br />
int y = Convert.ToInt32(txtSecondNum.Text);<br />
x + y;<br />
<br />
}
Sorry bout that.
Wacky waving inflateable arm flailing tube man!
- Family Guy
|
|
|
|
|
|
Sounds just like project 5 in the Basic Programming course at St Louis Community college.
Good luck.
|
|
|
|
|
Somebody has to start somewhere.
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hi all,
does anyone have any idea about using the microsoft speech api in a c# application. I've got the basics down but there's limited to no documentation available. MSDN only seem to documentation, examples, etc for C++. The problem is that some of the classes etc are either not available or different in some way that those available in c#.
I'm particularly interested in changing voices, pitch, rate, volume, etc.
Thanks
Rich
|
|
|
|
|
Does anyone know anything about Microsoft's plans for Source Safe? Have they just lost interest in providing version configuration management packages? Someonce mentioned 2007 to me?
I am currently using the old Visual Studio Source Safe. Does anybody know of any plugins or anyway to improve the differ?
Cheers
AJ
|
|
|
|
|
SourceSafe 2007 was released with the latest version of Visual Studio. It has some minor enhancements and fixes and is still adequate for a very small organization. It is supposed to have a remote, non-file system based, access ability, but I never got around to testing it.
MS also has what they call Team System, which is a full blown configuration management and bug tracking system. We evaluated it and found that it was very expensive, difficult to set up and extremely complicated to customize. (Besides, it's a 1.0 release and Microsoft, especially, is known for not getting it right until version 3.0.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
How come in my data grid for a date field all i see is the date, yet in the fields that are bound the the data also, for the date i see 12:00am. My date field is set to a smalldatetime, how do I get the time out of the bound date field?
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
I've implemented a word template into my purchase order app. When I open the template passing the merge info, everyhting works fine. However when I exit my app and I open task manager winword is still open even though I doing a close on the app and calling the garbage collector.
Is there something else that I need to do to close word correctly? Do I need to make the class that is handling opening word a member of IDisposable?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Did you call Close on the Word Application object? Or did you call Quit on it before you disposed it?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|