PantZ4 Posted June 16, 2007 Share Posted June 16, 2007 (edited) Here is a func I have made. I just wanna know if I can optimize it anymore. #region Func _MouseIsAround ;=============================================================================== ; ; Name: _MouseIsAround ; Description: Checks to see if the mouse is near the specified window ; Example Use: _MouseIsAround ( $g_gui [, $i_space [, $i_coordreset]] ) ; Parameter(s): $g_gui The GUI to check ; $i_space [optional] an additional border ; outside the GUI. By defualt 0. ; $i_coordreset [optional] The number the func shall ; reset "MouseCoordMode" to. By ; defualt 1. ; ; Requirement: The Option "MouseCoorMode" is 0 ; Return Value(s): Success: ; Return 1 if the mouse is around the GUI ; Failure: ; Returns 0 otherwise ; Author(s): Mr. Zero ; Note(s): None ; ;=============================================================================== Func _MouseIsAround($g_gui,$i_space=0,$i_coordreset=1) Opt("MouseCoordMode",0) $a_mousepos=MouseGetPos() $a_guipos=WinGetPos($g_gui) Opt("MouseCoordMode",$i_coordreset) If $a_mousepos[0]<$a_guipos[0]-$i_space Or $a_mousepos[1]<$a_guipos[1]-$i_space Or $a_mousepos[0]>$a_guipos[2]+$i_space Or $a_mousepos[1]>$a_guipos[3]+$i_space Then Return 0 EndIf Return 1 EndFunc ;==>_MouseIsAround #endregion (Hmm... the tags don't like tab?) And what do you put infront of a GUI variable? I have put a g_ prefix. Edited June 16, 2007 by Mr. Zero Link to comment Share on other sites More sharing options...
poisonkiller Posted June 16, 2007 Share Posted June 16, 2007 If I understood correctly, then your UDF checks, if mouse is inside your GUI. Here's another version of your UDF: #region Func _MouseIsAround ;=============================================================================== ; ; Name: _MouseIsAround ; Description: Checks to see if the mouse is near the specified window ; Example Use: _MouseIsAround ( $g_gui [, $i_space [, $i_coordreset]] ) ; Parameter(s): $g_gui The GUI to check ; $i_space [optional] an additional border ; outside the GUI. By defualt 0. ; $i_coordreset [optional] The number the func shall ; reset "MouseCoordMode" to. By ; defualt 1. ; ; Requirement: The Option "MouseCoorMode" is 0 ; Return Value(s): Success: ; Return 1 if the mouse is around the GUI ; Failure: ; Returns 0 otherwise ; Author(s): Mr. Zero ; Note(s): None ; ;=============================================================================== Func _MouseIsAround($g_gui, $i_space = 0, $i_coordreset=1) Opt("MouseCoordMode",$i_coordreset) $a_mousepos = GUIGetCursorInfo() $g_wh = WinGetClientSize($g_gui) If $a_mousepos[0]+$i_space < 0 or $a_mousepos[1]+$i_space < 0 Then Return 0 If $a_mousepos[0]-$i_space > $g_wh[0] Or $a_mousepos[1]-$i_space > $g_wh[1] Then Return 0 Return 1 EndFunc ;==>_MouseIsAround #endregion Link to comment Share on other sites More sharing options...
Uten Posted June 16, 2007 Share Posted June 16, 2007 (edited) I would just like to add that when a func uses Opt(...) it should save the returned value and restore it again when the function is done. EDIT: I would just want? OR I would just like? Edited June 16, 2007 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
PantZ4 Posted June 16, 2007 Author Share Posted June 16, 2007 I would just like to add that when a func uses Opt(...) it should save the returned value and restore it again when the function is done.EDIT: I would just want? OR I would just like?It does? Well that make a whole lot easier.Poisonkiller @ Hmmm that could work too. Thanks both of you Link to comment Share on other sites More sharing options...
martin Posted June 16, 2007 Share Posted June 16, 2007 EDIT: I would just want? OR I would just like?@UtenI would say one of theseI would just likeI would likeI want to addI just want to addThe combination 'I would just want to add' sounds a little strange to me in the context you used it, but it is a valid construction. Eg, 'if I could add anything to the world I would just want to add free running water.'(Caveats: I'm English so my English is not so good!) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
The Kandie Man Posted June 17, 2007 Share Posted June 17, 2007 @UtenI would say one of theseI would just likeI would likeI want to addI just want to addThe combination 'I would just want to add' sounds a little strange to me in the context you used it, but it is a valid construction. Eg, 'if I could add anything to the world I would just want to add free running water.'(Caveats: I'm English so my English is not so good!)OT(Discussing Phrase Usage):"I would just want to add" also sounds odd to me. I think the reason for this is because there is a future tense to the phrase. For example, if someone asked you what you would do different about your next computer you may say, "I would just want to add an additional hard drive because I am always running out of disk space." There is just a certain future tense to it. When you say, "I would just like to add..." it has a difinitive present tense about it. For example, if someone were to ask you what was wrong with their script, you at that very moment might respond with, "I would just like to add that there is an error on line 71 of your script."-The Kandie Man ;-) "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
Uten Posted June 17, 2007 Share Posted June 17, 2007 (edited) It sounded odd to me to, as you all probably have figured out.. I have learned English from the television and by reading. The study part at school did not go to well I'm afraid. But I'm happy to see that playing it by the ear worked this time to, even if I did not figure out why at the time. Thanks for the explanations. Now that AutoIt is unicode enabled maybe we all should move on to a country neutral language. Esperanto any one? I would have to learn it to first to.. PS: Maybe I should have used the simpler "I Just want to add". Edited June 17, 2007 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling 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