Rapid-Q by William Yu (c)1999-2000 .

Upload il tuo script su Rapidq.it

Sendkey ad applicazione

'sendkey to application



$typecheck on



const KEYEVENTF_KEYUP = &H2 ' Release key

Declare function keybd_event Lib "user32" alias "keybd_event" (bVk As Byte, bScan _

As Byte, dwFlags As Long, dwExtraInfo As Long) as long

Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As Long
Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" _

(hwnd As Long) As Long



const VK_LBUTTON=&h01 'Left mouse button.

const VK_RBUTTON=&h02 'Right mouse button.

const VK_CANCEL=&h03 'Used for control-break processing.

const VK_MBUTTON=&h04h 'Middle mouse button (3-button mouse).

const VK_BACK=&h08

const VK_TAB=&h09

const VK_CLEAR=&h0C

const VK_RETURN=&h0D

const VK_SHIFT=&h10

const VK_CONTROL=&h11

const VK_MENU=&h12

const VK_PAUSE=&h13

const VK_CAPITAL=&h14

const VK_ESCAPE=&h1B

const VK_SPACE=&h20

const VK_PRIOR=&h21 'Page up.

const VK_NEXT=&h22 'Page down.

const VK_END=&h23

const VK_HOME=&h24

const VK_LEFT=&h25

const VK_UP=&h26

const VK_RIGHT=&h27

const VK_DOWN=&h28

const VK_SELECT=&h29

const VK_INSERT=&h2D

const VK_DELETE=&h2E

const VK_HELP=&h2F

const VK_0=&h30

const VK_1=&h31

const VK_2=&h32

const VK_3=&h33

const VK_4=&h34

const VK_5=&h35

const VK_6=&h36

const VK_7=&h37

const VK_8=&h38

const VK_9=&h39

const VK_A=&h41

const VK_B=&h42

const VK_C=&h43

const VK_D=&h44

const VK_E=&h45

const VK_F=&h46

const VK_G=&h47

const VK_H=&h48

const VK_I=&h49

const VK_J=&h4A

const VK_K=&h4B

const VK_L=&h4C

const VK_M=&h4D

const VK_N=&h4E

const VK_O=&h4F

const VK_P=&h50

const VK_Q=&h51

const VK_R=&h52

const VK_S=&h53

const VK_T=&h54

const VK_U=&h55

const VK_V=&h56

const VK_W=&h57

const VK_X=&h58

const VK_Y=&h59

const VK_Z=&h5A

const VK_NUMPAD0=&h60

const VK_NUMPAD1=&h61

const VK_NUMPAD2=&h62

const VK_NUMPAD3=&h63

const VK_NUMPAD4=&h64

const VK_NUMPAD5=&h65

const VK_NUMPAD6=&h66

const VK_NUMPAD7=&h67

const VK_NUMPAD8=&h68

const VK_NUMPAD9=&h69

const VK_MULTIPLY=&h6A

const VK_ADD=&h6B

const VK_SEPARATER=&h6C

const VK_SUBTRACT=&h6D

const VK_DECIMAL=&h6E

const VK_DIVIDE=&h6F

const VK_F1=&h70

const VK_F2=&h71

const VK_F3=&h72

const VK_F4=&h73

const VK_F5=&h74

const VK_F6=&h75

const VK_F7=&h76

const VK_F8=&h77

const VK_F9=&h78

const VK_F10=&h79

const VK_F11=&h7A

const VK_F12=&h7B

const VK_F13=&h7C

const VK_F14=&h7D

const VK_F15=&h7E

const VK_F16=&h7F

const VK_F17=&h80

const VK_F18=&h81

const VK_F19=&h82

const VK_F20=&h83

const VK_F21=&h84

const VK_F22=&h85

const VK_F23=&h86

const VK_F24=&h87



declare sub go



Create form as qform

                center

                create Button1 as QButton

                               Caption="Send 'world' to notepad"

                               Left=18

                               Top=18

                               Width=261

                               onclick=go

                end create

end create



dim hwnd as long

run("notepad.exe")

sleep .3

hwnd=Getforegroundwindow() 'get handle



form.showmodal



sub go

                SetForegroundWindow(hwnd)'focus to notepad

               

                keybd_event (vk_shift, 0, 0, 0) 'shiftkey down



                keybd_event (vk_w, 0, 0, 0) 'w key down

                keybd_event (vk_w, 0, 0 ,KEYEVENTF_KEYUP)'key up

                sleep .3

                keybd_event (vk_shift, 0, 0, KEYEVENTF_KEYUP) 'shiftkey up



                keybd_event (vk_o, 0, 0, 0) 'o

                keybd_event (vk_o, 0, 0 ,KEYEVENTF_KEYUP)

                sleep .3

                keybd_event (vk_r, 0, 0, 0) 'r

                keybd_event (vk_r, 0, 0 ,KEYEVENTF_KEYUP)

                sleep .3

                keybd_event (vk_l, 0, 0, 0) 'l

                keybd_event (vk_l, 0, 0 ,KEYEVENTF_KEYUP)

                sleep .3

                keybd_event (vk_d, 0, 0, 0) 'd

                keybd_event (vk_d, 0, 0 ,KEYEVENTF_KEYUP)

                sleep .3

end sub




2003 Holyguard.net - 2007 Abruzzoweb