PantZ4 Posted June 14, 2007 Share Posted June 14, 2007 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? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 14, 2007 Moderators Share Posted June 14, 2007 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. Link to comment Share on other sites More sharing options...
PantZ4 Posted June 14, 2007 Author Share Posted June 14, 2007 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 . Link to comment Share on other sites More sharing options...
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