Scrivus 172 Share Posted March 11, 2017 Hi there, I was trying to help out @Pistol with a form of antiban he's developing and we came upon the issue of not being able to hold/press a key other than Shift. So I would like to request this function to be added. getKeyboard.pressKey(char key); getKeyboard.pressKey(char key, int duration); key = key being pressed duration = the time for the key to be hold (Could be defaulted to a certain amount of MS?) I don't think this would be a huge change for the API because it would probably just be a modified getKeyboard.pressShift() method. Thanks in advance, @Pistol Link to comment Share on other sites More sharing options...
Hashtag 8694 Share Posted March 11, 2017 Should be useful =) Link to comment Share on other sites More sharing options...
Pistol 1 Share Posted March 11, 2017 Just to clarify some things,Holding down a key is already possible by manually sending KeyEvents (as Hashtag points out here: https://dreambot.org/forums/index.php/topic/7118-getkeyboardtype-instantly/)Part of the antiban behavior I have in mind is that the client can hold the key in compliance with operating system standards:This is particularly useful for going through dialogI'm a novice when it comes to KeyEvents so if someone with some expertise wants to clarify some things, that would be great.My understanding of keyboard presses is as follows on Windows specifically:1. A KeyPress event occurs as soon as the keyboard key is pushed, to the nearest poll 2. KeyType event occurs arbitrarily close to the KeyPress event3.(The operating system waits by KeyboardDelay parameter in HKEY_CURRENT_USER\Control Panel\Keyboard (approx 250ms) | see source)4. A KeyType event occurs5. (The operating system waits by KeyboardSpeed parameter (roughly 33ms)| see source2) {4 & 5 loop indefinitely until the key is released}6. (Anywhere from 0-30ms may have passed since the last KeyType event)7. A KeyReleased event occurs as the key is physically Some pseudocode could work as follows to simulate holding down a key: PressKey TypeKey sleep(random(250*.8,250*1.2) //sleep for the "initial delay" when holding a key before repeated typeKey events take place, note the 20% randomness since the MSDN notes this may not be linear by upwards of 20% TypeKey do { sleep(Random(33.3*.8,33.3*1.2) //we do an average of 30 per second (1000/30) = 33.33..., but the MSDN says delays may fluctuate by 20% in both directions?? TypeKey } while (conditionsToReleaseUnsatisfied) //evaulate if we are ready to "release key", make sure to account for human reaction times as well. We can have another thread evaluating this for time-intensive checks sleep(Random(0,33.3*1.2)) //a key release can occur anywhere from 0ms after the most previous TypeKey envents, upwards of a single cpu cycle away from the next TypeKey, so we sleep anywhere from 0ms to the amount of time it would take to get another TypeKey event naturally ReleaseKey I currently have a utility that does the above, but am hesitant to use it for multiple reasons.It's generally not a good idea to sway from the API for keyboard events in general, but my fear is that the above approach could be easily patterned out. Is the 20% randomness too obvious? Do some machines skew random in different directions? Does a linear random pattern work well? It does provide some opportunities to make "unique" profiles for each bot, as each operating system/hardware sends KeyType events with slightly different patterns/skews. I could change the rates and add higher/lower spreads as well as use different distributions for sending repeated KeyType events, but I simply haven't gathered enough data to make an informed decision on if this is a good or bad thing, and how "regular" physical keyboards act across different computers/operating systemsMy hope is that I'm nitpicking too much here, but my fear it is that it would be very easy to tell that the keyboard events are not coming from a physical keyboard when simulating holding a key. Can anyone with expertise step in? How does the client internally register Keyboard logic? Thanks so much everyone Edit: I forgot to mention, the entire method is of course, multi threaded, to allow us to move the mouse or do whatever processing we need to do while the key is being held.Edit2: Also, is there some way to signal to the OS to step in here and send key events as if a key were physically being held, to avoid detection from manually sending events straight from our script?Edit3: An even more elegant way to do things would be to loop KeyType events in a seperate thread, and immediately terminate the thread once stopping conditions + human reaction has been accounted for, and send out a KeyRelease event. So Thread1 would start Thread2 to press and repeatedly type the keys as above. Thread 1 then constantly checks if conditions to release are met, waits for a human-like reaction time, terminates Thread2, and sends a KeyRelease event. Link to comment Share on other sites More sharing options...
Ayylmao42000 6 Share Posted March 12, 2017 maybe you guys could also add something like this; getKeyboard().isPressed(char key) so instead of always callined pressKey we can actually do it once Link to comment Share on other sites More sharing options...
Volcom 0 Share Posted March 28, 2017 This really needs to be implemented! With the new shift-drop, it would be awesome. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.