Anas Posted September 5, 2010 Share Posted September 5, 2010 Hello If I run a GDIplus code in a loop then run a Game, WMP or some webpages (like Youtube) the CPU usage increases from 0 to 30-45% till that program is closed, is this normal? Can it be avoided without having to increase sleep time? Example: expandcollapse popup#include <GUIConstants.au3> #include <GDIplus.au3> Global Const $width=100 Global Const $height=10 GLobal $title="GDI+" ; Build your GUI here Opt("GUIOnEventMode",1) $hwnd = GUICreate($title,$width,$height) GUISetOnEvent($GUI_EVENT_CLOSE, "close") GUISetState() ; Load your GDI+ resources here: _GDIPlus_Startup() $graphics=_GDIPlus_GraphicsCreateFromHWND($hwnd) $bitmap=_GDIPlus_BitmapCreateFromGraphics($width,$height,$graphics) $backbuffer=_GDIPlus_ImageGetGraphicsContext($bitmap) $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) Do _GDIPlus_GraphicsClear($backbuffer) $hFamily = _GDIPlus_FontFamilyCreate("7px2bus") $hFont = _GDIPlus_FontCreate($hFamily, 5.5, 0) $tLayout = _GDIPlus_RectFCreate(8, 3, 0, 0) _GDIPlus_GraphicsDrawStringEx($backbuffer, "0", $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_GraphicsDrawImageRect($graphics,$bitmap,0,0,$width,$height) Sleep(10) Until False Func close() _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Exit EndFunc Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 5, 2010 Share Posted September 5, 2010 On Windows XP (or older) or Vista (or newer) with Aero disabled, GDI+ is all done on the main processor and not on the graphics card. This is probably what you are experiencing. Link to comment Share on other sites More sharing options...
Anas Posted September 5, 2010 Author Share Posted September 5, 2010 I meant the process CPU usage, not the overall CPU usage. and the same script will run with almost no CPU usage without these programs/content. Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 5, 2010 Share Posted September 5, 2010 I'm afraid I've never seen a situation like that before. I just tested your code and ran several things like a media player and some YouTube videos. The processor time on the AutoIt process stayed below 3% for me. Link to comment Share on other sites More sharing options...
Anas Posted September 5, 2010 Author Share Posted September 5, 2010 Actually I just tested it, and unlike the one I use, it seems that this one is only affected by Games can you please test it with a directx game? Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 5, 2010 Share Posted September 5, 2010 I haven't got any DirectX games installed on my laptop, sorry. 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