Go Down

Topic: Help with mouse input and output? (Read 7648 times) previous topic - next topic

David1937

So basically what I am trying to achieve and why I bought the Arduino at least the main purpose that is was to have the mouse plugged into it and then while I push down the Left Mouse Button on the mouse it sends rapid fire mouse clicks to the game (Call of Duty) on my computer. Basically I thought this would make it look like the mouse is clicking from the actual mouse, and I understand the code libarary since the Due can use USBHost which means it has the getButtonStatus which in theory will work?

I literally just ordered the Arduino Due, will this board achieve this small problem?

westfw

You need two USB ports; one a USB Host to attach your mouse, and one a USB device to connect to your computer.
In theory this should be possible; the "programming port" should be usable as a device port.  But I'm not sure that the mouse/etc libraries for Due are set up to use that - the more common case would be to use the "USB Native" port for the direct connection to PC *or* a device...


David1937

#2
Jan 05, 2017, 04:27 am Last Edit: Jan 05, 2017, 05:49 am by David1937
So when using the board on a PC for non-programming purposes you plug it into the "Native USB Port".

Would some sort of splitter or USB hub work around this if there is no other way?

I found this, does it mean that I cannot do it:? http://forum.arduino.cc/index.php?topic=248226.0

I literally just ordered this board for this purpose and I thought that it was the right thing for it? Hopefully can find a way around it if it doesn't work.

weird_dave

Blasted forum, I had written a longer reply, but submission failed and I lost it! Here's a short version.

Is your intention to have 1 mouse and pipe all the controls to the PC? I wouldn't do it this way. In fact, I wouldn't even use an arduino unless I needed extra functions that couldn't be mapped to a keyboard easily. Rapid fire of the Left Mouse Button can be mapped to key on the PC keyboard using autoit:
https://www.autoitscript.com/site/
Do you have 'extra' mouse buttons? mapping to these is feasible. You could map directly to the left mouse but it's trickier and you need a key to disable the function otherwise you'll be having fun in the game menus.

There are some options for using the Arduino, you could connect a mouse to the native port then emulate a serial mouse via the programming COM port. This could be quite involved. You'll need a button on the Due to enable/disable the function as well.
You could also use mouse emulation and connect it as a 2nd mouse. Either control the rapid fire with a button on the Due or send commands to the due via the programming COM port which then tell the Due to rapid fire. An autoit script could map a key or mouse button to the sending of the command to the Due. I'm not sure if you could map the left mouse button for this as you'd have the real mouse button held down and the Due 'mouse' rapid firing, I suspect this wouldn't work.

David1937

#4
Jan 05, 2017, 07:01 pm Last Edit: Jan 05, 2017, 07:09 pm by David1937
See, using autohotkey/autoit is a great idea in theory and I have used that before for other small games and I do have a fair amount of knowledge about it. The reason I would prefer to use the Arduino is because it's an external device so it would appear to the computer as if it's coming from the actual mouse. The thing with software on these types of games nowadays is that the Anti-Cheat on games scans through the memory and all the files on your PC. So using software is not a good option for me, basically defeats the purpose why I got the arduino.

So are you saying that the issue with my design is that I couldn't do it with the left mouse button behind held down because that is what is clicking? So it would be better to do it off a side button on my mouse or something???

