Page 1 of 1

Inverting Mouse (outside of app)

Posted: Thu Nov 14, 2013 3:34 am
by Mythros
Hi all! I was just looking around the forums when I stumbled upon an "Invert Mouse Y coords" code.

I decided to make it even MORE fun, and ALSO inverted the X-Axis!

This has absolutely no real use, it's just for fun!

Enjoy!

InvertMouse_XY.pb:

Code: Select all

Procedure CheckCursor(Parameter)
  
  Protected x=-100
  Protected y=-100

  Repeat
    xPos = DesktopMouseX() : yPos = DesktopMouseY()
    If x = -100
      x = xPos
    Else
      If xPos = 0
        xPos=-1
      EndIf
      newX = 2*x - xPos
      x = newX
      If x < 0
        x = GetSystemMetrics_(#SM_CXSCREEN)-2
      ElseIf x >= GetSystemMetrics_(#SM_CXSCREEN)
        x=0
      EndIf
    EndIf
    If y = -100
      y = yPos
    Else
      If yPos = 0
        yPos=-1
      EndIf
      newY = 2*y - yPos
      y = newY
      If y < 0
        y = GetSystemMetrics_(#SM_CYSCREEN)-2
      ElseIf y >= GetSystemMetrics_(#SM_CYSCREEN)
        y=0
      EndIf
    EndIf
      SetCursorPos_(x, y)
    Delay(1)
  ForEver

EndProcedure

th = CreateThread(@CheckCursor(), 0)

If OpenWindow(0, 100, 200, 195, 260, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)

  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow 
  KillThread(th)

EndIf
Mythros