Using a control for SendInput on a custom form ? (will pay)

Ok this is so beyond frustrating that I will even be willing to pay someone to help me via skype....

I am using visual studio c++, I know this is a custom button and not a Windows button so probably cant just use the standard API to "click" it , but surely there has to be something very similar or a workaround for it?

I have a form , parent form I want to be able to sendinput to a button on that that form. However spy++ shows it has no control ID but it grabs the caption. I tried Enumchildproc which came back with nothing so I really am lost , this button being pressed without the mouse / keyboard being affected is absoloutley key to my program, so this is urgent. As I said before willing to pay if I really have too :\, included spy ++ screenshot and a screenshot of the control.

spy++:
http://img5.imageshack.us/img5/8217/registerbuttonj.jpg

control:
http://img90.imageshack.us/img90/6322/registere.jpg

ANY suggestions are more than welcome ,

Ben.
Last edited on
Up, still need this one. Badly!
This is a Win32 project?

What do you mean by its being a 'custom button'?

Atm I am just running it in console but the form itself is custom and the button itself is a "pokerstars button class" instead of being a "windows button" which can easily be controlled by API , I am in a little over my head with this one which is why I am willing to pay for help if it is required. I need the button pressed as if it was a "windows button" being pressed by the API.

Hope that makes sense?

Ben.
Doesn't make much sense to me, unfortunately. I'd help for free if I was sure of what you are doing, and what you need to know is something I indeed know myself. If all you need to know is how to send a button a message to simulate a click, look up the BM_CLICK message, and the BN_CLICKED message.

I really don't know what a 'pokerstars' button is. And I'm not entirely sure if you are doing console mode programming or GUI programming. Its also possible to be doing GUI programming, but have a console window too.
Here is your example Ben ...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//Main.h
#ifndef Main_h
#define Main_h

#define  IDC_BUTTON1          1500
#define  IDC_BUTTON2          1505

#define dim(x) (sizeof(x) / sizeof(x[0]))

struct WndEventArgs
{
 HWND                         hWnd;
 WPARAM                       wParam;
 LPARAM                       lParam;
 HINSTANCE                    hIns;
};

long fnWndProc_OnCreate       (WndEventArgs& Wea);
long fnWndProc_OnCommand      (WndEventArgs& Wea);
long fnWndProc_OnDestroy      (WndEventArgs& Wea);

struct EVENTHANDLER
{
 unsigned int                 iMsg;
 long                         (*fnPtr)(WndEventArgs&);
};

const EVENTHANDLER EventHandler[]=
{
 {WM_CREATE,                  fnWndProc_OnCreate},
 {WM_COMMAND,                 fnWndProc_OnCommand},
 {WM_DESTROY,                 fnWndProc_OnDestroy}
};
#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//Main.cpp
#include <windows.h>
#include <tchar.h>
#include "Main.h"


long fnWndProc_OnCreate(WndEventArgs& Wea)
{
 HWND hCtl;

 Wea.hIns=((LPCREATESTRUCT)Wea.lParam)->hInstance;
 hCtl=CreateWindow(_T("button"),_T("Button #1"),WS_CHILD | WS_VISIBLE,75,60,150,30,Wea.hWnd,(HMENU)IDC_BUTTON1,Wea.hIns,0);
 hCtl=CreateWindow(_T("button"),_T("Button #2"),WS_CHILD | WS_VISIBLE,75,110,150,30,Wea.hWnd,(HMENU)IDC_BUTTON2,Wea.hIns,0);

 return 0;
}


long fnWndProc_OnCommand(WndEventArgs& Wea)
{
 switch(LOWORD(Wea.wParam))
 {
    case IDC_BUTTON1:
         //MessageBox(Wea.hWnd,_T("You Thought About It Then Chose And Clicked Button #1!"),_T("Received WM_COMMAND Message!"),MB_OK);
         SendMessage(GetDlgItem(Wea.hWnd,IDC_BUTTON2),BM_CLICK,0,0);
         break;
    case IDC_BUTTON2:
         MessageBox(Wea.hWnd,_T("You Thought About It Then Chose And Clicked Button #2!"),_T("Received WM_COMMAND Message!"),MB_OK);
         break;
 }

 return 0;
}


long fnWndProc_OnDestroy(WndEventArgs& Wea)
{
 PostQuitMessage(0);
 return 0;
}



LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
 WndEventArgs Wea;

 for(unsigned int i=0; i<dim(EventHandler); i++)
 {
     if(EventHandler[i].iMsg==msg)
     {
        Wea.hWnd=hwnd, Wea.lParam=lParam, Wea.wParam=wParam;
        return (*EventHandler[i].fnPtr)(Wea);
     }
 }

 return (DefWindowProc(hwnd, msg, wParam, lParam));
}


int WINAPI WinMain(HINSTANCE hIns, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
 TCHAR szClassName[]=_T("Send Click");
 WNDCLASSEX wc;
 MSG messages;
 HWND hWnd;

 wc.lpszClassName=szClassName;                wc.lpfnWndProc=fnWndProc;
 wc.cbSize=sizeof (WNDCLASSEX);               wc.style=CS_DBLCLKS;
 wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);     wc.hInstance=hIns;
 wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION);  wc.hCursor=LoadCursor(NULL,IDC_ARROW);
 wc.hbrBackground=(HBRUSH)COLOR_BTNSHADOW;    wc.cbWndExtra=0;
 wc.lpszMenuName=NULL;                        wc.cbClsExtra=0;
 RegisterClassEx(&wc);
 hWnd=CreateWindowEx(0,szClassName,szClassName,WS_OVERLAPPEDWINDOW,75,75,320,305,HWND_DESKTOP,0,hIns,0);
 ShowWindow(hWnd,iShow);
 while(GetMessage(&messages,NULL,0,0))
 {
    TranslateMessage(&messages);
    DispatchMessage(&messages);
 }

 return messages.wParam;
}
Topic archived. No new replies allowed.