1
Answer

Need help with SendMessage / PostMessage

Paul

Paul

14y
12.6k
1
Need help or a really good tutorial on using PostMessage / SendMessage
I'm using VS2k10 c#
Here is what I am trying to do.

Have a program that you have to press a refresh button, it doesn't have a hotkey so I can't send F5 key to the window so I need to send WM_LBUTTONDOWN and WM_LBUTTONUP on a button. This will be for other people on other machines as well not just mine.
Also as you can see below one of the window text changes with user login creds. idk if this matters or not. Also the window may not always have focus so I need it to issue the click without it being in focus. (Example. split windows or dual monitors, app may not have main focus but it is still viewable)

Now I know I need to grab info from spy++ (*I think anyhow lol*) so here is the run down of the location of the button I want pressed.


 Windows 0008024C "Clientele" Afx:400000:8:10011:0:62044b
- Window 000C027C "" MDIClient
-- Window 000901FC "Main Search Form MY APP LOGIN CREDS SHOW HERE" Afx:400000:b:10011:6:83f02ed
--- Window 000C027C "" AfxFrameOrView42
---- Window 0008028A "Refresh" Button


Here is what I attempted to do before but I know its wrong.

 IntPtr hwnd = FindWindow(null, "Clientele");
IntPtr refresh = FindWindowEx(hwnd, IntPtr.Zero, "Button", "Refresh");
SendMessage(refresh, (int)WMessages.WM_LBUTTONDOWN, 0, 0);
SendMessage(refresh, (int)WMessages.WM_LBUTTONUP, 0, 0);

again no idea if this is correct or if I am in the ball park of this being correct.

Thanks in advance.
Answers (1)
1
rajendra singh
NA 382 423 8y
select empid,
(select min(attandancedate) from tbl_test where empid=a1.empid and (cast(attandancedate as time) between '08:00:00' and '09:59:59')) as intime,
(select max(attandancedate) from tbl_test where empid=a1.empid and (cast(attandancedate as time) >= '17:00:00')) as outtime
from tbl_test a1 group by a1.empid
 
 
But This Query Gives Null For Emp1 As Outtime Because He Does Not Punched After 5 PM
 
For Ideal Case We Can Remove Time from second query because we can get last punch of any employee using max, that can be use as outtime
 
Please Tell If This Is Usefull. 
 
 
 
Accepted
0
Technetshadow
NA 147 5.7k 8y
select empid, min(attendencedate) as inTime, max(attendencedate) as outTime
from temp
group by empid;