November 25, 2020, 05:16:10 AM

Author Topic: [bb] Simulate mouse click by Andres [ 1+ years ago ]  (Read 672 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Simulate mouse click by Andres [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Simulate mouse click
Author : Andres
Posted : 1+ years ago

Description : Simulate left mouse click where you want to.

Code :
Code: BlitzBasic
  1. Function SimulateMouseClick(x%, y%)
  2.         cur_x% = MouseX():cur_y% = MouseY()
  3.         api_SetCursorPos(x%, y%)
  4.         api_mouse_event($0201, 0, 0, 0, 0)
  5.         api_mouse_event($0202, 0, 0, 0, 0)
  6.         api_SetCursorPos(cur_x%, cur_y%)
  7. End Function


Comments :


jfk EO-11110(Posted 1+ years ago)

 Sometimes useful. Tho, decls are missing, for those who are not so familar with the API stuff.


blade007(Posted 1+ years ago)

 ya im not familar with the API stuff


ZJP(Posted 1+ years ago)

 Just create a file named for example "mouse_api.decls" and put it in the blitz3d userlibs directory.mouse_api.decls
Code: [Select]
.lib "user32.dll"
api_SetCursorPos% (x%, y%) : "SetCursorPos"
api_mouse_event (dwFlags%, dx%, dy%, cButtons%, dwExtraInfo%) : "mouse_event"



Wings(Posted 1+ years ago)

 well i go code my wow bot then ... so i can code in bb while loling my account on wow  :)   )


blade007(Posted 1+ years ago)

 this is great!can you simulate the right mouse button too?


AJ00200(Posted 1+ years ago)

 Thanks, this works good!


blade007(Posted 1+ years ago)

 Hey I figured out how to do the right mouse button too
Code: [Select]
Function SimulateRightMouseClick(x%, y%)
cur_x% = MouseX():cur_y% = MouseY()
api_SetCursorPos(x%, y%)
api_mouse_event($0204, 0, 0, 0, 0)
api_mouse_event($0205, 0, 0, 0, 0)
api_SetCursorPos(cur_x%, cur_y%)
End Function



Andres(Posted 1+ years ago)

 I've noticed that
Code: [Select]
api_mouse_event(2, 0, 0, 0, 0)
api_mouse_event(4, 0, 0, 0, 0)
does a "better" clicking, the other or older one had some glitches, i think it didn't very good work on key-up function. Atleast it didn't work in Morrowind. But the decimal numbers worked fine. [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal