Sign in to follow this  
Followers 0
UnknownWarrior

SendKeyDownDelay...?

10 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by BrettF

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by UnknownWarrior

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by UnknownWarrior

Share this post


Link to post
Share on other sites

@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


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

@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

I 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 :S

EDIT: 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 by UnknownWarrior

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Bring

Up

My

Post

:)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0