2011-02-14 10 views

risposta

6

Prova questo sulla vostra FormCreate:

procedure TForm1.FormCreate(Sender: TObject); 
var 
    MyKeys: array of tagInput; 
begin 
    setLength(MyKeys, 2); 
    MyKeys[0].Itype:=INPUT_KEYBOARD; 
    MyKeys[0].ki.wVk:=VK_CAPITAL; 
    MyKeys[0].ki.wScan:=0; 
    MyKeys[0].ki.dwFlags:=4; 
    MyKeys[0].ki.time:=0; 
    MyKeys[0].ki.dwExtraInfo:=0; 

    MyKeys[1].Itype:=INPUT_KEYBOARD; 
    MyKeys[1].ki.wVk:=VK_CAPITAL; 
    MyKeys[1].ki.wScan:=0; 
    MyKeys[1].ki.dwFlags:=4+2; 
    MyKeys[1].ki.time:=0; 
    MyKeys[1].ki.dwExtraInfo:=0; 
    SendInput(2, MyKeys[0], sizeof(tagInput)); 
end; 

è possibile trovare maggiori informazioni msdn

+0

Che il codice * * presse il tasto caps-lock. Potresti voler aggiungere un altro evento per tastiera per simulare il * rilascio * della chiave. –

+0

@Rob: giusto, grazie. – CloudyMarble

+0

Questo non ha funzionato per me. Sto usando XP a casa se questo è importante. –

Problemi correlati