Need help on checkbox issue.

Pages: 12
hi there guy
i need help on creating a button to tick checkbox like a timer.
example is there is 3 checkbox. checkbox1, 2 and 3.
i check the 1st checkbox, after 30s checkbox1 uncheck and check 2nd checkbox.
then after 5s 2nd checkbox uncheck and check checkbox1 again.

i am using idc_check1, 2 and 3. thanks.
Show what you have so far and clearly state where you need help at/with.
actually i making a dll marco bot.

i got gui.cpp, gui.h, trainer.h, trainer.cpp, dllmain.h, dllmain.cpp

i only touching on trainer.cpp

there 3 checkbox. idc_check1 for movement left, idc_check2 for movement right, idc_check3 for attack.

--------------------------------------------------------------------------------------------------------------------------

VOID MovementL(__in BOOL bMovementLEnable)
{

if(bMovementLEnable)
keybd_event(VK_LEFT,0x25,0 , 0);

else
keybd_event(VK_LEFT,0x25,KEYEVENTF_KEYUP,0);
}

VOID MovementR(__in BOOL bMovementREnable)
{

if(bMovementREnable)
keybd_event(VK_RIGHT,0x27,0 , 0);

else
keybd_event(VK_RIGHT,0x27,KEYEVENTF_KEYUP,0);
}

VOID Attack(__in BOOL bAttackEnable)
{

if(bAttackEnable)
keybd_event(VK_LCONTROL,0xA2,0 , 0);

else
keybd_event(VK_LCONTROL,0xA2,KEYEVENTF_KEYUP,0);
}

-----------------------------------------------------------------------------------------------------------

this is the trainer.cpp file
FYI, keybd_event() is deprecated. You should be using SendInput().

What you show has nothing to do with the original question. Do you have any code written? It is also unclear to me now if the three checkboxes belong to a window that you created or not.
i am sorry, i am beginner to c++
the 3 checkbox below to dialog.

may i know what code you wish to see because there is 6 file.
gui.cpp, gui.h, trainer.h, trainer.cpp, dllmain.h, dllmain.cpp

---------------------------------------------------------------------------------------------

case WM_COMMAND: //This is where you run your control. The control will let you connect with the checkboxes.
switch(LOWORD(wParam))
{
case IDC_CHECK1:
checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK1);//check if the check box is checked.
MovementL(checked);//if checkbox checked, read and execute.
break;
case IDC_CHECK2:
checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK2);//check if the check box is checked.
MovementR(checked);//if checkbox checked, read and execute.
break;
case IDC_CHECK3:
checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK3);//check if the check box is checked.
Attack(checked);//if checkbox checked, read and execute.
break;
}
break;

-----------------------------------------------------------------------------------------------------------------------------------

this code is inside gui.cpp

between send input cannot work for left and right movement. only keybd event can.
Last edited on
Ok, cool. That code is relevant. Before I forget: This forum can automatically format C and C++ code if you surround your code with code tags:

[code]
1
2
3
4
5
6
7
8
#include <iostream>

using namespace std;

int main()
{
    //See how nice code tags are?  Always use them.
}

[/code]

For every check you need to start one timer and potentially kill another. Read about the SetTimer() function: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644906(v=vs.85).aspx . Just like checkboxes, you can identify the timer by its identifier. Whenever the timer triggers, the window receive a WM_TIMER message. Process WM_TIMER. If the timer identifier belongs to the identifier you have assign as the first timer, then kill the first timer, then select the other check box. In the code that you show (processing WM_COMMAND), I suppose that you start the timer whenever you check the checkbox, so this is where you put your calls to SetTimer().

In the processing of WM_TIMER, you perform whatever action you need to perform, plus you kill the timer so as to stop the action from re-ocurring, unless of course this is what you want. To kill a timer you use KillTimer().
Last edited on
so i put the SetTimer() inside the below code like this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
case WM_COMMAND: //This is where you run your control. The control will let you connect with the checkboxes.
 switch(LOWORD(wParam))
 {
 case IDC_CHECK1: 
 checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK1);//check if the check box is checked.
 MovementL(checked);//if checkbox checked, read and execute.
 SetTimer()
 KillTimer()
 break;
 case IDC_CHECK2: 
 checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK2);//check if the check box is checked.
 MovementR(checked);//if checkbox checked, read and execute.
 SetTimer()
 KillTimer()
 break; 
 case IDC_CHECK3: 
 checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK3);//check if the check box is checked.
 Attack(checked);//if checkbox checked, read and execute.
 SetTimer()
 KillTimer()
 break; 
 }
 break;


i am sorry if i do it wrongly, just start to learn c++ by reading all the forum.
Last edited on
1. The code piece I showed in my previous post is an EXAMPLE of how nice code looks inside code tags.
2. You continued to post code WITHOUT code tags.
3. You did not study the SetTimer() link I gave you in my previous post. SetTimer() and KillTimer() require arguments that you are not giving.
4. If you call SetTimer() and then immediately call KillTimer() you gain nothing. You call SetTimer() whenever the checkbox is checked, and KillTimer() whenever the checkbox is unchecked. You need some IF statements to accomplish this.
1&2. haha. i realise it after i see properly. thanks.

3&4. can u give me a example like what should i put inside the code below?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
case WM_COMMAND: //This is where you run your control. The control will let you connect with the checkboxes.
 switch(LOWORD(wParam))
 {
 case IDC_CHECK1: 
 checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK1);//check if the check box is checked.
 MovementL(checked);//if checkbox checked, read and execute.
 break;
 case IDC_CHECK2: 
 checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK2);//check if the check box is checked.
 MovementR(checked);//if checkbox checked, read and execute.
 break; 
 case IDC_CHECK3: 
 checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK3);//check if the check box is checked.
 Attack(checked);//if checkbox checked, read and execute.
 break; 
 }
 break;


this?

1
2
3
4
SetTimer(hwnd,             // handle to main window 
    IDT_TIMER1,            // timer identifier 
    10000,                 // 10-second interval 
    (TIMERPROC) NULL);     // no timer callback  


but what should i declare hwnd as? it say hwnd is undefine. or what header file should i add?
Last edited on
hwnd is usually the name of the parameter in the window procedure. You said you had a dialog, right? Well, that dialog has a dialog or window procedure similar to:

1
2
3
4
LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
...
}


I would have imagined that the case WM_COMMAND statement that you show was inside one of these window procedures.

Anyway, the hwnd in the call to SetTimer() would be the hwnd that represents your window or dialog. This same window will be the one receiving WM_TIMER messages through its window procedure.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
        case WM_COMMAND:
            switch (LOWORD (wParam))
            {
                case IDC_CHECK1:
                    checked = IsDlgButtonChecked(...);
                    if (checked) SetTimer(hwnd, IDT_TIMER1, 10000, NULL);
                    else KillTimer(hwnd, IDT_TIMER1);
                ...
            }
    }
}


That may work for you.
}
thanks you very much gentleman.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
INT_PTR CALLBACK DialogProc(__in HWND hwndDlg,__in UINT uMsg,__in WPARAM wParam,__in LPARAM lParam,__in HWND hwnd,__in UINT IDT_TIMER1)
{
	int checked;

	switch(uMsg)
	{
	case WM_INITDIALOG: //To initiate the dialog box

		return TRUE;

	case WM_COMMAND: //This is where you run your control. The control will let you connect your hacks with the checkboxes.
		switch(LOWORD(wParam))
		{
		        case IDC_CHECK1:      
			checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK1);//check if the check box is checked.
			if (checked) SetTimer(hwnd, IDT_TIMER1, 30000, NULL);
            else KillTimer(hwnd, IDT_TIMER1);
			break;


this set timer to check checkbox for 30s. after that it kill. how to check idc_check2 after idc_check1 is uncheck?
Check MSDN Online: http://msdn.microsoft.com/en-us/library/windows/desktop/bb775943(v=VS.85).aspx . It is all there. I would use the CheckDlgButton() function while processing the WM_TIMER message:

1
2
3
4
5
6
7
8
9
10
case WM_TIMER:
    switch (wParam)
    {
        case IDT_TIMER1:
            CheckDlgButton(hwnd, IDC_CHECK1, BST_UNCHECKED);
            //Do whatever else you want to do.
            break;
        ...
    }
...
it show error on IDT_TIMER1

expression must have a constant value. what does that mean?
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
INT_PTR CALLBACK DialogProc(__in HWND hwndDlg,__in UINT uMsg,__in WPARAM wParam,__in LPARAM lParam,__in HWND hwnd,__in UINT IDT_TIMER1,__in UINT IDT_TIMER2,__in UINT IDT_TIMER3,__in UINT IDT_TIMER4)
{
	int checked;

	switch(uMsg)
	{
	case WM_INITDIALOG: //To initiate the dialog box

		return TRUE;

	case WM_COMMAND: //This is where you run your control. The control will let you connect with the checkboxes.
		switch(LOWORD(wParam))
		{
		        case IDC_CHECK1:      
			checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK1);//check if the check box is checked.
			if (checked)
			{ 
				SetTimer(hwnd, IDT_TIMER2, 1000, NULL);
			    MovementL(checked);
			}
            else KillTimer(hwnd, IDT_TIMER2);
			break;
			    case IDC_CHECK2:      
			checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK2);//check if the check box is checked.
			if (checked)
			{ 
				SetTimer(hwnd, IDT_TIMER4, 1000, NULL);
			    MovementR(checked);//if checkbox checked, read and execute.
			}
			else KillTimer(hwnd, IDT_TIMER4);
			break; 
			    case IDC_CHECK3:      
			checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK3);//check if the check box is checked.
			if (checked)
			{ 
				SetTimer(hwnd, IDT_TIMER1, 30000, NULL);
			    Attack(checked);//if checkbox checked, read and execute.
			}
			else KillTimer(hwnd, IDT_TIMER1);
			break;  
			    case IDC_CHECK4:      
			checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK4);//check if the check box is checked.
			if (checked)
			{ 
				SetTimer(hwnd, IDT_TIMER3, 30000, NULL);
			    Attack(checked);//if checkbox checked, read and execute.
			}
			else KillTimer(hwnd, IDT_TIMER3);
			break;  
			}
		break;

	case WM_TIMER:
		switch (LOWORD(wParam))
    {
        case IDT_TIMER1:
            CheckDlgButton(hwnd, IDC_CHECK3, BST_UNCHECKED);
            CheckDlgButton(hwnd, IDC_CHECK1, BST_CHECKED);
            break;
		case IDT_TIMER2:
            CheckDlgButton(hwnd, IDC_CHECK1, BST_UNCHECKED);
            CheckDlgButton(hwnd, IDC_CHECK4, BST_CHECKED);
            break;
		case IDT_TIMER3:
            CheckDlgButton(hwnd, IDC_CHECK4, BST_UNCHECKED);
            CheckDlgButton(hwnd, IDC_CHECK2, BST_CHECKED);
            break;
		case IDT_TIMER4:
            CheckDlgButton(hwnd, IDC_CHECK2, BST_UNCHECKED);
            CheckDlgButton(hwnd, IDC_CHECK3, BST_CHECKED);
            break;
    }
    break;


this is my code. and i got error on expression must have a constant value. haha.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
INT_PTR CALLBACK DialogProc(__in HWND hwndDlg,HWND hwnd,UINT IDT_TIMER1,UINT IDT_TIMER2,UINT IDT_TIMER3,UINT IDT_TIMER4,__in UINT uMsg,__in WPARAM wParam,__in LPARAM lParam)

			    case IDC_CHECK4:      
			checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK4);//check if the check box is checked.
			if (checked)
			{ 
				SetTimer(hwnd, IDT_TIMER3, 30000, NULL);
			    Attack(checked);//if checkbox checked, read and execute.
			}
			else
			{
				KillTimer(hwnd, IDT_TIMER3);
				CheckDlgButton(hwnd, IDC_CHECK4, BST_UNCHECKED);
				CheckDlgButton(hwnd, IDC_CHECK1, BST_CHECKED);
			}
			break


i set it this way it cannot work also because

 
INT_PTR CALLBACK DialogProc(__in HWND hwndDlg,HWND hwnd,UINT IDT_TIMER1,UINT IDT_TIMER2,UINT IDT_TIMER3,UINT IDT_TIMER4,__in UINT uMsg,__in WPARAM wParam,__in LPARAM lParam) 


this got error
Last edited on
Why did you add all those parameters to the function signature???????? You never touch the function's signature.

You need to #define IDT_TIMER1, etc. and give them numeric values. Look up the definition of your IDC_CHECK1, for example.
my idc_check1 is #define 1001

so what should i put for #define IDT_TIMER1?
Since timers and controls are not in the same category, you can re-use the ID's. You could do:

#define IDT_TIMER1 IDC_CHECK1

Same goes for the other timer identifiers. and you delete all those parameters you added. I assume you used Visual Studio's resource editor to create the dialog box, so I recommend that you don't touch resource.h yourself. Do those #define's elsewhere.
thanks alot for helping me. i am appreciated.. now i got another question..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
case IDC_CHECK3:      
			checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK3);//check if the check box is checked.
			if (checked)
			{ 
				// i want to set a wm_keydown for Z key. what code should i put?
				SetTimer(hwnd, IDT_TIMER1, 30000, NULL);
			    
			}
            else
			{
				// i want to set a wm_keyup for Z key. what code should i put?
				KillTimer(hwnd, IDT_TIMER1);
			}
			break;


thanks you.
any help guy?
Pages: 12