pieeater Posted April 16, 2011 Posted April 16, 2011 im trying to make a program that opens a GUI and when you move the mouse too close to the button it moves it away so you cant click it, i have a feeling im not even close to what i should be doing since im rlly new to autoit but heres my code so far expandcollapse popup#include <GUIConstantsEx.au3> Global $MoX, $MoY $X=50 $Y=100 gui() Func gui() $hGUI=GUICreate("mouse repeler", 600, 400, 10, 10) $button = GUICtrlCreateButton("Click Me",$X,$Y,100,90) GUISetState() AdlibRegister("CursorCords") AdlibRegister("_Win") While 1 Sleep(10) $msg = GUIGetMsg() If $msg = $button Then button() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func button() MsgBox(0,"good job","you are a sneaky ninja") Exit EndFunc Func CursorCords() $a = GUIGetCursorInfo() GUICtrlSetData($MoX, $a[0]) GUICtrlSetData($MoY, $a[1]) EndFunc Func _Win() If $MoX-25<=$X And $X<=$MoX+30 And $MoY-18<=$Y And $Y<=$MoY+18 Then $1=Random() $2=Random() MouseMove($1,$2) EndIf EndFunc also the _Win() function wasnt completly made by me i used it from taietel who helped me in another program. i just changed what was after the Then and the variables. [spoiler]My UDFs: Login UDF[/spoiler]
smartee Posted April 16, 2011 Posted April 16, 2011 Hi pieeater, here you go #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 600, 350, -1, -1) $Button1 = GUICtrlCreateButton("please click me", 230, 140, 120, 50) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 If WinActive($Form1) Then $cMsg = GUIGetCursorInfo() If IsArray($cMsg) Then $newx = $cMsg[0] + 20 $newy = $cMsg[1] + 20 If ($newx < 0) Or ($newy < 0) or ($newx > (600 - 120)) Or ($newy > (350 - 50)) Then $newx = 230 $newy = 140 EndIf GUICtrlSetPos($Button1, $newx, $newy) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(64, "WOW", "You're good!!") EndSwitch EndIf WEnd
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now