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
Photo

[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

#1
Feretorix

Feretorix

    Administrator

  • Administrators
  • 3,144 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_LEFTDOWN        = 0x0002;
MOUSEEVENTF_LEFTUP          = 0x0004;
MOUSEEVENTF_RIGHTDOWN       = 0x0008;
MOUSEEVENTF_RIGHTUP         = 0x0010;
KEYEVENTF_KEYUP             = 0x0002;
 
OnTick(function()
 
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); 
end
 
--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); 
--end
 
end)
 

  • 6




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users