Pupil wrote:For the 'l' missing i said that a key up event should be sent in case of two same chars following. [...]
Sorry for that - usually I read the postings before I write an answer
Your code is great - just playing around with it to see why some chars (e.g. Euro 0x80 and Middot 0x95) will produce a "?" at the output...
Code: Select all
Global Dim SendInputData.INPUT(0)
Procedure SendInput(Text.s)
#KEYEVENTF_UNICODE = 4
Protected i.l; Pointer to Character in the Text
Protected j.l; Counter for SendInput
Protected k.l; Total Size for SendInput
Protected Char.l
Protected NewChar.l
Protected KeyDown.l
k=Len(Text)
If k
ReDim SendInputData(k)
While j < k
PokeS(@newchar,Chr(PeekB(@Text+i)),#PB_Unicode)
SendInputData(j)\Type=#INPUT_KEYBOARD
SendInputData(j)\ki\wVk=0
SendInputData(j)\ki\dwExtraInfo=0
SendInputData(j)\ki\time=0
If (newchar=char) And KeyDown
KeyDown=#False
SendInputData(j)\ki\dwFlags=#KEYEVENTF_UNICODE|#KEYEVENTF_KEYUP
k+1
ReDim SendInputData(k)
Else
char=newchar
KeyDown=#True
SendInputData(j)\ki\dwFlags=#KEYEVENTF_UNICODE
i+1
EndIf
SendInputData(j)\ki\wScan=char
j+1
Wend
; Just for testing...
RunProgram("notepad.exe")
Delay(500)
SendInput_(k, SendInputData(0), SizeOf(INPUT))
EndIf
EndProcedure
Define x.s=""
Define i.l
For i=32 To 255
x+RSet(Hex(i),2,"0")+":"+Chr(i)
If i&15=15
x+#CR$
Else
x+" "
EndIf
Next i
SendInput(x)
Anyhow there's (again) one more problem - SendInput works fine on most applications without doing some changes, but...
...there's Excel and this @%§&-software does not accept even Chr(13) as a return
Okay, got this also, but still fail to create an Alt+Enter simulation to get more than one text line into one cell:
Code: Select all
Global Dim SendInputData.INPUT(0)
Procedure SendPrepare(n,VK,Char,UpDown,*Resize.l=#Null)
SendInputData(n)\Type=#INPUT_KEYBOARD
SendInputData(n)\ki\wVk=VK
SendInputData(n)\ki\time=0
SendInputData(n)\ki\dwExtraInfo=0
SendInputData(n)\ki\wScan=Char
SendInputData(n)\ki\dwFlags=UpDown
If *Resize
n=PeekL(*Resize)+1
PokeL(*Resize,n)
ReDim SendInputData(n)
EndIf
EndProcedure
Procedure SendInput(Text.s)
#KEYEVENTF_UNICODE = 4
Protected i.l; Pointer to Character in the Text
Protected j.l; Counter for SendInput
Protected k.l; Total Size for SendInput
Protected Char.l
Protected NewChar.l
Protected KeyDown.l
k=Len(Text)
If k
ReDim SendInputData(k)
While j < k
PokeS(@NewChar,Chr(PeekB(@Text+i)),#PB_Unicode)
If (newchar=char) And KeyDown
KeyDown=#False
SendPrepare(j,0,Char,#KEYEVENTF_UNICODE|#KEYEVENTF_KEYUP,@k)
Else
char=newchar
KeyDown=#True
If char=13
SendPrepare(j,#VK_MENU,0,#KEYEVENTF_EXTENDEDKEY,@k)
SendPrepare(j,#VK_RETURN,0,#KEYEVENTF_EXTENDEDKEY)
SendPrepare(j,#VK_MENU,0,#KEYEVENTF_KEYUP,@k)
Else
SendPrepare(j,0,Char,#KEYEVENTF_UNICODE)
EndIf
i+1
EndIf
j+1
Wend
SendInput_(k,SendInputData(0),SizeOf(INPUT))
EndIf
EndProcedure
; Start Excel now...
Delay(4000)
SendInput("Hello..."+#CR$+"Where is this?!")
So there are still (at least) two open points...
1) is there a way to get the code working also with character codes from 0x80 to 0x9F?
2) how to do a Alt+Enter for the Excel application?
Thanks for your tips,
Michael