Jump to content

jiggunjer

Members
  • Posts

    6
  • Joined

  • Last visited

jiggunjer's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. @Danyfirex Thanks but that raises at least 3 questions for me: - Do I always need to use an AutoIt GUI to get the shell hook stuff? - How do you know the parameters WM_SHELLHOOK takes, I can't find it on MSDN - Don't you need to call the next hook in the chain after your callback?
  2. @spudw2k I want to listen to events of an external app. So in the meantime I found winapi's shellhookex(), with shellproc but I can't seem to trigger it when I create new windows after running the script. #include <MsgBoxConstants.au3> #include <StructureConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $g_hHook Example() Func Example() OnAutoItExitRegister("Cleanup") $pcallback = DllCallbackGetPtr(DllCallbackRegister("MyCallback", "long", "int;wparam;lparam"));$WM_SHELL types $g_hHook = _WinAPI_SetWindowsHookEx($WH_SHELL, $pcallback, _WinAPI_GetModuleHandle(0)) MsgBox($MB_SYSTEMMODAL, "", "Click OK, then in notepad type..." & _ @CRLF & @CRLF & "Jon" & @CRLF & "AutoIt" & @CRLF & @CRLF & "Press Esc to exit script") Run("notepad.exe") WinWait("[CLASS:Notepad]") WinActivate("[CLASS:Notepad]") While 1 Sleep(10) WEnd EndFunc ;==>Example Func EvaluateKey() EndFunc ;==> ; =========================================================== ; callback function ; =========================================================== Func MyCallback($nCode, $wParam, $lParam) ; never called msgbox(0,"Test","Test") If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndIf If $nCode <> 1 Then msgbox(0,"Test","Test") EndIf Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndFunc ;==>_KeyProc Func Cleanup() _WinAPI_UnhookWindowsHookEx($g_hHook) ;DllCallbackFree($g_hStub_KeyProc) EndFunc ;==>Cleanup
  3. I want to listen for certain windows events like window open/closed. After reading the help I think I need to use ObjCreate('shell.application') and ObjEvent with that object to create/register a listener. The problem is I don't know what interface or events (i.e. the specific event names) are available for the listener. I tried searching MSDN but it is a labyrinth and I'm not that familiar with the programming frameworks/models used by Windows, and all the examples seem to refer to compiled code using .NET or some other api. Can any1 point me in the right direction? Also is using COM objects considered the 'modern' way to do this, or should I be using some other framework/resources?
  4. this ever work out?
  5. Not sure how to edit my old post, but ignore that global variable, it's a typo.
  6. Hi new AutoIt user here. Trying to change my capslock into a conditional backspace, but it keeps toggling back on. What am I missing? #include <WinAPISys.au3> ;#include <MsgBoxConstants.au3> ;For debugging/finding a keyboard ID value Opt("SendAttachMode", 1) Opt("SendCapslockMode", 0) ;1 restores Caps to pre-send state (default!), 0 doesn't store Send("{CapsLock off}") HotKeySet("{CapsLock}","capsfun") $KBL_CUSTOM = "0xF0C00409" ;My Custom Keyboard Layout code ;$KBL_US = "0x04090409" ;US Keyboard Layout code ;$KBL_USINT = "0xF0010409" ;US-international Keyboard Layout code ;$KBL_GREEK = "0x04080408" ;Greek Keyboard Layout code while 1 Sleep(400) WEnd ;--- Functions Func capsfun() $handl = WinGetHandle("") $ID = _WinAPI_GetKeyboardLayout ( $handl ) ;gets 32bit hex value of keyboard layout Global $key_on ;MsgBox($MB_SYSTEMMODAL, "", $ID) ;Debugging If $ID == $KBL_CUSTOM then HotKeySet("{CapsLock}") Send("{CapsLock off}") Send("{CapsLock off}{BACKSPACE}{CapsLock off}") ;Apparently switching Caps off once isn't enough... Send("{CapsLock off}") HotKeySet("{CapsLock}","capsfun") Else Send("{CapsLock toggle}") ;Since the capslock isn't captured by HotKeySet this shouldn't be necessary, but it is?! EndIf EndFunc ;---Bugs ;Sometimes the backspace-version actives caps lock with repeated presses (though keyboard light isn't on). Using that mode should always result in caps lock off, i.e. matching the keyboard light state.
×
×
  • Create New...