Jump to content

Help sending keys


Recommended Posts

I would like to press and hold the Ctrl key on the right side of the keyboard while pressing the Scroll Lock key twice in quick succession.

The following code does not work for me.

Any help to correct it?

Send("{Right CONTROL down}") ;12
Send("{SCROLL LOCK 2}") ;91

Regards.

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

The right control key is "{RCTRL}" and scroll lock is "{SCROLLLOCK}"

Check this page or this for more details.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The right control key is "{RCTRL}" and scroll lock is "{SCROLLLOCK}"

Check this page or this for more details.

Water thanks for pointing the proper keys aliases.

My code is not working can you please look at it?

I did not figure out how from the documents how to make it to works as I mentioned in my first post.

#include <GUIConstants.au3>
#include <Misc.au3>
#include <File.au3>
#include <Array.au3>
Send("{RCTRL up}")
Global $hDll = DllOpen("user32.dll")
Global $TheKey1 = "12" ; alt
Global $TheKey2 = "42" ; b
;RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters", "CrashOnCtrlScroll", "REG_DWORD", "1")
;RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters", "CrashOnCtrlScroll")
While 1
    _PressedKeyBoard($TheKey1, $TheKey2)
    Sleep(100)
WEnd

Func _PressedKeyBoard($TheKey1, $TheKey2)

    Select
        Case StringLen($TheKey1) > 0 And StringLen($TheKey2) > 0
            If _IsPressed($TheKey1, $hDll) Then
                If _IsPressed($TheKey2, $hDll) Then
                    ;MsgBox(0,0,0)
                    Send("{RCTRL down}")
                    For $i = 1 To 2
                        Send("{SCROLLLOCK toggle}") ;91
                    Next
                    ;Send("{RCTRL up}") ;Releases the key
                    While _IsPressed($TheKey2, $hDll) And _IsPressed($TheKey1, $hDll)
                        Sleep(10)
                    WEnd
                EndIf
            EndIf
        Case Else
    EndSelect
EndFunc   ;==>_PressedKeyBoard

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

Try sending just {SCROLLLOCK} instead of adding toggle in, that may be a different key code than just scrolllock, not sure. Also you can send the 2 scrollock key codes like this Send("{Scrolllock 4}")

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Try sending just {SCROLLLOCK} instead of adding toggle in, that may be a different key code than just scrolllock, not sure. Also you can send the 2 scrollock key codes like this Send("{Scrolllock 4}")

Its still not working for me:

#include <GUIConstants.au3>
#include <Misc.au3>
#include <File.au3>
#include <Array.au3>
Send("{RCTRL up}")
Global $hDll = DllOpen("user32.dll")
Global $TheKey1 = "12" ; alt
Global $TheKey2 = "42" ; b
;RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters", "CrashOnCtrlScroll", "REG_DWORD", "1")
;RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters", "CrashOnCtrlScroll")
While 1
    _PressedKeyBoard($TheKey1, $TheKey2)
    Sleep(100)
WEnd

Func _PressedKeyBoard($TheKey1, $TheKey2)

    Select
        Case StringLen($TheKey1) > 0 And StringLen($TheKey2) > 0
            If _IsPressed($TheKey1, $hDll) Then
                If _IsPressed($TheKey2, $hDll) Then
                    ;MsgBox(0,0,0)
                    Send("{RCTRL down}")
                    ;For $i = 1 To 2
                    Send("{SCROLLLOCK 2}") ;91
                    ;Next
                    ;Send("{RCTRL up}") ;Releases the key
                    While _IsPressed($TheKey2, $hDll) And _IsPressed($TheKey1, $hDll)
                        Sleep(10)
                    WEnd
                EndIf
            EndIf
        Case Else
    EndSelect
EndFunc   ;==>_PressedKeyBoard

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

Why do you press the SCROLLLOCK key two times? Do you want to set it on or off? "{SCROLLLOCK xy}" allows xy to be on, off or toggle.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Why do you press the two times? Do you want to set it on or off? "{SCROLLLOCK xy}" allows xy to be on, off or toggle.

I am trying to create some kind of utility to create a crash of the system for QA testing purpose.

Read Here.

Finally, the crash will happen on certain event that my application will generate.

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

02,04,2011 heare, he is late :)

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

I see.

If you uncomment the msgbox statements (or replace them with ConsoleWrite so the script is not halted) does the script run so far where the send commands are executed?

The pcsupport site talks about:

To create the BSOD, press and hold the Ctrl key on the right side of the keyboard while you press the Scroll Lock key twice in quick succession.

But maybe AutoIt is sending the two Scrolllock keys too fast. Try to put a sleep(x) between the two send statements.

This example encreases the wait time by 10 ms each time.

Send("{RCTRL down}")
For $i = 1 To 100
    Send("{SCROLLLOCK}") ;91
    Sleep($i*10)
    Send("{SCROLLLOCK}") ;91
Next

Another question: If you set the regkeys do you get the BSOD if you press the keys yourself?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...