polaski Posted July 19, 2015 Posted July 19, 2015 (edited) I`ve got little problem with my drawing script.When detonating that script in paint it just draw a BMP array but flipped by 90 degrees and "mirror image".I was testing it in winXP mspaint. In other systems just place MouseMove it in diffrent place. 150pix x 150 pix Black&White BMP. Can some one just rebuild my arrays to get normal image?expandcollapse popupMouseMove(105,76,1) in other place. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.0 Author: polaski Marcin PRzyborowski Script Function: Convert BMP image into Array[x,y]=[Hex colour] https://www.autoitscript.com/forum/topic/112540-is-there-a-function-for-reading-images-into-2d-arrays/?do=findComment&comment=788472 https://www.autoitscript.com/forum/topic/27362-bitmap-library/ script create an 2d Matrix. #ce ---------------------------------------------------------------------------- #include <BMP3.au3> ;https://www.autoitscript.com/forum/topic/27362-bitmap-library/ #include <Array.au3> #include <File.au3> ;;;;;;;;;;;;;;;;;hotkeye;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Press Esc to terminate script, Pause/Break to "pause" Global $g_bPaused = False HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ;While 1 ; Sleep(100) ;WEnd Func TogglePause() $g_bPaused = Not $g_bPaused While $g_bPaused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit EndFunc ;==>Terminate ;;;;;;;;;;;;;;;;;hotkey end;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Global $Paused Local $filename = FileOpenDialog("Select image", @DesktopCommonDir, "All images (*.jpg;*.png;*.gif;*.bmp;)", 1) $bmp = _BMPOpen($filename,1) ;zwraca uchwyt do bitmapy która otworzylismy. Dim $tab3d[$bmp[1]][$bmp[2]] ;tablica o wymiarach bitmapy ;;;pętla zbierająca pixele;;;; For $j = 0 To $bmp[1] - 1 For $i = 0 To $bmp[2] - 1 $tab3d[$j][$i]=_PixelRead($bmp,$j,$i) Next Next ;hójowa tablica 6 na 6 Global $glebokosc = 0 Global $kolor = 0 Global $pamiec = 0 Global $w1 call(start) call (czytaj) func start() If WinExists("[CLASS:MSPaintApp]") Then WinKill("[CLASS:MSPaintApp]", "") ;WinKill("Kolko i Krzyzyk") EndIf Run("mspaint.exe") $hWnd = WinWait("[CLASS:MSPaintApp]", "",2) sleep(2000) WinMove("[CLASS:MSPaintApp]", "", 0, 0, 1000, 1000) Sleep(10000) MouseMove(105,76,1) EndFunc func czytaj() For $j = 0 to $bmp[1] - 1 $w1=MouseGetPos() For $i = 0 To $bmp[2] - 1 $pamiec=$glebokosc ;$kolor=$tab3d[$j][$i] if $tab3d[$j][$i]='000000' Then call(wierc) while $i < $bmp[2]-1 And $tab3d[$j][$i]=$tab3d[$j][$i+1] $i=$i+1 ;if $i=$bmp[2] then ExitLoop ;if $i=$bmp[2]-1 then ExitLoop ;_ArrayDisplay ($tab3d) MouseDown ( "left" ) call(posowaj) WEnd MouseUP ("left") call(wyciagaj) call(posowaj) EndIf if $tab3d[$j][$i]='FFFFFF' Then call(posowaj) EndIf Next call(wroc) Next EndFunc Func wierc() Local $w2=mousegetpos() MouseClick ("left", $w2[0],$w2[1] , 1 , 1 ) ;beep(300,300) EndFunc Func wyciagaj() Local $w2=mousegetpos() ;MouseClick ("right", $w2[0],$w2[1] , 1 , 1 ) ;beep(800,300) EndFunc Func posowaj() Local $w2=mousegetpos() MouseMove ($w2[0]+2,$w2[1] , 0 ) EndFunc func wroc() MouseMove ( $w1[0],$w1[1]+2 , 0 ) EndFunc Edited July 19, 2015 by polaski
JohnOne Posted July 19, 2015 Posted July 19, 2015 Your script does not work, $g_bPaused is not declared. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
polaski Posted July 19, 2015 Author Posted July 19, 2015 (edited) Now Declared. It should Pause now.I added image that worsk with that script. imagemirror.bmp Edited July 19, 2015 by polaski
LarsJ Posted July 19, 2015 Posted July 19, 2015 Try this code:expandcollapse popup#include <BMP3.au3> ;https://www.autoitscript.com/forum/topic/27362-bitmap-library/ #include <Array.au3> #include <File.au3> Global $g_bPaused = False HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") Func TogglePause() $g_bPaused = Not $g_bPaused While $g_bPaused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc Func Terminate() Exit EndFunc Local $filename = FileOpenDialog("Select image", @DesktopCommonDir, "All images (*.jpg;*.png;*.gif;*.bmp;)", 1) $bmp = _BMPOpen($filename,1) ;zwraca uchwyt do bitmapy która otworzylismy. Dim $tab3d[$bmp[2]][$bmp[1]] For $i = 0 To $bmp[1] - 1 For $j = 0 To $bmp[2] - 1 $tab3d[$j][$i]=_PixelRead($bmp,$i,$j) Next Next If WinExists("[CLASS:MSPaintApp]") Then _ WinKill("[CLASS:MSPaintApp]", "") Run("mspaint.exe") $hWnd = WinWait("[CLASS:MSPaintApp]", "",2) sleep(200) WinMove("[CLASS:MSPaintApp]", "", 0, 0, 1000, 1000) Sleep(200) MouseMove(105,76,1) Local $w1, $w2 For $i = 0 to $bmp[2] - 1 $w1=MouseGetPos() For $j = 0 To $bmp[1] - 1 if $tab3d[$i][$j]='000000' Then Local $w2=MouseGetPos() MouseClick( "left", $w2[0],$w2[1], 1, 1 ) while $j < $bmp[2]-1 And $tab3d[$i][$j] = $tab3d[$i][$j+1] $j += 1 MouseDown( "left" ) $w2 = MouseGetPos() MouseMove( $w2[0]+2, $w2[1], 0 ) WEnd MouseUp("left") $w2 = MouseGetPos() MouseMove( $w2[0]+2, $w2[1], 0 ) EndIf if $tab3d[$i][$j]='FFFFFF' Then $w2 = MouseGetPos() MouseMove( $w2[0]+2, $w2[1], 0 ) EndIf Next MouseMove( $w1[0], $w1[1]+2, 0 ) Next polaski 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
polaski Posted July 20, 2015 Author Posted July 20, 2015 Thanks. Solved. I will try to use that code to program my CNC drill .It helps me alot to understand: how read arrays better.
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