Sign in to follow this  
Followers 0
erifash

Keymouse - Use your keyboard as a mouse!

11 posts in this topic

Do you have a sticky, ball-type mouse? This could be useful for those who aren't privelaged enough to have an optical mouse. Plus, it's just plain cool! Here's the code:

Thanks to ezzetabi for the _IsPressed fuction!

Use the arrow keys to move, the numpad selects the speed setting, F1 left clicks (hold it down to drag), F2 right clicks (hold it down to drag), and control+F11 exits.

Opt("TrayIconHide", 1)

HotkeySet("{UP}", "n")
HotkeySet("{DOWN}", "s")
HotkeySet("{RIGHT}", "e")
HotkeySet("{LEFT}", "w")

HotkeySet("{F1}", "none")
HotkeySet("{F2}", "none")

HotKeySet("{NUMPAD1}", "sp1")
HotKeySet("{NUMPAD2}", "sp2")
HotKeySet("{NUMPAD3}", "sp3")
HotKeySet("{NUMPAD4}", "sp4")
HotKeySet("{NUMPAD5}", "sp5")
HotKeySet("{NUMPAD6}", "sp6")
HotKeySet("{NUMPAD7}", "sp7")
HotKeySet("{NUMPAD8}", "sp8")
HotKeySet("{NUMPAD9}", "sp9")

HotkeySet("^{F11}", "myexit")

$sp = 20
$left = "up"
$right = "up"

While 1
  Sleep(10)
  If _IsPressed('70') = 1 and $left = "up" Then
    $left = "down"
    MouseDown("left")
  EndIf
  If _IsPressed('70') = 0 and $left = "down" Then
    $left = "up"
    MouseUp("left")
  EndIf
  If _IsPressed('71') = 1 and $right = "up" Then
    $right = "down"
    MouseDown("right")
  EndIf
  If _IsPressed('71') = 0 and $right = "down" Then
    $right = "up"
    MouseUp("right")
  EndIf
Wend



Func myexit()
  Exit
EndFunc



Func none()
  
EndFunc



Func _IsPressed($hexKey)
; $hexKey must be the value of one of the keys.
; _IsPressed will return 0 if the key is not pressed, 1 if it is.
  
  Local $aR, $bRv;$hexKey
  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
;If $aR[0] = -32767 Then
  If $aR[0] <> 0 Then
     $bRv = 1
  Else
     $bRv = 0
  EndIf
  
  Return $bRv
EndFunc ;==>_IsPressed



Func n()
  $pos = MouseGetPos()
  MouseMove($pos[0], $pos[1] - $sp, 1)
EndFunc
Func s()
  $pos = MouseGetPos()
  MouseMove($pos[0], $pos[1] + $sp, 1)
EndFunc
Func e()
  $pos = MouseGetPos()
  MouseMove($pos[0] + $sp, $pos[1], 1)
EndFunc
Func w()
  $pos = MouseGetPos()
  MouseMove($pos[0] - $sp, $pos[1], 1)
EndFunc



Func leftc()
  $pos = MouseGetPos()
  MouseClick("left", $pos[0], $pos[1], 1, 1)
EndFunc
Func rightc()
  $pos = MouseGetPos()
  MouseClick("right", $pos[0], $pos[1], 1, 1)
EndFunc



Func sp1()
  $sp = 1
EndFunc
Func sp2()
  $sp = 5
EndFunc
Func sp3()
  $sp = 10
EndFunc
Func sp4()
  $sp = 15
EndFunc
Func sp5()
  $sp = 20
EndFunc
Func sp6()
  $sp = 30
EndFunc
Func sp7()
  $sp = 50
EndFunc
Func sp8()
  $sp = 70
EndFunc
Func sp9()
  $sp = 100
EndFunc

Any questions/comments would be greatly appreciated!

Share this post


Link to post
Share on other sites

Excellent idea, very interesting :idiot:


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

sounds just like a dllcall... , but great work! :idiot:


FootbaG

Share this post


Link to post
Share on other sites

great work, good program, whered you get such a brilliant idea?

Share this post


Link to post
Share on other sites

From Microsoft. IIRC every windows from Win98+ has this function builtin.

Share this post


Link to post
Share on other sites

Yep, It's in the accessability options in the control panel.


Who else would I be?

Share this post


Link to post
Share on other sites

nice hehe i already wrong a script like that... it was long time ago ..

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Wow, the option to select the speed is really nice. This is really better than Microsoft's. The only thing I complain is that you can't move diagonally. But the script can be changed so the speed is selected with the alfanumeric numbers (or the Function keys) and the direction is selected with the Numeric keypad. The buttons are simple to use, not as MS's that you have to remember wether you pressed "0", then just release it with a ".".

I'll be working in the modifications if you are OK with it, all credits to you of course! :-D

Cheers, Lucas.

Edited by Ktulu789

AutoIt is a blessing, I don't know how I was able to use my computer before [Auto]It :-S

Share this post


Link to post
Share on other sites

How do you turn it off?

Uh.... just wondering.


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

hmmmmmmmmmmmm, this has already been done.............a while ago though.


The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0