Jump to content

Moving Button


Recommended Posts

I wanna make a moving Gui button that runs away from your mouseso if you move you mouse one way, it will move away, until it hits the End of the screen area and then maybe it moves to other side, or goes to the middle and continues,

I made a GUI to use for it, but i can't get the button to work right, i've tried but all attempts fail

heres code

;-----Include-----
#include <GuiConstants.au3>

;-----Variabales-----
Global $count=0, $button_[1], $label_[4], $left, $top, $mouseleft, $mousetop

;-----Hotkeys-----
#cs
HotKeyset("werty", "Terminate")
#ce
;-----GUI-----
$wind = GuiCreate("", @DesktopWidth, @DesktopHeight,-1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GuiSetBkColor("0xcccccc")
$label_[0] = GUICtrlCreateLabel("The Annoying Game", @DesktopWidth/2-325, 50, 800, 100)
GUICtrlSetFont($label_[0], 50, 500, 4, "Arial")
$label_[1] = GuiCtrlCreateLabel("If you want this message to go away, click the button below.", @DesktopWidth/2-150, 150, 500, 35)
GUICtrlSetFont($label_[1], 12, 300, 2, "Arial")
$label_[2] = GuiCtrlCreateLabel("You've Clicked The Button: " & $count & "/10 Times", 50, 900, 500, 35)
GUICtrlSetFont($label_[2], 20, 600, 2, "Arial")
GuiCtrlCreateGroup("", 50, 200, 1150, 675)
$button_[0] = GuiCtrlCreateButton("-§§§-", @DesktopWidth/2-100, @DesktopHeight/2-35, 100, 35)

GuiSetState()

;-----Display-----
While 1
$msg = GuiGetMsg()
$mousepos= MouseGetPos()

If $msg = $button_[0] then 
$count = $count+1
Endif
if $msg = $GUI_EVENT_CLOSE Then Exitloop
    
Wend

The buton count thing doesn't work either,

any help?

Link to comment
Share on other sites

I wanna make a moving Gui button that runs away from your mouseso if you move you mouse one way, it will move away, until it hits the End of the screen area and then maybe it moves to other side, or goes to the middle and continues,

I made a GUI to use for it, but i can't get the button to work right, i've tried but all attempts fail

heres code

;-----Include-----
#include <GuiConstants.au3>

;-----Variabales-----
Global $count=0, $button_[1], $label_[4], $left, $top, $mouseleft, $mousetop

;-----Hotkeys-----
#cs
HotKeyset("werty", "Terminate")
#ce
;-----GUI-----
$wind = GuiCreate("", @DesktopWidth, @DesktopHeight,-1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GuiSetBkColor("0xcccccc")
$label_[0] = GUICtrlCreateLabel("The Annoying Game", @DesktopWidth/2-325, 50, 800, 100)
GUICtrlSetFont($label_[0], 50, 500, 4, "Arial")
$label_[1] = GuiCtrlCreateLabel("If you want this message to go away, click the button below.", @DesktopWidth/2-150, 150, 500, 35)
GUICtrlSetFont($label_[1], 12, 300, 2, "Arial")
$label_[2] = GuiCtrlCreateLabel("You've Clicked The Button: " & $count & "/10 Times", 50, 900, 500, 35)
GUICtrlSetFont($label_[2], 20, 600, 2, "Arial")
GuiCtrlCreateGroup("", 50, 200, 1150, 675)
$button_[0] = GuiCtrlCreateButton("-§§§-", @DesktopWidth/2-100, @DesktopHeight/2-35, 100, 35)

GuiSetState()

;-----Display-----
While 1
$msg = GuiGetMsg()
$mousepos= MouseGetPos()

If $msg = $button_[0] then 
$count = $count+1
Endif
if $msg = $GUI_EVENT_CLOSE Then Exitloop
    
Wend

The buton count thing doesn't work either,

any help?

GUICtrlSetPos()...
Link to comment
Share on other sites

I wanna make a moving Gui button that runs away from your mouseso if you move you mouse one way, it will move away, until it hits the End of the screen area and then maybe it moves to other side, or goes to the middle and continues,

I made a GUI to use for it, but i can't get the button to work right, i've tried but all attempts fail

heres code

CODE

;-----Include-----

#include <GuiConstants.au3>

;-----Variabales-----

Global $count=0, $button_[1], $label_[4], $left, $top, $mouseleft, $mousetop

;-----Hotkeys-----

#cs

HotKeyset("werty", "Terminate")

#ce

;-----GUI-----

$wind = GuiCreate("", @DesktopWidth, @DesktopHeight,-1, -1, $WS_POPUP, $WS_EX_TOPMOST)

GuiSetBkColor("0xcccccc")

$label_[0] = GUICtrlCreateLabel("The Annoying Game", @DesktopWidth/2-325, 50, 800, 100)

GUICtrlSetFont($label_[0], 50, 500, 4, "Arial")

$label_[1] = GuiCtrlCreateLabel("If you want this message to go away, click the button below.", @DesktopWidth/2-150, 150, 500, 35)

GUICtrlSetFont($label_[1], 12, 300, 2, "Arial")

$label_[2] = GuiCtrlCreateLabel("You've Clicked The Button: " & $count & "/10 Times", 50, 900, 500, 35)

GUICtrlSetFont($label_[2], 20, 600, 2, "Arial")

GuiCtrlCreateGroup("", 50, 200, 1150, 675)

$button_[0] = GuiCtrlCreateButton("-§§§-", @DesktopWidth/2-100, @DesktopHeight/2-35, 100, 35)

GuiSetState()

;-----Display-----

While 1

$msg = GuiGetMsg()

$mousepos= MouseGetPos()

If $msg = $button_[0] then

$count = $count+1

Endif

if $msg = $GUI_EVENT_CLOSE Then Exitloop

Wend

The buton count thing doesn't work either,

any help?

This does not do exactly what you want, but it demonstrates what you need. It will update the count if you manage to click on the button, and it updates the position of the button relative the the mouse. That at least moves the ball forward for you...

;-----Include-----
#include <GuiConstants.au3>

;-----Variabales-----
Global $count = 0, $button_[1], $label_[4], $left, $top, $mouseleft, $mousetop

;-----GUI-----
$wind = GUICreate("", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor("0xcccccc")
$label_[0] = GUICtrlCreateLabel("The Annoying Game", @DesktopWidth / 2 - 325, 50, 800, 100)
GUICtrlSetFont($label_[0], 50, 500, 4, "Arial")
$label_[1] = GUICtrlCreateLabel("If you want this message to go away, click the button below.", @DesktopWidth / 2 - 150, 150, 500, 35)
GUICtrlSetFont($label_[1], 12, 300, 2, "Arial")
$label_[2] = GUICtrlCreateLabel("You've Clicked The Button: " & $count & "/10 Times", 50, 900, 500, 35)
GUICtrlSetFont($label_[2], 20, 600, 2, "Arial")
GUICtrlCreateGroup("", 50, 200, 1150, 675)
$button_[0] = GUICtrlCreateButton("-§§§-", @DesktopWidth / 2 - 100, @DesktopHeight / 2 - 35, 100, 35)

GUISetState()

;-----Display-----
While 1
    $msg = GUIGetMsg()
    $mousepos = MouseGetPos()
    GUICtrlSetPos($button_[0], $mousepos[0] + 50, $mousepos[1] + 50)
    If $msg = $button_[0] Then
        $count += 1
        GUICtrlSetData($label_[2], "You've Clicked The Button: " & $count & "/10 Times")
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

:D

Edit: Beaten to it by camronsdad... ncurses!

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...