vb6 - mouse_event not defining and DllImport not working -


i'm using visual basic 6.0 (i know, it's outdated, can say? i'm old-timey that). i've been trying program work makes mouse click on predetermined point on screen after clicking button (that's not whole program be, i'm still building , roadblock)

[system.runtime.interopservices.dllimport("user32.dll")] private declare function mouse_event lib "user32.dll" alias "mouse_event()" (byval dwflags long, byval dx long, byval dy long, byval cbuttons long, byval dwextrainfo long) private const mouseeventf_leftdown = &h2 private const mouseeventf_leftup = &h4  public function mouse_leftclick()   mouse_event mouseeventf_leftdown, 0, 0, 0, 0   mouse_event mouseeventf_leftup, 0, 0, 0, 0 end function  private sub command1_click()     dim x long     dim y long     dim mouse_x long     dim mouse_y long     x = clng(1285)     y = clng(134)      mouse_x = clng(x * 65535 / screen.width)     mouse_y = clng(y * 65535 / screen.height)      = mouse_event(mouseeventf_absolute + mouseeventf_move, mouse_x, mouse_y, 0, 0)     n = mouse_leftclick() end sub  private sub command2_click()     end end sub 

(this literally entire program far)

to clear, i'm relatively new @ this, code entirely taken website. have since forgotten website was, unfortunately.

now, before had first line there (the dllimport), vb6 telling me "mouse_event()" didn't exist in user32.dll -- which, understanding, still doesn't.

once researched problem, though, found dllimport line placed internet told me place it, same line producing error message:

compile error:  invalid outside procedure 

...which confused me, since got people knew doing (i assumed so, anyways).

anyways, it's been long since program's worked, can't remember last time able run without getting critical error ends program, turn stackoverflow tell me i've done terribly wrong code.

thank in advance offers help.

remove dllimport stuff. it's vb.net, it's not valid vb6 @ all.

 [system.runtime.interopservices.dllimport("user32.dll")]  

and then, hans said, remove parentheses alias in declare.


Comments