stryderjess Posted January 21, 2009 Share Posted January 21, 2009 I'm just learning how to make scripts, and right now I am trying to make a script that makes the mouse move slightly to the right and left click every time I press the z key. I'm trying to learn this on my own and so far I came up with HotKeySet("{z}","moveclick") Func moveclick() MouseGetPos() MouseMove($array[0]+20,$array[1],0) MouseClick("left") EndFunc But it doesnt seem to be working and I've been trying to figure this out on my own, but like I said I'm a noob Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
monoceres Posted January 21, 2009 Share Posted January 21, 2009 Hi! Welcome to the forums. Please create a better thread title next time, people tend to ignore threads were the title doesn't give a hint about the problem. Your problem is easy, it's because the script exits immediately, add this: While Sleep(10) WEnd And it will work great Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Drew Posted January 22, 2009 Share Posted January 22, 2009 I had a problem understanding the while + sleep thing at first too But the computer reads your script from top to bottom of what you tell it to do. It sets the hotkey , than moves on. Since your hotkey calls upon your function , the computer skips over that.... and ends the program since theres nothing for it to do. The Sleep(10) is there in the while loop to give the program something to do while it waits for you to call upon your created function . Note: I just felt the need to explain that because that was one of the things that gave me trouble in my newb days of autoit . Link to comment Share on other sites More sharing options...
stryderjess Posted January 22, 2009 Author Share Posted January 22, 2009 (edited) Hi! Welcome to the forums. Please create a better thread title next time, people tend to ignore threads were the title doesn't give a hint about the problem. Your problem is easy, it's because the script exits immediately, add this: While Sleep(10) WEnd And it will work great Thanks very much for the tips, I will definitely be more descriptive in the future on the subject titles on my threads, and your code helped my script make a little progress although I'm not sure how(though thanks for the insight Drew). Now I'm having a new problem however in that I'm getting a error message that I'm not declaring the variable on line 4 saying Error: Variable used without being declared. Any ideas how to fix that? Edited January 22, 2009 by stryderjess Link to comment Share on other sites More sharing options...
Drew Posted January 22, 2009 Share Posted January 22, 2009 (edited) I'm just learning how to make scripts, and right now I am trying to make a script that makes the mouse move slightly to the right and left click every time I press the z key. I'm trying to learn this on my own and so far I came up with HotKeySet("{z}","moveclick") Func moveclick() MouseGetPos() MouseMove($array[0]+20,$array[1],0) MouseClick("left") EndFunc But it doesnt seem to be working and I've been trying to figure this out on my own, but like I said I'm a noob Any help would be greatly appreciated. Try This: HotKeySet("z","moveclick") While 1 Sleep( 10 ) WEnd Func moveclick() $array = MouseGetPos() MouseClick("left", $array[0]+20, $array[1], 1, 0) EndFunc Reasoning: MouseGetPos returns a 2 array variable , so you need to give it a variable to use. That is why I put $array = MouseGetPos() ... ( To "declare" it. ) And instead of having MouseClick("left") you could do this: $array = MouseGetPos() MouseClick("left", $array[0]+20, $array[1], 1, 0) Its the same thing but I combined the mouse movement with the mouseclick. Now it will move there and click all in 1 go. Edited January 22, 2009 by Drew Link to comment Share on other sites More sharing options...
stryderjess Posted January 22, 2009 Author Share Posted January 22, 2009 Awesome thanks a lot. It works beautifully. Hopefully I'll start getting the hang of this a little better Your help was much appreciated. Link to comment Share on other sites More sharing options...
CodyBarrett Posted January 22, 2009 Share Posted January 22, 2009 Thats what the Forums are here for to get help when you need it, dont be shy to ask BUT BE SENSIBLE on topic titles and that jazz USE SEARCH lol but yeah forums ARE here for a reason [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...
stryderjess Posted January 22, 2009 Author Share Posted January 22, 2009 Thats why I love em 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