Seite 1 von 1

Maus verschieben

Verfasst: 22.06.2006 14:54
von Jilocasin
Tach!
Ich hab mal eben nen lustigen Code gemacht, der einfach nur totaler Schwachsinn ist... :lol:

Die Funktionesweise ist ganz einfach:
Der Windows-Mauscursor wird zum Spass einfach mal so durch die Gegend geschoben. :mrgreen:

Code: Alles auswählen


Structure FloatPoint
  x.f
  y.f
EndStructure

mouse.FloatPoint
getmouse.POINT

#Speed = 1

GetCursorPos_(@getmouse)

mouse\x = getmouse\x
mouse\y = getmouse\y

direction.f = Random(360)

ScreenW = GetSystemMetrics_(0)
ScreenH = GetSystemMetrics_(1)

Repeat
  Delay(10)
  
  direction + Random(10)-5
  
  
  If mouse\x < 80
    If direction < 180
      direction - #Speed
    Else
      direction + #Speed
    EndIf
  EndIf
  
  If mouse\y < 80
    If direction < 270 And direction > 90
      direction - #Speed
    Else
      direction + #Speed
    EndIf
  EndIf
  
  If mouse\x > ScreenW-80
    If direction < 180
      direction + #Speed
    Else
      direction - #Speed
    EndIf
  EndIf
  
  If mouse\y > ScreenH-80
    If direction < 90 Or direction > 270
      direction - #Speed
    Else
      direction + #Speed
    EndIf
  EndIf
  
  
  
  If direction > 360 : direction - 360 : EndIf
  If direction < 0 : direction + 360 : EndIf
  
  mouse\x + Cos(direction*2*3.1415/360)*#Speed
  mouse\y + Sin(direction*2*3.1415/360)*#Speed
  
  
  SetCursorPos_(Int(mouse\x),Int(mouse\y))
  
  
Until GetAsyncKeyState_(#VK_ESCAPE)
End

Verfasst: 22.06.2006 14:57
von #NULL
nein nein nein, der courser bleibt wo er ist, das restliche universum wird verschoben :allright: :freak:

prost

Verfasst: 22.06.2006 14:59
von Jilocasin
Ja genau... das mach ich auch noch.. die Maus bleibt in der mitte un man verschiebt das desktop :lol: :mrgreen:

Verfasst: 22.06.2006 15:18
von DrShrek
Jilocasin hat geschrieben:Ja genau... das mach ich auch noch.. die Maus bleibt in der mitte un man verschiebt das desktop :lol: :mrgreen:
warum nicht gleich den Monitor :lol:

Verfasst: 22.06.2006 16:09
von Alves
Shit, hab ich komplett falsch gestartet.

Naja, lustig. :mrgreen:

Wer hier StrokeIt hat, sollte das mal ausprobierne und dabei die rechte maustaste gedrückt halten und die MAus analog bewegen . :D

Verfasst: 22.06.2006 20:33
von Jilocasin
So.. :lol:
ist jetzt ein bisschen spaßiger:

Code: Alles auswählen


Structure FloatPoint
  x.f
  y.f
EndStructure

mouse.FloatPoint
getmouse.POINT



GetCursorPos_(@getmouse)

mouse\x = getmouse\x
mouse\y = getmouse\y

direction.f = Random(360)

ScreenW = GetSystemMetrics_(0)
ScreenH = GetSystemMetrics_(1)



OpenWindow(0,0,0,250,240,"Daniel's Bildschirmschoner ;-)",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)

CreateGadgetList(WindowID(0))
ButtonGadget(1,75,205,100,24,"Start")

Frame3DGadget(2,10,10,230,50,"Geschwindigkeit")
TrackBarGadget(3,20,27,210,20,1,9,#PB_TrackBar_Ticks) : SetGadgetState(3,4)

CheckBoxGadget(4,10,70,230,20,"Größenänderung") : SetGadgetState(4,1)

Frame3DGadget(7,10,100,230,80,"Maximale Größe (Pixel)")
TrackBarGadget(8,20,117,210,24,5,100) : SetGadgetState(8,10)
TextGadget(9,40,150,100,20,"10 Pixel")



Repeat
  EventID = WaitWindowEvent(100)
  If EventID = 16
    End
  EndIf
  
  If EventID = #PB_Event_Gadget And EventGadget() = 8
    SetGadgetText(9,Str(GetGadgetState(8))+" Pixel")
  EndIf
  
Until EventID = #PB_Event_Gadget And EventGadget() = 1

SIZE_MODIFIER = GetGadgetState(4)
SIZE_MAX = GetGadgetState(8)
SPEED = GetGadgetState(3)

CloseWindow(0)




Global Mem.l

Mem = AllocateMemory(1024)

Procedure.l DesktopOutput()
  PokeL(Mem, 1)
  ProcedureReturn Mem
EndProcedure



CR = Random(255)
CG = Random(255)
CB = Random(255)

Repeat
  Delay(10)
  
  direction + Random(10)-5
  
  StartDrawing(DesktopOutput()) 
    If SIZE_MODIFIER
      size.f = Abs(Sin(radius*2*3.1415/360)*SIZE_MAX/2)
      size + SIZE_MAX/2
      Circle(mouse\x,mouse\y,size/2,RGB(CR,CB,CG))
    Else
      Circle(mouse\x,mouse\y,SIZE_MAX,RGB(CR,CB,CG)) 
    EndIf
  StopDrawing() 
  
  radius + 1
  If radius > 360 : radius - 360 : EndIf
  
  CR + Random(8)-4
  CG + Random(8)-4
  CB + Random(8)-4
  
  If CR < 0 : CR = 0 : EndIf
  If CG < 0 : CG = 0 : EndIf
  If CB < 0 : CB = 0 : EndIf
  
  If CR > 255 : CR = 255 : EndIf
  If CG > 255 : CG = 255 : EndIf
  If CB > 255 : CB = 255 : EndIf
  
   
  If mouse\x < 80
    If direction < 180
      direction - Speed
    Else
      direction + Speed
    EndIf
  EndIf
  
  If mouse\y < 80
    If direction < 270 And direction > 90
      direction - Speed
    Else
      direction + Speed
    EndIf
  EndIf
  
  If mouse\x > ScreenW-80
    If direction < 180
      direction + Speed
    Else
      direction - Speed
    EndIf
  EndIf
  
  If mouse\y > ScreenH-80
    If direction < 90 Or direction > 270
      direction - Speed
    Else
      direction + Speed
    EndIf
  EndIf
  
  
  
  If direction > 360 : direction - 360 : EndIf
  If direction < 0 : direction + 360 : EndIf
  
  mouse\x + Cos(direction*2*3.1415/360)*Speed
  mouse\y + Sin(direction*2*3.1415/360)*Speed
  
  
  ;SetCursorPos_(Int(mouse\x),Int(mouse\y))
  
  
Until GetAsyncKeyState_(#VK_ESCAPE)
InvalidateRect_(0, 0, 0) 
End