This is the code I prepared for it but since but Arduino hasn't come in yet, I don't know if it will work: while(mouse.getButton(LEFT_BUTTON)) {

loopNumber = random(x, y) //number of times clicks before stops


for (int x = 1; x > loopNumber; x++) {

if (!mouse.getButton(LEFT_BUTTON)){     
       break;
    } 
Mouse.press(MOUSE_LEFT);
delay(random(minDelay, maxDelay));
Mouse.release(MOUSE_LEFT);
delay(random(minDelay, maxDelay));
  if (!mouse.getButton(LEFT_BUTTON)){     
       break;
    } 
}


Thanks for the help.

David1937

#5
Jan 06, 2017, 01:16 am Last Edit: Jan 06, 2017, 07:56 am by David1937
See, using autohotkey/autoit is a great idea in theory and I have used that before for other small games and I do have a fair amount of knowledge about it. The reason I would prefer to use the Arduino is because it's an external device so it would appear to the computer as if it's coming from the actual mouse. The thing with software on these types of games nowadays is that the Anti-Cheat on games scans through the memory and all the files on your PC. So using software is not a good option for me, basically defeats the purpose why I got the arduino.

So are you saying that the issue with my design is that I couldn't do it with the left mouse button behind held down because that is what is clicking? So it would be better to do it off a side button on my mouse or something???

This is the code I prepared for it but since but Arduino hasn't come in yet, I don't know if it will work: while(mouse.getButton(LEFT_BUTTON)) {

loopNumber = random(x, y) //number of times clicks before stops


for (int x = 1; x > loopNumber; x++) {

if (!mouse.getButton(LEFT_BUTTON)){     
       break;
    } 
Mouse.press(MOUSE_LEFT);
delay(random(minDelay, maxDelay));
Mouse.release(MOUSE_LEFT);
delay(random(minDelay, maxDelay));
  if (!mouse.getButton(LEFT_BUTTON)){     
       break;
    } 
}


Thanks for the help.

Not like remapping the rapid fire button to the left click is the biggest priorotiy here but what I basically am trying to achieve is to have the mouse plugged into whereever, doesn't really matter where, but I am assuming it has to be plugged into the Due to get information on the mouse. Preferlly the left mouse button (but like I said, that isn't the biggest issue), but as a button is held down I want the Due to send clicks to the PC and as soon as the button is released stop. I appreciate your long answer as although I do know a fair bit about the code and such already, I literally know nothing about the Arduinos and their coponents and in fact the Due is coming in during the next couple of days.

Now that I think of it back in the day maybe a few years ago I used a script back in the day with AutoIt and it indeed did use the left mouse button being held down to produce the clicks. It really does suck because with the insane advance of Anti-Cheat's in competitive games you can't use software at all anymore even if it is external which is one of the main reason I got the Arduino like I said. This was the only option that would be easy to handle as the only other option that wouldn't be detected by the anti cheat was to take another mouse,  and somehow make it click by accessing the mouses Hardware.

I really do appreciate the help though, as I am new to this and don't really understand much and really want to make this as it was the whole reason I bought this thing. @weird_dave

weird_dave

If anti-cheat is an issue with using autoit to generate the mouseclicks [I have seen anticheat stop the use of controlclick() but not yet mouseclick() ] then I would probably use autoit to send a control to the Arduino via USB COM port to do rapid fire, pretending to be a 2nd mouse via the Native USB. You'd probably still need to use a spare keyboard key or extra mouse button to trigger autoit to send the command to the Arduino rather than the left mouse button, but you can always try it and see what happens :)
I'd do this in stages, hook up a button to the due and get it doing mouseclicks as a 2nd mouse, then move on to serial comms and mapping to a key/button. Finally, I'd then implement the rapid fire on the due.
I would be surprised if the anticheat was unhappy with a script that didn't interact with any game binded keys, if it does then the only options left are to use a button on the arduino to do the rapidfire as a 2nd mouse, which is probably inconvenient, or, plug a mouse into the Due Native USB and forward all the movements to the PC as a serial mouse via the USB COM port. This may not be easy. You won't be able to plug the PC and mouse into the Native USB port and use something along the lines of the code you posted as this would require the port being a host and slave simultaneously and the PC would also see the mouse. The programming USB (COM) port can't be used as a generic USB device.

I may have a go at this myself at some point, there are times when 'hardware macros' do work better :D (the autoit/Due version, not the in-line method, too crazy for me :) )


David1937

If anti-cheat is an issue with using autoit to generate the mouseclicks [I have seen anticheat stop the use of controlclick() but not yet mouseclick() ] then I would probably use autoit to send a control to the Arduino via USB COM port to do rapid fire, pretending to be a 2nd mouse via the Native USB. You'd probably still need to use a spare keyboard key or extra mouse button to trigger autoit to send the command to the Arduino rather than the left mouse button, but you can always try it and see what happens :)
I'd do this in stages, hook up a button to the due and get it doing mouseclicks as a 2nd mouse, then move on to serial comms and mapping to a key/button. Finally, I'd then implement the rapid fire on the due.
I would be surprised if the anticheat was unhappy with a script that didn't interact with any game binded keys, if it does then the only options left are to use a button on the arduino to do the rapidfire as a 2nd mouse, which is probably inconvenient, or, plug a mouse into the Due Native USB and forward all the movements to the PC as a serial mouse via the USB COM port. This may not be easy. You won't be able to plug the PC and mouse into the Native USB port and use something along the lines of the code you posted as this would require the port being a host and slave simultaneously and the PC would also see the mouse. The programming USB (COM) port can't be used as a generic USB device.

I may have a go at this myself at some point, there are times when 'hardware macros' do work better :D (the autoit/Due version, not the in-line method, too crazy for me :) )


What do you mean by sending commands? Serial?

This anti-cheat is insane, it literally scans through what you are running with your ram. Macros are a big think in competative Call of Duty, so I am just afraid that since AutoHotkey/AutoIt is such a popular method of making macros, that it will be picked up or picked up as a even a cheat.

I am pretty new at this stuff which kind sucks and limits me on what I wanna do.

westfw

You could probably use a PS/2 mouse with a Due and USB computer port.  And a lot of mice still have PS/2 support built in, I think.  Or the other way around.  Or all PS/2 if your computer still has PS/2 ports.   Or all PS/2 on the Arduino, with an external commercial PS/2 to USB adapter.


David1937

If anti-cheat is an issue with using autoit to generate the mouseclicks [I have seen anticheat stop the use of controlclick() but not yet mouseclick() ] then I would probably use autoit to send a control to the Arduino via USB COM port to do rapid fire, pretending to be a 2nd mouse via the Native USB. You'd probably still need to use a spare keyboard key or extra mouse button to trigger autoit to send the command to the Arduino rather than the left mouse button, but you can always try it and see what happens :)
I'd do this in stages, hook up a button to the due and get it doing mouseclicks as a 2nd mouse, then move on to serial comms and mapping to a key/button. Finally, I'd then implement the rapid fire on the due.
I would be surprised if the anticheat was unhappy with a script that didn't interact with any game binded keys, if it does then the only options left are to use a button on the arduino to do the rapidfire as a 2nd mouse, which is probably inconvenient, or, plug a mouse into the Due Native USB and forward all the movements to the PC as a serial mouse via the USB COM port. This may not be easy. You won't be able to plug the PC and mouse into the Native USB port and use something along the lines of the code you posted as this would require the port being a host and slave simultaneously and the PC would also see the mouse. The programming USB (COM) port can't be used as a generic USB device.

I may have a go at this myself at some point, there are times when 'hardware macros' do work better :D (the autoit/Due version, not the in-line method, too crazy for me :) )


I literally know nothing of what you are talking about, since I am so knew at this. Could you give me subjects I could research so I have a better understanding of this communication stuff, because of right now I barely have a clue what that means or how it applies to AutoHotkey. If you do end up trying it yourself do you mind giving me the code of how you did it?

David1937

Also is the Due able to appear as  a HID like the Leonardo is? Like if I wanted to make it appear as a mouse?

weird_dave

What do you mean by sending commands? Serial?
Yes :)

This anti-cheat is insane, it literally scans through what you are running with your ram. Macros are a big think in competative Call of Duty, so I am just afraid that since AutoHotkey/AutoIt is such a popular method of making macros, that it will be picked up or picked up as a even a cheat.
You can compile the autoit code, so as long as it doesn't directly interact with the game, it shouldn't be picked up. A lot of mice and keyboards have macro options built-in, are they going after those as well?
The windows OS is pretty insecure which is why autoit works, you can hook into most of the system and do things, like pretend to be a mouse, up to a certain point, the system doesn't know if it's a real mouse, there's a number of layers to jump through between the real mouse and what the OS and/or games can see, a quick google:
"There is no way to detect if the mouse is a real one or a really well simulated one. The Windows HID/MacOS/Linux driver layer abstracts away the distinction between Mice, TrackPens, TrackBalls, draw-pads, touch screens... and of course script-mice.."

I would go for an autoit version until they break it, then redirect the control to the Due via serial

I am pretty new at this stuff which kind sucks and limits me on what I wanna do.
That will change :)

I literally know nothing of what you are talking about, since I am so knew at this. Could you give me subjects I could research so I have a better understanding of this communication stuff, because of right now I barely have a clue what that means or how it applies to AutoHotkey. If you do end up trying it yourself do you mind giving me the code of how you did it?
There's the autoit com port stuff:
https://www.autoitscript.com/forum/topic/128546-serial-port-com-port-udf/
and obviously the arduino com port stuff:
https://www.arduino.cc/en/reference/serial

The Due just has to sit and listen to the serial port (the programming USB port looks like a serial port on the PC), autoit could send a single byte, 'N' for 'oN' F for 'oFf' and the Due reacts by autofiring as a mouse via the native USB port when it sees 'N', then switches the autofire off when it sees 'F'

