TheReveller Posted April 6, 2009 Share Posted April 6, 2009 Hello,I have a huge script using _IsPressed for every control and action and I just noticed this in the Help File :If calling this function repeatidly, should open 'user32.dll' and pass in handle.Make sure to close at end of scriptWhat's the use of doing this ?Thanks. Link to comment Share on other sites More sharing options...
monoceres Posted April 6, 2009 Share Posted April 6, 2009 It speeds it up a little. Since the api _IsPressed is calling (GetAsyncKeyState) resides in user32 the UDF have to reopen it all the time to call the function. If you open it yourself it doesn't need too. However the speed impact of not opening it is not as big as people seem to think, because user32 is always loaded in autoit processes by default, so when the udf opens the dll again it just increment the internal reference count.More info here. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
CodyBarrett Posted April 6, 2009 Share Posted April 6, 2009 to check if a certain event is called..say a keypress.. [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
TheReveller Posted April 7, 2009 Author Share Posted April 7, 2009 Ok, because in my code I had something messy like this... While Not _IsPressed($_XButton1) And Not _IsPressed($_End); Loop ends with XButton1 or End [...] While Not (_IsPressed($_LButton) And Not _IsPressed($_Ctrl)) And Not (_IsPressed($_Enter) And Not _IsPressed($_Alt)) And Not _IsPressed($_XButton1) And Not _IsPressed($_End) [...] While _IsPressed($_LButton) Or (_IsPressed($_Alt) And (_IsPressed($_Left) Or _IsPressed($_Up) Or _IsPressed($_Right) Or _IsPressed($_Down))) [...] So now I did this... Func OnAutoItExit() [...] DllClose($dll) EndFunc Global $dll = DllOpen("user32.dll") While Not _IsPressed($_XButton1, $dll) And Not _IsPressed($_End, $dll); Loop ends with XButton1 or End [...] While Not (_IsPressed($_LButton, $dll) And Not _IsPressed($_Ctrl, $dll)) And Not (_IsPressed($_Enter, $dll) And Not _IsPressed($_Alt, $dll)) And Not _IsPressed($_XButton1, $dll) And Not _IsPressed($_End, $dll) [...] While _IsPressed($_LButton, $dll) Or (_IsPressed($_Alt, $dll) And (_IsPressed($_Left, $dll) Or _IsPressed($_Up, $dll) Or _IsPressed($_Right, $dll) Or _IsPressed($_Down, $dll))) [...] Sounds OK ? Link to comment Share on other sites More sharing options...
monoceres Posted April 7, 2009 Share Posted April 7, 2009 Sounds OK ?Yes. That is the intended use. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
CodyBarrett Posted April 7, 2009 Share Posted April 7, 2009 _Ispressed() works everytime for me even when i DONT open the DLL [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Richard Robertson Posted April 7, 2009 Share Posted April 7, 2009 Yes it works. That doesn't make it efficient. In this case there's not a huge difference but with non-Windows dlls, opening it once instead of opening it over and over would be better. Link to comment Share on other sites More sharing options...
CodyBarrett Posted April 7, 2009 Share Posted April 7, 2009 ah... multiplatform codes... or multiplatform Dlls... in any case YOUR right haha, i guess ill add DLLopen() in my scripts JUST to be GREEN [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] 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