Wurschtbrot Posted February 12, 2008 Share Posted February 12, 2008 (edited) Code ATM: ;~ Declare Variable $maxx1 = 873 $maxy1 = 54 $maxx2 = 1018 $maxy2 = 199 $xline = 1 $yrow = 1 #include <GUIConstants.au3> GUICreate("My Main", $maxx2 - $maxx1 + 4, $maxy2 - $maxy1 + 4, 1030, 28) $G = GUICtrlCreateGraphic(2, 2, $maxx2 - $maxx1, $maxy2 - $maxy1) GUICtrlSetBkColor($G, 0x000000) ;~ While 1 GUISetState(@SW_UNLOCK) $yrow = 1 Do $xline = 1 Do GUICtrlSetGraphic($G, $GUI_GR_COLOR, PixelGetColor($maxx1 + $xline, $maxy1 + $yrow)) GUICtrlSetGraphic($G, $GUI_GR_PIXEL, $xline, $yrow) $xline += 1 Until $xline = $maxx2 - $maxx1 $yrow += 1 Until $yrow = $maxy2 - $maxy1 GUISetState() Sleep(2500) ;~ WEnd Problem: it makes layers and i dont want it to atm when u remove the comments on the while loop and change the pic in the coords u will see it.... after i made the "small screenshot" i want to draw 4 lines on it + 1 little moving icon(arrow) Edited February 12, 2008 by Wurschtbrot Link to comment Share on other sites More sharing options...
LokErik Posted February 12, 2008 Share Posted February 12, 2008 CODE$line = 1 $row = 1 #include <GUIConstants.au3> GUICreate("My Main", 141, 141, 351, 251) $G = GUICtrlCreateGraphic(0, 0, 80, 80) GUICtrlSetBkColor($G, 0x000000) ;~ Do ;~ Do GUICtrlSetGraphic($G, $GUI_GR_COLOR, 0xffff00) GUICtrlSetGraphic($G, $GUI_GR_PIXEL, $line, $row) ;~ $row += 1 ;~ Until $row = 5 ;~ $line += 1 ;~ Until $line = 5 GUISetState() While 1 Sleep(500) WEnd If you delete the :~ it will work i think The first error is one step closer to the perfect program. Link to comment Share on other sites More sharing options...
Wurschtbrot Posted February 12, 2008 Author Share Posted February 12, 2008 (edited) CODE$line = 1 $row = 1 #include <GUIConstants.au3> GUICreate("My Main", 141, 141, 351, 251) $G = GUICtrlCreateGraphic(0, 0, 80, 80) GUICtrlSetBkColor($G, 0x000000) ;~ Do ;~ Do GUICtrlSetGraphic($G, $GUI_GR_COLOR, 0xffff00) GUICtrlSetGraphic($G, $GUI_GR_PIXEL, $line, $row) ;~ $row += 1 ;~ Until $row = 5 ;~ $line += 1 ;~ Until $line = 5 GUISetState() While 1 Sleep(500) WEnd If you delete the :~ it will work i think upper script and lower script both the same exept for the line comments ..... the upper does not work the lower one does ... i tested both uharg i smell the error ^^ i need to reset row variable! $line = 1 $row = 1 #include <GUIConstants.au3> GUICreate("My Main", 141, 141, 351, 251) $G = GUICtrlCreateGraphic(0, 0, 80, 80) GUICtrlSetBkColor($G, 0x000000) GUICtrlSetGraphic($G, $GUI_GR_COLOR, 0xffff00) Do $row = 1 Do GUICtrlSetGraphic($G, $GUI_GR_PIXEL, $line, $row) $row += 1 Until $row = 5 $line += 1 Until $line = 5 GUISetState() While 1 Sleep(500) WEnd with this its sloved Edited February 12, 2008 by Wurschtbrot Link to comment Share on other sites More sharing options...
FreeFry Posted February 12, 2008 Share Posted February 12, 2008 (edited) I think it would be better to use for loops instead(no need for global, or "external" variables): For $line = 1 To 5 For $row = 1 To 5 ;... Next Next Also handles the increment if the variables which means less code Edited February 12, 2008 by FreeFry Link to comment Share on other sites More sharing options...
Wurschtbrot Posted February 12, 2008 Author Share Posted February 12, 2008 (edited) I think it would be better to use for loops instead(no need for global, or "external" variables): For $line = 1 To 5 For $row = 1 To 5 ;... Next Next Also handles the increment if the variables which means less code can i update the picture ? it seems to draw it over and over actually making many many layers if i let it run like 5 min its pretty worse ^^ i just want to replace the old layer for now ;~ Declare Variable $maxx1 = 873 $maxy1 = 54 $maxx2 = 1018 $maxy2 = 199 $xline = 1 $yrow = 1 #include <GUIConstants.au3> GUICreate("My Main", 147, 147, 351, 251) $G = GUICtrlCreateGraphic(0, 0, 140, 140) GUICtrlSetBkColor($G, 0x000000) While 1 GUISetState(@SW_UNLOCK) $yrow = 1 Do $xline = 1 Do GUICtrlSetGraphic($G, $GUI_GR_COLOR, PixelGetColor($maxx1 + $xline, $maxy1 + $yrow)) GUICtrlSetGraphic($G, $GUI_GR_PIXEL, $xline, $yrow) $xline += 1 Until $xline = $maxx2 - $maxx1 $yrow += 1 Until $yrow = $maxy2 - $maxy1 GUISetState() Sleep(5500) WEnd later on i want to put an picture layer over it with a moving icon wich moves in a square area wich would hopefully not blast my cpu Edited February 12, 2008 by Wurschtbrot Link to comment Share on other sites More sharing options...
FreeFry Posted February 12, 2008 Share Posted February 12, 2008 You shouldn't put the for loops in a While 1 loop, neither GuiSetState() Link to comment Share on other sites More sharing options...
Siao Posted February 12, 2008 Share Posted February 12, 2008 If what you want to do is copy a part of the screen, why don't you do it properly using API? WinAPI UDF: functions GetDC, BitBlt, ReleaseDC. Or if you don't know how these work and don't want to bother, simply ScreenCapture UDF. "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Wurschtbrot Posted February 12, 2008 Author Share Posted February 12, 2008 You shouldn't put the for loops in a While 1 loop, neither GuiSetState()guiSetstate:without guisetstate in the loop it dosent workLoop:it will be a Func after i finish the script ... Link to comment Share on other sites More sharing options...
Wurschtbrot Posted February 12, 2008 Author Share Posted February 12, 2008 (edited) If what you want to do is copy a part of the screen, why don't you do it properly using API? WinAPI UDF: functions GetDC, BitBlt, ReleaseDC. Or if you don't know how these work and don't want to bother, simply ScreenCapture UDF. never done anyhing with api i have to check/read up first this is all i can imagine doing with a api and i dont think i got it right in that short time and it does not even start :/ maybe i need some more lessons ^^ ;~ Declare Variable $maxx1 = 873 $maxy1 = 54 $maxx2 = 1018 $maxy2 = 199 $xline = 1 $yrow = 1 #include <GUIConstants.au3> GUICreate("My Main", $maxx2 - $maxx1 + 4, $maxy2 - $maxy1 + 4, 1030, 28) $G = GUICtrlCreateGraphic(2, 2, $maxx2 - $maxx1, $maxy2 - $maxy1) GUICtrlSetBkColor($G, 0x000000) #Include <WinAPI.au3> $srcWnd = WinGetHandle("SciTE") $srcDC = _WinAPI_GetDC($scrWnd) $dstWnd = WinGetHandle("My Main") $dstDC = _WinAPI_GetDC($dstWnd) _WinAPI_BitBlt($dstDC, 1030, 28, $maxx2 - $maxx1, $maxy2 - $maxy1, $srcWnd, $maxx1, $maxy1, $SRCCOPY) _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_ReleaseDC($hWnd, $hDC) Edited February 12, 2008 by Wurschtbrot Link to comment Share on other sites More sharing options...
FreeFry Posted February 12, 2008 Share Posted February 12, 2008 I still don't see why they're needed inside the loop... just put em outside the loop, or use a variable to set it just once.. Link to comment Share on other sites More sharing options...
Wurschtbrot Posted February 12, 2008 Author Share Posted February 12, 2008 (edited) I still don't see why they're needed inside the loop... just put em outside the loop, or use a variable to set it just once..without "GUISetState(@SW_UNLOCK)" u cannot change the gui.....i think every time u change the gui u have to use :GUISetState()to display the changeif i take any out(/only use once) of the loop it dosent work as good as bevore Edited February 12, 2008 by Wurschtbrot Link to comment Share on other sites More sharing options...
FreeFry Posted February 12, 2008 Share Posted February 12, 2008 it turns black because you delete the control that the GUICtrlSetGraphic functions try to draw/paint in/to.. Link to comment Share on other sites More sharing options...
Wurschtbrot Posted February 12, 2008 Author Share Posted February 12, 2008 (edited) it turns black because you delete the control that the GUICtrlSetGraphic functions try to draw/paint in/to.. ATM: ;~ Declare Variable $maxx1 = 873 $maxy1 = 54 $maxx2 = 1018 $maxy2 = 199 $xline = 1 $yrow = 1 #include <GUIConstants.au3> GUICreate("My Main", $maxx2 - $maxx1 + 4, $maxy2 - $maxy1 + 4, 1030, 28) $G = GUICtrlCreateGraphic(2, 2, $maxx2 - $maxx1, $maxy2 - $maxy1) GUISetState() GUISetState(@SW_UNLOCK) While 1 $yrow = 1 Do $xline = 1 Do GUICtrlSetGraphic($G, $GUI_GR_COLOR, PixelGetColor($maxx1 + $xline, $maxy1 + $yrow)) GUICtrlSetGraphic($G, $GUI_GR_PIXEL, $xline, $yrow) $xline += 1 Until $xline = $maxx2 - $maxx1 $yrow += 1 Until $yrow = $maxy2 - $maxy1 Sleep(1500) WEnd u dont need the GUISetState() GUISetState(@SW_UNLOCK) inside the loop only something that changes the state that u can actually see the changes the problem u have to minimize / maximize the window to see the change ++ still makes layers not only one pic if i add GUISetState(@SW_HIDE) GUISetState(@SW_SHOW) in the loop it is like "reloading" the caption & i can see the changes but it still loads 1 layer after another until it reaches the last one Edited February 12, 2008 by Wurschtbrot Link to comment Share on other sites More sharing options...
FreeFry Posted February 12, 2008 Share Posted February 12, 2008 Hmm, I'm not quite sure what you're wanting to do, but if it's copying pixels on the fly, this higly ineffective, you should go with Siaos advice. I did some testing, and this works for me: #include <GUIConstants.au3> Dim $guiWidth = 147, $guiHeight = 147 ;~ Declare Variable $gui = GUICreate("My Main", 147, 147, 351, 251) $G = GUICtrlCreateGraphic(0, 0, 140, 140) GUICtrlSetBkColor($G, 0x000000) GUISetState() $G = GUICtrlCreateGraphic(2, 2, $guiWidth, $guiHeight) GUICtrlSetBkColor($G, 0x000000) Do GUISetState(@SW_UNLOCK) For $x = 1 To $guiWidth For $y = 1 To $guiHeight GUICtrlSetGraphic($G, $GUI_GR_COLOR, PixelGetColor($x, $y)) GUICtrlSetGraphic($G, $GUI_GR_PIXEL, $x, $y) Next Next Until GUIGetMsg() = $GUI_EVENT_CLOSE Exit But the GUI is highly inresponsive... 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