Jump to content

Detect press any key to contenue


Recommended Posts

Hello all i need to detect any key pressed by user  to continue 

i have this code but work just for gui "GUIRegisterMsg" is ther any semiler func that detect automatique the key & display msgbox  without gui thx masters

 

#include <WindowsConstants.au3>


GUIRegisterMsg($WM_KEYDOWN, "IsPressed")

$hGui = GUICreate("Press any key within 10s...", 400, 100)
GUISetState()
Sleep(10000)
GUIDelete($hGui)
Exit

Func IsPressed()
    MsgBox(4096, "Test", "Key is pressed!", 2)
EndFunc

 

 

Link to comment
Share on other sites

Sleep() puts all code to sleep nothing will run or be detected, you need a loop.

Just something basic to give you an idea.

#include <WindowsConstants.au3>


GUIRegisterMsg($WM_KEYDOWN, "IsPressed")
$iKeyPress = 0

$hGui = GUICreate("Press any key within 10s...", 400, 100)
GUISetState()

$iTime =TimerInit() ;Start a Timer
While 1
If TimerDiff($iTime) > 10000 Then ExitLoop ;Exit in 10 seconds if no key is pressed
If $iKeyPress = 1 Then ExitLoop
WEnd

Func IsPressed()
    MsgBox(4096, "Test", "Key is pressed!", 2)
    $iKeyPress = 1
EndFunc

 

Link to comment
Share on other sites

23 minutes ago, ViciousXUSMC said:

Sleep() puts all code to sleep nothing will run or be detected, you need a loop.

Just something basic to give you an idea.

#include <WindowsConstants.au3>


GUIRegisterMsg($WM_KEYDOWN, "IsPressed")
$iKeyPress = 0

$hGui = GUICreate("Press any key within 10s...", 400, 100)
GUISetState()

$iTime =TimerInit() ;Start a Timer
While 1
If TimerDiff($iTime) > 10000 Then ExitLoop ;Exit in 10 seconds if no key is pressed
If $iKeyPress = 1 Then ExitLoop
WEnd

Func IsPressed()
    MsgBox(4096, "Test", "Key is pressed!", 2)
    $iKeyPress = 1
EndFunc

 

but i need without gui ( hiden ) this my broblem  becose Guireglmsg it is for  gui i need semilar func to detect press key 

Edited by rayane888
Link to comment
Share on other sites

  • Moderators

rayane888,

Quote

i need to detect any key pressed by user 

This is always a difficult subject - please read this announcement to understand what is and, more importantly, what is NOT, permitted to be discussed here.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Yes key loggers and such, we don't wan't people trying to create malware with Autoit.

You could try to make your GUI invisible by making it 1px in size or transparent.

I do not know your goal, but some creative thinking goes a long way.

Edit: oh and hide status for GUI should work as well.

Edited by ViciousXUSMC
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...