Jump to content

Need easy help


Go to solution Solved by DW1,

Recommended Posts

  • Solution

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
Link to comment
Share on other sites

 

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

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.

Link to comment
Share on other sites

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!

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...