Jump to content

Beginner


Recommended Posts

Hi. I am making a program to automate putting sprites together in 1 file instead of several, since it takes many many hours to do manually. This is my first time using autoit, so i don't know very well how it works. The if code part is for testing, and it's exiting as soon as i launch the program with it in there. What am i doing wrong?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\Jonny\Mina dokument\Form1.kxf
$Form1_1 = GUICreate("Settings", 326, 477, 327, 174)
$Label7 = GUICtrlCreateLabel("Screen left X value", 16, 224, 94, 17, $WS_TABSTOP)
$Label6 = GUICtrlCreateLabel("Rows", 16, 168, 31, 17)
$Label5 = GUICtrlCreateLabel("Sprites per row", 16, 144, 74, 17)
$Label4 = GUICtrlCreateLabel("Bottom Y value", 16, 88, 76, 17)
$Label3 = GUICtrlCreateLabel("Top Y value", 16, 64, 62, 17)
$Label2 = GUICtrlCreateLabel("Right side X value", 16, 40, 107, 17)
$Label1 = GUICtrlCreateLabel("Left side X value", 16, 16, 104, 17)
$Button1 = GUICtrlCreateButton("Ok", 136, 424, 49, 25, $WS_GROUP)
$xMin = GUICtrlCreateInput("", 128, 16, 57, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$xMax = GUICtrlCreateInput("", 128, 40, 57, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$yMin = GUICtrlCreateInput("", 128, 64, 57, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$yMax = GUICtrlCreateInput("", 128, 88, 57, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$spritesPerRow = GUICtrlCreateInput("", 104, 144, 49, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$rows = GUICtrlCreateInput("", 104, 168, 49, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$screenLeftX = GUICtrlCreateInput("", 120, 224, 49, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
$Label8 = GUICtrlCreateLabel("Screen top Y value", 16, 248, 95, 17)
$screenTopY = GUICtrlCreateInput("", 120, 248, 49, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$blindSpot = 100

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $xMin
                $dragFromX = $xMin - ($screenLeftX)
        Case $xMax
                $dragToX = $xMax - ($screenLeftX)

        Case $yMin
                $dragFromY = $yMin - ($screenTopY - $blindSpot)
        Case $yMax
                $dragToY = $yMax - ($screenTopY - $blindSpot)

    EndSwitch
if $xMin = 200 Then
   Exit
EndIf

WEnd

Edit:

Also i am now attempting to use the drag function to create a rect, but it's not working. The mouse won't move to the coordinates that i put in. it moves to the same place no matter what.

$blindSpot = 95
$dragFromX = 0
$dragToX = 0
$dragFromY = 0
$dragToY = 0


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $xMin
                $dragFromX = $xMin - ($screenLeftX)
        Case $xMax
                $dragToX = $xMax - ($screenLeftX)

        Case $yMin
                $dragFromY = $yMin - ($screenTopY - $blindSpot)
        Case $yMax
                $dragToY = $yMax - ($screenTopY - $blindSpot)
        Case $Button1
                MouseClickDrag("left",$dragFromX,$dragFromY,$dragToX,$dragToY,0)

    EndSwitch

WEnd

The screenTopY and screenLeftX are negative numbers, so it becomes +. for example $yMax - ($screenTopY - $blindSpot) could be 3 -(-203 - 95) = 3 + 298 = 301. I do not know if this is done within computers, but i tried a different way and it still doesn't work to create a mouseClickDrag function when i'm using these variables.

Link to comment
Share on other sites

http://www.autoitscript.com/wiki/FAQ#When_should_I_bump_my_threads.3F

If you could find time to link me that i'm sure you can find time to tell me what i'm doing wrong in my code. A simple issue like this anyone with basic knowledge of autoit could answer.
Link to comment
Share on other sites

I don't know what more i can say. Input boxes don't take the correct values that i enter. I can write it like this:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $xMin
                $dragFromX = $xMin
        Case $xMax
                $dragToX = $xMax

        Case $yMin
                $dragFromY = $yMin
        Case $yMax
                $dragToY = $yMax
        Case $Button1
                MouseClickDrag("left",$dragFromX,$dragFromY,$dragToX,$dragToY,0)

    EndSwitch

WEnd

And it still won't take the values of xMin etc. The only time that it works is when i don't use input window, but instead just say that dragFromX = value. I believe this is a very simple problem, but i have never used autoit before.

Edited by zippo88
Link to comment
Share on other sites

Im not sure if you have posted all the relevant cade or not

So you have possible stripped the code down.

If you have missed it, take a look at GUICtrlRead().

When you hit the button 1 you need to use it to get the input data from the relevant fields.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Im not sure if you have posted all the relevant cade or not

So you have possible stripped the code down.

If you have missed it, take a look at GUICtrlRead().

When you hit the button 1 you need to use it to get the input data from the relevant fields.

ok i see what you mean with GUICtrlRead(). I will test this.
Link to comment
Share on other sites

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $xMin
                $dragFromX = GUICtrlRead($xMin) - (GUICtrlRead($screenLeftX))
        Case $xMax
                $dragToX = GUICtrlRead($xMax) - (GUICtrlRead($screenLeftX))

        Case $yMin
                $dragFromY = GUICtrlRead($yMin) - (GUICtrlRead($screenTopY) - $blindSpot)
        Case $yMax
                $dragToY = GUICtrlRead($yMax) - (GUICtrlRead($screenTopY) - $blindSpot)

        Case $Button1
                MouseClickDrag("left",$dragFromX,$dragFromY,$dragToX,$dragToY,0)

    EndSwitch

WEnd

This works. thanks :(

Edited by zippo88
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...