keyboard emulator buttons

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

keyboard emulator buttons

Post by idiot » Wed Nov 04, 2009 5:50 am

ok i know how to use vk_keys in code to make script ok now what i want to be able to do is make a program that has multiple buttons you can click with mouse to send each key a-z space and 1-0 keys i have no idea how to create buttons please help i need each button to press a key never done anything like this before but trying to help a friend whose keyboard broke
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Nov 04, 2009 2:12 pm

I started to write a keyboard script a couple of years ago. My need evaporated and I didn't finish it. What I have is posted below. It might give you or someone else an idea. If anyone gets this working please post it.

Dick

Code: Select all

VBSTART
VBEND
Let>comma=,
Dialog>Dialog1
Caption=KeyBoard
Width=874
Height=292
Top=446
Left=81
Label=selection,4,4,true
Button=9,760,88,49,25,57
Button=8,712,88,49,25,56
Button=7,664,88,49,25,55
Button=6,760,112,49,25,54
Button=5,712,112,49,25,53
Button=4,664,112,49,25,52
Button=3,760,136,49,25,51
Button=2,712,136,49,25,50
Button=1,664,136,49,25,49
Button=0,712,160,49,25,48
Button=*,760,64,49,25,42
Button=/,712,64,49,25,47
Button=-,808,64,49,25,45
Button=Enter,808,112,49,49,13
Button=+,808,88,49,25,43
Button=~,8,56,42,25,126
Button=1,50,56,42,25,49
Button=2,92,56,42,25,50
Button=3,134,56,42,25,51
Button=4,176,56,42,25,52
Button=5,218,56,42,25,53
Button=6,260,56,42,25,54
Button=7,302,56,42,25,55
Button=8,344,56,42,25,56
Button=9,386,56,42,25,57
Button=0,428,56,42,25,48
Button=-,470,56,42,25,45
Button==,512,56,42,25,61
Button=BackSpc,554,56,42,25,8
Button=Tab.,8,81,42,25,9
Button=Q,50,81,42,25,81
Button=W,92,81,42,25,87
Button=E,134,81,42,25,69
Button=R,176,81,42,25,82
Button=T,218,81,42,25,84
Button=Y,260,81,42,25,89
Button=U,302,81,42,25,85
Button=I,344,81,42,25,73
Button=O,386,81,42,25,79
Button=P,428,81,42,25,80
Button=[,470,81,42,25,91
Button=],512,81,42,25,93
Button=\,554,81,42,25,92
Button=A,8,106,42,25,65
Button=S,50,106,42,25,83
Button=D,92,106,42,25,68
Button=F,134,106,42,25,70
Button=G,176,106,42,25,71
Button=H,218,106,42,25,72
Button=J,260,106,42,25,74
Button=K,302,106,42,25,75
Button=L,344,106,42,25,76
Button=;,386,106,42,25,59
Button=',428,106,42,25,39
Button=Enter,470,106,42,25,13
Button=Home,512,106,42,25,2
Button=End,554,106,42,25,3
Button=Z,8,131,42,25,90
Button=X,50,131,42,25,88
Button=C,92,131,42,25,67
Button=V,134,131,42,25,86
Button=B,176,131,42,25,66
Button=N,218,131,42,25,78
Button=M,260,131,42,25,77
Button=%comma%,302,131,42,25,44
Button=.,344,131,42,25,46
Button=/,386,131,42,25,47
Button=Shift,428,131,42,25,901
Button=Page%CRLF%Up,470,131,42,25,902
Button=Page%CRLF%Down,512,131,42,25,903
Button=Del,554,131,42,25,904
Button=Ctrl,8,156,42,25,0
Button=WinKey,50,156,42,25,0
Button=Alt,92,156,42,25,0
Button=Space,134,156,42,25,32
Button=Space,176,156,42,25,32
Button=Space,218,156,42,25,32
Button=Space,260,156,42,25,32
Button=Alt,302,156,42,25,0
Button=WinKey,344,156,42,25,0
Button=MenuKey,386,156,42,25,0
Button=Ctrl,428,156,42,25,0
Button= ,470,156,42,25,0
Button= ,512,156,42,25,0
Button= ,554,156,42,25,0
EndDialog>Dialog1

