nusaki Posted June 26, 2009 Share Posted June 26, 2009 Hey how can I make Autoit to write in its own GUICtrlCreateInput. Here is example of my script #include <GUIConstants.au3> GUICreate("bot", 210, 200) $called = GUICtrlCreateInput ($pizza, 140, 70, 50, 25) $lab = GUICtrlCreateLabel("pizzas:", 50, 70, 80, 20) GUISetState(@SW_SHOW) while 1 $1col1=pixelgetcolor(10,10) If $1col1=16777215 Then $pizza=1 EndIf WEnd I want my program to look at pixel and when it finds right color, enter its value in an input box. However, I cant leave it like this, because value wasnt declared before hand. And if I do declare it in the begging then it starts going back and forth with two values. Any solutions to my problem? (and what is the right way to post scripts) keywen.com Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 26, 2009 Moderators Share Posted June 26, 2009 nusaki,You need to declare your variables first. Then use GUICtrlSetData to change the value in the input:#include <GUIConstants.au3> ; Declare variables $pizza = 0 $1col1 = 0 GUICreate("bot", 210, 200) $called = GUICtrlCreateInput($pizza, 140, 70, 50, 25) $lab = GUICtrlCreateLabel("pizzas:", 50, 70, 80, 20) GUISetState(@SW_SHOW) While 1 ; just for demonstration purposes <<<<<<<< Delete If @SEC = 30 Then $1col1 = 16777215 ;<<<<<<<< Delete ;$1col1 = PixelGetColor(10, 10) <<<<<<<< Uncomment If $1col1 = 16777215 Then $pizza += 1 ; Increase pizza each time GUICtrlSetData($called, $pizza) $1col1 = 0 ;<<<<<<<< Delete; Reset the colour until next time EndIf If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit ;<<<<<<<< Now your [X] button will exit! WEndYou will see that I have changed the code slightly so that it fires once every minute (at :30 to be precise). The lines marked with <<<<<<<<< will need to amended as shown to get your original code back.Two more points:1. If the pixel stays the trigger colour for a while, you will need to have another loop to wait until the pixel is no longer that colour - otherwise you will add to the $pizza variable continuously while the pixel is the trigger colour rather than each time it changes. It will look something like this:If $1col1 = 16777215 Then $pizza += 1 ; Increase pizza count GUICtrlSetData($called, $pizza) Do Sleep(10) ; Important or your CPU maxes out Until $1col1 <> 16777215 ; Loop until the pixel is no longer the trigger colour EndIf2. I added a way to exit using the red [X] - always a good idea. ;-)Ask if anything is unclear.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nusaki Posted June 26, 2009 Author Share Posted June 26, 2009 (edited) Thank you Melba. Check pix every 30 seconds isnt ideal for me. What Im trying to create is a bot that keeps track of a pot for online poker game and that number is increasing every second or so. So as number increase in a poker game it should simultaneously increase in my bot. Also here is another problem Pot amount isn't always showing is here way to keep old number untill it start showing again. I wanted to use GUICtrlCreateInput because its easy to copy and paste. So my Idea was to use GetColor and identify number and once its identified write it in GUICtrlCreateInput and keep it there as long as it doesnt change. May be you know a better way to insert number in GUICtrlCreateInput?? Or may be I should use a different approach? Edited June 26, 2009 by nusaki keywen.com Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 26, 2009 Moderators Share Posted June 26, 2009 nusaki,My apologies if I confused you - the 30sec timer was only to show you how the input value can be changed.As I tried to explain earlier, you can reset the code so that it will only increase the $pizza number when the colour changes at pixel (10, 10):#include <GUIConstantsEx.au3> $pizza = 0 $1col1 = 0 GUICreate("bot", 210, 200) $called = GUICtrlCreateInput($pizza, 140, 70, 50, 25) $lab = GUICtrlCreateLabel("pizzas:", 50, 70, 80, 20) GUISetState(@SW_SHOW) While 1 $1col1 = PixelGetColor(10, 10) If $1col1 = 16777215 Then $pizza += 1 ; Increase pizza count GUICtrlSetData($called, $pizza) Do If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit Until $1col1 <> 16777215 ; Loop until the pixel is no longer the trigger colour EndIf If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEndHowever, if you are trying to keep track of a number on screen, I do not believe this is best way to do it. There are numerous topics on reading from screens - try searching! :-)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now