Jump to content
Ranqers

Key Combos + if and then statement

Recommended Posts

How do I make Key Combos?

 

[scar]

procedure key;

begin

While not (ctrl+z) and not(ctrl+x) do wait(25);

if ctrl+z then

begin

ActivateACC;

end;

if ctrl+c then

begin

DeactivateACC;

end;

end;

[/scar]

 

i'm trying to do a combo hotkey (Control Key + Z and Control Key + C) also what command should i use? KeyDown(VK_) .. PressVKeyEx(VK_) ..

Link to comment
Share on other sites

I found this, but it dosn't work:x function IsFunctionKeyDown(Key: Byte): Boolean;

 

[scar]

function Checkkeys(FuncKey: Byte; C: Char; WaitTime: Integer):boolean;

Var

T: Integer;

Begin

T := GetSystemTime + WaitTime

repeat

if (IsFunctionKeyDown(FuncKey) and IsKeyDown©) then

result := True

else

result := False;

until (T < GetSystemTime) or (result = True);

end;

 

begin

if checkkeys(1,'a',1000) = true then

writeln('keys pressed')

else

WriteLn('keys not pressed');

end.[/scar]

 

http://wiki.scar-divi.com/index.php?title=IsFunctionKeyDown

says the func is available from 3.00 > 3.34V. i'm running 3.35, anyone know the current update on the command?

Edited by Ranqers
Link to comment
Share on other sites

Well, what do you do on your keyboard when you press a "combination of keys"?

 

You first hold one down and then press another...like CTRL+S. you don't press both, you hold one down.

 

So VKeyDown, and VKeyUp, come into play:

 

Like use this to select all the text you type in Notepad:

 

[scar]

program aaa;

begin

GetClient.Activate;

wait(500);

 

VKeyDown(VK_LCONTROL);

VKeyDown(CharToVKey('a'));

VKeyUp(CharToVKey('a'));

VKeyUp(VK_LCONTROL);

end.

 

[/scar]

 

Please do note the CharToVKey function. If you were to do KeyDown('a'); It wouldn't work...when I tried that, it simply typed 'a' in notepad.

Link to comment
Share on other sites

[scar]procedure key;

begin

While not (GetKeyState()) and not(GetKeyState()) do wait(25);

if GetKeyState() then

begin

ActivateACC;

end;

if GetKeyState() then

begin

DeactivateACC;

end;

end;

[/scar]

 

well how do I use KeyDown and KeyUp in this script sir?

this has yielded me all day.

Edited by Ranqers
Link to comment
Share on other sites

Did you even look at my example? Or did you refresh before it was in there? Anyway, you should read the beginner tutorial here - http://forums.scar-divi.com/showthread.php?1811-The-All-In-One-Beginners-Guide-To-SCAR-Divi!

And go down to the

8. SCAR Divi's AutoCompletion/Code Hints and Selecting a Client

9. SCAR Divi's Advanced Debugging

10. SCAR Divi Full Scripting/Coding Tutorial

 

Sections, and read up. GetKeyState, will tell you if the key is pressed down or not. GetKeyState replaced these functions you mentioned in your script I think:

IsFunctionKeyDown & IsKeyDown

 

That tutorial in those sections will go over how to script better, and use Auto Completion

Link to comment
Share on other sites

Yessir i looked at your example, but...

VKeyDown(VK_LCONTROL);

VKeyDown(CharToVKey('a'));

VKeyUp(CharToVKey('a'));

VKeyUp(VK_LCONTROL);

 

This tells me how to make the bot press these keys. I need my script to look for these keys, being pressed, and if&when found, execute procedure A or B..

i'll look into the read..thanks.

Edited by Ranqers
Link to comment
Share on other sites

Yessir i looked at your example, but...

 

 

This tells me how to make the bot press these keys, I need my script to look for these keys and if and when found, execute procedure A or B..

i'll look into the read..thanks.

 

You should be all to familiar with VKeys by now. So it gets the state of whatever key you pass as a parameter, and the result is TRUE if the key is DOWN.

But you have pointed something out to me. I cannot get it to detect key combinations that are down. I can get it to check if one key is down such as F11. But not two. For some reason...

 

I think these two functions are the only ones: GetKeyState & GetToggleKeyState. One is supposed to be using GetASyncKeyState from MSDN I think....I need Freddy's help x.x

 

Thus another example:

 

[scar]

program aaa;

begin

repeat

if GetKeyState(VK_LCONTROL) then

if GetToggleKeyState(VK_SHIFT) then

WriteLn('The keys Left Control, and Shift are pressed DOWN!');

 

until false;

end.

 

[/scar]

 

I've tried using Both and singled em out too. Maybe this is fixed in 3.37, let me check.

 

[scar]

program aaa;

begin

repeat

if GetKeyState(VK_LCONTROL) then

if GetKeyState(VK_SHIFT) then

WriteLn('BOoo GetKeyState');

if GetToggleKeyState(VK_LCONTROL) then

if GetToggleKeyState(VK_SHIFT) then

WriteLn('Boooo GetToggleKeyState');

wait(1000);

until false;

end.

 

[/scar]

 

Ehh, I don't know. Je ne sais pas. It acts weird......just try spamming the left control and shift keys at same time

Edited by LordJashin
Link to comment
Share on other sites

This works mate;

[scar]procedure key;

begin

Wait(50);

if GetKeyState(CharToVKey('z')) and (GetKeyState(VK_CONTROL)) then

begin

dosomething1;

end;

if GetKeyState(CharToVKey('x')) and (GetKeyState(VK_CONTROL)) then

begin

dosomething2;

end;

end;

[/scar]

 

SO siked to use this tomorrow;)

Edited by Ranqers
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...