ts29 Posted February 11, 2010 Share Posted February 11, 2010 (edited) Okay. I have copied out a UDF example to try and use in my code, however its a disaster. Please help. I want to create a 2D array that is 6 by 6 in dimensions. Now i want AutoIt to scan 36 pixels on a picture. x x x x x x This is the picture. All the pixels are spaced at the exact same distance apart from every x x x x x x single adjacent pixel. I want AutoIt to scan the colour and store them into the array. x x x x x x x x x x x x x x x x x x x x x x x x Local array [6][6] UDF EXAMPLE Local $iMax=6 Local $i Local $arr[$iMax] = ["1", "2", "3", "4", "5", "6"] For $i = 0 to $iMax - 1 ConsoleWrite($arr[$i] & @LF) Next How do i apply the UDF example to a 6 by 6 array? Thanks in advance. Edited February 11, 2010 by ts29 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2010 Moderators Share Posted February 11, 2010 ts29, Welcome to the AutoIt forum. You need a couple of loops to help you here: #include <Array.au3> Global $aPixelArray[6][6] ; Create a 6x6 array ; You can see that it is currently empty _ArrayDisplay($aPixelArray) $iX = 100 ; Put the top left coordinates of the area you want to scan here $iY = 100 For $x = 0 To 5 $iPixelX = $iX + $x ; We need to convert the loop value (0 To 5) into the screen coordinates For $y = 0 To 5 $iPixelY = $iY + $y ; And the same here ; Now $iPixelX and $iPixelY hold the coordinates of the top left of the area ; As you move through the 2 loops, you move through the area like this: ; 1 7 13 19 ; 2 8 14 ... and so on ; 3 9 ... ; 4 10 ; 5 11 ; 6 12 ; Get the colour of the pixel and store it in the array $aPixelArray[$x][$y] = PixelGetColor($iPixelX, $iPixelY) Next Next ; And here is the array that you have filled _ArrayDisplay($aPixelArray) I think everything is explained in the comments - 2D arrays look a bit intimidating, but they are not really. Please 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...
ts29 Posted February 11, 2010 Author Share Posted February 11, 2010 Wow! You replied very fast with exactly the stuff i was looking for! I will ++rep if its possible later. Thanks! But can i ask for more help =3 How do I make it so that the program starts the coordinate system from ONLY the white area in an empty "Untitled - Notepad" window? Like right below the F in File in Notepad. I dont want to make this program work only on my resolution.. that is why. Under UDF, I found this. Run("notepad.exe") WinWait("[CLASS:Notepad]") Local $hWnd = WinGetHandle("[CLASS:Notepad]") Local $sHWND = String($hWnd) ; Convert to a string WinSetState(HWnd($sHWND), "", @SW_MINIMIZE) Sleep(5000) ; Notepad should be minimized WinClose(HWnd($sHWND)) Does AutoIt let you use the WindowHandle to determine the exact starting top-left coordinates of the white space in Notepad? Once again, Thank You Very Much for your previous post Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2010 Moderators Share Posted February 11, 2010 ts29,You should try opening the Help file...... _WinAPI_ClientToScreen - Converts the client coordinates of a specified point to screen coordinatesSo you would use this to convert from Notepad's client 0,0 to screen coordinates to use in the code above. But read the help page carefully - it is not as easy to use as someof the Autoit commands. 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...
ts29 Posted February 11, 2010 Author Share Posted February 11, 2010 Oh. Heh. I've put together this from multiple sample codes in the help file#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #Include <WinAPI.au3> Opt('MustDeclareVars', 1) Dim $X, $Y, $colour, $hWnd, $sHWND $X=0 $Y=0 Run("notepad.exe") WinWait("[CLASS:Notepad]") Local $hWnd = WinGetHandle("[CLASS:Notepad]") Local $sHWND = String($hWnd) ; Convert to a string Local Const $tpoint = "int X;int Y" _WinAPI_ClientToScreen($sHWND, ByRef $tpoint) <-------- this line, the error points directly to the ByRef $colour = PixelGetColor ( $X , $Y [, $sHWND] ) MsgBox(0, "_WINAPI_ClientToScreen Example", "Colour of client's x,y position: 0,0 is: " & $colour & @LF)When i run the .au3 file i get an Error: Error In ExpressionI could not find documentation for this errorWould you mind helping me look at it? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2010 Moderators Share Posted February 11, 2010 ts29,Go and read the Help page for _WinAPI_ClientToScreen carefully as I suggested. In particular, study the example that is put there expressly to show you how it works. You are not using the correct method at present. You have had a lot of code written for you so far - try and solve this bit yourself. But do come back if you are still stuck in a little while and I will offer some more hints. 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...
ts29 Posted February 11, 2010 Author Share Posted February 11, 2010 (edited) Oh yeah.. I did not read throroughly enough. So a tagpoint actually needs to be defined with a DLLStructCreate, then the values must be set with a DllStructSetData. It all works smoothly now. Thanks. By the way, how come i cannot edit my own previous posts? *EDIT It is 4 posts to edit my own posts This is the proof. Anyway, i tried submitting a feature request via Ticket and i got a rejection due to "Potential Spam" as detected by Akismet. Lol. I was thinking they could make Scite4AutoIt such that when multiple scripts were open, then there could be a small "X" button to close it. But, hey, they dont like the idea. Anyway, here's the code. It's just copy and paste with a bit of change only. Haha. It's barely an achievement #AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WinAPI.au3> Opt('MustDeclareVars', 1) dim $colour _Main() Func _Main() Run("notepad.exe") WinWait("[CLASS:Notepad]") Local $hWnd = WinGetHandle("[CLASS:Notepad]") Local $tpoint = DllStructCreate("int X;int Y") DllStructSetData($tpoint, "X", 0) DllStructSetData($tpoint, "Y", 0) GUISetState(@SW_SHOW) Sleep(1000) _WinAPI_ClientToScreen($hwnd, $tpoint) $colour = PixelGetColor ( 0 , 0 , $hwnd ) ;REMOVE ALL SQ BRACKETS FROM UDF CODES MsgBox(0, "_WINAPI_ClientToScreen Example", "Screen Cordinates of client's x,y position: 0,0 is: " & @LF & _ "X: " & DllStructGetData($tpoint, "X") & @LF & _ "Y: " & DllStructGetData($tpoint, "Y") & @LF & _ "Colour: " & $colour & @LF) EndFunc ;==>_Main Edited February 11, 2010 by ts29 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2010 Moderators Share Posted February 11, 2010 ts29, I knew you could do it! Well done! To keep out undesirable elements, you need a minimum number of posts before you can access certain forum features. I think it is 5 posts to edit your own posts. Not long to go now.... Good luck with the rest of the project - you know where we are if you need a hand. 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...
ts29 Posted February 11, 2010 Author Share Posted February 11, 2010 (edited) I have come to realise it is as important as coding to actually know the exact behaviour you want your program to exhibit, like if window not active, window not maximised, window etcetc blablabla Edited February 11, 2010 by ts29 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2010 Moderators Share Posted February 11, 2010 ts29,Now that is worthy of a round of applause. You have, in my opinion, understood the most important aspect of any form of programming.All you have in front of you is a piece of fused silicon with some rare earth impurities - it cannot read your mind, make assumptions, or correct bad typing. All it does is do what you tell it - so you had best get that right. (Actually AutoIt does try to help you rather more than you realise, but the principle is still holds)You MUST have a good idea of what you are trying to achieve before you start - even to the extent of creating logic flow charts if you are trying to do something reasonably complicated. Otherwise you will soon get lost and your code will rapidly become unmaintainable. I often wonder how many of the scripts we help to "perfect" here could be understood by their creators only a few weeks later. Many of them do not even bother to structure their code in any meaningful way - for some good examples of how it should be done, go and look at the UDFs included with AutoIt.So congratulations for the second time today! I look forward to your future contributions here - they should be interesting... 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...
ts29 Posted February 11, 2010 Author Share Posted February 11, 2010 (edited) Nah.. My contributions wont be anything interesting XD That is, i hope they will, but i doubt it. Autoit is the language i have delved deepest into, and as you can see from above, its not very deep.. Edited February 11, 2010 by ts29 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2010 Moderators Share Posted February 11, 2010 ts29, Pity. 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...
Bert Posted February 11, 2010 Share Posted February 11, 2010 Nah.. My contributions wont be anything interesting XDTo be great, think great. To be poor and dumb, think poor and dumb. I think you can be great.You did well there and picked it up very fast. The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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