Jump to content

Welcome to Gaming On Steroids Forums
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account

[21 April 2016] Added mouse_event, keybd_event, SetCursorPos API, updated GetCursorPos API.

  • This topic is locked This topic is locked
No replies to this topic




  • Administrators
  • 2,543 posts

Since some people could feel safer using keyboard and mouse clicks, i thought why not release them in LUA.


Here is some code example:

MOUSEEVENTF_LEFTUP          = 0x0004;
MOUSEEVENTF_RIGHTUP         = 0x0010;
KEYEVENTF_KEYUP             = 0x0002;
if KeyIsDown(0x11) then --CTRL key
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);  --perform right click
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); 
--if KeyIsDown(0x12) then --ALT key --if we set up holding down a key it doesn't work
SetCursorPos(WINDOW_W/2,WINDOW_H/2); --set cursor at center of the screen
keybd_event(string.byte("Q"), MapVirtualKey(string.byte("Q"), 0), 0, 0); --press Q
keybd_event(string.byte("Q"), MapVirtualKey(string.byte("Q"), 0), KEYEVENTF_KEYUP, 0);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); --left click with mouse in case user does not have smartcast enabled
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); 

  • 6

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users