HERBERS Excel-Forum - die Beispiele

Thema: Auslesen der Mausposition

Home

Gruppe

API

Problem

Wie kann ich die Mausposition nach Points auslesen?

Lösung
Geben Sie den nachfolgenden Code in ein Standardmodul ein und weisen Sie ihn einer Schaltfläche zu.
StandardModule: basMain

Declare Function GetCursorPos& Lib "user32" (lpPoint As POINTAPI)

Type POINTAPI
   x As Long
   y As Long
End Type

Sub Orientieren()
   Dim lPos As Long
   Dim PT As POINTAPI
   If Application.DisplayFullScreen = False Then
      Beep
      MsgBox "Zuerst Schaltfläche 'Start' drücken!"
      Exit Sub
   End If
   lPos = GetCursorPos(PT)
   If PT.x >= 3 And PT.x <= 30 And PT.y >= 198 And PT.y <= 240 Then
      MsgBox "Bad Honnef"
   ElseIf PT.x >= 68 And PT.x <= 116 And PT.y >= 328 And PT.y <= 337 Then
      MsgBox "Linz am Rhein"
   ElseIf PT.x >= 214 And PT.x <= 239 And PT.y >= 238 And PT.y <= 264 Then
      MsgBox "Neustadt/Wied"
   ElseIf PT.x >= 207 And PT.x <= 240 And PT.y >= 145 And PT.y <= 182 Then
      Beep
      MsgBox "Asbach"
   ElseIf PT.x >= 222 And PT.x <= 237 And PT.y >= 278 And PT.y <= 293 Then
      MsgBox "Autobahnabfahrt Neustadt/Wied"
   ElseIf PT.x >= 236 And PT.x <= 251 And PT.y >= 288 And PT.y <= 309 Then
      MsgBox "Autobahntankstelle Fernthal"
   ElseIf PT.x >= 112 And PT.x <= 127 And PT.y >= 194 And PT.y <= 209 Then
      MsgBox "Autobahnabfahrt Bad Honnef/Linz"
   ElseIf PT.x >= 52 And PT.x <= 67 And PT.y >= 131 And PT.y <= 146 Then
      MsgBox "Autobahnabfahrt Siebengebirge"
   ElseIf PT.x >= 182 And PT.x <= 201 And PT.y >= 126 And PT.y <= 144 Then
      MsgBox "Buchholz"
   ElseIf PT.x >= 141 And PT.x <= 159 And PT.y >= 201 And PT.y <= 217 Then
      MsgBox "Windhagen"
   ElseIf PT.x >= 42 And PT.x <= 70 And PT.y >= 90 And PT.y <= 111 Then
      MsgBox "Oberpleis"
   ElseIf PT.x >= 8 And PT.x <= 33 And PT.y >= 105 And PT.y <= 135 Then
      MsgBox "Heisterbacherrott"
   ElseIf PT.x >= 33 And PT.x <= 58 And PT.y >= 142 And PT.y <= 163 Then
      MsgBox "Ittenbach"
   ElseIf PT.x >= 121 And PT.x <= 143 And PT.y >= 250 And PT.y <= 274 Then
      MsgBox "Vettelschoß"
   ElseIf PT.x >= 130 And PT.x <= 149 And PT.y >= 294 And PT.y <= 310 Then
      MsgBox "St. Katharinen"
   Else
      MsgBox "Bitte einen Ort oder eine Autobahnabfahrt anklicken!"
   End If
End Sub

Sub Zurueck()
   With Application
      .DisplayFullScreen = Not .DisplayFullScreen
   End With
   If [Button].Caption = "Zurück" Then
      [Button].Caption = "Start"
   Else
      [Button].Caption = "Zurück"
   End If
End Sub

Beiträge aus dem Excel-Forum zu den Themen API und Maus

Excel to Word Kapitel VBA Anfangskapital berechnen
Gestapelte Säulen-Diagramm: Ich kapier's nicht Googel Maps API in Excel VBA einfügen
Markierung mit Maus langsam rechte Maustaste Zellen formatieren funzt nicht
Mauszeiger Quickinfo Rechte Maustaste
Listboxeintrag unter Mauszeiger Punkte im Diagramm unter der Maus ermitteln
AutoFormen Werte per Mausklick zuordnen Berechnung vom Endkapital
Mauszeiger auf CommandButton Diagrammwerte am Mauszeiger unterdrücken
Kontextmenü der rechten Maustaste anpassen Bei Mausklick auf eine Zelle eins weiterzählen
Menü der rechten Maustaste API? - xl-Parameter aus Long-Wert bestimmen
Berechnung Kapitalanlage Telefonnummer auslesen per TAPI
Menü der rechten Maustaste Sendkeys-Befehl für rechte Maustaste
Rechte Maustaste Mausklick auf Autoform (Bild) registrieren
Rechter Mausklick in geschütztem Blatt Formel runter ziehen mit der Maus 3er Schritte
Läuft RSAPI.DLL mit WIN2000 und XP? mit der Maus Text aus UF-Textfeld kopierenEinfügen
Zahl per Mausklick in andere Zelle kopieren Systemauslastung mitloggen
rechts maus klick verhindern... JAVA API mit VBA verwenden
Werte anzeigen mit re. Maustaste Alternative zu "Formel mit Maus ziehen"?
Alternative zu "Formel mit Maus ziehen"? Maus Scrollen verhindern...
Text erscheinen lassen wenn maus darüber Inhalt von Zellen kopieren per Mausklick
Mit Mausklick auf eine Zelle automatisch sortieren Mausclick aktiviert Taste
Mit Mausklick Datum verschieben ? Msgbox bei gedrückter Maustaste
Rechte Maustaste auf Registerkarte Text in Textbox mit Maus scrollen
PageSetup - absolute Systemauslastung Mausclick auf Zelle generieren
Mausklick: Wechsel in erste freie Zelle der Spalte Per Mausklick Zellwert in andere Zelle übernehmen
Probleme mit rechter Maustaste Diagrammauswertung