Sign in to follow this  
Followers 0
pezo89

Requesting help with my codes

3 posts in this topic

Due to the first post where sort of a mess iv reposted it

I have this code for a farmtown script

And iv made an GUI for it, so ppl do not need to go into the basecode to change the X & Y pos of the diamond scan,

This GUI also has a X &Y pos viewer on it, but my problem per todays date is that I cannot get the input fields (Left X, Left Y, Top Left, Top Y, Right X, Right Y bottom X, Bottom Y) into the code itself

What im after is that when someone is inputting something in the boxes it should change this line

_DiamondScan(276, 431, 885, 125, 1484, 430, 881, 735)

Each number is a X-Y pos for the scan itself

Below u have the GUI code (I know an error there I cannot figure out, opening two windows =/)

And the code,

Is there anyone out there who could be so kind to explain me how to do it?, or do it for me?

I need the gui also to do some events upon OK & Cancel

Ok = Starts the script

Cancel = exits the script

The GUI code

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Andreas Walseng\Desktop\koda_1.7.2.1_b191_2009-07-09\Forms\farmtown.kxf
$Form1 = GUICreate("FarmTown Replant script", 378, 193, 320, 253, BitOR($WS_POPUP,$WS_CLIPSIBLINGS))
GUISetIcon("D:\004.ico")
$GroupBox1 = GUICtrlCreateGroup("", 0, 1, 281, 193)
$LEFT = GUICtrlCreateInput("LEFT X", 0, 8, 121, 21)                     ;<<<Left X
$RIGHT = GUICtrlCreateInput("RIGHT X", 144, 8, 121, 21)                 ;<<<Right X
$BOTTOM = GUICtrlCreateInput("BOTTOM X", 144, 72, 121, 21)              ;<<<Bottom X
$Label3 = GUICtrlCreateLabel("Made by Andreas W ", 64, 152, 104, 17)
$Label1 = GUICtrlCreateLabel("Copyright 2009", 63, 172, 75, 17)
$Input1 = GUICtrlCreateInput("LEFT Y", 0, 30, 121, 21)                  ;<<<Left Y
$Input2 = GUICtrlCreateInput("RIGHT Y", 144, 29, 121, 21)               ;<<<Right Y
$Input3 = GUICtrlCreateInput("BOTTOM Y", 142, 95, 121, 21)              ;<<<Bottom Y
$Input4 = GUICtrlCreateInput("TOP X", 4, 75, 121, 21)                   ;<<<Top X
$Input5 = GUICtrlCreateInput("TOP Y", 5, 97, 121, 21)                   ;<<<Top Y
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("&OK", 286, 35, 75, 25, BitOR($BS_FLAT,$WS_GROUP))     ;<<<Ok button

$Button2 = GUICtrlCreateButton("&Cancel", 285, 76, 75, 25, BitOR($BS_FLAT,$WS_GROUP)) ; <<<Cancel button
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#include <GuiConstants.au3>


$label = GUICtrlCreateLabel("Mousepos",285, 140, 75, 25, BitOR($BS_FLAT,$WS_GROUP))
$GUI = GUICreate("Cords",285, 76, 75, 25, BitOR($BS_FLAT,$WS_GROUP))
GUISetState()

While 1
    $pos = MouseGetPos()
    $control = WinGetPos($GUI)
    GUICtrlSetData($label,"x "&$pos[0]&" --- y "&$pos[1])
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

Exit
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button2

EndSwitch
WEnd

The Script itself

Global $Paused sleep ("1000") HotKeySet("{Pause}", "TogglePause") HotKeySet("{Insert}", "Terminate") sleep ("2000")   send ("{Pause}")  ; Opt("MouseClickDelay", 2) ; adjust as needed ; Alters the length of the brief pause in between mouse clicks. ; Time in milliseconds to pause (default=10).  Opt("MouseClickDownDelay", 2) ; adjust as needed ; Alters the length a click is held down before release. ; Time in milliseconds to pause (default=10).  HotKeySet("{ESC}", "Terminate")  _DiamondScan(276, 431, 885, 125, 1484, 430, 881, 735)   ; For Diamond shape $xL, $yL - Left x,y coordinate etc. Func _DiamondScan($xL, $yL, $xTop, $yTop, $xR, $tR, $xB, $yB, $xSpacing = 100, $ySpacing = 100)     Local $width = $xR - $xL     Local $Height = $yB - $yTop     Local $rat = $width / $Height     Local $x1, $y1, $Grad = ($Height - $Height / $rat) / ($width - $width / $rat)     ConsoleWrite("$Height " & $Height & @CRLF)     ConsoleWrite("@DesktopWidth / 2 " & $width / $rat & @CRLF)     For $y = $Height To $Height / $rat Step -Int(($Height - $Height / $rat) / $ySpacing)         For $x = ($width / $rat) To $width Step Int(($width - $width / $rat) / $xSpacing)               $x1 = $x + ($y - $Height) / $Grad + $xL             $y1 = $y - ($x - $width / $rat) * $Grad + $yTop              ;MouseClick("left", $x1, $y1, 1, 0)             mouseclick("Left", $x1, $y1, 1,1)         Next     Next    sleep (3000)    mouseclick ("Left", 1122, 16,2) EndFunc   ;==>_DiamondScan  Func Terminate()     Exit 0 EndFunc   ;==>Terminate ;        Func TogglePause()     $Paused = NOT $Paused     While $Paused         sleep(100)         ;toolTip('Script -  "Scriptet er - AV"',0, 40)     WEnd     ToolTip("") EndFunc

Share this post


Link to post
Share on other sites



You need to use GuiCtrtlRead to read the contents of the edits, and you could have a while loop something like this.

While 1
    $pos = MouseGetPos()
    $control = WinGetPos($GUI)
    GUICtrlSetData($label, "x " & $pos[0] & " --- y " & $pos[1])
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop

        Case $Button1
            _DiamondScan(GUICtrlRead($Left), GUICtrlRead($Input1),... etc

    EndSwitch
WEnd

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I'm working on a similar project

I chose to have the GUI create an ini file from the input fields

The idea is to then have the script retrieve the variable values from that ini file (although I am still researching how to do this)

Hope it helps you


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

Monkey's are, like, natures humans.

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  
Followers 0