Sign in to follow this  
Followers 0

Holding Delete Key Down

3 posts in this topic

Hi all,

I currently have this small script here:

$T_INIT = TimerInit()
Send("{DEL down}")
Until TimerDiff($T_INIT) >= 2000 ;2000  miliseconds = 2 seconds, exactly how long it takes to delete one entire row in Microsoft Word
Send("{DEL up}")

What the above code does is hold down the delete key for 2 seconds.

How would I make this script do the exact same thing if I had "DEL" as a variable? For example something like this: (Which by the way doesn't work)

$ChosenKey = "DEL"
$T_INIT = TimerInit()
Send("{$ChosenKey& down}")
Until TimerDiff($T_INIT) >= 2000 
Send("{$ChosenKey& up}")

All the parenthesis and "&" symbols and brackets make this difficult.

Share this post

Link to post
Share on other sites
$ChosenKey = "DEL"
$T_INIT = TimerInit()
    Send("{" & $ChosenKey & " Down}")
Until TimerDiff($T_INIT) >= 2000 
Send("{" & $ChosenKey & " Up}")


1 person likes this

Share this post

Link to post
Share on other sites

Thanks InunoTaishou, you solved my problem!

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

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      Hi all
      I want a way to get the last key pressed.
      I have a program that works with keyboard shortcuts and I want to  give the permission for the user to edit shortcut keys depending on what suits him
      i  want to make read-only edit box and the program writes the latest shortcut key pressed
      Please help me,
      greetings to all
      And thanks in advance
    • JustinZandee
      By JustinZandee
      I want to create a loop which loops a code until for example f2 is pressed.
      So I tried something with _IsPressed but it doesn't work.
      Local $test = WinActivate("Notepad") Do Send("hi") Until _IsPressed("72", $test)  
      I don't know how I can do nothing when pressing f2 because it says "error: _IsPressed(): undefined function.".
      I did put 
      Send("hi") after Local $test = but it gives the same error.
      Does anyone know how to solve this problem? 
      Maybe I am wrong and I need to use a whole other Function.. I am new to AutoIT so I am sorry..
    • chacoya121
      By chacoya121
      send("{Down Down}") sleep(1000) send("{Down Up}") just curious on the send function
      i try but doesn't work some how
    • Wingens
      By Wingens
      i a stuck with a hopefully a little problem.
      I know the value of a not yet known key in an ini file.
      I need to be able to find the key using the value. The value is a unique value in a section.
      Hope you guys can help me.
    • Jefrey
      By Jefrey
      Hi guys!
      I took @GaryFrost's Scripting Dictionary UDF and made just a few modifications.
      It now accepts multiple Scripting Dictionary objects around your script (many at once) and also allows you to choose any name for your variable. Also, it now uses OOP-like approach as proposed by @guinness.
      The modifications were too simple (and I would post it on the original thread, but it's dated 2007) so all credit goes to @GaryFrost.
      #include 'scriptingdic.au3' #include <Array.au3> ; Needed only for _ArrayDisplay, and not required by the lib ; Init the object $oObj = _InitDictionary() ; Adding a single value _AddItem($oObj, 0, "Test") ; And showing it msgbox(0, '', _Item($oObj, 0)) ; Adding an array Dim $aArr[] = [0, -80, -49, -44, 80, 100, 8, 7, 6, 5, 4, 3, 2, 1] _AddItem($oObj, 1, $aArr) ; And showing it _ArrayDisplay(_Item($oObj, 1)) ; We can also use this approach: $oObj3 = _InitDictionary() $oObj.Add("test", "foo") MsgBox(0, '', $oObj.Item("test")) Download: scriptingdic.au3