Jump to content
Sign in to follow this  
PantZ4

Update problem?

Recommended Posts

PantZ4

I have made a little box you can move around - well that was the plan was. For some reason it can't move out from it's starting position.

Code:

#include <GUIConstants.au3>
#include <Misc.au3>

$ShowBox = ""
$ShowBoxWidth = 50
$ShowBoxHeight = 50

$ShowBox = GUICreate('Show Box',$ShowBoxWidth,$ShowBoxHeight,0,0, $WS_POPUP+$WS_SIZEBOX,$WS_EX_TOPMOST+$WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)
GUISetCursor(9,0,$ShowBox)

While 1
    $TempMousePosition = MouseGetPos()
    $TempGUIPosition = WinGetPos($ShowBox)
    If (_IsPressed("01") Or _IsPressed("02")) And $TempMousePosition[0] > $TempGUIPosition[0] And $TempMousePosition[0] < $TempGUIPosition[2] And $TempMousePosition[1] > $TempGUIPosition[1] And $TempMousePosition[1] < $TempGUIPosition[3] Then
        WinMove($ShowBox,"",$TempMousePosition[0]-($TempGUIPosition[2]/2),$TempMousePosition[1]-($TempGUIPosition[3]/2))
        ToolTip("X "&$TempGUIPosition[0]&" | Y "&$TempGUIPosition[1])
    EndIf
    Sleep(10)
WEnd

If you try to drag the box below the 50 width and height, it will stop. And it does not help you drop it at the edge and pick it up again. It won't move from there!

Can someone tell me what I'm doing wrong?

Share this post


Link to post
Share on other sites
SmOke_N

I think you have "And" mixed up with "Or"

#include <GUIConstants.au3>
#include <Misc.au3>

$ShowBox = ""
$ShowBoxWidth = 50
$ShowBoxHeight = 50

$ShowBox = GUICreate('Show Box',$ShowBoxWidth,$ShowBoxHeight,0,0, $WS_POPUP+$WS_SIZEBOX,$WS_EX_TOPMOST+$WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)
GUISetCursor(9,0,$ShowBox)

While 1
    $aMpos = MouseGetPos()
    $aWpos = WinGetPos($ShowBox)
    If (_IsPressed("01") Or _IsPressed("02")) Then
        If ($aMpos[0] >= $aWpos[0] Or _
            $aMpos[0] <= $aWpos[2]) Or _
            ($aMpos[1] >= $aWpos[1] Or _
            $aMpos[1] <= $aWpos[3]) Then
            WinMove($ShowBox,"",$aMpos[0]-($aWpos[2]/1.5),$aMpos[1]-($aWpos[3]/1.5))
            ToolTip("X "&$aWpos[0]&" | Y "&$aWpos[1])
        EndIf
    EndIf
    Sleep(10)
WEnd


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
PantZ4

I think you have "And" mixed up with "Or"

#include <GUIConstants.au3>
#include <Misc.au3>

$ShowBox = ""
$ShowBoxWidth = 50
$ShowBoxHeight = 50

$ShowBox = GUICreate('Show Box',$ShowBoxWidth,$ShowBoxHeight,0,0, $WS_POPUP+$WS_SIZEBOX,$WS_EX_TOPMOST+$WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)
GUISetCursor(9,0,$ShowBox)

While 1
    $aMpos = MouseGetPos()
    $aWpos = WinGetPos($ShowBox)
    If (_IsPressed("01") Or _IsPressed("02")) Then
        If ($aMpos[0] >= $aWpos[0] Or _
            $aMpos[0] <= $aWpos[2]) Or _
            ($aMpos[1] >= $aWpos[1] Or _
            $aMpos[1] <= $aWpos[3]) Then
            WinMove($ShowBox,"",$aMpos[0]-($aWpos[2]/1.5),$aMpos[1]-($aWpos[3]/1.5))
            ToolTip("X "&$aWpos[0]&" | Y "&$aWpos[1])
        EndIf
    EndIf
    Sleep(10)
WEnd
Well now it moves anywere you click, but thanks. I will try and see if I can fix that :rolleyes:.

Share this post


Link to post
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
Sign in to follow this  

×