Making the mouse click.

Hi,

I am currently making a mod so that i can use my wired xbox 360 contoller in gmod. I have already made it do that i can move the mouse in the spawnmenu using the left thumbstick but now i need to know how to make it actually click. I was thinking of finding out what panel you where hovering over and then just calling the DoClick function, but i can’t figure out how to get the panel i am hovering over. Any help?

Also if anyone knows a way to freeze the player client side that would also be much appreciated at the moment i am doing it sever side but i would like to be able to use it on any server. Player:Freeze() does not work even though it says it is shared on the wiki.

What happens if you run +attack?

Also, for freeze, you could maybe do something with User Commands and CreateMove mixed with PlayerBindPressed. Unsure how you would actually go about it, though.

The player attacks but it does not click the mouse

You mean made with Wire or Normal joystick? Oo

If you mean real joystick, I think about this:
Get the key command from the joystick and then bind it to +attack1

If i just bind it to attack then it does what it says on the tin it attacks it does not click the mouse on the vgui panel.

it would be better if u just made a module

I know a friend wanted to click in menus with lua (for an assmod autoclicker, hp spammer) and ended up making a c# programm… not very optimistic but hey maybey you get it to work.

errm cant you just map the buttons with the controller software?

I don’t know c++ or c# so I can’t make a module. If someone would be so kind as to do it for me :slight_smile: I would be very grateful.

Sorry to bump after only 6 hours but i really need an answer to this.

Well
You could check the Active Panel somehow. And then check if youre under it. But I really dont know how. xD

Yea I wish there was a function to get what panel the mouse is hovering over. I was trying to see how tooltips do it but I could not figure it out.

[lua]
/---------------------------------------------------------
Name: gamemode:GUIMouseReleased( mousecode )
Desc: The mouse has been released on the game screen
---------------------------------------------------------
/
function GM:GUIMouseReleased( mousecode, AimVector )

hook.Call( "CallScreenClickHook", GAMEMODE, false, mousecode, AimVector )

end

/---------------------------------------------------------
Name: gamemode:GUIMouseReleased( mousecode )
Desc: The mouse was double clicked
---------------------------------------------------------
/
function GM:GUIMouseDoublePressed( mousecode, AimVector )
// We don’t capture double clicks by default,
// We just treat them as regular presses
GAMEMODE:GUIMousePressed( mousecode, AimVector )
end[/lua]
from base/gamemode/cl_init.lua

Does this really emulate a click? For me, it just looks like calling hooks.

He was just showing the code inside the file:

http://luabin.foszor.com/code/gamemodes/base/gamemode/cl_init.lua#146

well i’ve been mucking about with it and if i do:

[lua]
GAMEMODE:GUIMousePressed( 107, LocalPlayer():GetCursorAimVector() )
[/lua]

It clicks but it does not click on the open vgui. I can tell because when i have the toolgun out and press a it is shooting the toolgun where i have clicked on the screen. As it would if you have the context menu open.

Just to answer to this person:
He means an xbox controller that has a wire.

Yea sorry about any confusion there.

I Still need help if anyone can.

I’ll try to slap together a module for you.

[editline]04:45PM[/editline]

Almost done. Testing…