@westfw 's idea(s) should all work too.

Another option is to modify a mouse to autofire directly.
https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=mouse%20autofire%20hack
I both love and hate this solution. If there was a spare button on the mouse, I'd wire that to do the autofire on the left using a 555.


David1937

Yes :)

You can compile the autoit code, so as long as it doesn't directly interact with the game, it shouldn't be picked up. A lot of mice and keyboards have macro options built-in, are they going after those as well?
The windows OS is pretty insecure which is why autoit works, you can hook into most of the system and do things, like pretend to be a mouse, up to a certain point, the system doesn't know if it's a real mouse, there's a number of layers to jump through between the real mouse and what the OS and/or games can see, a quick google:
"There is no way to detect if the mouse is a real one or a really well simulated one. The Windows HID/MacOS/Linux driver layer abstracts away the distinction between Mice, TrackPens, TrackBalls, draw-pads, touch screens... and of course script-mice.."

I would go for an autoit version until they break it, then redirect the control to the Due via serial
That will change :)

There's the autoit com port stuff:
https://www.autoitscript.com/forum/topic/128546-serial-port-com-port-udf/
and obviously the arduino com port stuff:
https://www.arduino.cc/en/reference/serial

The Due just has to sit and listen to the serial port (the programming USB port looks like a serial port on the PC), autoit could send a single byte, 'N' for 'oN' F for 'oFf' and the Due reacts by autofiring as a mouse via the native USB port when it sees 'N', then switches the autofire off when it sees 'F'

@westfw 's idea(s) should all work too.

Another option is to modify a mouse to autofire directly.
https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=mouse%20autofire%20hack
I both love and hate this solution. If there was a spare button on the mouse, I'd wire that to do the autofire on the left using a 555.


Thanks for all the information!

Something that I should mention is that the anti-cheat is client side, meaning that they have this insane program that runs as administrator on your PC. It all sounds good except the AutoIt seems to be the only part that sounds kinda sketchy.

David1937

Yes :)

You can compile the autoit code, so as long as it doesn't directly interact with the game, it shouldn't be picked up. A lot of mice and keyboards have macro options built-in, are they going after those as well?
The windows OS is pretty insecure which is why autoit works, you can hook into most of the system and do things, like pretend to be a mouse, up to a certain point, the system doesn't know if it's a real mouse, there's a number of layers to jump through between the real mouse and what the OS and/or games can see, a quick google:
"There is no way to detect if the mouse is a real one or a really well simulated one. The Windows HID/MacOS/Linux driver layer abstracts away the distinction between Mice, TrackPens, TrackBalls, draw-pads, touch screens... and of course script-mice.."

I would go for an autoit version until they break it, then redirect the control to the Due via serial
That will change :)

There's the autoit com port stuff:
https://www.autoitscript.com/forum/topic/128546-serial-port-com-port-udf/
and obviously the arduino com port stuff:
https://www.arduino.cc/en/reference/serial

The Due just has to sit and listen to the serial port (the programming USB port looks like a serial port on the PC), autoit could send a single byte, 'N' for 'oN' F for 'oFf' and the Due reacts by autofiring as a mouse via the native USB port when it sees 'N', then switches the autofire off when it sees 'F'

@westfw 's idea(s) should all work too.

Another option is to modify a mouse to autofire directly.
https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=mouse%20autofire%20hack
I both love and hate this solution. If there was a spare button on the mouse, I'd wire that to do the autofire on the left using a 555.


Also it would be easier for me if it was done on AutoHotkey (if it's possible idk) because I have a fair bit of understand on how to use that.

Also would using a powered USB hub or if I buy the USB Host Sheild make it any easier to do it the other way?

David1937

#14
Jan 09, 2017, 06:29 am Last Edit: Jan 09, 2017, 06:35 am by David1937

Thanks for all the information!

Something that I should mention is that the anti-cheat is client side, meaning that they have this insane program that runs as administrator on your PC. It all sounds good except the AutoIt seems to be the only part that sounds kinda sketchy.

I don't really want to mess up my mouse though that is the thing. I use different mouses too sometimes and they are both quite expensive. My aim for this project is:

Have the clicking be coming from External, I don't care how complicated or messy it is on the outside as long as it's external I don't care it's not for looks.

Having the ability to use code so I can code it the way I want and add things like random delays etc.

Be able to use with any of my gaming mice. (not one modded bad mouse)

The external clicks to appear like they are coming from a real HID device (mouse)




Go Up