Kan man emulera en musklickning på en utvald pixel, eller en koordinat i ett objekt, t.ex. en WebBrowser? Skapa två textboxar och en knapp. Jag fick bara upp det där felmeddelandet hela tiden så jag skrev det såhär: Jag glömde visst bort att säga att du måste fylla i värden som finns.Emulera musklickning?
Sv: Emulera musklickning?
Lägg in det här i en modul:
<code>
Declare Function SetCursorPos& Lib "user32" (ByVal x As Long, ByVal y As Long)
Public t&
</code>
Sen är det bara att lägga in den här koden i en CommandButton.
<code>
On Error GoTo korv
t& = SetCursorPos(Text1.Text, Text2.Text)
korv:
If Err.Number = 0 Then
Exit Sub
Else
MsgBox "Woops, you made something bad!", vbCritical, "Bad user!"
End If
</code>
/HjortenSv: Emulera musklickning?
MsgBox "Woops, you made something bad! Error: " & Err.Number, vbCritical, "Bad user!"
Då sa programmet:
"Woops, you made something bad! Error: 13"
Men jag hittade inget om error 13 även om jag känner igen det och det känns vanligt...Sv: Emulera musklickning?
T.ex 500 och 500.
Error 13 är det här: (taget från hjälpfilen i VB5)
sual Basic is able to convert and coerce many values to accomplish data type assignments that weren't possible in earlier versions. However, this error can still occur and has the following causes and solutions:
· The variable or property isn't of the correct type. For example, a variable that requires an integer value can't accept a string value unless the whole string can be recognized as an integer.
Try to make assignments only between compatible data types. For example, an Integer can always be assigned to a Long, a Single can always be assigned to a Double, and any type (except a user-defined type) can be assigned to a Variant.
· An object was passed to a procedure that is expecting a single property or value.
Pass the appropriate single property or call a method appropriate to the object.
· A module or project name was used where an expression was expected, for example:
Debug.Print MyModule
Specify an expression that can be displayed.
· You attempted to mix traditional Basic error handling with Variant values having the Error subtype (10, vbError), for example:
Error CVErr(n)
To regenerate an error, you must map it to an intrinsic Visual Basic or a user-defined error, and then generate that error.
· A CVErr value can't be converted to Date. For example:
MyVar = CDate(CVErr(9))
Use a Select Case statement or some similar construct to map the return of CVErr to such a value.
· At run time, this error typically indicates that a Variant used in an expression has an incorrect subtype, or a Variant containing an array appears in a Print # statement.
To print arrays, create a loop that displays each element individually.
For additional information, select the item in question and press F1.
/Hjorten