Sign in to follow this  
Followers 0
Trequarta

Read out to GUI box. Newbie

7 posts in this topic

Hey I'm attempting to overall make a script to create a gui box (which I understand how to do) with a button that I click then it collects the location of the cursor so i'm using mousegetpos() and the color of the pixel of the cursor with pixelgetcolor. I however do not know how to add it in. I'd like best to have them appear in individual labeled boxes,(which im sure i can figure out) I apologize if this is posted somewhere else I couldn't find it in search. Any help is appreciated,

Share this post


Link to post
Share on other sites



Trequarta.

Welcome to the AutoIt forum. :)

If you look at the example for GUICtrlCreateButton in the Help file you will see how to detect a button being clicked. In the example the buttons run Notepad and open a MsgBox - what you will need to do is to run the 2 functions you want instead. You should store the return values from these functions into variables so that you can use them in the next part.

You say you want the values you get from your functions to appear in labelled boxes in you GUI - you need to add these controls to the GUI yourself when you create it using GUICtrlCreateLabel. Then when you get values returned from the functions you can display them in the labels using [GUICtrlSetData.

As you can see, nothing too difficult. So give it a go and see what you can come up with - you know where we are if you run into problems. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

So this is what I have made so far reading tutorials and attempting a with a basic understanding. I see more about how to use the GuiCtrlSetData, Now I know the code reads top to bottom, This is the exact part I am having difficulty understanding. I have 4 boxes, So when I click my "Take Measurements button I want it to wait 5 seconds (used sleep) then take mouse cursor and print out to the box A in a $pos[0] "," $pos[1] format. (i know i have 2 seperate boxes but I can always change the labels to make the x/y into one box.) Sorry if this is difficult to understand.

#cs ----------------------------------------------------------------------------

Author: Trequarta

#ce ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>

GUICreate("Trequarta's Bot", 500, 200)

GUISetState(@SW_SHOW)

GUICtrlCreateLabel("X Cord",8,10)

$key1 = GUICtrlCreateInput("", 45,8,120)

GUICtrlCreateLabel("Y Cord",8,44)

$key2 = GUICtrlCreateInput("", 45,44,120)

GUICtrlCreateLabel("Color",8,80)

$key3 = GUICtrlCreateInput("", 45,80,120)

GUICtrlCreateLabel("?",8,116)

$key4 = GUICtrlCreateInput("", 45,116,120)

$startbutton = GUICtrlCreateButton("Take Measurement",190,8,200)

$count = 0

$key1 = MouseGetPos()

While 1

Switch GUIGetMsg()

Case $startbutton

If $count = 1 Then

GUICtrlSetData($startbutton, "Start")

sleep(5000)

GUICtrlSetData($key1, $pos[0] "," $pos[1])

$count = 0

ElseIf $count = 0 Then

GUICtrlSetData($startbutton, "Stop")

$count = 1

EndIf

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEND

While 1

sleep(1)

WEnd

Share this post


Link to post
Share on other sites

I got closer to what I was working toward with this. Not perfect but usable

#cs ----------------------------------------------------------------------------

Author: Trequarta

#ce ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>

GUICreate("Trequarta's Bot", 500, 200)

GUISetState(@SW_SHOW)

$startbutton = GUICtrlCreateButton("Take Measurement",190,8,200)

$count = 0

While 1

Switch GUIGetMsg()

Case $startbutton

If $count = 1 Then

GUICtrlSetData($startbutton, "Start")

$pos = MouseGetPos()

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

GUICtrlCreateLabel("X Cord",8,10)

$key1 = GUICtrlCreateInput($pos[0], 45,8,120)

GUICtrlCreateLabel("Y Cord",8,44)

$key2 = GUICtrlCreateInput($pos[1], 45,44,120)

GUICtrlCreateLabel("Dec",8,80)

$key3 = GUICtrlCreateInput($var, 45,80,120)

GUICtrlCreateLabel("Hex",8,116)

$key4 = GUICtrlCreateInput(hex($var, 6),45,116,120)

$count = 0

ElseIf $count = 0 Then

sleep(5000)

GUICtrlSetData($startbutton, "Stop")

$count = 1

EndIf

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#include <GUIConstantsEx.au3>

HotKeySet('^p', '_SetData' )

WinSetOnTop( GUICreate("Trequarta's Bot", 500, 200), '' , 1 )
GUISetState()


Global $startbutton = GUICtrlCreateButton("Take Measurement", 190, 8, 200)
GUICtrlCreateLabel("", 8, 10, 100, 15)
GUICtrlCreateLabel("", 8, 44, 100, 15)
GUICtrlCreateLabel("", 8, 74, 100, 15)
$count = 0

While 1
Switch GUIGetMsg()
Case $startbutton
_SetData()

Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

Func _SetData()

$pos = MouseGetPos()
GUICtrlSetData( $startbutton + 1, "X Cord: " & $pos[0] ) ;X Pos | $startbutton + 1 : the control created after startbutton
GUICtrlSetData( $startbutton + 2, "Y Cord: " & $pos[1] ) ;Y Pos

GUICtrlSetData( $startbutton + 3, "Color: " & Hex( PixelGetColor($pos[0], $pos[1]), 6 ) );Color

EndFunc

Added the code ! (use "[autoit]" tags to get such code style )

Pressing Ctrl + P will also perform the check

The GUI is set on top

Regards :)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

PhoenixXL,

Merely using the word "bot" is not illegal - only when the code evidently interacts with a game does a script break the rules. In this case I see no obvious interaction so I am happy for you to help for the moment. :)

M23

Edited by Melba23
Fixed BB tags

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Added the code !


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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