Ranqers Posted November 15, 2012 Share Posted November 15, 2012 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_) .. Quote Link to comment Share on other sites More sharing options...
Ranqers Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) 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 November 15, 2012 by Ranqers Quote Link to comment Share on other sites More sharing options...
LordJashin Posted November 15, 2012 Share Posted November 15, 2012 GetKeyState...VK_F1 ...etc.? Quote Link to comment Share on other sites More sharing options...
Ranqers Posted November 15, 2012 Author Share Posted November 15, 2012 But how do I use combinations of keys?? Quote Link to comment Share on other sites More sharing options...
LordJashin Posted November 15, 2012 Share Posted November 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
Ranqers Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) [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 November 15, 2012 by Ranqers Quote Link to comment Share on other sites More sharing options...
LordJashin Posted November 15, 2012 Share Posted November 15, 2012 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 Quote Link to comment Share on other sites More sharing options...
Ranqers Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) 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 November 15, 2012 by Ranqers Quote Link to comment Share on other sites More sharing options...
Ranqers Posted November 15, 2012 Author Share Posted November 15, 2012 Awesome I figured it out; [scar] if GetKeyState(CharToVKey('z')) and GetKeyState(VK_CONTROL) then begin writeln('keys pressed'); end;[/scar] Thanks for the GetKeyState command, and Auto-completion tip. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted November 15, 2012 Share Posted November 15, 2012 (edited) 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 November 15, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
Ranqers Posted November 15, 2012 Author Share Posted November 15, 2012 Thanks for the example. (and understanding i suppose) :] Quote Link to comment Share on other sites More sharing options...
Ranqers Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) 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 November 15, 2012 by Ranqers Quote Link to comment Share on other sites More sharing options...