Enigma Posted February 8, 2009 Share Posted February 8, 2009 (edited) Ok. :-) I know I didn't probably explain myself too well on submitting the ticket #804. So this is directed to Valik. :-) What I meant with the program I submitted was that I understand if you change the one(1) to something like a thousand (1000) that the program will run longer. That's a given. However, Autoit just sits there and does nothing. Or does it? First I tried changing where the GUISetState was - all that did was to show me a window with a blue square in it and nothing else until at last it refreshed itself and drew everything. I looked around for a command thinking that maybe there was double buffering going on. Didn't find one. (Not that there might not be such a command - but I just didn't find it.) Every test the program would just sit there for a very long period of time -and then- it would do all of the graphics (ie: The placing of the blobs if you will and the writing of the word "Creating" would only appear after all of the blobs had been written to the screen. Even if I put the writing of the word first - it always appears last.) So then I decided to get out the AutoIt debugger and try it. To my surprise, AutoIt ran the entire set of commands twice. That's right. It went through all of the FOR loops et al and when it got to the last statement, then it began over again and this time it drew everything as it ran. Now, I don't remember having put a loop around everything so it would run twice so I'm going "Eh? Is AutoIt checking the entire execution of the program before it actually executes the program?" And that's why I posted. You say the problem is obvious but call me a noob and drop me on my head cause I must be too close to the program to see why it is running everything twice and not writing everything to the screen immediately as the program executes. I did not have the debugger up and going to begin with and I even tried right-click compiling the program. All with the same results. So am I missing some simple command here? I'm going by the example programs so I made sure I had all of the commands I needed in the program and they were in the proper order. Edited February 8, 2009 by Enigma Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 8, 2009 Share Posted February 8, 2009 (edited) GUISetState() is the command that shows the GUI and since you have it after the loop that's why it seems to do nothing. If you need more help then you must post your current code so we can see what is happening Edited February 8, 2009 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Enigma Posted February 9, 2009 Author Share Posted February 9, 2009 GUISetState() is the command that shows the GUI and since you have it after the loop that's why it seems to do nothing. If you need more help then you must post your current code so we can see what is happeningI can post it again (or you could have just looked at ticket #804 in the bug list for the complete source code listing). As I stated in the bug report - I tried moving the GUISetState to the first few lines of the program and all I got was a window with a big blue box in it. Nothing else happened. Just like I said in my post. As I also said - that is not why I'm posting (or submitting a bug). Tried that. The debugger shows the program completely executes before it shows any of the graphical stuff being plotted. Further, it executes twice. As if it is trying out each command before it decides it is ok to execute the program. My suspicion (code is at work and I'm at home presently) is the "Opt" command. I'm wondering if the option causes AutoIt to search for new variables as it executes. So I'm going to try removing that option tomorrow. Now that I've had a few days to think about this I do remember that this came up a few years back in an earlier version of AutoIt. There was a very simple reason why this was happening but I can't remember what it was. (Otherwise I'd say I'm sorry for bothering anyone and present the problem/solution.) This is what I get for having to program in PHP for a couple of years and not doing any AutoIt stuff for that time frame. Link to comment Share on other sites More sharing options...
BrettF Posted February 9, 2009 Share Posted February 9, 2009 You can post it again. I for one can't be bothered to search through the tickets for it... From what it sounds like you're using it incorrectly? Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Enigma Posted February 9, 2009 Author Share Posted February 9, 2009 You can post it again. I for one can't be bothered to search through the tickets for it... From what it sounds like you're using it incorrectly?Cheers,BrettActually - you don't have too look far for it cause it was #3 on the list - but here is the newly fiddled around with code for your enjoyment! :-)CODE;; A graphics test;#include <GUIConstantsEx.au3>#include <StaticConstants.au3>; Opt('MustDeclareVars', 1); AutoItSetOption( "TrayAutoPause", 0 );; AutoItSetOption( "WinWaitDelay", 0 ); dim $child = GUICreate( "My Draw", 850, 650, 20, 20 ) dim $gc1; dim $gc2; dim $gc3; dim $i, $j, $k, $l; dim $pi = 3.14159265358979; dim $d2r = $pi / 180; dim $ir = 50; Island Radius GUISetState(@sw_show); $gc2 = GUICtrlCreateLabel( "Creating", 500, 40, 300, 40, $SS_CENTER ) GUICtrlSetColor($gc2, 0xaaaaaa) GUICtrlSetBkColor($gc2, $GUI_BKCOLOR_TRANSPARENT) $gc1 = GUICtrlCreateGraphic( 24, 24, 801, 601 ) GUICtrlSetBkColor($gc1, 0x000033) GUICtrlSetColor($gc1, 0) GUICtrlSetColor($gc1, 0xff0000) GUICtrlSetGraphic( $gc1, $GUI_GR_COLOR, 0xffff00 ); for $k=1 to 100 dim $xc = int( random() * 300 ) + 100; dim $yc = int( random() * 300 ) + 100; for $i=($xc - 100) to ($xc + 100) for $j=($yc - 100) to ($yc + 100) dim $r = random(); dim $ni = $i - $xc; dim $nj = $j - $yc; if( ($r * $ir) > sqrt(($ni * $ni) + ($nj * $nj)) )then $gc3 = GUICtrlSetGraphic( $gc1, $GUI_GR_PIXEL, $i, $j ); endif next next next GUICtrlSetGraphic( $gc1, $GUI_GR_REFRESH ); sleep( 10000 ); exit( 0 );What is really neat is that the GUICtrlSetGraphic on my system (don't know about yours), but nothing draws until it hits this statement (ie: the $GUI_GR_REFRESH). If you move this command up to being inside of the inner FOR loop (ie: the "for $j..." loop), AutoIt completely redraws all of the prior graphics each and every time this is called. So, as in the example above, first it just draws the first circle, then the 1st & 2nd circles, then the 1st, 2nd, and 3rd circles, and so on. :-) It also slows way down when it is doing this when it gets to about the 50th circle. The same program in FreeBasic, using their basic graphical commands, takes about a second to run. I finally killed the AutoIt program because it was running so slowly. However, having the command where it is right now just has that wait while AutoIt runs the entire program before it just does a single update (refresh) to the screen.This makes me wonder if the OpenGL interface would speed things back up. OpenGL is separate from AutoIt and OpenGL also has 2D drawing capabilities. Plus it has "swapbuffers" which allows you to write to the back buffer and then swap it out with the front buffer. So it might be a bit faster. Or you can set it to write to the front buffer automatically and the screen is supposed to update automatically. I'll have to try it. Link to comment Share on other sites More sharing options...
BrettF Posted February 10, 2009 Share Posted February 10, 2009 Your loop seems to be very messed up... I can't see a problem with AutoIt as everything is working as I expect it to- it is your code Maybe check out GDI+ Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Enigma Posted February 13, 2009 Author Share Posted February 13, 2009 Your loop seems to be very messed up... I can't see a problem with AutoIt as everything is working as I expect it to- it is your code Maybe check out GDI+Cheers,BrettI thought I had replied to this, but it doesn't appear to be showing up....My reply was: Could you be a bit more specific? After all, it is just three little loops. Could you tell me how it is messed up? I'd really like to know! Link to comment Share on other sites More sharing options...
BrettF Posted February 13, 2009 Share Posted February 13, 2009 Well thats weird. Last time I did this, the loops were crazy. I must have played with something. Check out GDI+ means you look in the helpfile for it... But check this out netherless. Very rough example expandcollapse popup; ; A graphics test ; #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> ; Opt('MustDeclareVars', 1) ; AutoItSetOption( "TrayAutoPause", 0 ); ; AutoItSetOption( "WinWaitDelay", 0 ); _GDIPlus_Startup() Dim $child = GUICreate("My Draw", 850, 650, 20, 20) Dim $gc1; Dim $gc2; Dim $gc3; Dim $i, $j, $k, $l; Dim $pi = 3.14159265358979; Dim $d2r = $pi / 180; Dim $ir = 50; Island Radius Dim $apems[3] $apems[0] = _GDIPlus_PenCreate(0xFFFF0000) $apems[1] = _GDIPlus_PenCreate(0xFF00FF00) $apems[2] = _GDIPlus_PenCreate(0xFF0000FF) $gc2 = GUICtrlCreateLabel("Creating", 500, 40, 300, 40, $SS_CENTER) GUICtrlSetColor($gc2, 0xaaaaaa) GUICtrlSetBkColor($gc2, $GUI_BKCOLOR_TRANSPARENT) $gc1 = GUICtrlCreatePic("", 24, 24, 801, 601) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($child) GUISetState(@SW_SHOW); For $k = 1 To 100 $hpen = $apems[Random(0, 2, 1)] Dim $xc = Int(Random() * 300) + 100; Dim $yc = Int(Random() * 300) + 100; ConsoleWrite("K = " & $k & @TAB & "( XC = " & $xc & ", YC = " & $yc & ")" & @CRLF) For $i = ($xc - 100) To ($xc + 100) For $j = ($yc - 100) To ($yc + 100) Dim $r = Random(); Dim $ni = $i - $xc; Dim $nj = $j - $yc; If (($r * $ir) > Sqrt(($ni * $ni) + ($nj * $nj))) Then _GDIPlus_GraphicsDrawLine($hGraphics, $i, $j, $i + 1, $j + 1, $hpen) EndIf Next Next Next Sleep(10000); For $i = 0 To 2 _GDIPlus_PenDispose($apems[$i]) Next _GDIPlus_Shutdown() Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Enigma Posted February 17, 2009 Author Share Posted February 17, 2009 Well thats weird. Last time I did this, the loops were crazy. I must have played with something.<snip>Ok. Using GDI, it runs at the speed of Emergence Basic - so I'm guessing EB uses GDI to do it's graphics. (EB is by Paul Turley.) It runs fine under OpenGL also. But that still makes me scratch my head on why the standard graphics things completely redraw everything. Hmmmmmmm.....must have to do with a canvas on a window that is really meant to draw buttons and such. FreeBasic seems to be the fastest at drawing grahics. Whereas AutoIt and EB can take up to as long as thirty seconds, FreeBasic draws everything in less than a 1/10 of a second. So I guess I'm going to go with FreeBasic for the graphics stuff. Still, that is no slight meant to AutoIt. I heavily push AutoIt at work to do just about anything - even Linux things. Yes! AutoIt and Linux. Actually, it is more AutoIt and Cygwin (which allows me to log in to a Linux box easily). I push the commands out to Linux via Cygwin. By just setting "xhost +<tcp/ip>" I can then run XWindows apps on my Windows box and have AutoIt move the mouse, push buttons, etc.... (I know there are apps out there that allow me to record macros and replay them but AutoIt allows me to have more control over the apps and there isn't anything that I know of out there that will do as good of a job as AutoIt does.)Ok. So for now - off to write code in FreeBasic. Thanks for the help everyone (especially BrettF). I was going to write this stuff in AutoIt but I can adapt my little graphics program to FreeBasic and suffer through the unfamiliar stuff. I'm trying to write a little D&D program which will generate an entire world of cities, people, ruins, caves, dungeons, et al and I needed something that could get through the graphics parts very quickly (ie: generate and save images). Now all I have to do is to figure out how to save an image as a PNG file instead of a BMP file (default for FreeBasic whereas AutoIt now has UDFs that will save as PNG).Thanks again! Later! Link to comment Share on other sites More sharing options...
ProgAndy Posted February 17, 2009 Share Posted February 17, 2009 Well, FB must be much faster, since it's a compiler language. AutoIt is "just" interpreting you scripts at runtime. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Enigma Posted February 18, 2009 Author Share Posted February 18, 2009 Well, FB must be much faster, since it's a compiler language. AutoIt is "just" interpreting you scripts at runtime.So when I right-click and it says "Compile X" actually it is building a compilation of the libraries, the interpreter, and the source? (Like how Perl does it.) Or is it compiling in the traditional sense? (Like Visual C does it.) Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 18, 2009 Share Posted February 18, 2009 It basically pastes all the #included scripts into they corresponding places in the script and places that together with a stub of AutoIt.exe (usually AutoItSC.bin) + any FileInstall-ed files into your new file. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Enigma Posted February 19, 2009 Author Share Posted February 19, 2009 It basically pastes all the #included scripts into they corresponding places in the script and places that together with a stub of AutoIt.exe (usually AutoItSC.bin) + any FileInstall-ed files into your new file.Ah. So it does it like Perl does it. (Although come to think of it I think that perlcc actually converts the Perl code into C code and then compiles it.) Ok - thanks! 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