Naokoło, ale udało się...
uses ShellApi;
procedure PostKeyEx32(key: Word; const shift: TShiftState; specialkey: Boolean);
type
TShiftKeyInfo = record
shift: Byte;
vkey: Byte;
end;
ByteSet = set of 0..7;
const
shiftkeys: array [1..3] of TShiftKeyInfo = ((shift: Ord(ssCtrl); vkey: VK_CONTROL), (shift: Ord(ssShift); vkey: VK_SHIFT),(shift: Ord(ssAlt); vkey: VK_MENU));
var
flag: DWORD;
bShift: ByteSet absolute shift;
j: Integer;
begin
for j := 1 to 3 do
begin
if shiftkeys[j].shift in bShift then keybd_event(shiftkeys[j].vkey, MapVirtualKey(shiftkeys[j].vkey, 0), 0, 0);
end;
if specialkey then flag := KEYEVENTF_EXTENDEDKEY
else flag := 0;
keybd_event(key, MapvirtualKey(key, 0), flag, 0);
flag := flag or KEYEVENTF_KEYUP;
keybd_event(key, MapvirtualKey(key, 0), flag, 0);
for j := 3 downto 1 do
begin
if shiftkeys[j].shift in bShift then keybd_event(shiftkeys[j].vkey, MapVirtualKey(shiftkeys[j].vkey, 0), KEYEVENTF_KEYUP, 0);
end;
end;
function OknoIstnieje(Nazwa: string): Boolean;
var
txt: THandle;
begin
Result := False;
txt := FindWindow(nil, pchar(Nazwa));
if txt <> 0 then Result := True;
end;
Wykorzystanie w/w funkcji
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
ShellExecute(Handle, 'open', 'control', 'folders', nil, SW_SHOW);
while OknoIstnieje('Opcje folderów') = False do
begin
Application.ProcessMessages;
if OknoIstnieje('Opcje folderów') = True then
begin
for i := 0 to 5 do PostKeyEx32(VK_TAB, [], False);
Application.ProcessMessages;
PostKeyEx32(VK_RIGHT, [], False);
PostKeyEx32(VK_RIGHT, [], False);
end;
end;
end;