Creating a wrapper for interception.dll (fixed and working!) Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Noesis
Posts: 208
Joined: 26 Apr 2014, 07:57

Re: Creating a wrapper for interception.dll (fixed and working!)

09 Jul 2017, 09:28

Ok, so I'm going to go ahead and assume these values are correct and are in fact absolute values, they just aren't pixel coordinates (which can happen), just means we can't simply send the coordinates the easy way via ahk using mouse move (which may not have worked anyway). So just to confirm, the actual process of that should be happening is trigger pressed, gun fires at that position, and can't fire again until that guns trigger is released, then pressed again. And you want it so that each gun only fires at it's own position. Is that about right ? - not sure at the moment how to do it exactly I'll get back to you, one gun would be easy but two makes it a bit more difficult as there will need to be a kind of queue since effectively only one shot can fire at a time due to the guns interfering with each other.
phasermaniac
Posts: 55
Joined: 09 Apr 2017, 14:05

Re: Creating a wrapper for interception.dll (fixed and working!)

09 Jul 2017, 14:46

the actual process of that should be happening is trigger pressed, gun fires at that position,


yes thats it, I want to block cursor movement but on gun trigger send %flasher%, %triggerdelay%, send cursor on that gun position and %trigger down%, %triggerlength%, %trigger up%.

Note that theorically the cursor should be unblocked after %flasher%, %triggerdelay% otherwise the gun doesn't track well on dark colors.

and can't fire again until that guns trigger is released, then pressed again

until trigger is released ( automatically, after %triggerlenght%), I think it can't be any other shot because %triggerlenght% is necessary to register the shot. I suppose the ideal way may be pospose that one until the first ends.
Noesis
Posts: 208
Joined: 26 Apr 2014, 07:57

Re: Creating a wrapper for interception.dll (fixed and working!)

10 Jul 2017, 01:35

So while the trigger is down, the gun is meant to continuously fire (i.e. it's akin to an automatic weapon not a semi-automatic weapon in real life) - meaning triggerlength is kind of like a shot delay (i.e. time taken for bullet to fire/re-fire, after the trigger is pressed or last shot was fired). Please confirm if this is the case.

FYI, If this is the case, it complicates things further as I'm not sure exactly how we are going to keep the two guns independent of each other with regard to where the shot is fired, i.e. you mentioned previously that gun 2's position could be used when gun 1's trigger was pressed and vice versa. There is also another issue in that if both guns have their triggers pressed, using AHK hotkeys in the second script the way it currently is will mean the last trigger pressed can block the script from acting on the release of the first trigger, until the last trigger is also released (to do with how ahk is single threaded), so that will need changing too.
phasermaniac
Posts: 55
Joined: 09 Apr 2017, 14:05

Re: Creating a wrapper for interception.dll (fixed and working!)

10 Jul 2017, 07:31

So while the trigger is down, the gun is meant to continuously fire


No, only one shot for trigger press

. you mentioned previously that gun 2's position could be used when gun 1's trigger was pressed and vice versa

May be missunderstanding, each gun shot must correspond with its coords
Noesis
Posts: 208
Joined: 26 Apr 2014, 07:57

Re: Creating a wrapper for interception.dll (fixed and working!)

11 Jul 2017, 07:58

phasermaniac wrote:
. you mentioned previously that gun 2's position could be used when gun 1's trigger was pressed and vice versa

May be missunderstanding, each gun shot must correspond with its coords


What I meant by this is it's an issue that gun 2's position could be used when gun 1's trigger was pressed (or the other way around, or in other words a current issue is the gun positions conflict with each other), I didn't mean you want it like this.

Something else I forgot to ask with regard to this, how does the mouse affect this (if at all) ? eg if you don't point either of the guns at the screen, and fire one of them, does the "bullet" fire at the mouses position a) when it isn't moved at the same time, and, if not, b) if you move the mouse while pressing a guns trigger ?

Anyway the good news is I did some tests and it's possible to send the mouse via interception from another script which isn't also reading/blocking inputs so it shouldn't matter that we don't know how to convert the unit's being reported by mouse.x and mouse.y into pixel coordinates. Anyway got a fairly good Idea how to achieve it now (especially since it's one shot per gun).
Helgef
Posts: 2404
Joined: 17 Jul 2016, 01:02
Contact:

Re: Creating a wrapper for interception.dll (fixed and working!)

11 Jul 2017, 13:54

Hello. I have only read fragments of this thread, so please ignore / forgive me if I'm irrelevant.
Regarding coordinates at ~(60000,60000), maybe this is the same thing that SendInput() does, SendInput it takes its coordinates over (0,0)x(65535,65535), to map screen coordinates to this field, you can do

