sensalim Posted March 12, 2008 Posted March 12, 2008 Seem to work first one or two attempts. Thanks! expandcollapse popup;includes #include <GUIConstants.au3> ;hotkeys HotKeySet("{F1}", "TellPos") Dim $JBList[8] = ["", "Abort", "Cancel", "Ignore", "Help", "ARGH!", "AIEEE!", "Oouch..."] $wt = "Jumping Button" $width = @DesktopWidth - 2 $height = @DesktopHeight - 30 $JB_x = 10 $JB_y = 10 $JB_w = 100 $JB_h = 30 $counter = 0 Opt("GUIOnEventMode", 1) Opt("MouseCoordMode", 2) $guiJB = GUICreate($wt, 400, 400) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ;GUISetBkColor (0xE0FFFF) $JB = GUICtrlCreateButton($JBList[Random(1, 7, 1)], $JB_x, $JB_y, $JB_w, $JB_h) GUICtrlSetOnEvent($JB, "TellPos") $lStatus = GUICtrlCreateLabel("0", 10, 10, 390, 20) GUISetState (@SW_SHOW, $guiJB) While 1 CheckMousePos() GUICtrlSetData($lStatus, $counter) Sleep(10) WEnd Func TellPos() $mousepos = MouseGetPos() MsgBox(0, "Tell Coordinates", "Mouse: " & $mousepos[0] & ":" & $mousepos[1] & @crlf & "Button: " & $JB_x & ":" & $JB_y) EndFunc Func CheckMousePos() $mousepos = MouseGetPos() $mouse_x = $mousepos[0] $mouse_y = $mousepos[1] If ($mouse_x >= $JB_x-5 and $mouse_x <= $JB_x+50+5) and _ ($mouse_y >= $JB_x-5 and $mouse_y <= $JB_y+30+10) _ Then $JB_x = Random(10, 350, 1) $JB_y = Random(10, 350, 1) GUICtrlSetPos($JB, $JB_x, $JB_y) GUICtrlSetData($JB, $JBList[Random(1, 7, 1)] & " " & $JB_x & ":" & $JB_y) $counter = 0 Else $counter = $counter + 1 If $counter > 999 Then $counter = 0 EndIf EndFunc Func CLOSEClicked() ;If handle is from main window, exit. If @GUI_WINHANDLE = $guiJB Then Exit Else ;If not, hide the window and switch to main window. GUISetState(@SW_HIDE, @GUI_WINHANDLE) GUISwitch($guiJB) GUISetState(@SW_SHOW, $guiJB) EndIf EndFunc
rasim Posted March 13, 2008 Posted March 13, 2008 (edited) Hi!Jumping ButtonFrom mouse cursor? Look to GUIGetCursorInfo() function. Edited March 13, 2008 by rasim
sensalim Posted March 13, 2008 Author Posted March 13, 2008 (edited) Oh I didn't think of that, let me try it. Thanks. Edit: Works. Edited March 13, 2008 by sensalim
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