Alexxander Posted July 2, 2013 Share Posted July 2, 2013 hi all i was watching this vid Link to comment Share on other sites More sharing options...
Solution DW1 Posted July 2, 2013 Solution Share Posted July 2, 2013 A few things wrong here. First, the reason it isn't working at all is because "(up)" should be "{up}". Note the curly brackets. The rest of the arrow keys should also use curly brackets. Now the script should be working, but not correctly... you'll notice the mouse moves in unexpected ways. This is because you have confused $pos[1] vs $pos[0] in both the left and right functions. HotKeySet("{UP}", "up") HotKeySet("{DOWN}", "down") HotKeySet("{RIGHT}", "right") HotKeySet("{LEFT}", "left") While 1 Sleep(10) WEnd Func up() $pos = MouseGetPos() MouseMove($pos[0], $pos[1] - 1, 1) EndFunc ;==>up Func down() $pos = MouseGetPos() MouseMove($pos[0], $pos[1] + 1, 1) EndFunc ;==>down Func right() $pos = MouseGetPos() MouseMove($pos[0] + 1, $pos[1], 1) EndFunc ;==>right Func left() $pos = MouseGetPos() MouseMove($pos[0] - 1, $pos[1], 1) EndFunc ;==>left Alexxander 1 AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Alexxander Posted July 2, 2013 Author Share Posted July 2, 2013 A few things wrong here. First, the reason it isn't working at all is because "(up)" should be "{up}". Note the curly brackets. The rest of the arrow keys should also use curly brackets. Now the script should be working, but not correctly... you'll notice the mouse moves in unexpected ways. This is because you have confused $pos[1] vs $pos[0] in both the left and right functions. HotKeySet("{UP}", "up") HotKeySet("{DOWN}", "down") HotKeySet("{RIGHT}", "right") HotKeySet("{LEFT}", "left") While 1 Sleep(10) WEnd Func up() $pos = MouseGetPos() MouseMove($pos[0], $pos[1] - 1, 1) EndFunc ;==>up Func down() $pos = MouseGetPos() MouseMove($pos[0], $pos[1] + 1, 1) EndFunc ;==>down Func right() $pos = MouseGetPos() MouseMove($pos[0] + 1, $pos[1], 1) EndFunc ;==>right Func left() $pos = MouseGetPos() MouseMove($pos[0] - 1, $pos[1], 1) EndFunc ;==>left thank u a lot bro it worked but in the TUT he made it "(up)" how did it worked with him ? another question is why we used sleep ? Link to comment Share on other sites More sharing options...
DW1 Posted July 2, 2013 Share Posted July 2, 2013 thank u a lot bro it worked but in the TUT he made it "(up)" how did it worked with him ? another question is why we used sleep ? It was curly brackets in the video as well, just hard to see it. The sleep is there because we have an infinite loop. I think autoit does a good job of not killing the CPU even without it there, but lets say for example that we are doing a basic calculation in that loop. Now we are using the processor to do a basic calculation and as soon as it's done, do it again, rinse and repeat. With no sleep in an infinite loop that does a basic calculation, we would expect one full core to get utilized because it is doing exactly what we told it to; do this as fast as you can, over and over. With the sleep, we guarantee that we are not trying to run this as fast as possible and freeing up processor time for other programs. Alexxander 1 AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Developers Jos Posted July 2, 2013 Developers Share Posted July 2, 2013 but in the TUT he made it "(up)".... Are you sure? maybe look again... Alexxander 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Alexxander Posted July 2, 2013 Author Share Posted July 2, 2013 thank you guys i really appreciate your help >> i <3 this forum Link to comment Share on other sites More sharing options...
water Posted July 2, 2013 Share Posted July 2, 2013 BTW: Could you please give your threads a meaningful title Everyone on the General Help and Support forum is seeking for help. So "Need easy help" doesn't tell us what you are looking for! Alexxander 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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