Show>Dialog1
Let>HWND_TOPMOST=-1
Let>HWND_NOTOPMOST=-2
Let>SWP_NOSIZE=1
Let>SWP_NOMOVE=2
Let>SWP_NOACTIVATE=16
Let>SWP_SHOWWINDOW=64
LibFunc>user32,FindWindowA,dhwnd,TForm,KeyBoard
Let>Flags={%SWP_NOACTIVATE% Or %SWP_SHOWWINDOW% Or %SWP_NOMOVE% Or %SWP_NOSIZE%}
LibFunc>User32,SetWindowPos,swpr,dhwnd,HWND_TOPMOST,0,0,0,0,Flags
CloseDialog>dialog1

Let>LastTitle=Program Manager*

Show>dialog1
Label>AlphabetLoop
  GetActiveWindow>WinTitle,WinX,WinY
  If>%Wintitle%=KeyBoard
    Let>WinTitle=%LastTitle%
  Else
    Let>LastTitle=%Wintitle%
  EndIf
  GetDialogAction>dialog1,res1
  If>%res1%=2
    Exit>0
  EndIf
  If>%res1%>0
    Wait>0.1
    VBEval>chr(%res1%),character
    Let>dialog1.mslabel1=character
    RDA>dialog1
  EndIF
  GetWindowPos>KeyBoard,keyX,keyY
  MoveWindow>KeyBoard,keyX,keyY
  Wait>0.01
Goto>AlphabetLoop

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Wed Nov 04, 2009 7:51 pm

ok im thinking this part here is the code that displays the key pressed within the program and id im right then all that needs to be done to get this to work is to ad a small function to send character to an active window when the button is clicked im not great at vb but im giving it a shot maybe adding bottun you can drag to selct window to send to would be good option

Code: Select all

If>%res1%=2
    Exit>0
  EndIf
  If>%res1%>0
    Wait>0.1
    VBEval>chr(%res1%),character
    Let>dialog1.mslabel1=character
    RDA>dialog1
  EndIF

if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Nov 04, 2009 8:01 pm

I think you've got it. You might try replacing Let>dialog1.mslabel1=character with Setfocus to some window and then Send> the variable "character"

Good Luck. Sorry I don't have time to work on it. :(

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Wed Nov 04, 2009 8:33 pm

yes works but you have to click on the window you wish to send character each time then click button i will need to edit to keep focus on window LastWindow so you can type more freely
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Wed Nov 04, 2009 9:02 pm

all finished heres edited code had to add wait after setfocus to get keys to send correctly but works great thanks for the help bro

Code: Select all

VBSTART
VBEND
Let>comma=,
Dialog>Dialog1
Caption=KeyBoard
Width=874
Height=292
Top=446
Left=81
Label=selection,4,4,true
Button=9,760,88,49,25,57
Button=8,712,88,49,25,56
Button=7,664,88,49,25,55
Button=6,760,112,49,25,54
Button=5,712,112,49,25,53
Button=4,664,112,49,25,52
Button=3,760,136,49,25,51
Button=2,712,136,49,25,50
Button=1,664,136,49,25,49
Button=0,712,160,49,25,48
Button=*,760,64,49,25,42
Button=/,712,64,49,25,47
Button=-,808,64,49,25,45
Button=Enter,808,112,49,49,13
Button=+,808,88,49,25,43
Button=~,8,56,42,25,126
Button=1,50,56,42,25,49
Button=2,92,56,42,25,50
Button=3,134,56,42,25,51
Button=4,176,56,42,25,52
Button=5,218,56,42,25,53
Button=6,260,56,42,25,54
Button=7,302,56,42,25,55
Button=8,344,56,42,25,56
Button=9,386,56,42,25,57
Button=0,428,56,42,25,48
Button=-,470,56,42,25,45
Button==,512,56,42,25,61
Button=BackSpc,554,56,42,25,8
Button=Tab.,8,81,42,25,9
Button=Q,50,81,42,25,81
Button=W,92,81,42,25,87
Button=E,134,81,42,25,69
Button=R,176,81,42,25,82
Button=T,218,81,42,25,84
Button=Y,260,81,42,25,89
Button=U,302,81,42,25,85
Button=I,344,81,42,25,73
Button=O,386,81,42,25,79
Button=P,428,81,42,25,80
Button=[,470,81,42,25,91
Button=],512,81,42,25,93
Button=\,554,81,42,25,92
Button=A,8,106,42,25,65
Button=S,50,106,42,25,83
Button=D,92,106,42,25,68
Button=F,134,106,42,25,70
Button=G,176,106,42,25,71
Button=H,218,106,42,25,72
Button=J,260,106,42,25,74
Button=K,302,106,42,25,75
Button=L,344,106,42,25,76
Button=;,386,106,42,25,59
Button=',428,106,42,25,39
Button=Enter,470,106,42,25,13
Button=Home,512,106,42,25,2
Button=End,554,106,42,25,3
Button=Z,8,131,42,25,90
Button=X,50,131,42,25,88
Button=C,92,131,42,25,67
Button=V,134,131,42,25,86
Button=B,176,131,42,25,66
Button=N,218,131,42,25,78
Button=M,260,131,42,25,77
Button=%comma%,302,131,42,25,44
Button=.,344,131,42,25,46
Button=/,386,131,42,25,47
Button=Shift,428,131,42,25,901
Button=Page%CRLF%Up,470,131,42,25,902
Button=Page%CRLF%Down,512,131,42,25,903
Button=Del,554,131,42,25,904
Button=Ctrl,8,156,42,25,0
Button=WinKey,50,156,42,25,0
Button=Alt,92,156,42,25,0
Button=Space,134,156,42,25,32
Button=Space,176,156,42,25,32
Button=Space,218,156,42,25,32
Button=Space,260,156,42,25,32
Button=Alt,302,156,42,25,0
Button=WinKey,344,156,42,25,0
Button=MenuKey,386,156,42,25,0
Button=Ctrl,428,156,42,25,0
Button= ,470,156,42,25,0
Button= ,512,156,42,25,0
Button= ,554,156,42,25,0
EndDialog>Dialog1

