|
2 registered members (Quad, AndrewAMD),
1,007
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: include windows headers / WinUser.h
[Re: Reconnoiter]
#457485
01/19/16 12:52
01/19/16 12:52
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
You dont need the windows headers. Just declare a typedef / prototype somewhere and call GetModuleHandle/GetProcAddress to get the address, then simply call it. Nearly 99% of the structs are just void* pointers aka 4 bytes so you dont need the structs either.
Last edited by Ch40zzC0d3r; 01/19/16 12:52.
|
|
|
Re: include windows headers / WinUser.h
[Re: Ch40zzC0d3r]
#457487
01/19/16 13:42
01/19/16 13:42
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Something like this? (I am doing something wrong):
void* INPUT();
...
function main()
{
...
// GetProcAddress(WinUser.h, INPUT); // compiler gives error
GetModuleHandle(INPUT); // works?
INPUT ip; // compiler gives error here
...
}
Last edited by Reconnoiter; 01/19/16 13:42.
|
|
|
Re: include windows headers / WinUser.h
[Re: Reconnoiter]
#457488
01/19/16 14:43
01/19/16 14:43
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Do I need to do something like this Ch40zzC0d3r?:
INPUT = GetModuleHandle(???);
Last edited by Reconnoiter; 01/19/16 14:44.
|
|
|
Re: include windows headers / WinUser.h
[Re: Reconnoiter]
#457492
01/19/16 16:43
01/19/16 16:43
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
int __stdcall MessageBox(int hWnd, char *lpText, char *lpCaption, int uType);
MessageBox = GetProcAddress(LoadLibrary("User32.dll"), "MessageBoxA");
MessageBox(0, "cool", "A messagebox", 0);
Also use keybd_event, your function is just a wrapper. Anyways, if you need a struxt or something then just go to msdn and copy and paste it to your project.
Last edited by Ch40zzC0d3r; 01/19/16 16:44.
|
|
|
Re: include windows headers / WinUser.h
[Re: Ch40zzC0d3r]
#457594
01/23/16 16:05
01/23/16 16:05
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Okay I think I am almost there with your help Ch40zzC0d3r, I still get a crash though when running the code cause of SENDINPUT. Maybe cause I actually need to use 1 struct for INPUT ( https://msdn.microsoft.com/en-us/library/windows/desktop/ms646270%28v=vs.85%29.aspx ) and 1 sub struct for the keyboard input parameters/variables? ( https://msdn.microsoft.com/en-us/library/windows/desktop/ms646271%28v=vs.85%29.aspx ) I now have this:
#include <acknex.h>
#include <windows.h>
#include <stdio.h>
#include <default.c>
#define _INPUT_MOUSE 0
#define _INPUT_KEYBOARD 1
#define _INPUT_HARDWARE 2
typedef struct {
int type;
int wVk;
int wScan;
int dwFlags;
int time;
long dwExtraInfo;
} INPUT_STRUCT;
INPUT_STRUCT input;
function main()
{
...
//set up SENDINPUT function
int __stdcall SENDINPUT(int nInputs, int* pInputs, int cbSize);
SENDINPUT = GetProcAddress(LoadLibrary("User32.dll"), "SendInputU");
//set up input
input.type = _INPUT_KEYBOARD;
input.wScan = 0; // hardware scan code for key
input.time = 0;
input.dwExtraInfo = 0;
wait(-3); //time to switch to notepad
//Press A
input.wVk = 0x41; // virtual-key code for the "a" key
input.dwFlags = 0; // 0 for key press
SENDINPUT(1, &input, sizeof(INPUT_STRUCT));
// Release A
input.dwFlags = 0x0002; // KEYEVENTF_KEYUP for key release
SENDINPUT(1, &input, sizeof(INPUT_STRUCT));
}
Last edited by Reconnoiter; 01/23/16 16:10.
|
|
|
Re: include windows headers / WinUser.h
[Re: Ch40zzC0d3r]
#457608
01/24/16 12:26
01/24/16 12:26
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
That's cause I thought keybd_event didn't work when trying to influence other programs, but it seems it does work but it is just a bit tricky to get it to work for an touch-overlay program, cause I forgot to put a wait before putting the main/other program/game on the foreground. And than after to other program is on the foreground you need to call the keybd_event (the latter is quite obvious for me but the wait wasn't).
Anyway ty for your help.
Last edited by Reconnoiter; 01/24/16 12:26.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|