Code: [Select all] [Download] GeSHi © Codebox Plus

mapFromScreen(x,y){
static w:=((1<<16)-1)/A_ScreenWidth
static h:=((1<<16)-1)/A_ScreenHeight
return {dx:round(x*w),dy:round(y*h)}
}

and the other way

Code: [Select all] [Download] GeSHi © Codebox Plus

mapToScreen(dx,dy){
static w:=((1<<16)-1)/A_ScreenWidth
static h:=((1<<16)-1)/A_ScreenHeight
return {x:round(dx/w), y:round(dy/h)}
}

Cheers.
Noesis
Posts: 208
Joined: 26 Apr 2014, 07:57

Re: Creating a wrapper for interception.dll (fixed and working!)

12 Jul 2017, 05:26

Thanks for that Helgef, figured there would be some kind of proportion to it but had no idea what. It may not actually be needed for this particular implementation, but still good to actually know what's likely going on :), thanks again.
phasermaniac
Posts: 55
Joined: 09 Apr 2017, 14:05

Re: Creating a wrapper for interception.dll (fixed and working!)

13 Jul 2017, 14:03

Sorry for the delay,
if you don't point either of the guns at the screen, and fire one of them, does the "bullet" fire at the mouses position a) when it isn't moved at the same time, and, if not, b) if you move the mouse while pressing a guns trigger ?

If I shoot pointning offscreen with both guns, they shoot at mmouse position
Noesis
Posts: 208
Joined: 26 Apr 2014, 07:57

Re: Creating a wrapper for interception.dll (fixed and working!)

14 Jul 2017, 08:24

Cool, that's what I suspected (and kind of hoped), means the position won't have to be spammed and should only need to be reported once prior to the shot. I'll get back to you with a script that should hopefully work as I don't have time to put one together at the moment.
angpogibow
Posts: 2
Joined: 16 Jul 2017, 04:07

Re: Creating a wrapper for interception.dll (fixed and working!)

16 Jul 2017, 04:16

From example as guide
https://github.com/oblitum/Interception ... ointer.cpp

I'm trying to send custom mouse click in specific screen coordinate. I was able to make it work partially but I'm getting stuck in sending correctly. Sometimes mouse just move anywhere then freeze. :lol:
Can anyone give me a hint or small example in correctly sending click on a specified screen coordinates?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Noesis
Posts: 208
Joined: 26 Apr 2014, 07:57

Re: Creating a wrapper for interception.dll (fixed and working!)

16 Jul 2017, 06:37

angpogibow, There is an important line in the example, which you left out of your code, mice use relative coordinates by default. The line you left out would be this:

mstroke.flags = INTERCEPTION_MOUSE_MOVE_ABSOLUTE;

At least that what I suspect based on a quick look, haven't tested it and don't really plan to, as it's not exactly AHK code you're using here.
Noesis
Posts: 208
Joined: 26 Apr 2014, 07:57

Re: Creating a wrapper for interception.dll (fixed and working!)

16 Jul 2017, 08:01

Hi phasermaniac, I've got some code for you to try. Firstly, I've created a more library like wrapper for Interception, which you'll need to use, it's like the one I posted earlier and is similar to the original one by ToonyTom but there is some basic stuff changed so key & mouse objects can be created easier and I've also added in access to another function which can set the precedence of devices within a context, which is part of interception.dll but wasn't included in the original wrapper. You'll need this for the scripts to work properly together and not fight with each other, since interception will be used to do the position reporting for the guns, but only when the button is pressed.

You'll need the following code and call the saved file "Interception.ahk". Either put it in a library folder (as per ahk's instructions to do so) or change how the other scripts include it for their use. You'll also need to set this up a bit for your machine. I've put comments in the code for what needs to be done, and all the changes you'll need to make are near the top of the script. There are 3 of them, they're essentially making sure it can access the actual interception.dll file on your machine and that the hardware strings match your hardware (instead of the ones already there which won't be correct for your machine).

Interception.ahk

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Next, This is the script you'll need to run, it's an autohotkey style script and you can call it whatever you want, I've been using LightGun.ahk. Make sure you also have the script after this one before you run it, as it will try to run that one when you start this one. Also, If you don't like the name I gave the script after this one, You'll need to change the name in this script located in the Intercept object next to the CaptureScriptName field to match.

LightGun.ahk

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



And the final script, is the intercept portion. I've hidden the icon of this script as a right click on it will cause inputs to not be processed properly until a reboot. The previous script should shut this one down, or you can still press F12 and that will break the loop and also close both scripts. This script can't be run on it's own, as it needs a window handle to communicate with, which is sent from the previous script when it runs this one. Also I wasn't sure what the other mouse buttons for the gun devices were meant to do so I just made them hit the keys you had in the last script you posted, and removed the sleeps, so they act like key down when button is down key up when button goes up. You should name this one:

LightGunIntercept.ahk

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

angpogibow
Posts: 2
Joined: 16 Jul 2017, 04:07

Re: Creating a wrapper for interception.dll (fixed and working!)

17 Jul 2017, 01:50

Noesis wrote:angpogibow, There is an important line in the example, which you left out of your code, mice use relative coordinates by default. The line you left out would be this:

mstroke.flags = INTERCEPTION_MOUSE_MOVE_ABSOLUTE;

At least that what I suspect based on a quick look, haven't tested it and don't really plan to, as it's not exactly AHK code you're using here.


yes I missed some lines. I used the code posted by Helgef above to fix the coordinates. Its now working perfectly. :D
phasermaniac
Posts: 55
Joined: 09 Apr 2017, 14:05

Re: Creating a wrapper for interception.dll (fixed and working!)

17 Jul 2017, 12:01

thanks Noesis,, but I'm getting a problem:
In my working pc it seems to work, after customizing the scripts with my data, I launch Lightgun.ahk and blocks the cursor, I can't test more here as It dont have lightguns attached.
In the arcade pc, Im getting "Call to nonexistent function: OnExit("ExitSub"), that is at the begining of interception.ahk.
Both are win 10 64 with interception installed, interception.dll (64) in the same folder than the scripts and interception.ahk in lib folder, with _Struct.ahk... Any idea?
Noesis
Posts: 208
Joined: 26 Apr 2014, 07:57

Re: Creating a wrapper for interception.dll (fixed and working!)

18 Jul 2017, 02:07

Perhaps check the version of ahk being used on the arcade PC, also It can't be coming from Interception.ahk as that line doesn't exist there, you must mean one of the other scripts (the LightGunIntercept.ahk script ?).
phasermaniac
Posts: 55
Joined: 09 Apr 2017, 14:05

Re: Creating a wrapper for interception.dll (fixed and working!)

18 Jul 2017, 13:03

It can't be coming from Interception.ahk as that line doesn't exist there, you must mean one of the other scripts

You got reason, It didnt come from interception.ahk.
Seems I have running ahk 64 u in both pcs, I'll give another try this night, I may have messed something
Noesis
Posts: 208
Joined: 26 Apr 2014, 07:57

Re: Creating a wrapper for interception.dll (fixed and working!)

19 Jul 2017, 00:48

Yes mate, I have a reason which I shared in the original post, "that line doesn't exist there" meaning intercpetion.ahk doesn't contain any OnExit() lines in it, only the other two scripts have that line in them. Also by AHK version I mean the version number i.e. 1.1.??.??. Wondering if you've got an older version on the arcade machine. Since OnExit didn't always accept functions as parameters, although it has for quite a some time now.
phasermaniac
Posts: 55
Joined: 09 Apr 2017, 14:05

Re: Creating a wrapper for interception.dll (fixed and working!)

19 Jul 2017, 17:41

Yes, that's it! Now it works, but when I shot any of the guns crosshair goes to down right corner.
the id part in interception.ahk its working fine, and I'm using a ps2 keyboard.
gun1 sends ab, gun2 sends ko, I can move the cursor with the mouse, but when shot goes to the corner
Noesis
Posts: 208
Joined: 26 Apr 2014, 07:57

Re: Creating a wrapper for interception.dll (fixed and working!)

20 Jul 2017, 10:06

So the shot goes to the bottom right corner all the time, and doesn't matter where the mouse is ? Try this, I've only changed one script, the Lightgun.ahk script.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


I haven't changed much there was a line declaring & assigning a global variable in a function which I changed, (it was only meant to be declared, it was meant to be assigned earlier, which it is now, shouldn't have caused this problem though). I've added in a tooltip which should report the position when a gun is fired (it should even appear where the gun was fired) Let me know if it's got values and if those values change when aimed at different spots. Basically I need to determine where it is failing, and I'm first checking the position the gun is reporting right before the buttons are sent.
phasermaniac
Posts: 55
Joined: 09 Apr 2017, 14:05

Re: Creating a wrapper for interception.dll (fixed and working!)

20 Jul 2017, 11:20

ok tested and the tooltipe is reporting me the correct coordinates (0 ~ 65.000)for x and y, they are correct as the x growed from left to right and the y from top to bottom in a logical way for each shoot. But the cursor doesn't move from the bottom-right corner.

I'm testing in a white background, so it shouldnt be a problem now, but I think to work on dark colors, SendMousePosition must be after triggerdelay, to get the position while the screen is flashing and it is all white:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot] and 37 guests