
Эксперт
  
Профиль
Группа: Завсегдатай
Сообщений: 1278
Регистрация: 3.11.2005
Репутация: 6 Всего: 50
|
| Код | const LRUS=$04190419; LENG=$04090409;
procedure SetKeyState(const Wnd: HWND;const Code: DWORD); begin SendMessage( Wnd, WM_INPUTLANGCHANGEREQUEST, $1, Code); end;
procedure WRText(NewWnd: HWND;const s: String); function SetMod(const b: Short;const Mode: Integer): Boolean; var isCtrl,isShift,isAlt: Boolean; Code: Integer; begin isShift := ((Hi(b) and 1) = 1); isCtrl := ((Hi(b) and 2) = 2); isAlt := ((Hi(b) and 4) = 4);
if Mode=1 then Code := 0 else Code := KEYEVENTF_KEYUP; if isShift then Keybd_Event(VK_SHIFT,0,Code,0); if isCtrl then Keybd_Event(VK_CONTROL,0,Code,0); if isAlt then Keybd_Event(VK_MENU,0,Code,0);
Result := (isShift or isCtrl or isAlt); end;
const AUpE=['A'..'Z']; AUpR=['А'..'Я']; ALoE=['a'..'z']; ALoR=['а'..'я'];
AEng=['`','1','2','3','4','5','6','7','8','9','0','-','=', '\','/','*','q','w','e','r','t','y','u','i','o','p', '[',']','a','s','d','f','g','h','j','k','l',';','''', 'z','x','c','v','b','n','m',',','.','~','!','@','#', '$','%','^','&','(',')','_','+','|','Q','W','E','R', 'T','Y','U','I','O','P','{','}','A','S','D','F','G', 'H','J','K','L',':','"','Z','X','C','V','B','N','M', '<','>','?']; ARus=['ё','№','й','ц','у','к','е','н','г','ш','щ','з','х', 'ъ','ф','ы','в','а','п','р','о','л','д','ж','э','я', 'ч','с','м','и','т','ь','б','ю','Ё','Й','Ц','У','К', 'Е','Н','Г','Ш','Щ','З','Х','Ъ','Ф','Ы','В','А','П', 'Р','О','Л','Д','Ж','Э','Я','Ч','С','М','И','Т','Ь', 'Б','Ю']; var OldWnd: HWND; i: Integer; Ch: Char; b: Short; L: DWORD; begin OldWnd := GetForegroundWindow;
ShowWindow(NewWnd, SW_HIDE); ShowWindow(NewWnd, SW_SHOWNORMAL); SetForegroundWindow(NewWnd);
for i := 1 to Length(s) do begin Ch := s[i];
if Ch in ARus then begin b := VkKeyScanEx(Ch,LRUS); SetKeyState(NewWnd,LRUS); end else begin b := VkKeyScanEx(Ch,LENG); SetKeyState(NewWnd,LENG); end; SetMod(b,1); Keybd_Event(b,0,0,0); if (not SetMod(b,0)) then Keybd_Event(b,0,KEYEVENTF_KEYUP,0); end;
ShowWindow(OldWnd, SW_HIDE); ShowWindow(OldWnd, SW_SHOWNORMAL); SetForegroundWindow(OldWnd); end;
procedure SetTop(Wnd: HWND); begin ShowWindow(Wnd, SW_HIDE); ShowWindow(Wnd, SW_SHOWNORMAL); SetForegroundWindow(Wnd); end;
procedure WrShiftTab; begin Keybd_Event(VK_SHIFT,0,0,0); Keybd_Event(VK_TAB,0,0,0); Keybd_Event(VK_SHIFT,0,KEYEVENTF_KEYUP,0); end;
procedure WrCtrlDown; begin Keybd_Event(VK_CONTROL,0,0,0); Keybd_Event(VK_Down,0,0,0); Keybd_Event(VK_CONTROL,0,KEYEVENTF_KEYUP,0); end;
procedure WrTab; begin Keybd_Event(VK_TAB,0,0,0); Keybd_Event(VK_TAB,0,KEYEVENTF_KEYUP,0); end;
procedure WrEnter; begin Keybd_Event(VK_RETURN,0,0,0); Keybd_Event(VK_RETURN,0,KEYEVENTF_KEYUP,0); end;
procedure WrAlt; begin Keybd_Event(VK_Menu,0,0,0); Keybd_Event(VK_Menu,0,KEYEVENTF_KEYUP,0); end;
procedure WrAltX; begin Keybd_Event(VK_Menu,0,0,0); Keybd_Event(Ord('X'),0,0,0); Keybd_Event(VK_Menu,0,KEYEVENTF_KEYUP,0); end;
procedure WrDown; begin Keybd_Event(VK_Down,0,0,0); Keybd_Event(VK_Down,0,KEYEVENTF_KEYUP,0); end;
procedure WrLeft; begin Keybd_Event(VK_Left,0,0,0); Keybd_Event(VK_Left,0,KEYEVENTF_KEYUP,0); end;
procedure WrRight; begin Keybd_Event(VK_Right,0,0,0); Keybd_Event(VK_Right,0,KEYEVENTF_KEYUP,0); end;
procedure WrStr(s: String); var i: Integer; isUpper: Boolean; begin for i := 1 to Length(s) do begin isUpper := (s[i] in ['A'..'Z']); if isUpper then Keybd_Event(VK_SHIFT,0,0,0); if s[i]='.' then Keybd_Event(VK_DECIMAL,0,0,0) else Keybd_Event(Ord(UpCase(s[i])),0,0,0); if isUpper then Keybd_Event(VK_SHIFT,0,KEYEVENTF_KEYUP,0) else begin if s[i]='.' then Keybd_Event(VK_DECIMAL,0,KEYEVENTF_KEYUP,0) else Keybd_Event(Ord(UpCase(s[i])),0,KEYEVENTF_KEYUP,0); end; end; end;
procedure Send1; var h:HWND; begin ShellExecute(0,'open','y:\load\canopus\CAN.lnk',nil,nil,SW_SHOWNORMAL); repeat SLeep(1000); //ждем загрузки программы. h:= FindWindow (nil,'Welcome to Program'); until h<>0; if h>0 then begin SetTop(h); //Поверх всех и активное окно //Ввод данных для авторизации WrShiftTab; WrStr('pan'); WrTab; WrStr('panas5'); WrTab; WrStr('MACROBANK'); WrTab; WrStr('82.142.131.160'); WrTab; WrEnter;
Sleep(20000); //Задержка для ожидания появления основного окна h:= FindWindow (nil,'CAN MacroTest'); SetTop(h);
WrCtrlDown; //Вызов меню для загрузки WrLeft; WrLeft; WrLeft; WrRight; WrDown; WrDown; WrEnter;
WrAlt; WrRight; WrDown; WrEnter;
WrTab; WrTab; WrDown; WrEnter;
WrAlt; WrRight; WrDown; WrDown; WrEnter; WrEnter;
// Ожидаем, пока CanTest загрузит документы и закрываем его.
Sleep(30000); //Время ожидания SetTop(h); WrAltX; repeat SLeep(1000); //ждем загрузки программы. h:= FindWindow (nil,'CAUTION'); until h<>0; WrEnter; end;
end;
| Это сообщение отредактировал(а) Демо - 8.12.2005, 17:49
|