UnknownWarrior Posted December 25, 2008 Share Posted December 25, 2008 In the milliseconds part of it, can you put a variable that represents a time?I want my bot to record how long a certain key was held down and to use that in SendKeyDownDelay... Would this work? If so how should I record the time that the key is held down, with a timer possibly? Could someone help me develop this code with the timer? I'm not sure how to make it read if the key was held down or if it was just being pressed again... I need something like 'If _ispressed("70) Then blah blah... EndIf...' then repeat back to the If and read 'if _ispressed(70) still Then' Too bad there wasn't something like that ... You guys have any idea how to do this? Link to comment Share on other sites More sharing options...
BrettF Posted December 25, 2008 Share Posted December 25, 2008 (edited) Check this out: ;Key Pressed Length #include <Misc.au3> $dll = DllOpen("user32.dll") ToolTip ("Hold down shift") While 1 If _IsPressed (10, $dll) Then ToolTip ("Shift held") $timer = TimerInit () While (_IsPressed (10, $dll) <> 0) Sleep (50) WEnd $endtime = TimerDiff ($timer) ToolTip ("Shift Released. Time was " & $endtime & "ms") EndIf WEnd Cheers, Brett EDIT: And on a side note, keyloggers are banned. So if you plan to make one, don't bother asking for help, cause your only help will be a ban... Edited December 25, 2008 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
UnknownWarrior Posted December 25, 2008 Author Share Posted December 25, 2008 (edited) Check this out: ;Key Pressed Length #include <Misc.au3> $dll = DllOpen("user32.dll") ToolTip ("Hold down shift") While 1 If _IsPressed (10, $dll) Then ToolTip ("Shift held") $timer = TimerInit () While (_IsPressed (10, $dll) <> 0) Sleep (50) WEnd $endtime = TimerDiff ($timer) ToolTip ("Shift Released. Time was " & $endtime & "ms") EndIf WEnd Cheers, Brett EDIT: And on a side note, keyloggers are banned. So if you plan to make one, don't bother asking for help, cause your only help will be a ban... No intention at all, though I am making a Mouse click and keyboard recorder as a bot alone... So instead of trying to scavenge through google for a free macro program, mine I can adapt to my needs and use it how I want to. I found this script in these forums and I was wondering something: Script: #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 sleep(100) For $i = 0 to 255 If _IsPressed(Hex($i,2), $dll) Then ConsoleWrite("Hex key:" & Hex($i,2) & @TAB & "Decimal:"&$i & @CRLF) If Hex($i,2) = "1B" Then Exit EndIf Next WEnd DllClose($dll) How could I instead of it writing the Hex key recorded, have it write the actual key that was pressed? The only other way I see doing is Global declare say: Global $70 = "F1", $71 = "F2" ConsoleWrite("$" & Hex($i,2)) That would I believe write down F1 because if F1 is pressed it returns 70.. and add a $ in front of that makes it $70 which ='s to F1.... But is there an easier way to do this than declaring every single key on the keyboard as global? Edited December 25, 2008 by UnknownWarrior Link to comment Share on other sites More sharing options...
FireFox Posted December 25, 2008 Share Posted December 25, 2008 (edited) @UnknownWarrior If you want your script always check for how long time key is pressed like this : Here I use F12 #include <Misc.au3> While 1 If _IsPressed("7B") Then $Init = TimerInit() Do;--- Sleep(10) $Diff = StringLeft(TimerDiff($Init) * 0.001, 7) TrayTip("", "One key has been pressed : " & $Diff & " sec(s)", 1, 4) Until Not _IsPressed("7B") TrayTip("", "Key released !", 1, 4) EndIf WEnd Edited December 25, 2008 by FireFox Link to comment Share on other sites More sharing options...
UnknownWarrior Posted December 25, 2008 Author Share Posted December 25, 2008 (edited) @UnknownWarrior If you want your script always check for how long time key is pressed like this : Here I use F12 #include <Misc.au3> While 1 If _IsPressed("7B") Then $Init = TimerInit() Do;--- Sleep(10) $Diff = StringLeft(TimerDiff($Init) * 0.001, 7) TrayTip("", "One key has been pressed : " & $Diff & " sec(s)", 1, 4) Until Not _IsPressed("7B") TrayTip("", "Key released !", 1, 4) EndIf WEnd Thanks... Whats StringLeft do/for? Also, any ideas on my other question from above? For instead of declaring every single key in Global, is there any equation I could use so it KNOWS what key was pressed and instead of writing down the Hex value, to write down the key iteself...? P.S> Merry Christmas Edited December 25, 2008 by UnknownWarrior Link to comment Share on other sites More sharing options...
FireFox Posted December 25, 2008 Share Posted December 25, 2008 @UnknownWarrior I cant give you reponse for know what key is pressed because its way to keylogger...(Just Use Case IsPressed("KEY") and then you write key) StringLeft i used for my script get the 7number for decimal seconds because without stringleft you've 15 Link to comment Share on other sites More sharing options...
UnknownWarrior Posted December 25, 2008 Author Share Posted December 25, 2008 (edited) @UnknownWarriorI cant give you reponse for know what key is pressed because its way to keylogger...(Just Use Case IsPressed("KEY") and then you write key)StringLeft i used for my script get the 7number for decimal seconds because without stringleft you've 15I understand, I could just as easily declare my variables in the Global scope and make it a keylogger, but that's not my intentions and which is why I am not releasing my script to anyone at all, it stays on my computer alone.Could you explain what Case is and more explanation on the Stringleft... I found it in the help file, but I don't quite understand why you used it in that script... maybe I don't understand it at all :SEDIT: I looked up on Case... Do I use Switch or Select with Case? And whatever one, how do I make _IsPressed("Hex") change to _IsPressed("Key").... Would it be that simple to just change it? But _IsPressed shouldn't know what it's doing because it reads for Hex, not for keys...Thanks for the help, give me all you can to the length you are not assisting in making a keylogger. With my way I could anyways, it would just take up more CPU, this way it will take less CPU, but get the same job done. Edited December 25, 2008 by UnknownWarrior Link to comment Share on other sites More sharing options...
FireFox Posted December 25, 2008 Share Posted December 25, 2008 (edited) @UnknownWarrior StringLeft is for take x caracters from left Before : $string = "abcdefghijk" After : $String2 = StringLeft($string, 5) ;count 5 caracters from left $String2 = "abcde" For _IsPressed with case take a look to IsPressed_UDF Cheers, FireFox. Edited December 25, 2008 by FireFox Link to comment Share on other sites More sharing options...
UnknownWarrior Posted December 26, 2008 Author Share Posted December 26, 2008 So, would I just put: Switch _IsPressed(Hex($i,2), $dll) Case _IsPressed("key", $dll) MsgBox(0,"","Key was read!") EndSwitch That just don't seem right, don't seem like it would work :S. I don't think I'm understand the Switch and Case thing so well :S. Link to comment Share on other sites More sharing options...
UnknownWarrior Posted December 30, 2008 Author Share Posted December 30, 2008 Bring Up My Post Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now