_MouseRepel

« Older   Newer »
  Share  
Dragon[ITA]
CAT_IMG Posted on 10/3/2010, 21:17     +1   -1




Ho trovato questa funzione sul forum ufficiale di autoit, ho controllato se funge ma ho notato che non respinge completamente il mouse dall'area ... allora ho pensato a questo:

CODICE
#include <Misc.au3>
Func ExampleMouseRepel()
Global $GUI = GUICreate("Can't Touch This", 200, 100, 200, 200)
GUICtrlCreateButton("PREMI QUI",20,20,160,60)
GUISetState()
AdlibEnable("CallMouseRepel", 10)
Do
Until GUIGetMsg() = -3
EndFunc

Func CallMouseRepel()
       $coords = WinGetPos($GUI)
       _MouseRepel($coords[0]+23, $coords[1]+44, $coords[0] + $coords[2]-23, $coords[1] + $coords[3]-23,0)
EndFunc   ;==>CallMouseRepel
;===========================================================
;$i_left, $i_top, $i_right, $i_bottom = rectangle coord
;$param = 0 mouse cant go in the rectangle
;                  1 mouse can go in for a little
;===========================================================
Func _MouseRepel($i_left = 0, $i_top = 0, $i_right = 0, $i_bottom = 0, $param = 0)
       Local $a_MousePos = MouseGetPos()
       Local $i_XCordinate = -1, $i_YCordinate = -1
       If $param <> 1 And $param <> 0 Then
               return -1
       ElseIf $param = 1 Then
               If $a_MousePos[0] >= $i_left And $a_MousePos[0] <= $i_right Then
                       If ($a_MousePos[0] - $i_left) < ($i_right - $a_MousePos[0]) Then
                               $i_XCordinate = $i_left - 1
                       Else
                               $i_XCordinate = $i_right + 1  
                       EndIf
               EndIf  
               If $a_MousePos[1] >= $i_top And $a_MousePos[1] <= $i_bottom Then  
                       If ($a_MousePos[1] - $i_top) < ($i_bottom - $a_MousePos[1]) Then
                               $i_YCordinate = $i_top - 1    
                       Else        
                               $i_YCordinate = $i_bottom + 1    
                       EndIf  
               EndIf  
               If $i_XCordinate <> -1 And $i_YCordinate <> -1 Then  
                       If Abs($i_XCordinate - $a_MousePos[0]) > Abs($i_YCordinate - $a_MousePos[1]) Then      
                               MouseMove($a_MousePos[0], $i_YCordinate, 1)  
                       ElseIf Abs($i_XCordinate - $a_MousePos[0]) < Abs($i_YCordinate - $a_MousePos[1]) Then    
                               MouseMove($i_XCordinate, $a_MousePos[1], 1)    
                       Else        
                               MouseMove($i_XCordinate, $i_YCordinate, 1)      
                       EndIf
               EndIf
       ElseIf $param = 0 Then
               If  $a_MousePos[0] < $i_left And $a_MousePos[1] < $i_top Then
                       _MouseTrap()
               ElseIf $a_MousePos[0] > $i_right And $a_MousePos[1] < $i_top Then
                       _MouseTrap()
               ElseIf $a_MousePos[0] > $i_right And $a_MousePos[1] > $i_bottom Then
                       _MouseTrap()
               ElseIf $a_MousePos[0] < $i_left And $a_MousePos[1] > $i_bottom Then
                       _MouseTrap()
               ElseIf $a_MousePos[0] >= $i_left And $a_MousePos[0] <= $i_right And $a_MousePos[1] <= $i_top Then
                       _MouseTrap(0,0,@DesktopWidth,$i_top)
               ElseIf $a_MousePos[0] <= $i_left And $a_MousePos[1] >= $i_top And $a_MousePos[1] <= $i_bottom Then
                       _MouseTrap(0,0,$i_left,@DesktopHeight)
               ElseIf $a_MousePos[0] >= $i_left And $a_MousePos[0] <= $i_right And $a_MousePos[1] >= $i_bottom Then
                       _MouseTrap(0,$i_bottom,@DesktopWidth,@DesktopHeight)
               ElseIf $a_MousePos[0] >= $i_right And $a_MousePos[1] >= $i_top And $a_MousePos[1] <= $i_bottom Then
                       _MouseTrap($i_right,0,@desktopWidth,@desktopheight)
               Else
                       MouseMove($i_left,$i_top,0)
               EndIf
       EndIf
EndFunc


NB. la parte fatta da me è quella con _mouseTrap(...)
 
Top
SuperAntani
CAT_IMG Posted on 11/3/2010, 21:56     +1   -1




E a che serve?
 
Top
Gianlu-thebest
CAT_IMG Posted on 12/3/2010, 16:31     +1   -1




Serve a non far passare il mouse in una zona ma AdlibEnable lo devi trasformare in AdlibRegister
 
Top
CAT_IMG Posted on 12/3/2010, 18:14     +1   -1

So creare belle gui

Group:
Bannato
Posts:
555
Reputazione:
0

Status:


appunto...

non funge comunque...
 
Top
Gianlu-thebest
CAT_IMG Posted on 12/3/2010, 19:59     +1   -1




O.i? a me funziona... cmq sono riuscito a premre il bottone con la tastiera!
 
Top
4 replies since 10/3/2010, 21:17   171 views
  Share