Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error Ambigious Name Detected: PointAPI??

Status
Not open for further replies.

ThaVolt

Programmer
Aug 12, 2002
34
NL
Hi im playing a game on the net its a gambling game in flash you've to push a button the whole time so i wanted to create a program that keeps pressing the button but now im stuck.. my code is the following:

Dim ORIGINAL_TIME As Date
Dim SECONDS_TO_WAIT As String

Private Sub Timer1_Timer()
Dim Result As Long
Dim Pos As PointAPI
Result = GetCursorPos(Pos)
If Result <> 0 Then
StatusBar1.SimpleText = Pos.X & &quot;,&quot; & Pos.Y
Else
StatusBar1.SimpleText = &quot;Error&quot;
End If
End Sub

Public Sub HoldOn(Seconds)
Dim CurrentTime As Long
CurrentTime = Timer
Do
DoEvents
Loop Until CurrentTime + Seconds <= Timer
End Sub

Private Sub Command1_Click()
MsgBox &quot;Over 5 Secondes Begint De AutoGok Ga Naar Het GokAutomaat Venster&quot;, vbInformation
HoldOn (5)
Timer1.Enabled = True
Timer2.Enabled = True
Timer3.Enabled = True
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
End Sub

Private Sub Timer2_Timer()
Call SetMousePos(622, 117)
LeftClick
End Sub

Private Sub Timer3_Timer()
If StatusBar1.SimpleText = &quot;622,117&quot; Then
Timer2.Enabled = True
Else
Timer2.Enabled = False
End If
End Sub

command 1 & 2 are the start and stop buttons the holdon() command is so that the user can open the internet explorer with the gambling game in it, so far so good but i want timer2 (wich clicks all the time) to stop when the user moves the mouse. thats why i put in timer 3 wich checks if the coordinates are changed and if they are it will stop timer2. Well i thought the code was ok but since i added the 3rd timer i get this error: Compile Error Ambigious Name Detected: PointAPI, wich i didn't have before i added it and when i delete it it still gives the error.. :( anyone knows what i'm missing here?

Thanks in advance,

Greets,

ThaVolt
 
It looks like you haven't actually included all the relevant code to let us help you. For example SetMousePos, LeftClick. Nor do you seem to include all the declarations (eg where is the declaration of PointAPI?).
 
In modules..

These are the modules i used:

Module1

Public Declare Sub mouse_event Lib &quot;user32&quot; (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Declare Function SetCursorPos Lib &quot;user32&quot; (ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function GetCursorPos Lib &quot;user32&quot; (lpPoint As PointAPI) As Long
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
Public Const MOUSEEVENTF_MIDDLEUP = &H40
Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Public Const MOUSEEVENTF_RIGHTUP = &H10
Public Const MOUSEEVENTF_MOVE = &H1
Public Type PointAPI
X As Long
Y As Long
End Type

' Function to get mouse x-position
Public Function GetX() As Long
Dim n As PointAPI
GetCursorPos n
GetX = n.X
End Function

' Function to get mouse y-position
Public Function GetY() As Long
Dim n As PointAPI
GetCursorPos n
GetY = n.Y
End Function

' Sub to emulate left button click (down + up)
Public Sub LeftClick()
LeftDown
LeftUp
End Sub

' Sub to emulate left button down
Public Sub LeftDown()
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
End Sub

' Sub to emulate left button up
Public Sub LeftUp()
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub

' Sub to emulate middle button click (down + up)
Public Sub MiddleClick()
MiddleDown
MiddleUp
End Sub

' Sub to emulate middle button down
Public Sub MiddleDown()
mouse_event MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0
End Sub

' Sub to emulate middle button up
Public Sub MiddleUp()
mouse_event MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0
End Sub

' Sub to emulate right button click (down + up)
Public Sub RightClick()
RightDown
RightUp
End Sub

' Sub to emulate right button down
Public Sub RightDown()
mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
End Sub

' Sub to emulate right button up
Public Sub RightUp()
mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
End Sub

' Sub to move mouse position with x,y
Public Sub MoveMouse(xMove As Long, yMove As Long)
mouse_event MOUSEEVENTF_MOVE, xMove, yMove, 0, 0
End Sub

' Sub to set mouse position to x,y
Public Sub SetMousePos(xPos As Long, yPos As Long)
SetCursorPos xPos, yPos
End Sub


Module2

Option Explicit

Type PointAPI
X As Long
Y As Long
End Type

Public Declare Function GetCursorPos Lib &quot;user32&quot; (lpPoint As PointAPI) As Long

Hope u got enough information to help me if you need more just say it :D

Greetings,

ThaVolt
 
Yep - you've got two definitions of PointAPI, one in Module 1 and one in Module 2. Get rid of the one in Module 2.
 
hmm another problem. when i have the code of my first post, i changed the code of timer3 that checks if the mouse was moved.

Private Sub Timer3_Timer()
If If StatusBar1.SimpleText Is Not &quot;622,117&quot; Then Timer1.Enabled = False
Timer2.enabled = false
timer3.enabled = false
End If
End Sub

but this doesn't work anyone has an idea what could do the trick? the program should stop de clicking when the mouse is moved...

thanks in advance,

ThaVolt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top