Duvida 01

09/12/2018

0

Ola Pessoal Tudo Bem.. Bom Pessoal eu estou a procura de alguem q posso esta me ajudando em um projeto fantastico.. mas eu me deparei com esse erro aqui.. primeiro posta codigo inteiro... e no final posta o erro..ok.... obg.. pela att e ajuda...

(*
SendKeys routine for 32-bit Delphi.

Written by Ken Henderson

Copyright (c) 1995 Ken Henderson

This unit includes two routines that simulate popular Visual Basic
routines: Sendkeys and AppActivate. SendKeys takes a PChar
as its first parameter and a boolean as its second, like so:

SendKeys(''''KeyString'''', Wait);

where KeyString is a string of key names and modifiers that you want
to send to the current input focus and Wait is a boolean variable or value
that indicates whether SendKeys should wait for each key message to be
processed before proceeding. See the table below for more information.

AppActivate also takes a PChar as its only parameter, like so:

AppActivate(''''WindowName'''');

where WindowName is the name of the window that you want to make the
current input focus.

SendKeys supports the Visual Basic SendKeys syntax, as documented below.

Supported modifiers:

+ = Shift
^ = Control
% = Alt

Surround sequences of characters or key names with parentheses in order to
modify them as a group. For example, ''''+abc'''' shifts only ''''a'''', while ''''+(abc)'''' shifts
all three characters.

Supported special characters

~ = Enter
( = Begin modifier group (see above)
) = End modifier group (see above)
{ = Begin key name text (see below)
} = End key name text (see below)

Supported characters:

Any character that can be typed is supported. Surround the modifier keys
listed above with braces in order to send as normal text.

Supported key names (surround these with braces):

BKSP, BS, BACKSPACE
BREAK
CAPSLOCK
CLEAR
DEL
DELETE
DOWN
END
ENTER
ESC
ESCAPE
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
F16
HELP
HOME
INS
LEFT
NUMLOCK
PGDN
PGUP
PRTSC
RIGHT
SCROLLLOCK
TAB
UP

Follow the keyname with a space and a number to send the specified key a
given number of times (e.g., {left 6}).
*)

unit sndkey32;

interface

Uses SysUtils, Windows, Messages;

Function SendKeys(SendKeysString : PChar; Wait : Boolean) : Boolean;
function AppActivate(WindowName : PChar) : boolean; overload;
function AppActivate(WindowHandle : HWND) : boolean; overload;

{Buffer for working with PChar''''s}

const
WorkBufLen = 40;
var
WorkBuf : array[0..WorkBufLen] of Char;

implementation
type
THKeys = array[0..pred(MaxLongInt)] of byte;
var
AllocationSize : integer;

(*
Converts a string of characters and key names to keyboard events and
passes them to Windows.

Example syntax:

SendKeys(''''abc123def456{left 6}ghi789'''', True);

*)

Function SendKeys(SendKeysString : PChar; Wait : Boolean) : Boolean;
type
WBytes = array[0..pred(SizeOf(Word))] of Byte;

TSendKey = record
Name : ShortString;
VKey : Byte;
end;

const
{Array of keys that SendKeys recognizes.

If you add to this list, you must be sure to keep it sorted alphabetically
by Name because a binary search routine is used to scan it.}

MaxSendKeyRecs = 41;
SendKeyRecs : array[1..MaxSendKeyRecs] of TSendKey =
(
(Name:''''BACKSPACE''''; VKey:VK_BACK),
(Name:''''BKSP''''; VKey:VK_BACK),
(Name:''''BREAK''''; VKey:VK_CANCEL),
(Name:''''BS''''; VKey:VK_BACK),
(Name:''''CAPSLOCK''''; VKey:VK_CAPITAL),
(Name:''''CLEAR''''; VKey:VK_CLEAR),
(Name:''''DEL''''; VKey:VK_DELETE),
(Name:''''DELETE''''; VKey:VK_DELETE),
(Name:''''DOWN''''; VKey:VK_DOWN),
(Name:''''END''''; VKey:VK_END),
(Name:''''ENTER''''; VKey:VK_RETURN),
(Name:''''ESC''''; VKey:VK_ESCAPE),
(Name:''''ESCAPE''''; VKey:VK_ESCAPE),
(Name:''''F1''''; VKey:VK_F1),
(Name:''''F10''''; VKey:VK_F10),
(Name:''''F11''''; VKey:VK_F11),
(Name:''''F12''''; VKey:VK_F12),
(Name:''''F13''''; VKey:VK_F13),
(Name:''''F14''''; VKey:VK_F14),
(Name:''''F15''''; VKey:VK_F15),
(Name:''''F16''''; VKey:VK_F16),
(Name:''''F2''''; VKey:VK_F2),
(Name:''''F3''''; VKey:VK_F3),
(Name:''''F4''''; VKey:VK_F4),
(Name:''''F5''''; VKey:VK_F5),
(Name:''''F6''''; VKey:VK_F6),
(Name:''''F7''''; VKey:VK_F7),
(Name:''''F8''''; VKey:VK_F8),
(Name:''''F9''''; VKey:VK_F9),
(Name:''''HELP''''; VKey:VK_HELP),
(Name:''''HOME''''; VKey:VK_HOME),
(Name:''''INS''''; VKey:VK_INSERT),
(Name:''''LEFT''''; VKey:VK_LEFT),
(Name:''''NUMLOCK''''; VKey:VK_NUMLOCK),
(Name:''''PGDN''''; VKey:VK_NEXT),
(Name:''''PGUP''''; VKey:VK_PRIOR),
(Name:''''PRTSC''''; VKey:VK_PRINT),
(Name:''''RIGHT''''; VKey:VK_RIGHT),
(Name:''''SCROLLLOCK''''; VKey:VK_SCROLL),
(Name:''''TAB''''; VKey:VK_TAB),
(Name:''''UP''''; VKey:VK_UP)
);

{Extra VK constants missing from Delphi''''s Windows API interface}
VK_NULL=0;
VK_SemiColon=186;
VK_Equal=187;
VK_Comma=188;
VK_Minus=189;
VK_Period=190;
VK_Slash=191;
VK_BackQuote=192;
VK_LeftBracket=219;
VK_BackSlash=220;
VK_RightBracket=221;
VK_Quote=222;
VK_Last=VK_Quote;

ExtendedVKeys : set of byte =
[VK_Up,
VK_Down,
VK_Left,
VK_Right,
VK_Home,
VK_End,
VK_Prior,
VK_Next,
VK_Insert,
VK_Delete];

const
INVALIDKEY = $FFFF {Unsigned -1};
VKKEYSCANSHIFTON = $01;
VKKEYSCANCTRLON = $02;
VKKEYSCANALTON = $04;
UNITNAME = ''''SendKeys'''';
var
UsingParens, ShiftDown, ControlDown, AltDown, FoundClose : Boolean;
PosSpace : Byte;
I, L : Integer;
NumTimes, MKey : Word;
KeyString : String[20];

procedure DisplayMessage(Message : PChar);
begin
// MessageBox(0,Message,UNITNAME,0);
end;

function BitSet(BitTable, BitMask : Byte) : Boolean;
begin
Result:=ByteBool(BitTable and BitMask);
end;

procedure SetBit(var BitTable : Byte; BitMask : Byte);
begin
BitTable:=BitTable or Bitmask;
end;

Procedure KeyboardEvent(VKey, ScanCode : Byte; Flags : Longint);
var
KeyboardMsg : TMsg;
begin
keybd_event(VKey, ScanCode, Flags,0);
If (Wait) then While (PeekMessage(KeyboardMsg,0,WM_KEYFIRST, WM_KEYLAST, PM_REMOVE)) do begin
TranslateMessage(KeyboardMsg);
DispatchMessage(KeyboardMsg);
end;
end;

Procedure SendKeyDown(VKey: Byte; NumTimes : Word; GenUpMsg : Boolean);
var
Cnt : Word;
ScanCode : Byte;
NumState : Boolean;
KeyBoardState : TKeyboardState;
begin
If (VKey=VK_NUMLOCK) then begin
NumState:=ByteBool(GetKeyState(VK_NUMLOCK) and 1);
GetKeyBoardState(KeyBoardState);
If NumState then KeyBoardState[VK_NUMLOCK]:=(KeyBoardState[VK_NUMLOCK] and not 1)
else KeyBoardState[VK_NUMLOCK]:=(KeyBoardState[VK_NUMLOCK] or 1);
SetKeyBoardState(KeyBoardState);
exit;
end;

ScanCode:=Lo(MapVirtualKey(VKey,0));
For Cnt:=1 to NumTimes do
If (VKey in ExtendedVKeys)then begin
KeyboardEvent(VKey, ScanCode, KEYEVENTF_EXTENDEDKEY);
If (GenUpMsg) then
KeyboardEvent(VKey, ScanCode, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP)
end else begin
KeyboardEvent(VKey, ScanCode, 0);
If (GenUpMsg) then KeyboardEvent(VKey, ScanCode, KEYEVENTF_KEYUP);
end;
end;

Procedure SendKeyUp(VKey: Byte);
var
ScanCode : Byte;
begin
ScanCode:=Lo(MapVirtualKey(VKey,0));
If (VKey in ExtendedVKeys)then
KeyboardEvent(VKey, ScanCode, KEYEVENTF_EXTENDEDKEY and KEYEVENTF_KEYUP)
else KeyboardEvent(VKey, ScanCode, KEYEVENTF_KEYUP);
end;

Procedure SendKey(MKey: Word; NumTimes : Word; GenDownMsg : Boolean);
begin
If (BitSet(Hi(MKey),VKKEYSCANSHIFTON)) then SendKeyDown(VK_SHIFT,1,False);
If (BitSet(Hi(MKey),VKKEYSCANCTRLON)) then SendKeyDown(VK_CONTROL,1,False);
If (BitSet(Hi(MKey),VKKEYSCANALTON)) then SendKeyDown(VK_MENU,1,False);
SendKeyDown(Lo(MKey), NumTimes, GenDownMsg);
If (BitSet(Hi(MKey),VKKEYSCANSHIFTON)) then SendKeyUp(VK_SHIFT);
If (BitSet(Hi(MKey),VKKEYSCANCTRLON)) th
Shecknah

Shecknah

Responder

Post mais votado

11/12/2018

bom pessoal codigo fico grande mas aqui em baixo sao os erros...

[dcc32 Error] sndkey32.pas(420): E2010 Incompatible types: 'Char' and 'AnsiChar'
[dcc32 Fatal Error] Conectar.pas(7): F2063 Could not compile used unit 'sndkey32.pas'
Failed




Cara, tem esse link do próprio site, com resposta:
https://www.devmedia.com.br/forum/e2010-incompatible-types-char-and-ansichar/458440


E quando for postar código, para ficar mais legivel. colocar como fonte de código. </> - Formatação.

Rebeca Domingos

Rebeca Domingos
Responder

Mais Posts

09/12/2018

Shecknah

bom pessoal codigo fico grande mas aqui em baixo sao os erros...

[dcc32 Error] sndkey32.pas(420): E2010 Incompatible types: 'Char' and 'AnsiChar'
[dcc32 Fatal Error] Conectar.pas(7): F2063 Could not compile used unit 'sndkey32.pas'
Failed
Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar