Jump to content

Keeps Drawing the GUI


Recommended Posts

I have a bit of code that creates a visible box around a scan area, so the user can see where they are moving the scan area to. However, it just keeps drawing itself over and over and over.

Here's the code.

Case $msg = $move
            Stop()
            $MoveMode = True
            While 1
                
    $Top = GUICreate("Top Line", $ScanWidth, 2,$x,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Left = GUICreate("Left Line", 2, $ScanHeight,$x,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Right = GUICreate("Right Line", 2, $ScanHeight,$x + $ScanWidth - 2,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Bottom = GUICreate("Bottom Line", $ScanWidth, 2,$x,$y + 40 + $ScanHeight,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    
                
                $MousePos = MouseGetPos()
                WinMove($GUI,"", $MousePos[0],$MousePos[1])
                
                WinMove($Top,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Left,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Right,"", $MousePos[0]+ $ScanWidth - 2,$MousePos[1]+40)
                WinMove($Bottom,"", $MousePos[0],$MousePos[1]+ 40 + $ScanHeight)
                
                $x = $MousePos[0]
                $y = $MousePos[1]
                
                If _IsPressed(01) Then
                    ExitLoop
                EndIf
            WEnd
Link to comment
Share on other sites

Messy..

Case $msg = $move
            Stop()
            $MoveMode = True
               
    $Top = GUICreate("Top Line", $ScanWidth, 2,$x,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Left = GUICreate("Left Line", 2, $ScanHeight,$x,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Right = GUICreate("Right Line", 2, $ScanHeight,$x + $ScanWidth - 2,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Bottom = GUICreate("Bottom Line", $ScanWidth, 2,$x,$y + 40 + $ScanHeight,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
   
               While $Movemode
                $MousePos = MouseGetPos()
                WinMove($GUI,"", $MousePos[0],$MousePos[1])
               
                WinMove($Top,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Left,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Right,"", $MousePos[0]+ $ScanWidth - 2,$MousePos[1]+40)
                WinMove($Bottom,"", $MousePos[0],$MousePos[1]+ 40 + $ScanHeight)
               
                $x = $MousePos[0]
                $y = $MousePos[1]
               
                If _IsPressed(01) Then
                    ExitLoop
                EndIf
            WEnd
Link to comment
Share on other sites

Could you show the entire script please? All I can tell from here is that you don't have an EndSelect or EndSwitch, depending on which one you're doing.

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Link to comment
Share on other sites

I just fixed it from drawing forever by moving it outside the While 1 ...

like this

Case $msg = $move
            Stop()
            $MoveMode = True
    $Top = GUICreate("Top Line", $ScanWidth, 2,$x,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Left = GUICreate("Left Line", 2, $ScanHeight,$x,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Right = GUICreate("Right Line", 2, $ScanHeight,$x + $ScanWidth - 2,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Bottom = GUICreate("Bottom Line", $ScanWidth, 2,$x,$y + 40 + $ScanHeight,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
            While 1         
                
                $MousePos = MouseGetPos()
                WinMove($GUI,"", $MousePos[0],$MousePos[1])
                
                WinMove($Top,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Left,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Right,"", $MousePos[0]+ $ScanWidth - 2,$MousePos[1]+40)
                WinMove($Bottom,"", $MousePos[0],$MousePos[1]+ 40 + $ScanHeight)
                
                $x = $MousePos[0]
                $y = $MousePos[1]
                
                If _IsPressed(01) Then
                    ExitLoop
                EndIf
            WEnd

But now it won't erase the gui once the move has finished.

Edited by inline853
Link to comment
Share on other sites

i wrote it elsewhere, then pasted where i thought it fit ... not a good idea i guess.

if you could explain how to make my scripts less messy please do so. =)

See if the code above works for you, what i meant by messy is you should tidy it up.
Link to comment
Share on other sites

Got this to work. =)

Case $msg = $move
            
            Stop()
            
            $MoveMode = True
            
            $Top = GUICreate("Top Line", $ScanWidth, 2,$x,$y + 40,$WS_POPUP,-1,$GUI)
            GUISetBkColor(0xFF0000)
            GUISetState()
            
            $Left = GUICreate("Left Line", 2, $ScanHeight,$x,$y + 40,$WS_POPUP,-1,$GUI)
            GUISetBkColor(0xFF0000)
            GUISetState()
            
            $Right = GUICreate("Right Line", 2, $ScanHeight,$x + $ScanWidth - 2,$y + 40,$WS_POPUP,-1,$GUI)
            GUISetBkColor(0xFF0000)
            GUISetState()
            
            $Bottom = GUICreate("Bottom Line", $ScanWidth, 2,$x,$y + 40 + $ScanHeight,$WS_POPUP,-1,$GUI)
            GUISetBkColor(0xFF0000)
            GUISetState()
            
            While 1         
                $MousePos = MouseGetPos()
                WinMove($GUI,"", $MousePos[0],$MousePos[1])
                
                WinMove($Top,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Left,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Right,"", $MousePos[0]+ $ScanWidth - 2,$MousePos[1]+40)
                WinMove($Bottom,"", $MousePos[0],$MousePos[1]+ 40 + $ScanHeight)
                
                $x = $MousePos[0]
                $y = $MousePos[1]
                
                If _IsPressed(01) Then
                    GuiDelete($Bottom)
                    GuiDelete($Right)
                    GuiDelete($Left)
                    GuiDelete($Top)
                    ExitLoop
                EndIf
            WEnd
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...