llllJakubllll Posted June 4, 2009 Share Posted June 4, 2009 I have never written a script in my life. I'm looking for a way to set several keys on my keyboard to perform mouse clicks. So for example pressing "1" would trigger a mouseclick at x 375 y 764 coordinates. Can anyone help me out with this please? Link to comment Share on other sites More sharing options...
schilbiz Posted June 4, 2009 Share Posted June 4, 2009 (edited) I have never written a script in my life. I'm looking for a way to set several keys on my keyboard to perform mouse clicks. So for example pressing "1" would trigger a mouseclick at x 375 y 764 coordinates. Can anyone help me out with this please? As a quick example. HotKeySet("1", "one") While 1 Sleep(150) WEnd Func one() MouseMove(1,1) Endfunc I did a MouseMove but you would want to use a MouseClick. Edited June 4, 2009 by schilbiz Link to comment Share on other sites More sharing options...
llllJakubllll Posted June 4, 2009 Author Share Posted June 4, 2009 As a quick example. HotKeySet("1", "one") While 1 Sleep(150) WEnd Func one() MouseMove(1,1) Endfunc I did a MouseMove but you would want to use a MouseClick. So would the (1,1) be the x and y coordinates. For example MouseClick(437,582)? Link to comment Share on other sites More sharing options...
stampy Posted June 4, 2009 Share Posted June 4, 2009 Welcome to the forums. Yes the 1,1, is a x,y coord However the Mouseclick() also needs the button MouseClick('left',x,y) The help file details all of this along with the other options for the functions. Link to comment Share on other sites More sharing options...
Achilles Posted June 4, 2009 Share Posted June 4, 2009 So would the (1,1) be the x and y coordinates. For example MouseClick(437,582)?Yep... They are the x and y coordinates, where 0,0 is the top left corner. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
llllJakubllll Posted June 4, 2009 Author Share Posted June 4, 2009 (edited) Well my script looks like this:HotKeySet("1", "one")While 1 Sleep(150)WEndFunc one() MouseClick('left'431,597)EndfuncWhen I double click to script to execute it I see it appear below in my taskbar and when I press 1 i get the following error message:Line 9 (File C:\Documents and Settings\Jakub\My Documents\helloworld.au3"):MouseClick('left'431,597)MouseClick(^ ERRORError: Error in expression. Edited June 4, 2009 by llllJakubllll Link to comment Share on other sites More sharing options...
llllJakubllll Posted June 4, 2009 Author Share Posted June 4, 2009 I also tried removing the ' around left and adding a , and a space, etc. Link to comment Share on other sites More sharing options...
Azaw Posted June 4, 2009 Share Posted June 4, 2009 it should be smt like this: HotKeySet("1", "one") While 1 Sleep(150) WEnd Func one() MouseClick("left", 431, 597) Endfunc Link to comment Share on other sites More sharing options...
Roman9 Posted June 4, 2009 Share Posted June 4, 2009 Your error was the single quote ' around the word left. You needed a " MouseClick("left",431,597) Link to comment Share on other sites More sharing options...
llllJakubllll Posted June 4, 2009 Author Share Posted June 4, 2009 it should be smt like this: HotKeySet("1", "one") While 1 Sleep(150) WEnd Func one() MouseClick("left", 431, 597) Endfunc Ok awesome it works, is there any way to speed this up now. The mouse moves pretty slow - I would like the motion to be as quick as possible. I tried changing the sleep to 50 thinking that may speed it up but it didnt change anything. Link to comment Share on other sites More sharing options...
llllJakubllll Posted June 4, 2009 Author Share Posted June 4, 2009 I wanted to add 3 more functions and I was unable too. Do they all have to have their own scripts? HotKeySet("1", "one") While 1 Sleep(150) WEnd Func one() MouseClick("left", 590, 498) Endfunc HotKeySet("2", "two") While 2 Sleep(150) WEnd Func two() MouseClick("left", 578, 549) Endfunc HotKeySet("3", "three") While 3 Sleep(150) WEnd Func three() MouseClick("left", 691, 499) Endfunc HotKeySet("4", "four") While 4 Sleep(150) WEnd Func four() MouseClick("left", 582, 598) Endfunc Link to comment Share on other sites More sharing options...
Azaw Posted June 4, 2009 Share Posted June 4, 2009 I wanted to add 3 more functions and I was unable too. Do they all have to have their own scripts? HotKeySet("1", "one") While 1 Sleep(150) WEnd Func one() MouseClick("left", 590, 498) Endfunc HotKeySet("2", "two") While 2 Sleep(150) WEnd Func two() MouseClick("left", 578, 549) Endfunc HotKeySet("3", "three") While 3 Sleep(150) WEnd Func three() MouseClick("left", 691, 499) Endfunc HotKeySet("4", "four") While 4 Sleep(150) WEnd Func four() MouseClick("left", 582, 598) Endfunc inspired by you i tried to make smt like this instead for finishing my bot and i think u should try this out expandcollapse popupGlobal $paused HotKeySet("{F3}", "togglepause") HotKeySet("{ESC}", "terminate") HotKeySet("1", "one") HotKeySet("2", "two") HotKeySet("3", "three") HotKeySet("4", "four") Func TogglePause() $paused = Not $paused While $paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip('Script is "Running"', 0, 0) EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate While 1 Sleep(150) WEnd Func one() MouseClick("left", 590, 498) EndFunc ;==>one While 2 Sleep(150) WEnd Func two() MouseClick("left", 578, 549) EndFunc ;==>two While 3 Sleep(150) WEnd Func three() MouseClick("left", 691, 499) EndFunc ;==>three While 4 Sleep(150) WEnd Func four() MouseClick("left", 582, 598) EndFunc ;==>four I added an Pause and exit, so if u press F3 u will pause / unpause the script and ESC will end it. the functions u addad look okay just be sure to use right cords and please start using code tags Link to comment Share on other sites More sharing options...
llllJakubllll Posted June 4, 2009 Author Share Posted June 4, 2009 Azaw is f3 supposed to pause the script and disable the hotkeys so you can use the numbers 1-4 because even when paused the hotkeys still work? Also is this the quickest it can go? Link to comment Share on other sites More sharing options...
schilbiz Posted June 4, 2009 Share Posted June 4, 2009 Azaw is f3 supposed to pause the script and disable the hotkeys so you can use the numbers 1-4 because even when paused the hotkeys still work? Also is this the quickest it can go? Assuming you use SciTE you should look up MouseClick in Help, it will give you all the information you need to get started with MouseClick. I have added and removed a few things from Azaw's script so that it will do what you are asking, and about as fast as it can. expandcollapse popupGlobal $paused HotKeySet("1", "one") HotKeySet("2", "two") HotKeySet("3", "three") HotKeySet("4", "four") HotKeySet("{F3}", "togglepause") HotKeySet("{ESC}", "terminate") While 1 Sleep(150) WEnd Func one() MouseClick("left", 590, 498, 1, 1) EndFunc ;==>one Func two() MouseClick("left", 578, 549, 1, 1) EndFunc ;==>two Func three() MouseClick("left", 691, 499, 1, 1) EndFunc ;==>three Func four() MouseClick("left", 582, 598, 1, 1) EndFunc ;==>four Func TogglePause() $paused = Not $paused While $paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip('Script is "Running"', 0, 0) EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate 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