AutoHotkey Community

It is currently May 27th, 2012, 5:01 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 45 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: April 13th, 2010, 11:32 pm 
Offline

Joined: April 13th, 2010, 7:03 pm
Posts: 23
Location: Netherlands
History thread
http://www.autohotkey.com/forum/topic56690.html

FATAL-1
Quote:
hi everyone, my name is izzy. i have a physical disability which prevents me from using a computer in the normal way. i am able to use my computer via a custom made joystick mouse which moves the mouse cursor around and 2 micro switches for left and right clicking.

i have very limited movement in my hands and i control the joystick mouse with my chin. i have become interested in using the jnes nintendo emulator to play some old nintendo games however this program only accepts keyboard input.

can someone please create a script for me so that when i'm moving the mouse to the right, it will think that i am holding down the right arrow key, moving the mouse left would be the left arrow key, up = arrow key up and down = arrow key down.

i would also like the right mouse button to press the F key and the left mouse button to press the D key.

If someone could create a script to do these things i would be eternally grateful, thanks.


Last edited by AHK_Lee on April 14th, 2010, 12:23 am, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: Try outs
PostPosted: April 13th, 2010, 11:32 pm 
Offline

Joined: April 13th, 2010, 7:03 pm
Posts: 23
Location: Netherlands
Try outs

1st script
Code:

#SingleInstance force
#Persistent
SetTitleMatchMode, 2 ; you may need to change this
SetBatchLines -1
Process Priority,,R
Step=1
SendMode Input ; alternatives Play|Event|InputThenPlay
SetKeyDelay, 0

BlockInput SendAndMouse     ; user mouse input is ignored during MouseMove
CoordMode Mouse, Screen     ; absolute coordinates
SetMouseDelay -1            ; fastest action
 
MouseGetPos x0, y0          ; get initial mouse pointer location
SetTimer WatchMouse, 1      ; run the subroutine fast (10..16ms)
Return

WatchMouse:
IfWinNotActive, Jnes ;
   Return
   
KeyToHoldDownPrev1 = %KeyToHoldDown1%  ; Prev now holds the key that was down before (if any).
KeyToHoldDownPrev2 = %KeyToHoldDown2%  ; Prev now holds the key that was down before (if any).

    MouseGetPos x, y         ; get current mouse position
   tooltip,%x% %y%
   If (x < (x0-Step))
   {
KeyToHoldDown1 = Left
   }
   Else If (x > (x0+Step))
   {
KeyToHoldDown1 = Right
   }
   Else   
KeyToHoldDown1 =
   
If (y > (y0+Step))
   {
KeyToHoldDown2 = Down
   }
   Else If (y < (y0-Step))
   {
KeyToHoldDown2 = Up
   }
   Else
KeyToHoldDown2 =



; Otherwise, release the previous key and press down the new key:

if KeyToHoldDown1 != %KeyToHoldDownPrev1%
{
if KeyToHoldDownPrev1   ; There is a previous key to release.
    Send, {%KeyToHoldDownPrev1% up}  ; Release it.
if KeyToHoldDown1   ; There is a key to press down.
    Send, {%KeyToHoldDown1% down}  ; Press it down.
}

if KeyToHoldDown2 != %KeyToHoldDownPrev2%
{
if KeyToHoldDownPrev2   ; There is a previous key to release.
    Send, {%KeyToHoldDownPrev2% up}  ; Release it.
if KeyToHoldDown2   ; There is a key to press down.
    Send, {%KeyToHoldDown2% down}  ; Press it down.
}

ends:
   MouseGetPos x1, y1         ; get current mouse position
   if x!=x1 || y!=y1
   MouseMove x0, y0, 0         ; set mouse to original location
   Return

#IfWinActive Jnes
lbutton::d
rbutton::f
#IfWinActive

del::reload
#z::ExitApp



2nd script

