Jump to content

Recommended Posts

Posted (edited)

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 169, 31, 192, 114)
$Label1 = GUICtrlCreateLabel("P X", 8, 8, 18, 17)
$Label2 = GUICtrlCreateLabel("P Y", 48, 8, 18, 17)
$Input1 = GUICtrlCreateInput("Pixel Color", 96, 8, 41, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
HotKeySet ("{F2}", "Fun") ;;First Check Positions and color
HotKeySet ("{F1}", "Relat") ;;Write Positions and color thats at Labels
HotKeySet ("{F3}", "Test") ;;Ingnore.

$ok=1
While 1
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
            Case $GUI_EVENT_CLOSE
            Exit
        Case $ok=1
        $Aposx = GUICtrlRead($Label1)
        $Aposy = GUICtrlRead($Label2)
        $Acolor = GUICtrlRead($Input1)
        
            

    EndSwitch
WEnd

Func Fun() ;;This is the problem.
$pos = MouseGetPos()
$var = PixelGetColor( $pos[0] , $pos[1] )
$M1 = ($pos[0])
$Label1 = GUICtrlCreateLabel($pos[0], 8, 8, 18, 17)
$Label2 = GUICtrlCreateLabel($pos[1] , 48, 8, 18, 17)
$Input1 = GUICtrlCreateInput($var, 96, 8, 41, 21)
EndFunc

Func Relat() ;; This is OK.
    Send ("Mouse Pos x ")
    Send ("{SPACE}")
    Send ($Aposx)
    Send ("{ENTER}")
    Send ("Mouse Pos y ")
    Send ("{SPACE}")
    Send ($Aposy)
    Send ("{ENTER}")
    Send ("Pixel Color")
    Send ("{SPACE}")
    Send ($Acolor)
EndFunc

Func Test() ;;Ignore.

EndFunc

This is a lil program that I'm trying to do, F2 get mouse positions and color and F1 write it, it's ok but I think theres a problem in this part:

Func Fun() ;;This is the problem.
$pos = MouseGetPos()
$var = PixelGetColor( $pos[0] , $pos[1] )
$M1 = ($pos[0])
[b]$Label1 = GUICtrlCreateLabel($pos[0], 8, 8, 18, 17)
$Label2 = GUICtrlCreateLabel($pos[1] , 48, 8, 18, 17)
$Input1 = GUICtrlCreateInput($var, 96, 8, 41, 21)[/b]
EndFunc

This is creating new Labels everytime that I hit F2.

So, i don't know if theres a way to only change the "text" at guis instead create a new one everytime or just atualize this text for example, when i move my mouse and turn this a dynamic text or w/e, gotcha?

Can some1 have any idea?

Edited by TribO
Posted

If the labels and input is already created, then you just need to use GuiCtrlSetData instead of creating a new label

But how do exactly I set it here?

Func Fun() ;;This is the problem.

$pos = MouseGetPos()

$var = PixelGetColor( $pos[0] , $pos[1] )

$M1 = ($pos[0])

$Label1 = GUICtrlCreateLabel($pos[0], 8, 8, 18, 17)

$Label2 = GUICtrlCreateLabel($pos[1] , 48, 8, 18, 17)

$Input1 = GUICtrlCreateInput($var, 96, 8, 41, 21)

EndFunc

Ty for reply.

Posted

But how do exactly I set it here?

Func Fun() ;;This is the problem.

$pos = MouseGetPos()

$var = PixelGetColor( $pos[0] , $pos[1] )

$M1 = ($pos[0])

$Label1 = GUICtrlCreateLabel($pos[0], 8, 8, 18, 17)

$Label2 = GUICtrlCreateLabel($pos[1] , 48, 8, 18, 17)

$Input1 = GUICtrlCreateInput($var, 96, 8, 41, 21)

EndFunc

Ty for reply.

if when your labels and input was first created, they were named $Label1, $Label2 and $Input1

($Label1 = GUICtrlCreateLabel)

then in the func you only need to do

Func Fun() ;;This is the problem.

$pos = MouseGetPos()

$var = PixelGetColor( $pos[0] , $pos[1] )

$M1 = ($pos[0])

GUICtrlSetData($Label1,$pos[0])

GUICtrlSetData($Label2,$pos[1])

GUICtrlSetData($Input1,$var)

EndFunc

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Posted

if when your labels and input was first created, they were named $Label1, $Label2 and $Input1

($Label1 = GUICtrlCreateLabel)

then in the func you only need to do

Func Fun() ;;This is the problem.

$pos = MouseGetPos()

$var = PixelGetColor( $pos[0] , $pos[1] )

$M1 = ($pos[0])

GUICtrlSetData($Label1,$pos[0])

GUICtrlSetData($Label2,$pos[1])

GUICtrlSetData($Input1,$var)

EndFunc

Thank you very much :mellow:

Tested and worked 100% as I wondering.

ty mate.

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
×
×
  • Create New...