Show>Dialog1
Let>HWND_TOPMOST=-1
Let>HWND_NOTOPMOST=-2
Let>SWP_NOSIZE=1
Let>SWP_NOMOVE=2
Let>SWP_NOACTIVATE=16
Let>SWP_SHOWWINDOW=64
LibFunc>user32,FindWindowA,dhwnd,TForm,KeyBoard
Let>Flags={%SWP_NOACTIVATE% Or %SWP_SHOWWINDOW% Or %SWP_NOMOVE% Or %SWP_NOSIZE%}
LibFunc>User32,SetWindowPos,swpr,dhwnd,HWND_TOPMOST,0,0,0,0,Flags
CloseDialog>dialog1

Let>LastTitle=Program Manager*

Show>dialog1
Label>AlphabetLoop
 GetActiveWindow>WinTitle,WinX,WinY
  If>%Wintitle%=KeyBoard
    Let>WinTitle=%LastTitle%
  Else
    Let>LastTitle=%Wintitle%
  EndIf
  GetDialogAction>dialog1,res1
  If>%res1%=2
    Exit>0
  EndIf
  If>%res1%>0
    Wait>0.1
    VBEval>chr(%res1%),character
    SetFocus>LastTitle
    wait>0.53
    send>character
    RDA>dialog1
  EndIF
  GetWindowPos>KeyBoard,keyX,keyY
  MoveWindow>KeyBoard,keyX,keyY
  Wait>0.01
Goto>AlphabetLoop

if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sat Nov 07, 2009 11:13 pm

Thanks for sharing.

Dumb question. What's wrong with Windows On-screen keyboard?

run>%SYS_DIR%\osk.exe

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sun Nov 08, 2009 12:44 am

When I originally started this script it was to run on Windows NT. Before I had it working properly we were forced to abandon our Windows NT computers. They can no longer run the current version of our ERP software.

I'd like to point out that the keyboard script as posted in this thread is still not fully functional. There are several keys that will not work and the "Home" key will kill the program completely. I have too many unfinished projects that I want completed... so I won't be finishing this one. I would still request that if anyone does make a fully functional keyboard script using my concept, that they post it so the community can benefit.

Thanks,
Dick

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Thu Nov 12, 2009 10:00 pm

hmmmm every key worked for me but ill check into it see what i can do maybe ill change all the buttons to use vk_keys instead that might make it more compatible with current windows but will take awhile to change all that so give me some time


and to rain well not everyone has it or even if they do have they not know where to find it and having one they can download to desktop would be much easier especially if keyboard breaks me using bad version of xp so i dont have it myself i even still have to use teamviewer cause i dont have everything most xp users have
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts