![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
отправить значение буквы в стороннее приложение [D7, WinXP]
sotrudnik1 © (2009-06-01 08:54:00)собственно:
1. есть сторонее приложение, с заголовком допустим "каракат"
2. в нем существует хот-кей привязанный к букве "V"
как отправить средствами дельфей это значение в вышеуказанное приложение при условии что окно не активно или свернуто
P.S. если не сложно с примером
sotrudnik1 (2009-06-02 21:24:00) [1]Удалено модератором
@!!ex (2009-06-02 21:10:00) [2]> [30] Andy BitOff © (02.06.09 20:51)
> Всё, доигрался Игорь =)))
Ко мне тоже стучался. Читер.
Игорь Шевченко (2009-06-02 21:05:00) [3]Обещанный пример:
Есть приложение, которое реагирует на комбинацию Alt+C (конкретно закрывается). Вот его форма:
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 286
ClientWidth = 426
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
Menu = MainMenu1
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object ActionList1: TActionList
Left = 32
Top = 36
object Action1: TAction
Caption = '&Close'
OnExecute = Action1Execute
end
end
object MainMenu1: TMainMenu
Left = 72
Top = 40
object Close1: TMenuItem
Action = Action1
end
end
end
И код:
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ActnList, Menus;
type
TForm1 = class(TForm)
ActionList1: TActionList;
Action1: TAction;
MainMenu1: TMainMenu;
Close1: TMenuItem;
procedure Action1Execute(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Action1Execute(Sender: TObject);
begin
Close;
end;
end.
Есть приложение, которое его убивает путем имитации нажатия комбинации клавиш Alt+C
unit KillerApp;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TtfKiller = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;
var
tfKiller: TtfKiller;
implementation
{$R *.dfm}
procedure TtfKiller.Button1Click(Sender: TObject);
var
Victim: HWND;
begin
Victim := FindWindow('TForm1', 'Form1');
if IsWindow(Victim) then
begin
SetForegroundWindow(Victim);
keybd_event(VK_MENU, 0, 0, 0);
keybd_event(Ord('C'), 0, 0, 0);
keybd_event(Ord('C'), 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, 0, 0, KEYEVENTF_KEYUP);
end;
end;
end.
Причем, вполне реально убивает.
Дальнейшие действия состоят в подборе вариантов клавиш, необходимых для получения желаемого эффекта.
Andy BitOff (2009-06-02 20:51:00) [4]> стучусь к Вам в аську за помощью...
Всё, доигрался Игорь =)))
sotrudnik1 (2009-06-02 19:36:00) [5]
> Игорь Шевченко © (02.06.09 18:57) [27]
стучусь к Вам в аську за помощью... заранее спасибо за понимание...
sotrudnik1 (2009-06-02 19:10:00) [6]windows.SetForegroundWindow(Hnd);
PostMessage(Hnd, WM_KEYDOWN, ord('x'), 0);
и ноль эмоций... мало того что свернутое окно разворачивает, дак еще и значение не отправляет((((
Игорь Шевченко (2009-06-02 18:57:00) [7]
> ну почему????
в посте [20] написано, что тип никак не Char, а
> WPARAM wParam, // first message parameter
Тебе тут подсказали слово Ord зачем-то.
sotrudnik1 (2009-06-02 18:53:00) [8]windows.SetForegroundWindow(Hnd);
PostMessage(Hnd, WM_KEYDOWN, 'x', 0);
ну почему???? почему несовместимость типов????
turbouser (2009-06-02 00:13:00) [9]
> sotrudnik1 (01.06.09 17:32) [21]
Было бы не сложно подсказать, будь это для чего-то полезного.. а так.. самообразование рулит :)
@!!ex (2009-06-01 23:33:00) [10]> [20] sotrudnik1 (01.06.09 17:31)
Тут ВСЕ написано. Информации более чем достаточно для того, чтобы понять как, куда и что передавать.
ord еще вспомните, если не знаете.
Andy BitOff (2009-06-01 23:31:00) [11]> sotrudnik1 (01.06.09 17:32) [21]
Меня убивает твоя твердая уверянность в том, что тебе ОБЯЗАНЫ помочь, хотя сам ты для решения проблемы не собираешься напрягаться.
clickmaker (2009-06-01 17:42:00) [12]http://www.google.ru/search?hl=ru&newwindow=1&q=postmessage+wm_char&btnG=%D0%9F%D0%BE%D0%B8%D1%81%D0%BA&lr=&aq=f&oq=
sotrudnik1 (2009-06-01 17:32:00) [13]вот и все что мне пишет в справке... и ни одного примера!!! что так сложно подсказать???
sotrudnik1 (2009-06-01 17:31:00) [14]The PostMessage function places (posts) a message in the message queue associated with the thread that created the specified window and then returns without waiting for the thread to process the message. Messages in a message queue are retrieved by calls to the GetMessage or PeekMessage function.
BOOL PostMessage(
HWND hWnd, // handle of destination window
UINT Msg, // message to post
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
Parameters
hWnd
Identifies the window whose window procedure is to receive the message. Two values have special meanings:
Value Meaning
HWND_BROADCAST The message is posted to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows. The message is not posted to child windows.
NULL The function behaves like a call to PostThreadMessage with the dwThreadId parameter set to the identifier of the current thread.
Msg
Specifies the message to be posted.
wParam
Specifies additional message-specific information.
lParam
Specifies additional message-specific information.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage function to obtain a unique message for inter-application communication.
If you send a message in the range below WM_USER to the asynchronous message functions (PostMessage, SendNotifyMessage, and SendMessageCallback), make sure that the message parameters do not include pointers. Otherwise, the functions will return before the receiving thread has had a chance to process the message and the sender will free the memory before it is used.
See Also
GetMessage, PeekMessage, SendMessageCallback, SendNotifyMessage
sotrudnik1 (2009-06-01 17:28:00) [15]
> Игорь Шевченко © (01.06.09 16:34) [18]
буду очень признателен если поможете разобраться...
Игорь Шевченко (2009-06-01 16:34:00) [16]
> как сделать-то???
как в справке написано
sotrudnik1 (2009-06-01 15:48:00) [17]
> Fragoria - absolutely NEW MMORPG with amazing quality of
> graphics and deep world structure developed with new technology.
>
>
> Кулхацкеров развелось. Уже пишут...
что за бред??? просто в свернутом окне хочется касты кидать и при этом работать в другом софте...
sotrudnik1 (2009-06-01 15:46:00) [18]PostMessage (Hnd, WM_CHAR, INT('v');
PostMessage (Hnd, WM_CHAR, CHAR('v');
как сделать-то???
Andy BitOff (2009-06-01 15:46:00) [19]Fragoria- absolutely NEW MMORPG with amazing quality of graphics and deep world structure developed with new technology.
Кулхацкеров развелось. Уже пишут...
Игорь Шевченко (2009-06-01 15:27:00) [20]
> несовместимые типы Integer и Char
> в чем ошибка???
В этом