Jump to content

[Solved] SetWindowsHookEx need to disable detection


 Share

Recommended Posts

Hi, taken from the help file is this example, changed it a bit so that uppon pressing the space key, the script should send some text, but the problem is that it seems like the space key i press to trigger the send, pushes a space into the middle of the send. Aka a string like 'abcdefgh123456789abcdefgh123456789' can become: 'abcdefgh123456789abcdefgh12345 6789'

So i think i need to disable the key detection or something, before the send, allowing me to press any keys, without them being sent in the middle of the send.

Before you suggest a hotkeyset or something else, no, it has to be this way, this is to be part of something bigger that needs to work with this method.

Like the "hotstrings" example in the forum.

 

 

#include <MsgBoxConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Global $g_hHook, $g_hStub_KeyProc, $g_sBuffer = ""

Example()
Func Example()
    OnAutoItExitRegister("Cleanup")
    $g_hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")
    Local $hMod = _WinAPI_GetModuleHandle(0)
    $g_hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod)
    While 1
        Sleep(100)
        ConsoleWrite($g_sBuffer &' - '&@MSEC&@CRLF)
    WEnd
EndFunc   ;==>Example

Func EvaluateKey($iKeycode)
    If ($iKeycode = 32) Then ; space key
        Go()
    Else
        $g_sBuffer = ""
    EndIf
    ;ConsoleWrite('$g_sBuffer - '& $g_sBuffer &' - '&@MSEC&@CRLF)
EndFunc   ;==>EvaluateKey
;=============================================================================
Func Go()
        Send('abcdefgh123456789abcdefgh123456789')
        $g_sBuffer = ''
        Return
    Return
EndFunc   ;==>UseAndGo
;=============================================================================
Func _KeyProc($nCode, $wParam, $lParam)
    Local $tKEYHOOKS
    $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
    If $nCode < 0 Then
        Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
    EndIf
    If $wParam = $WM_KEYDOWN Then
        EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode"))
        Else
        Local $iFlags = DllStructGetData($tKEYHOOKS, "flags")
        Switch $iFlags
            Case $LLKHF_ALTDOWN
                ;ConsoleWrite("$LLKHF_ALTDOWN" & @CRLF)
            Case $LLKHF_EXTENDED
                ;ConsoleWrite("$LLKHF_EXTENDED" & @CRLF)
            Case $LLKHF_INJECTED
                ;ConsoleWrite("$LLKHF_INJECTED" & @CRLF)
            Case $LLKHF_UP
                ;ConsoleWrite("$LLKHF_UP: scanCode - " & DllStructGetData($tKEYHOOKS, "scanCode") & @TAB & "vkCode - " & DllStructGetData($tKEYHOOKS, "vkCode") & @CRLF)
        EndSwitch
    EndIf
    Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
EndFunc   ;==>_KeyProc
;=============================================================================
Func Cleanup()
    _WinAPI_UnhookWindowsHookEx($g_hHook)
    DllCallbackFree($g_hStub_KeyProc)
EndFunc   ;==>Cleanup

 

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

If you space key is pressed  return 1 in _KeyProc instead _WinAPI_CallNextHookEx. that will block the space key.

 

Saludos

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...