Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
2 registered members (Quad, AndrewAMD), 1,007 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
include windows headers / WinUser.h #457484
01/19/16 12:47
01/19/16 12:47
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Howdy,

I need to include WinUser.h to be able to use window's SendInput and other input functions. Problem is including WinUser.h only is not enough, cause WinUser.h requires other windows headers. Although I do have all the required header files I think (by simple downloadING the whole Windows SDK).
So what I am actually asking is it possible to include the Windows SDK as #include files in Gamestudio3d and if so how?

thanks for taking the time

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
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

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 Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Something like this? (I am doing something wrong):

Code:
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 Offline OP
Serious User
Reconnoiter  Offline 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
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Code:
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 Offline OP
Serious User
Reconnoiter  Offline 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:

Code:
#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: Reconnoiter] #457596
01/23/16 16:18
01/23/16 16:18
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
I doubt "SendInputU" is a valid fnction.
Try "SendInput" only (I guess its a typo)

Anyways, why dont you listen and just use keybd_event?
SendInput is just a wrapper which directly calls keybd_event, and you wont need any structs either..

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 Offline OP
Serious User
Reconnoiter  Offline 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.

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1