Code:
#SingleInstance force
BlockInput off
MsgBox, 3,, Would you like to use stepmode?`n(press Yes, No or Cancel for exit)
IfMsgBox Yes
       stepmode = Yes
IfMsgBox No
       stepmode = No
IfMsgBox Cancel
   exitapp   


SetTitleMatchMode, 2 ; you may need to change this
SetBatchLines -1
Process Priority,,R
Step=1
SendMode Input ; alternatives Play|Event|InputThenPlay
SetKeyDelay, 0

BlockInput SendAndMouse     ; user mouse input is ignored during MouseMove
CoordMode Mouse, Screen     ; absolute coordinates
SetMouseDelay -1            ; fastest action




SetTimer WatchMouse, 1      ; run the subroutine fast (10..16ms)
Return

WatchMouse:
IfWinNotActive, Jnes ;
{
startingpos = 0
GetKeyState, state, up
if state = D
send, {up up}
GetKeyState, state, down
if state = D
send, {down up}
GetKeyState, state, left
if state = D
send, {left up}
GetKeyState, state, right
if state = D
send, {right up}
   Return
}


If startingpos = 0
MouseMove A_ScreenWidth/2, A_ScreenHeight/2, 0
startingpos = 1
   
KeyToHoldDownPrev1 = %KeyToHoldDown1%  ; Prev now holds the key that was down before (if any).
KeyToHoldDownPrev2 = %KeyToHoldDown2%  ; Prev now holds the key that was down before (if any).


    MouseGetPos x, y         ; get current mouse position
   
;tooltip,%x% %y%

   If (x < (A_ScreenWidth/2-Step))
   {
KeyToHoldDown1 = Left
   }
   Else If (x > (A_ScreenWidth/2+Step))
   {
KeyToHoldDown1 = Right
   }
   Else
KeyToHoldDown1 =
 

If (y > (A_ScreenHeight/2+Step))
   {
KeyToHoldDown2 = Down
   }
   Else If (y < (A_ScreenHeight/2-Step))
   {
KeyToHoldDown2 = Up
   }
   Else
KeyToHoldDown2 =


; Otherwise, release the previous key and press down the new key:


if KeyToHoldDown1 != %KeyToHoldDownPrev1%
{
if KeyToHoldDownPrev1   ; There is a previous key to release.
    Send, {%KeyToHoldDownPrev1% up}  ; Release it.
if KeyToHoldDown1   ; There is a key to press down.
    Send, {%KeyToHoldDown1% down}  ; Press it down.
}

if KeyToHoldDown2 != %KeyToHoldDownPrev2%
{
if KeyToHoldDownPrev2   ; There is a previous key to release.
    Send, {%KeyToHoldDownPrev2% up}  ; Release it.
if KeyToHoldDown2   ; There is a key to press down.
    Send, {%KeyToHoldDown2% down}  ; Press it down.
}

ends:
if stepmode = Yes
MouseMove A_ScreenWidth/2, A_ScreenHeight/2, 0
Return

#IfWinActive Jnes
lbutton::d
rbutton::f
#IfWinActive

del::
BlockInput off
reload
return
home::
BlockInput off
edit
return
end::
BlockInput off
ExitApp
return


FATAL-1
Quote:
the second script works great, especially when running games in fullscreen, however i have noticed 2 issues which need to be fixed.

the first issue is when i move the mouse down, my character crouches but after a few seconds the character stands up again even though i'm still moving the mose down.

the second issue is when i press the right mouse button to attack and then press the left mouse button to jump, it sometimes won't jump until i press the right mouse button again.

also i would like to only use stepmode, no stepmode isn't really suitable for me.

i would also like the script to only start working when i press a hotkey and i would like the script to pause when i press a hotkey as well.

thanks.


None of the above changes have been done, yet


Last edited by AHK_Lee on April 13th, 2010, 11:49 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 13th, 2010, 11:33 pm 
Offline

Joined: April 13th, 2010, 7:03 pm
Posts: 23
Location: Netherlands
ßeta Gui Only

Version = 0.8.1

Code:
#Singleinstance force
SetWorkingDir, %A_ScriptDir%   
Version = 0.8.1

ScriptName =  Mouse 2 Keyboard

;#include C:\WINDOWS\ShellNew\Auto_Backup.ahk

Menu, Tray, Icon, Shell32.dll, 44

gosub Window_List

Gui, Add, GroupBox, x22 y2 w430 h50 , Select Visible Window
Gui, Add, DropDownList, x32 y22 w270 vWindow_Choice Choose%Prefer_Window%, %visible_window_list%
Gui, Add, Button, x322 y22 w120 h20 gReload, Reload

Gui, Add, GroupBox, x22 y62 w280 h140 , General Settings
Gui, Add, Radio, x42 y102 w110 h20 checked 1 vMode, 1. Step Mode
Gui, Add, Radio, x182 y102 w110 h20 , 2. Continous Mode

Gui, Add, Text, x42 y142 w100 h20 +Center, Idle Center Size
Gui, Add, Edit, x152 y142 w30 h20 +Center number limit4 vStep, 1
Gui, Add, Text, x192 y142 w100 h20 +Center, Pixels

Gui, Add, GroupBox, x322 y62 w130 h140 , Program Settings
Gui, Add, Text, x332 y82 w40 h20 +Center, Start
Gui, Add, Hotkey, x382 y82 w60 h20 vHotkey_Start, ^A
Gui, Add, Text, x332 y112 w40 h20 +Center, Pause
Gui, Add, Hotkey, x382 y112 w60 h20 vHotkey_Pause, ^P
Gui, Add, Text, x332 y142 w40 h20 +Center, Reload
Gui, Add, Hotkey, x382 y142 w60 h20 vHotkey_Reload, ^R
Gui, Add, Text, x332 y172 w40 h20 +Center, Exit
Gui, Add, Hotkey, x382 y172 w60 h20 vHotkey_Exit, ^X

Gui, Add, GroupBox, x22 y212 w280 h220 , Mouse Settings

Gui, Add, GroupBox, x42 y232 w240 h70 , Buttons
Gui, Add, Text, x92 y252 w40 h20 +Center, Left
Gui, Add, Hotkey, x92 y272 w40 h20 vHotkey_ButLeft, D
Gui, Add, Text, x152 y252 w40 h20 +Center, Middle
Gui, Add, Hotkey, x152 y272 w40 h20 vHotkey_ButMiddle, S
Gui, Add, Text, x212 y252 w40 h20 +Center, Right
Gui, Add, Hotkey, x212 y272 w40 h20 vHotkey_ButRight, F

Gui, Add, GroupBox, x42 y312 w240 h110 , Axis
Gui, Add, Text, x112 y332 w40 h20 +Center, Up
Gui, Add, Hotkey, x152 y332 w40 h20 vHotkey_Up, Up
Gui, Add, Text, x112 y392 w40 h20 +Center, Down
Gui, Add, Hotkey, x152 y392 w40 h20 vHotkey_Down, Down
Gui, Add, Text, x62 y362 w40 h20 +Center, Left
Gui, Add, Hotkey, x102 y362 w40 h20 vHotkey_Left, Left
Gui, Add, Text, x162 y362 w40 h20 +Center, Right
Gui, Add, Hotkey, x202 y362 w40 h20 vHotkey_Right, Right

Gui, Font, Arial Bold,
Gui, Add, Button, x322 y232 w130 h90 gStart, Start
Gui, Font, norm,

Gui, Add, Button, x322 y352 w130 h30 gWebsite, Project Website

Gui, Add, Text, x322 y412 w130 h20 +Center cF67D00 gAHK_Lee, AHK_Lee
Gui, Font, norm,
 
;-----------------------------------------------------------------------
Gui, Show, x134 y101 h456 w477, ßeta %ScriptName% - Version: %Version%

Gui,2: +toolwindow
Gui,2: Add, Text,+center, Project Contributers:
Gui,2: Add, Text,, Chris
Gui,2: Add, Text,, FATAL-1
Gui,2: Add, Text,, hugov
Gui,2: Add, Text,, Rajat
Gui,2: Add, Text,, tidbit
Gui,2: Add, Text,,
Gui,2: Add, Text,, Respect, Thanks!
Gui,2: Show

Return

Reload:
Reload
Return

Window_List:
WinGet, window_id, list,,, Program Manager
Loop, %window_id%
{
    this_window_id := window_id%A_Index%
    WinGetTitle, this_window_title, ahk_id %this_window_id%
   if (this_window_title = "Start" or "")
   continue
   if visible_window_list =
   visible_window_list = %this_window_title%
   else
   visible_window_list = %visible_window_list%|%this_window_title%
}

sort,visible_window_list, D|

Loop, parse, visible_window_list, |,
{
    ifinstring,A_LoopField,Jnes
   Prefer_window := A_Index
}
return

Start:
Gui, Submit
msgbox ßeta Gui Testing Only theres no script included`n%Window_choice%`n%Mode%`n%Step%`n%Hotkey_Start%`n%Hotkey_Pause%`n%Hotkey_Reload%`n%Hotkey_Exit%`n%Hotkey_ButLeft%`n%Hotkey_ButMiddle%`n%Hotkey_ButRight%`n%Hotkey_Up%`n%Hotkey_Down%`n%Hotkey_Left%`n%Hotkey_Right%
reload
return

Website:
Run http://www.autohotkey.com/forum/viewtopic.php?t=56899
return

AHK_Lee:
Run http://www.autohotkey.com/forum/profile.php?mode=viewprofile&u=44629
return

GuiClose:
ExitApp

del::reload
end::exitapp


Last edited by AHK_Lee on April 14th, 2010, 10:28 pm, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 13th, 2010, 11:33 pm 
Offline

Joined: April 13th, 2010, 7:03 pm
Posts: 23
Location: Netherlands
Version = 0.16.0
ScriptName = Mouse 2 Keyboard

Please post your errors and bugs.

Thanks.
:lol:

*Advanced dynamic hotkeys implemented for the mouse buttons.
Axis and program setting keys in future updates

Code:
#SingleInstance force

SetKeyDelay 0
SetBatchLines -1
SetMouseDelay -1
SetTitleMatchMode 2
SetDefaultMouseSpeed 0
Coordmode, Mouse , Screen

SetWorkingDir, %A_ScriptDir%   
Version = 0.16.0
ScriptName =  Mouse 2 Keyboard
;#include C:\WINDOWS\ShellNew\Auto_Backup.ahk


Menu, Tray, Icon, Shell32.dll, 44
Menu, tray, NoStandard
Menu, tray, add, Start, Menu_Start
Menu, tray, add, Pause, Menu_Pause
Menu, tray, add, Reload, Menu_Reload
Menu, tray, add, ExitApp, Menu_ExitApp

gosub Window_List
gosub Message
gosub Draw_Gui

Settimer Watch_Native, 300

return

+++++++++++++++++++++++++++


Draw_Gui:
Gui,1: Add, GroupBox, x22 y2 w450 h50 , Select Visible Window
Gui,1: Add, DropDownList, x32 y22 w270 vWindow_Choice Choose%Prefer_Window%, %visible_window_list%
Gui,1: Add, Button, x322 y22 w140 h20 gReload, Reload

Gui,1: Add, GroupBox, x22 y62 w280 h140 , General Settings
Gui,1: Add, CheckBox, x42 y92 w250 h20 vglobal_native, Use M2K settings as native for global system
Gui,1: Add, Radio, x42 y132 w110 h20 checked 1 vMode, 1. Step Mode
Gui,1: Add, Radio, x182 y132 w110 h20 vMode2, 2. Continous Mode

Gui,1: Add, Text, x42 y172 w100 h20 +Center, Idle Center Size
Gui,1: Add, Edit, x152 y172 w30 h20 +Center number limit4 vStep, 1
Gui,1: Add, Text, x192 y172 w100 h20 +Center, Pixels

Gui,1: Add, GroupBox, x322 y62 w150 h140 , Program Settings
Gui,1: Add, Text, x332 y82 w40 h20 +Center, Start
Gui,1: Add, Hotkey, x382 y82 w60 h20 vHotkey_Start, ^a
Gui,1: Add, Button, x442 y82 w20 h20 gscStart,
Gui,1: Add, Text, x332 y112 w40 h20 +Center, Pause
Gui,1: Add, Hotkey, x382 y112 w60 h20 vHotkey_Pause, ^p
Gui,1: Add, Button, x442 y112 w20 h20 gscPause,
Gui,1: Add, Text, x332 y142 w40 h20 +Center, Reload
Gui,1: Add, Hotkey, x382 y142 w60 h20 vHotkey_Reload, ^r
Gui,1: Add, Button, x442 y142 w20 h20 gscReload,
Gui,1: Add, Text, x332 y172 w40 h20 +Center, Exit
Gui,1: Add, Hotkey, x382 y172 w60 h20 vHotkey_Exit, ^x
Gui,1: Add, Button, x442 y172 w20 h20 gscExit,

Gui,1: Add, GroupBox, x22 y212 w280 h305 , Mouse Settings

Gui,1: Add, Text, x42 y232 w130 h20 , Tickbox: Native Function
Gui,1: Add, Text, x172 y232 w110 h20 ,Button :Advanced key

Gui,1: Add, GroupBox, x42 y252 w240 h135 , Buttons

Gui,1: Add, Text, x92 y302 w40 h20 +Center, Left
Gui,1: Add, Hotkey, x92 y322 w40 h20 vHotkey_ButLeft, d
Gui,1: Add, CheckBox, x82 y292 w10 h30 vHotkey_ButLeftNat, CheckBox
Gui,1: Add, Button, x132 y322 w20 h20 gscButLeft ,

Gui,1: Add, Text, x152 y302 w40 h20 +Center, Middle
Gui,1: Add, Hotkey, x152 y322 w40 h20 vHotkey_ButMiddle, s
Gui,1: Add, CheckBox, x142 y292 w10 h30 vHotkey_ButMiddleNat, CheckBox
Gui,1: Add, Button, x192 y322 w20 h20 gscButMiddle,


Gui,1: Add, Text, x212 y302 w40 h20 +Center, Right
Gui,1: Add, Hotkey, x212 y322 w40 h20 vHotkey_ButRight, f
Gui,1: Add, CheckBox, x202 y292 w10 h30 vHotkey_ButRightNat, CheckBox
Gui,1: Add, Button, x252 y322 w20 h20 gscButRight,

Gui,1: Add, Text, x102 y272 w50 h20 +Center, Wheel Up
Gui,1: Add, Hotkey, x152 y272 w40 h20 vHotkey_ButWheelUp, w
Gui,1: Add, CheckBox, x92 y262 w10 h30 vHotkey_ButWheelUpNat, CheckBox
Gui,1: Add, Button, x192 y272 w20 h20 gscButWheelup,

Gui,1: Add, Text, x102 y352 w50 h20 +Center, Wheel Dn
Gui,1: Add, Hotkey, x152 y352 w40 h20 vHotkey_ButWheelDn, x
Gui,1: Add, CheckBox, x92 y342 w10 h30 vHotkey_ButWheelDnNat, CheckBox
Gui,1: Add, Button, x192 y352 w20 h20 gscButWheelDn,

Gui,1: Add, GroupBox, x42 y392 w240 h115 , Axis
Gui,1: Add, CheckBox, x62 y412 w10 h20 vAxis, CheckBox

Gui,1: Add, Text, x112 y412 w40 h20 +Center, Up
Gui,1: Add, Hotkey, x152 y412 w40 h20 vHotkey_Up, Up
Gui,1: Add, Button, x192 y412 w20 h20 gscUP,

Gui,1: Add, Text, x112 y472 w40 h20 +Center, Down
Gui,1: Add, Hotkey, x152 y472 w40 h20 vHotkey_Down, Down
Gui,1: Add, Button, x192 y472 w20 h20 gscdown,

Gui,1: Add, Text, x62 y442 w40 h20 +Center, Left
Gui,1: Add, Hotkey, x102 y442 w40 h20 vHotkey_Left, Left
Gui,1: Add, Button, x142 y442 w20 h20 gscLeft,

Gui,1: Add, Text, x162 y442 w40 h20 +Center, Right
Gui,1: Add, Hotkey, x202 y442 w40 h20 vHotkey_Right, Right
Gui,1: Add, Button, x242 y442 w20 h20 gscRight,



Gui,1: Font, Arial Bold,
Gui,1: Add, Button, x332 y232 w130 h90 gStart, Start
Gui,1: Font, norm,

Gui,1: Add, Button, x332 y342 w130 h30 gWebsite, Project Website

Gui,1: Add, Text, x332 y492 w130 h20 +Center cF67D00 gAHK_Lee, AHK_Lee
Gui,1: Font, norm,

Gui,1: Font, italic
Gui,1: Font,, Arial Bold
Gui,1: Add, Button, x332 y392 w130 h30 gDonate, Donate a coffee

Gui,1: Show,h537 w496, %ScriptName% - Version: %Version%

Return

scStart:
scPause:
scReload:
scExit:
scButLeft:
scButMiddle:
scButRight:
scButWheelup:
scButWheelDn:
scUP:
scDown:
scLeft:
scRight:
scbutton = %A_ThisLabel%

Gui,2: Destroy

ScanCode:
Gui,2: Add, CheckBox, x22 y12 w70 h20 vWildcard, Wildcard
Gui,2: Add, CheckBox, x112 y12 w70 h20 vNative, Native
Gui,2: Add, CheckBox, x202 y12 w70 h20 vComprise, Comprise

Gui,2: Add, CheckBox, x22 y42 w50 h20 vShift, Shift
Gui,2: Add, CheckBox, x92 y42 w50 h20 vCTRL, CTRL
Gui,2: Add, CheckBox, x162 y42 w50 h20 vWIN, WIN
Gui,2: Add, CheckBox, x232 y42 w40 h20 vALT, ALT

Gui,2: Font, s14 Bold, Arial
Gui,2: Add, Text, x22 y72 w150 h40 vSC 0x201 +Border, Press any key

Gui,2: Add, Button, x192 y72 w80 h40 gButtonSC, Accept


Gui,2: +ToolWindow -SysMenu +AlwaysOnTop
Gui,2: Show,h125 w295, % "Input ScanCode: " scButton
Loop 9
  OnMessage( 255+A_Index, "ScanCode" ) ; 0x100 to 0x108
  Return
;%
return

Message:
OnMessage(0x7777, "MsgMonitor")
MsgMonitor(wParam, lParam, msg)
{
if wParam != 1
return

if lParam = 1
{
gosub Menu_Start
}
if lParam = 2
{
msgbox test
;gosub Menu_Pause
}
if lParam = 3
{
gosub Menu_Reload
}
if lParam = 4
{
gosub Menu_ExitApp
}
}
return

Menu_Start:
process,close, ahk Pid_sec
gosub start
return

Menu_Pause:
process,close, ahk Pid_sec
Pause
return

Menu_Reload:
process,close, ahk Pid_sec
reload
return

Menu_ExitApp:
process,close, ahk Pid_sec
exitapp
return

Reload:
process,close, ahk Pid_sec
Reload
Return

Window_List:
WinGet, window_id, list,,, Program Manager
Loop, %window_id%
{
    this_window_id := window_id%A_Index%
    WinGetTitle, this_window_title, ahk_id %this_window_id%
   if (this_window_title = "Start" or "")
   continue
   if visible_window_list =
   visible_window_list = %this_window_title%
   else
   visible_window_list = %visible_window_list%|%this_window_title%
}

sort,visible_window_list, D|

Loop, parse, visible_window_list, |,
{
    ifinstring,A_LoopField,Jnes
   Prefer_window := A_Index
}
return

ButtonSC:
Gui,2: Submit
Gui,2: Destroy

SC_hotkey:=

If Wildcard = 1
SC_hotkey.="*"

If Native = 1
SC_hotkey.="~"

If Comprise = 1
SC_hotkey.="$"

if SCButton = scStart
SC_hotkey.="scStart::"
if SCButton = scPause
SC_hotkey.="scPause::"
if SCButton = scReload
SC_hotkey.="scReload::"
if SCButton = scExit
SC_hotkey.="scExit::"

if SCButton = scButLeft
SC_hotkey.="lbutton::"

if SCButton = scButMiddle
SC_hotkey.="mbutton::"

if SCButton = scButRight
SC_hotkey.="rbutton::"

if SCButton = scButWheelup
SC_hotkey.="Wheelup::"

if SCButton = scButWheelDn
SC_hotkey.="Wheeldown::"


if SCButton = scUP
SC_hotkey.="scUP::"
if SCButton = scDown
SC_hotkey.="scDown::"
if SCButton = scLeft
SC_hotkey.="ScLeft::"
if SCButton = scRight
SC_hotkey.="scRight::"

If Shift = 1
SC_hotkey.="+"

If CTRL = 1
SC_hotkey.="^"

If WIN = 1
SC_hotkey.="#"

If ALT = 1
SC_hotkey.="!"

SC_hotkey.=SC

if SCButton = scButLeft
{
GuiControlGet, Hotkey_ButLeft,1:Pos
Guicontrol, 1:hide, Hotkey_ButLeft
GuiControlGet, ScHotkey_ButLeft, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButLeftX% y%Hotkey_ButLeftY% w%Hotkey_ButLeftW% h%Hotkey_ButLeftH% vScHotkey_ButLeft, %SC%
}
Guicontrol, 1:,ScHotkey_ButLeft,%SC%
Guicontrol, 1:disable, ScHotkey_ButLeft

sc_hotkey_butleft:=SC_Hotkey
}

if SCButton = scButMiddle
{
GuiControlGet, Hotkey_ButMiddle,1:Pos
Guicontrol, 1:hide, Hotkey_ButMiddle
GuiControlGet, ScHotkey_ButMiddle, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButMiddleX% y%Hotkey_ButMiddleY% w%Hotkey_ButMiddleW% h%Hotkey_ButMiddleH% vScHotkey_ButMiddle, %SC%
}
Guicontrol, 1:,ScHotkey_ButMiddle,%SC%
Guicontrol, 1:disable, ScHotkey_ButMiddle

sc_hotkey_butMiddle:=SC_Hotkey
}

if SCButton = scButRight
{
GuiControlGet, Hotkey_ButRight,1:Pos
Guicontrol, 1:hide, Hotkey_ButRight
GuiControlGet, ScHotkey_ButRight, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButRightX% y%Hotkey_ButRightY% w%Hotkey_ButRightW% h%Hotkey_ButRightH% vScHotkey_ButRight, %SC%
}
Guicontrol, 1:,ScHotkey_ButRight,%SC%
Guicontrol, 1:disable, ScHotkey_ButRight

sc_hotkey_butRight:=SC_Hotkey
}

if SCButton = scButWheelup
{
GuiControlGet, Hotkey_ButWheelup,1:Pos
Guicontrol, 1:hide, Hotkey_ButWheelup
GuiControlGet, ScHotkey_ButWheelup, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButWheelupX% y%Hotkey_ButWheelupY% w%Hotkey_ButWheelupW% h%Hotkey_ButWheelupH% vScHotkey_ButWheelup, %SC%
}
Guicontrol, 1:,ScHotkey_ButWheelup,%SC%
Guicontrol, 1:disable, ScHotkey_ButWheelup

sc_hotkey_butWheelup:=SC_Hotkey
}

if SCButton = scButWheelDn
{
GuiControlGet, Hotkey_ButWheelDn,1:Pos
Guicontrol, 1:hide, Hotkey_ButWheelDn
GuiControlGet, ScHotkey_ButWheelDn, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButWheelDnX% y%Hotkey_ButWheelDnY% w%Hotkey_ButWheelDnW% h%Hotkey_ButWheelDnH% vScHotkey_ButWheelDn, %SC%
}
Guicontrol, 1:,ScHotkey_ButWheelDn,%SC%
Guicontrol, 1:disable, ScHotkey_ButWheelDn

sc_hotkey_butWheelDn:=SC_Hotkey
}

return


Watch_Native:
GuiControlGet,global_native,1:
if global_native = 1
{
Guicontrol, 1:,mode2,1
Guicontrol, 1:,Axis,1
Guicontrol, 1:,Hotkey_ButWheelDnNat,1
Guicontrol, 1:,Hotkey_ButWheelUpNat,1
Guicontrol, 1:,Hotkey_ButRightNat,1
Guicontrol, 1:,Hotkey_ButMiddleNat,1
Guicontrol, 1:,Hotkey_ButLeftNat,1
Settimer,Watch_Native,off
}
return

Start:
Gui Submit

If Axis = 1
Mode = 2


StringLower, Hotkey_Start, Hotkey_Start
StringLower, Hotkey_Pause, Hotkey_Pause
StringLower, Hotkey_Reload, Hotkey_Reload
StringLower, Hotkey_Exit, Hotkey_Exit

StringLower, Hotkey_ButLeft, Hotkey_ButLeft
StringLower, Hotkey_ButMiddle, Hotkey_ButMiddle
StringLower, Hotkey_ButRight, Hotkey_ButRight
StringLower, Hotkey_ButWheelUp, Hotkey_ButWheelUp
StringLower, Hotkey_ButWheelDn, Hotkey_ButWheelDn

StringLower, Hotkey_Up, Hotkey_Up
StringLower, Hotkey_Down, Hotkey_Down
StringLower, Hotkey_Left, Hotkey_Left
StringLower, Hotkey_Right, Hotkey_Right

GuiControlGet, ScHotkey_ButLeft, 1:Enabled
if ScHotkey_Butleft = 0
Final_Hotkey_ButLeft:= Sc_Hotkey_Butleft
else
Final_Hotkey_ButLeft:= "lbutton::"Hotkey_ButLeft

GuiControlGet, ScHotkey_ButMiddle, 1:Enabled
if ScHotkey_ButMiddle = 0
Final_Hotkey_ButMiddle:= Sc_Hotkey_ButMiddle
else
Final_Hotkey_ButMiddle:= "mbutton::"Hotkey_ButMiddle

GuiControlGet, ScHotkey_ButRight, 1:Enabled
if ScHotkey_ButRight = 0
Final_Hotkey_ButRight:= Sc_Hotkey_ButRight
else
Final_Hotkey_ButRight:= "rbutton::"Hotkey_ButRight

GuiControlGet, ScHotkey_ButWheelUp, 1:Enabled
if ScHotkey_ButWheelUp = 0
Final_Hotkey_ButWheelUp:= Sc_Hotkey_ButWheelUp
else
Final_Hotkey_ButWheelUp:= "WheelUp::"Hotkey_ButWheelUp

GuiControlGet, ScHotkey_ButWheelDn, 1:Enabled
if ScHotkey_ButWheelDn = 0
Final_Hotkey_ButWheelDn:= Sc_Hotkey_ButWheelDn
else
Final_Hotkey_ButWheelDn:= "WheelDown::"Hotkey_ButWheelDn

if Hotkey_ButLeftNat = 1
Final_Hotkey_ButLeft := "lbutton::lbutton"
if Hotkey_ButMiddleNat = 1
Final_Hotkey_ButMiddle := "mbutton::mbutton"
if Hotkey_ButRightNat = 1
Final_Hotkey_ButRight := "rbutton::rbutton"
if Hotkey_ButWheelUpNat = 1
Final_Hotkey_ButWheelUp := "WheelUp::WheelUp"
if Hotkey_ButWheelDnNat = 1
Final_Hotkey_ButWheelDn := "WheelDown::WheelDown"

if global_native != 1
if Window_Choice =
reload
Gui Hide
Gosub dynamic_lee
Return

Website:
Run http://www.autohotkey.com/forum/viewtopic.php?p=347496#347496
Return

Donate:
Run "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=disput`%40home`%2enl&lc=US&currency_code=EUR&bn=PP"
Return

AHK_Lee:
Run http://www.autohotkey.com/forum/profile.php?mode=viewprofile&u=44629
return

GuiClose:
ExitApp

Dynamic_lee:

Pid_main := DllCall("GetCurrentProcessId")

Critical
FileDelete, %A_ScriptDir%\hotkey.ahk

Critical
FileAppend ,
(
#SingleInstance force
#NoTrayIcon
DetectHiddenWindows On

SetKeyDelay 0
SetBatchLines -1
SetMouseDelay -1
SetTitleMatchMode 2
SetDefaultMouseSpeed 0
Coordmode, Mouse , Screen

Axis = %Axis%
If Axis = 1
sleep -1
else
SetTimer WatchMouse, 1

), %A_ScriptDir%\hotkey.ahk


If global_native = 1
sleep -1
else
{
Critical
FileAppend ,
(
#IfWinActive %Window_Choice%

), %A_ScriptDir%\hotkey.ahk
}

{
Critical
FileAppend ,
(
%Final_Hotkey_ButLeft%
%Final_Hotkey_ButMiddle%
%Final_Hotkey_ButRight%
%Final_Hotkey_ButWheelUp%
%Final_Hotkey_ButWheelDn%

), %A_ScriptDir%\hotkey.ahk
}

If global_native = 1
sleep -1
else
{
Critical
FileAppend ,
(
#IfWinActive

), %A_ScriptDir%\hotkey.ahk
}

Critical
FileAppend ,
(



*%Hotkey_Start%::
Suspend, Permit
PostMessage, 0x7777, 1, 1 ,,ahk_pid %Pid_main%
exitapp
return

*%Hotkey_Pause%::
Suspend
Pause,,1
return

*%Hotkey_Reload%::
Suspend, Permit
PostMessage, 0x7777, 1, 3 ,,ahk_pid %Pid_main%
exitapp
return
*%Hotkey_Exit%::
Suspend, Permit
PostMessage, 0x7777, 1, 4 ,,ahk_pid %Pid_main%
exitapp
return

WatchMouse:
Process,exist,%Pid_main%
if errorlevel = 0
exitapp

IfWinNotActive, %Window_Choice%
{
startingpos = 0
return
}

If startingpos = 0
MouseMove A_ScreenWidth/2, A_ScreenHeight/2, 0
startingpos = 1
   
KeyToHoldDownPrev1 = `%KeyToHoldDown1`%
KeyToHoldDownPrev2 = `%KeyToHoldDown2`%


MouseGetPos x, y
   

   If (x < (A_ScreenWidth/2-%Step%))
   {
KeyToHoldDown1 = %Hotkey_Left%
   }
   Else If (x > (A_ScreenWidth/2+%Step%))
   {
KeyToHoldDown1 = %Hotkey_Right%
   }
   Else
KeyToHoldDown1 =
 

If (y > (A_ScreenHeight/2+%Step%))
   {
KeyToHoldDown2 = %Hotkey_Down%
   }
   Else If (y < (A_ScreenHeight/2-%Step%))
   {
KeyToHoldDown2 = %Hotkey_Up%
   }
   Else
KeyToHoldDown2 =


Hotkey_XAxis_Nat_Left = %Hotkey_XAxis_Nat_Left%
Hotkey_XAxis_Nat_Right = %Hotkey_XAxis_Nat_Right%

if KeyToHoldDown1 != `%KeyToHoldDownPrev1`%
{
if KeyToHoldDownPrev1
    Send, {`%KeyToHoldDownPrev1`% up}
if KeyToHoldDown1
    Send, {`%KeyToHoldDown1`% down}
}


Hotkey_YAxis_Nat_Up = %Hotkey_YAxis_Nat_Up%
Hotkey_YAxis_Nat_Down = %Hotkey_YAxis_Nat_Down%
if KeyToHoldDown2 != `%KeyToHoldDownPrev2`%
{
if KeyToHoldDownPrev2
    Send, {`%KeyToHoldDownPrev2`% up}
if KeyToHoldDown2
    Send, {`%KeyToHoldDown2`% down}
}


Mode = %mode%
if Mode = 1
MouseMove A_ScreenWidth/2, A_ScreenHeight/2, 0
Return

del::reload
home::pause
pgup::suspend
end::Exitapp
), %A_ScriptDir%\hotkey.ahk
FileSetAttrib, ^H, %A_ScriptDir%\hotkey.ahk
Run, autohotkey.exe hotkey.ahk,%A_ScriptDir%,,Pid_sec
return

ScanCode( wParam, lParam )
{
global
SetFormat, Integer, Hex
 Clipboard := "SC" SubStr((((lParam>>16) & 0xFF)+0xF000),-2)
 GuiControl,, SC, %Clipboard%
 SC:= Clipboard
}


Version = 0.18.0
ScriptName = Mouse 2 Keyboard

Since I am cleaning up my NAS after a worm attack I decided to put this version online aswell. Forgot wich changes I made between 16 and 18. Also it still needs alot of fine tunning to make the script smaller and better.


Code:
#SingleInstance force

SetKeyDelay 0
SetBatchLines -1
SetMouseDelay -1
SetTitleMatchMode 2
SetDefaultMouseSpeed 0
Coordmode, Mouse , Screen

SetWorkingDir, %A_ScriptDir%   
Version = 0.18.0
ScriptName =  Mouse 2 Keyboard
;#include C:\WINDOWS\ShellNew\Auto_Backup.ahk


Menu, Tray, Icon, Shell32.dll, 44
Menu, tray, NoStandard
Menu, tray, add, Start, Menu_Start
Menu, tray, add, Pause, Menu_Pause
Menu, tray, add, Reload, Menu_Reload
Menu, tray, add, ExitApp, Menu_ExitApp

gosub Window_List
gosub Message
gosub Draw_Gui

Settimer Watch_Native, 300

return

+++++++++++++++++++++++++++


Draw_Gui:
Gui,1: Add, GroupBox, x22 y2 w450 h50 , Select Visible Window
Gui,1: Add, DropDownList, x32 y22 w270 vWindow_Choice Choose%Prefer_Window%, %visible_window_list%
Gui,1: Add, Button, x322 y22 w140 h20 gReload, Reload

Gui,1: Add, GroupBox, x22 y62 w280 h140 , General Settings
Gui,1: Add, CheckBox, x42 y92 w250 h20 vglobal_native, Use M2K settings as native for global system
Gui,1: Add, Radio, x42 y132 w110 h20 checked 1 vMode, 1. Step Mode
Gui,1: Add, Radio, x182 y132 w110 h20 vMode2, 2. Continous Mode

Gui,1: Add, Text, x42 y172 w100 h20 +Center, Idle Center Size
Gui,1: Add, Edit, x152 y172 w30 h20 +Center number limit4 vStep, 1
Gui,1: Add, Text, x192 y172 w100 h20 +Center, Pixels

Gui,1: Add, GroupBox, x322 y62 w150 h140 , Program Settings
Gui,1: Add, Text, x332 y82 w40 h20 +Center, Start
Gui,1: Add, Hotkey, x382 y82 w60 h20 vHotkey_Start, ^a
Gui,1: Add, Button, x442 y82 w20 h20 gscStart,
Gui,1: Add, Text, x332 y112 w40 h20 +Center, Pause
Gui,1: Add, Hotkey, x382 y112 w60 h20 vHotkey_Pause, ^p
Gui,1: Add, Button, x442 y112 w20 h20 gscPause,
Gui,1: Add, Text, x332 y142 w40 h20 +Center, Reload
Gui,1: Add, Hotkey, x382 y142 w60 h20 vHotkey_Reload, ^r
Gui,1: Add, Button, x442 y142 w20 h20 gscReload,
Gui,1: Add, Text, x332 y172 w40 h20 +Center, Exit
Gui,1: Add, Hotkey, x382 y172 w60 h20 vHotkey_Exit, ^x
Gui,1: Add, Button, x442 y172 w20 h20 gscExit,

Gui,1: Add, GroupBox, x22 y212 w280 h305 , Mouse Settings

Gui,1: Add, Text, x42 y232 w130 h20 , Tickbox: Native Function
Gui,1: Add, Text, x172 y232 w110 h20 ,Button :Advanced key

Gui,1: Add, GroupBox, x42 y252 w240 h135 , Buttons

Gui,1: Add, Text, x92 y302 w40 h20 +Center, Left
Gui,1: Add, Hotkey, x92 y322 w40 h20 vHotkey_ButLeft, d
Gui,1: Add, CheckBox, x82 y292 w10 h30 vHotkey_ButLeftNat, CheckBox
Gui,1: Add, Button, x132 y322 w20 h20 gscButLeft ,

Gui,1: Add, Text, x152 y302 w40 h20 +Center, Middle
Gui,1: Add, Hotkey, x152 y322 w40 h20 vHotkey_ButMiddle, s
Gui,1: Add, CheckBox, x142 y292 w10 h30 vHotkey_ButMiddleNat, CheckBox
Gui,1: Add, Button, x192 y322 w20 h20 gscButMiddle,


Gui,1: Add, Text, x212 y302 w40 h20 +Center, Right
Gui,1: Add, Hotkey, x212 y322 w40 h20 vHotkey_ButRight, f
Gui,1: Add, CheckBox, x202 y292 w10 h30 vHotkey_ButRightNat, CheckBox
Gui,1: Add, Button, x252 y322 w20 h20 gscButRight,

Gui,1: Add, Text, x102 y272 w50 h20 +Center, Wheel Up
Gui,1: Add, Hotkey, x152 y272 w40 h20 vHotkey_ButWheelUp, w
Gui,1: Add, CheckBox, x92 y262 w10 h30 vHotkey_ButWheelUpNat, CheckBox
Gui,1: Add, Button, x192 y272 w20 h20 gscButWheelup,

Gui,1: Add, Text, x102 y352 w50 h20 +Center, Wheel Dn
Gui,1: Add, Hotkey, x152 y352 w40 h20 vHotkey_ButWheelDn, x
Gui,1: Add, CheckBox, x92 y342 w10 h30 vHotkey_ButWheelDnNat, CheckBox
Gui,1: Add, Button, x192 y352 w20 h20 gscButWheelDn,

Gui,1: Add, GroupBox, x42 y392 w240 h115 , Axis
Gui,1: Add, CheckBox, x62 y412 w10 h20 vAxis, CheckBox

Gui,1: Add, Text, x112 y412 w40 h20 +Center, Up
Gui,1: Add, Hotkey, x152 y412 w40 h20 vHotkey_Up, Up
Gui,1: Add, Button, x192 y412 w20 h20 gscUP,

Gui,1: Add, Text, x112 y472 w40 h20 +Center, Down
Gui,1: Add, Hotkey, x152 y472 w40 h20 vHotkey_Down, Down
Gui,1: Add, Button, x192 y472 w20 h20 gscdown,

Gui,1: Add, Text, x62 y442 w40 h20 +Center, Left
Gui,1: Add, Hotkey, x102 y442 w40 h20 vHotkey_Left, Left
Gui,1: Add, Button, x142 y442 w20 h20 gscLeft,

Gui,1: Add, Text, x162 y442 w40 h20 +Center, Right
Gui,1: Add, Hotkey, x202 y442 w40 h20 vHotkey_Right, Right
Gui,1: Add, Button, x242 y442 w20 h20 gscRight,



Gui,1: Font, Arial Bold,
Gui,1: Add, Button, x332 y232 w130 h90 gStart, Start
Gui,1: Font, norm,

Gui,1: Add, Button, x332 y342 w130 h30 gWebsite, Project Website

Gui,1: Add, Text, x332 y492 w130 h20 +Center cF67D00 gAHK_Lee, AHK_Lee
Gui,1: Font, norm,

Gui,1: Font, italic
Gui,1: Font,, Arial Bold
Gui,1: Add, Button, x332 y392 w130 h30 gDonate, Donate a coffee

Gui,1: Show,h537 w496, %ScriptName% - Version: %Version%

Return

scStart:
scPause:
scReload:
scExit:
scButLeft:
scButMiddle:
scButRight:
scButWheelup:
scButWheelDn:
scUP:
scDown:
scLeft:
scRight:
scbutton = %A_ThisLabel%

Gui,2: Destroy

ScanCode:
Gui,2: Add, CheckBox, x22 y12 w70 h20 vWildcard, Wildcard
Gui,2: Add, CheckBox, x112 y12 w70 h20 vNative, Native
Gui,2: Add, CheckBox, x202 y12 w70 h20 vComprise, Comprise

Gui,2: Add, CheckBox, x22 y42 w50 h20 vShift, Shift
Gui,2: Add, CheckBox, x92 y42 w50 h20 vCTRL, CTRL
Gui,2: Add, CheckBox, x162 y42 w50 h20 vWIN, WIN
Gui,2: Add, CheckBox, x232 y42 w40 h20 vALT, ALT

Gui,2: Font, s14 Bold, Arial
Gui,2: Add, Text, x22 y72 w150 h40 vSC 0x201 +Border, Press any key

Gui,2: Add, Button, x192 y72 w80 h40 gButtonSC, Accept


Gui,2: +ToolWindow -SysMenu +AlwaysOnTop
Gui,2: Show,h125 w295, % "Input ScanCode: " scButton
Loop 9
  OnMessage( 255+A_Index, "ScanCode" ) ; 0x100 to 0x108
  Return
;%
return

Message:
OnMessage(0x7777, "MsgMonitor")
MsgMonitor(wParam, lParam, msg)
{
if wParam != 1
return

if lParam = 1
{
gosub Menu_Start
}
if lParam = 2
{
msgbox test
;gosub Menu_Pause
}
if lParam = 3
{
gosub Menu_Reload
}
if lParam = 4
{
gosub Menu_ExitApp
}
}
return

Menu_Start:
process,close, ahk Pid_sec
gosub start
return

Menu_Pause:
process,close, ahk Pid_sec
Pause
return

Menu_Reload:
Reload:
process,close, ahk Pid_sec
Reload
Return

Menu_ExitApp:
process,close, ahk Pid_sec
exitapp
return


Window_List:
WinGet, window_id, list,,, Program Manager
Loop, %window_id%
{
    this_window_id := window_id%A_Index%
    WinGetTitle, this_window_title, ahk_id %this_window_id%
   if (this_window_title = "Start" or "")
   continue
   if visible_window_list =
   visible_window_list = %this_window_title%
   else
   visible_window_list = %visible_window_list%|%this_window_title%
}

sort,visible_window_list, D|

Loop, parse, visible_window_list, |,
{
    ifinstring,A_LoopField,Jnes
   Prefer_window := A_Index
}
return

ButtonSC:
Gui,2: Submit
Gui,2: Destroy

SC_hotkey:=

If Wildcard = 1
SC_hotkey.="*"

If Native = 1
SC_hotkey.="~"

If Comprise = 1
SC_hotkey.="$"

if SCButton = scStart
SC_hotkey.="scStart::"
if SCButton = scPause
SC_hotkey.="scPause::"
if SCButton = scReload
SC_hotkey.="scReload::"
if SCButton = scExit
SC_hotkey.="scExit::"

if SCButton = scButLeft
{
SC_hotkey.="lbutton::"
Create_Hotkey(SCBUTTON)
}
if SCButton = scButMiddle
SC_hotkey.="mbutton::"

if SCButton = scButRight
SC_hotkey.="rbutton::"

if SCButton = scButWheelup
SC_hotkey.="Wheelup::"

if SCButton = scButWheelDn
SC_hotkey.="Wheeldown::"


if SCButton = scUP
SC_hotkey.="scUP::"

if SCButton = scDown
SC_hotkey.="scDown::"

if SCButton = scLeft
SC_hotkey.="ScLeft::"

if SCButton = scRight
SC_hotkey.="scRight::"

If Shift = 1
SC_hotkey.="+"

If CTRL = 1
SC_hotkey.="^"

If WIN = 1
SC_hotkey.="#"

If ALT = 1
SC_hotkey.="!"

SC_hotkey.=SC


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;if SCButton = scButLeft
;{
;GuiControlGet, Hotkey_ButLeft,1:Pos
;Guicontrol, 1:hide, Hotkey_ButLeft
;GuiControlGet, ScHotkey_ButLeft, 1:
;if errorlevel = 1
;{
;Gui,1: Add, edit, x%Hotkey_ButLeftX% y%Hotkey_ButLeftY% w%Hotkey_ButLeftW% h%Hotkey_ButLeftH% vScHotkey_ButLeft, %SC%
;}
;Guicontrol, 1:,ScHotkey_ButLeft,%SC%
;Guicontrol, 1:disable, ScHotkey_ButLeft
;
;sc_hotkey_butleft:=SC_Hotkey
;}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


if SCButton = scButMiddle
{
GuiControlGet, Hotkey_ButMiddle,1:Pos
Guicontrol, 1:hide, Hotkey_ButMiddle
GuiControlGet, ScHotkey_ButMiddle, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButMiddleX% y%Hotkey_ButMiddleY% w%Hotkey_ButMiddleW% h%Hotkey_ButMiddleH% vScHotkey_ButMiddle, %SC%
}
Guicontrol, 1:,ScHotkey_ButMiddle,%SC%
Guicontrol, 1:disable, ScHotkey_ButMiddle

sc_hotkey_butMiddle:=SC_Hotkey
}

if SCButton = scButRight
{
GuiControlGet, Hotkey_ButRight,1:Pos
Guicontrol, 1:hide, Hotkey_ButRight
GuiControlGet, ScHotkey_ButRight, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButRightX% y%Hotkey_ButRightY% w%Hotkey_ButRightW% h%Hotkey_ButRightH% vScHotkey_ButRight, %SC%
}
Guicontrol, 1:,ScHotkey_ButRight,%SC%
Guicontrol, 1:disable, ScHotkey_ButRight

sc_hotkey_butRight:=SC_Hotkey
}

if SCButton = scButWheelup
{
GuiControlGet, Hotkey_ButWheelup,1:Pos
Guicontrol, 1:hide, Hotkey_ButWheelup
GuiControlGet, ScHotkey_ButWheelup, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButWheelupX% y%Hotkey_ButWheelupY% w%Hotkey_ButWheelupW% h%Hotkey_ButWheelupH% vScHotkey_ButWheelup, %SC%
}
Guicontrol, 1:,ScHotkey_ButWheelup,%SC%
Guicontrol, 1:disable, ScHotkey_ButWheelup

sc_hotkey_butWheelup:=SC_Hotkey
}

if SCButton = scButWheelDn
{
GuiControlGet, Hotkey_ButWheelDn,1:Pos
Guicontrol, 1:hide, Hotkey_ButWheelDn
GuiControlGet, ScHotkey_ButWheelDn, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButWheelDnX% y%Hotkey_ButWheelDnY% w%Hotkey_ButWheelDnW% h%Hotkey_ButWheelDnH% vScHotkey_ButWheelDn, %SC%
}
Guicontrol, 1:,ScHotkey_ButWheelDn,%SC%
Guicontrol, 1:disable, ScHotkey_ButWheelDn

sc_hotkey_butWheelDn:=SC_Hotkey
}

return


Watch_Native:
GuiControlGet,global_native,1:
if global_native = 1
{
Guicontrol, 1:,mode2,1
Guicontrol, 1:,Axis,1
Guicontrol, 1:,Hotkey_ButWheelDnNat,1
Guicontrol, 1:,Hotkey_ButWheelUpNat,1
Guicontrol, 1:,Hotkey_ButRightNat,1
Guicontrol, 1:,Hotkey_ButMiddleNat,1
Guicontrol, 1:,Hotkey_ButLeftNat,1
Settimer,Watch_Native,off
}
return

Start:
Gui Submit

If Axis = 1
Mode = 2


StringLower, Hotkey_Start, Hotkey_Start
StringLower, Hotkey_Pause, Hotkey_Pause
StringLower, Hotkey_Reload, Hotkey_Reload
StringLower, Hotkey_Exit, Hotkey_Exit

StringLower, Hotkey_ButLeft, Hotkey_ButLeft
StringLower, Hotkey_ButMiddle, Hotkey_ButMiddle
StringLower, Hotkey_ButRight, Hotkey_ButRight
StringLower, Hotkey_ButWheelUp, Hotkey_ButWheelUp
StringLower, Hotkey_ButWheelDn, Hotkey_ButWheelDn

StringLower, Hotkey_Up, Hotkey_Up
StringLower, Hotkey_Down, Hotkey_Down
StringLower, Hotkey_Left, Hotkey_Left
StringLower, Hotkey_Right, Hotkey_Right

Final_Hotkey_ButLeft:="lbutton"
Final_Hotkey_ButLeft:=HotkeyOrScanCode(Sc_Hotkey_ButLeft,Final_Hotkey_ButLeft,Hotkey_ButLeft,Hotkey_ButLeftNat)

Final_Hotkey_ButMiddle:="mbutton"
Final_Hotkey_ButMiddle:=HotkeyOrScanCode(Sc_Hotkey_ButMiddle,Final_Hotkey_ButMiddle,Hotkey_ButMiddle,Hotkey_ButMiddleNat)

Final_Hotkey_ButRight:="rbutton"
Final_Hotkey_ButRight:=HotkeyOrScanCode(Sc_Hotkey_ButRight,Final_Hotkey_ButRight,Hotkey_ButRight,Hotkey_ButRightNat)

Final_Hotkey_ButWheelUp:="WheelUp"
Final_Hotkey_ButWheelUp:=HotkeyOrScanCode(Sc_Hotkey_ButWheelUp,Final_Hotkey_ButWheelUp,Hotkey_ButWheelUp,Hotkey_ButWheelUpNat)

Final_Hotkey_ButWheelDn:="WheelDown"
Final_Hotkey_ButWheelDn:=HotkeyOrScanCode(Sc_Hotkey_ButWheelDn,Final_Hotkey_ButWheelDn,Hotkey_ButWheelDn,Hotkey_ButWheelDnNat)

if global_native != 1
if Window_Choice =
reload


Gui Hide
Gosub dynamic_lee
Return

Website:
Run http://www.autohotkey.com/forum/viewtopic.php?p=347496#347496
Return

Donate:
Run "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=disput`%40home`%2enl&lc=US&currency_code=EUR&bn=PP"
Return

AHK_Lee:
Run http://www.autohotkey.com/forum/profile.php?mode=viewprofile&u=44629
return

GuiClose:
ExitApp

Dynamic_lee:

Pid_main := DllCall("GetCurrentProcessId")

Critical
FileDelete, %A_ScriptDir%\hotkey.ahk

Critical
FileAppend ,
(
#SingleInstance force
#NoTrayIcon
DetectHiddenWindows On

SetKeyDelay 0
SetBatchLines -1
SetMouseDelay -1
SetTitleMatchMode 2
SetDefaultMouseSpeed 0
Coordmode, Mouse , Screen

Axis = %Axis%
If Axis = 1
sleep -1
else
SetTimer WatchMouse, 1

), %A_ScriptDir%\hotkey.ahk


If global_native = 1
sleep -1
else
{
Critical
FileAppend ,
(
#IfWinActive %Window_Choice%

), %A_ScriptDir%\hotkey.ahk
}

{
Critical
FileAppend ,
(
%Final_Hotkey_ButLeft%
%Final_Hotkey_ButMiddle%
%Final_Hotkey_ButRight%
%Final_Hotkey_ButWheelUp%
%Final_Hotkey_ButWheelDn%

), %A_ScriptDir%\hotkey.ahk
}

If global_native = 1
sleep -1
else
{
Critical
FileAppend ,
(
#IfWinActive

), %A_ScriptDir%\hotkey.ahk
}

Critical
FileAppend ,
(



*%Hotkey_Start%::
Suspend, Permit
PostMessage, 0x7777, 1, 1 ,,ahk_pid %Pid_main%
exitapp
return

*%Hotkey_Pause%::
Suspend
Pause,,1
return

*%Hotkey_Reload%::
Suspend, Permit
PostMessage, 0x7777, 1, 3 ,,ahk_pid %Pid_main%
exitapp
return
*%Hotkey_Exit%::
Suspend, Permit
PostMessage, 0x7777, 1, 4 ,,ahk_pid %Pid_main%
exitapp
return

WatchMouse:
Process,exist,%Pid_main%
if errorlevel = 0
exitapp

IfWinNotActive, %Window_Choice%
{
startingpos = 0
return
}

If startingpos = 0
MouseMove A_ScreenWidth/2, A_ScreenHeight/2, 0
startingpos = 1
   
KeyToHoldDownPrev1 = `%KeyToHoldDown1`%
KeyToHoldDownPrev2 = `%KeyToHoldDown2`%


MouseGetPos x, y
   

   If (x < (A_ScreenWidth/2-%Step%))
   {
KeyToHoldDown1 = %Hotkey_Left%
   }
   Else If (x > (A_ScreenWidth/2+%Step%))
   {
KeyToHoldDown1 = %Hotkey_Right%
   }
   Else
KeyToHoldDown1 =
 

If (y > (A_ScreenHeight/2+%Step%))
   {
KeyToHoldDown2 = %Hotkey_Down%
   }
   Else If (y < (A_ScreenHeight/2-%Step%))
   {
KeyToHoldDown2 = %Hotkey_Up%
   }
   Else
KeyToHoldDown2 =


Hotkey_XAxis_Nat_Left = %Hotkey_XAxis_Nat_Left%
Hotkey_XAxis_Nat_Right = %Hotkey_XAxis_Nat_Right%

if KeyToHoldDown1 != `%KeyToHoldDownPrev1`%
{
if KeyToHoldDownPrev1
    Send, {`%KeyToHoldDownPrev1`% up}
if KeyToHoldDown1
    Send, {`%KeyToHoldDown1`% down}
}


Hotkey_YAxis_Nat_Up = %Hotkey_YAxis_Nat_Up%
Hotkey_YAxis_Nat_Down = %Hotkey_YAxis_Nat_Down%
if KeyToHoldDown2 != `%KeyToHoldDownPrev2`%
{
if KeyToHoldDownPrev2
    Send, {`%KeyToHoldDownPrev2`% up}
if KeyToHoldDown2
    Send, {`%KeyToHoldDown2`% down}
}


Mode = %mode%
if Mode = 1
MouseMove A_ScreenWidth/2, A_ScreenHeight/2, 0
Return

del::reload
home::pause
pgup::suspend
end::Exitapp
), %A_ScriptDir%\hotkey.ahk
FileSetAttrib, ^H, %A_ScriptDir%\hotkey.ahk
Run, autohotkey.exe hotkey.ahk,%A_ScriptDir%,,Pid_sec
return

ScanCode( wParam, lParam )
{
global
SetFormat, Integer, Hex
 Clipboard := "SC" SubStr((((lParam>>16) & 0xFF)+0xF000),-2)
 GuiControl,, SC, %Clipboard%
 SC:= Clipboard
}

HotkeyOrScanCode(HS1,HS2,HS3,HS4)
{
   if HS1 !=
      HS:= HS1
   else
      HS:= "*" HS2 "::" HS3
   if HS4 = 1
      HS:=
Return HS
}

Create_hotkey(SCButton)
{
global
StringTrimLeft, SCButton, String, 5
GuiControlGet, Hotkey_But%SCButton%,1:Pos
Guicontrol, 1:hide, Hotkey_But%SCButton%
GuiControlGet, ScHotkey_But%SCButton%, 1:
if errorlevel = 1
{
test%A_index%:= test

msgbox %test0% %A_index%
Gui,1: Add, edit, x%Hotkey_But%SCButton%X% y%Hotkey_But%SCButton%Y% w%Hotkey_But%SCButton%W% h%Hotkey_But%SCButton%H% vScHotkey_But%SCButton%, %SC%
}
Guicontrol, 1:,ScHotkey_But%SCButton%,%SC%
Guicontrol, 1:disable, ScHotkey_But%SCButton%

sc_hotkey_but%SCButton%:=SC_Hotkey
}


Last edited by AHK_Lee on November 14th, 2010, 3:54 pm, edited 28 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 13th, 2010, 11:36 pm 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
instead of making pointless posts like this, do all the text/formatting in notepad or some BBCODE editor or w/e word processor/editor you prefer.
and it's not necessary to have 3 reserved spaces. 1 should be plenty.

edit:
you should also make the code semi-complete and working before making a topic about the script. this ain't twitter where we need to see every step of your work, we want working completed code.

_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2010, 3:36 am 
Offline

Joined: April 8th, 2010, 11:34 am
Posts: 32
any luck?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2010, 7:26 am 
Offline

Joined: April 13th, 2010, 7:03 pm
Posts: 23
Location: Netherlands
:?
I can't seem to get to simulate these isseus.

A step by step failure would be helpfull.

currently busy on adapting the script with gui to a more dynamic script wich gives the user the ability to even play for example; button played flash games with the mouse.

_________________
Confucius : 551 BC wrote:
And remember, no matter where you go, there you are.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2010, 8:44 am 
Offline

Joined: April 8th, 2010, 11:34 am
Posts: 32
i've been thinking, these issues could be from my joystick mouse because it's only a prototype version. i will hopefully be recieving a revised version on monday, hopefully then the issues will be fixed.

AHK_Lee could you add the pause and resume functionality to the script so i dont have to use window titles anymore.

when the script first executes, it needs to be paused until ctrl+a is pressed. also when the script is actually working, can we hide the mouse cursor and when it's paused can we show the mouse cursor again?

if you can add these features ASAP that would be terrific. thanks.

i've tested the last script with arcade games as well using an emulator called raine and it works great too.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2010, 2:37 am 
Offline

Joined: April 13th, 2010, 7:03 pm
Posts: 23
Location: Netherlands
Fatal check the new script please and make a summary whats missing or needs a change.

Do you got a link to the joystick mouse supplier?

Greetz,
Lee

_________________
Confucius : 551 BC wrote:
And remember, no matter where you go, there you are.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2010, 9:28 am 
Offline

Joined: April 8th, 2010, 11:34 am
Posts: 32
i have found the following bugs:

1: when the script is paused and started again, the gui pops up.

2: whenever i click any mouse button, left shift gets pressed.

3: i cannot map spacebar to a mouse button.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2010, 6:15 pm 
Offline

Joined: April 13th, 2010, 7:03 pm
Posts: 23
Location: Netherlands
FATAL-1 wrote:
i have found the following bugs:

1: when the script is paused and started again, the gui pops up.

2: whenever i click any mouse button, left shift gets pressed.

3: i cannot map spacebar to a mouse button.


1: Currently on purpose almost finished the dynamic hotkey crosslink.
2: Due to capital use, changed it, please check.
3: Limitation of the GUI usage:
Quote:
The Hotkey control has limited capabilities. For example, it does not support mouse/joystick hotkeys or the Windows key (LWin and RWin). One way to work around this is to provide one or more checkboxes as a means for the user to enable extra modifiers such as the Windows key.

will come back for that later


these fixes are applied on >= version 0.6.0

_________________
Confucius : 551 BC wrote:
And remember, no matter where you go, there you are.


Last edited by AHK_Lee on April 19th, 2010, 10:38 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 19th, 2010, 4:10 am 
Offline

Joined: April 8th, 2010, 11:34 am
Posts: 32
can you please let me know when you have updated the script. thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 21st, 2010, 6:35 am 
Offline

Joined: April 8th, 2010, 11:34 am
Posts: 32
can you give me an update on the script? how is it progressing?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 22nd, 2010, 11:06 pm 
Offline

Joined: April 13th, 2010, 7:03 pm
Posts: 23
Location: Netherlands
Updated the script again.

Any suggestions what behavior it should preform when the Start,pause,reload,exit hotkey is pressed ?

Any other bugs please post a reply.

Didn't got much time this week needed to get some deadline's at work.

_________________
Confucius : 551 BC wrote:
And remember, no matter where you go, there you are.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2010, 12:32 am 
Offline

Joined: May 8th, 2008, 2:58 pm
Posts: 39
Location: C:\ESTONIA\adavere\RIST.rar
nice script(Y) need middle up and down function, :)

_________________
Keegi Siin ka Eestlane? :)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 45 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg and 8 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group