| View previous topic :: View next topic |
| Author |
Message |
kopelito Master Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 483
|
Posted: Sun Jul 22, 2007 6:24 am Post subject: [Delphi] Hotkeys? |
|
|
How do I set hotkeys in Delphi?
Eg:
I wanna do so every time ill press F1 the help window will show up. |
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
|
| Back to top |
|
 |
kopelito Master Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 483
|
Posted: Sun Jul 22, 2007 6:43 am Post subject: |
|
|
Well, those websites are not really helping me because there is not explanation of how to do it, they just explains the script.
I need to know how to make F1 to a hotkey.. |
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Sun Jul 22, 2007 7:20 am Post subject: |
|
|
| Code: | If odd(GetAsyncKeyState(VK_F1)) Then
begin
ShowMessage ('HotKey called');
end |
This will probably work. Click here for the virtual keys _________________
|
|
| Back to top |
|
 |
kopelito Master Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 483
|
Posted: Sun Jul 22, 2007 7:32 am Post subject: |
|
|
| Im suposed to put this script in the main form or in the button I want the hotkey to work on? |
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Sun Jul 22, 2007 7:34 am Post subject: |
|
|
Main form I beleive. _________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sun Jul 22, 2007 9:11 am Post subject: |
|
|
Add a timer. Its in the system tab and looks like a clock. Click on it. Now put this code.
| Code: |
if Odd(GetAsyncKeyState(VK_F1)) then
Form2:=TForm2.Create(self); //replace Form2 with your Forms Name
Form2.ShowModal; //once again replace Form2 with your Forms Name
end;
|
Virtual Keys -> http://api.farmanager.com/en/winapi/virtualkeycodes.html _________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sun Jul 22, 2007 9:17 am Post subject: |
|
|
| u can also use MainMenu in Additionals and then go to Items -> make help tab -> ShortCut -> F1 |
|
| Back to top |
|
 |
kopelito Master Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 483
|
Posted: Sun Jul 22, 2007 5:41 pm Post subject: |
|
|
I still dont manage to set it correct..
Symbol, there is no MainMenu is additionls.
oib111, Somehow it doesnt work.
UnLmtD, Everytime I use that script delphi stucks. :/
What do I do wrong? |
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Sun Jul 22, 2007 5:55 pm Post subject: |
|
|
| kopelito wrote: |
UnLmtD, Everytime I use that script delphi stucks. :/
What do I do wrong? |
I don't know, I don't code in Delphi, make sure that you didn't make any syntax errors. _________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sun Jul 22, 2007 8:02 pm Post subject: |
|
|
Because you did it wrong. You add the GetAsyncKeyState stuff on a timer and you add Unit2 to your Uses list (under Implementation.) _________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sun Jul 22, 2007 8:34 pm Post subject: |
|
|
sorry my bad...
it was standard
its better u can make the form on the same project so u open both and only 1 visible and using hotkeys making them visible.
if u want a close on esc key command:
Add timer with interval of 1, double click and type:
If Odd(getAsyncKeyState(VK_ESCAPE)) then
Close;
it'll look like:
| Code: | procedure Timer1.Timer(Sender: TObject);
begin
If Odd(getAsyncKeyState(VK_ESCAPE)) then
Close;
end;
|
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Mon Jul 23, 2007 8:30 am Post subject: |
|
|
Yea, but I closing useless. Just have them click on the x or on a close button you can add. Same thing, but your way took up more lines of code. And, you shouldn't do all your hotkeys in the mainmenu, but you should do the hotkeys in the mainmenu when you have to. Like if you were making an ac, you wouldn't make something in the mainmenu that said start ac and turn off ac. You have a hotkey like F2 to do it (F1 is help so it would be really annoying)..
| Code: |
if Odd(GetAsyncKeyState(VK_F2)) then
if Timer1.Enabled = False then
Timer1.Enabled := True
else
Timer1.Enabled := False;
end;
|
But if you were making a text editor with the cut command then it would be a good thing to do a hotkey from the mainmenu instead of using the GetAsyncKeyState _________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
ZenX Grandmaster Cheater Supreme
Reputation: 1
Joined: 26 May 2007 Posts: 1021 Location: ">>Pointer<<" : Address 00400560 Offset :1FE
|
Posted: Tue Jul 31, 2007 11:25 am Post subject: |
|
|
| Code: |
procedure PostKeyEx32(key: Word; const shift: TShiftState; specialkey: Boolean);
{************************************************************
* Procedure PostKeyEx32
*
* Parameters:
* key : virtual keycode of the key to send. For printable
* keys this is simply the ANSI code (Ord(character)).
* shift : state of the modifier keys. This is a set, so you
* can set several of these keys (shift, control, alt,
* mouse buttons) in tandem. The TShiftState type is
* declared in the Classes Unit.
* specialkey: normally this should be False. Set it to True to
* specify a key on the numeric keypad, for example.
* Description:
* Uses keybd_event to manufacture a series of key events matching
* the passed parameters. The events go to the control with focus.
* Note that for characters key is always the upper-case version of
* the character. Sending without any modifier keys will result in
* a lower-case character, sending it with [ssShift] will result
* in an upper-case character!
************************************************************}
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;
i: Integer;
begin
for i := 1 to 3 do
begin
if shiftkeys[i].shift in bShift then
keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0), 0, 0);
end; { For }
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 i := 3 downto 1 do
begin
if shiftkeys[i].shift in bShift then
keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0),
KEYEVENTF_KEYUP, 0);
end; { For }
end; { PostKeyEx32 }
procedure TForm1.Timer1Timer(Sender: TObject);
begin
If
Odd(getasyncKeyState(86))
Then
Repeat
/////////////////////////////////////////////////////////
////PostKeyEx32(VK_LWIN, [], False);/////////////////////
/////////////////////////////////////////////////////////
PostKeyEx32(Ord('Z'), [], False);
/////////////////////////////////////////////////////////
/// PostKeyEx32(Ord('C'), [ssctrl, ssAlt], False)////////
/////////////////////////////////////////////////////////
Until
odd(getasynckeystate(86))
End;
|
_________________
CEF Moderator since 2007 ^_^
ZenX-Engine
Last edited by ZenX on Tue Jul 31, 2007 11:40 am; edited 1 time in total |
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Tue Jul 31, 2007 11:29 am Post subject: |
|
|
u use too complicated keys for nothing... =\
also, we already answerd him like 5 times... |
|
| Back to top |
|
 |
|