Steurendo Posted January 4, 2013 Posted January 4, 2013 I want to learn how i use DllCallbackRegister and what is its utility.. I didn't find any easy examples to learn. Can anyone post an easy example of this function? Thanks
Danyfirex Posted January 4, 2013 Posted January 4, 2013 (edited) search in the forum you wil find a lot of good examples. look: expandcollapse popup#include <winapi.au3> #include <guitooltip.au3> #include <WindowsConstants.au3> $hTool = _WinAPI_CreateWindowEx($WS_EX_TOPMOST, "tooltips_class32", 0, BitOR($TTS_ALWAYSTIP, $TTS_NOPREFIX, $TTS_BALLOON), 0, 0, 0, 0, 0) _GUIToolTip_AddTool($hTool, 0, "CPU Info:", 0, 0, 0, 0, 0, 16 + 128, 0) ; 16 = TTF_TRACK, 128 = TTF_PARSELINKS _GUIToolTip_TrackActivate($hTool) _GUIToolTip_SetTitle($hTool, "CPU Info:", 1) $m_callback = DllCallbackRegister("_mover", "long", "int;wparam;lparam") $pm_callback = DllCallbackGetPtr($m_callback) $hook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pm_callback, _WinAPI_GetModuleHandle(0)) While 1 sleep(1000) WEnd Func OnAutoItExit() _WinAPI_UnhookWindowsHookEx($hook) DllCallbackFree($m_callback) _WinAPI_DestroyWindow($hTool) EndFunc Exit Func _mover($nCode, $wparam, $lparam) If $nCode<0 Then Return _WinAPI_CallNextHookEx($hook, $nCode, $wparam, $lparam) ConsoleWrite("jk" & @CRLF) Switch Number($wparam) Case $WM_MOUSEMOVE Local $pos = DllStructCreate("long;long", $lparam) ;MsgBox(0,"","test") $x = DllStructGetData($pos, 1) $y = DllStructGetData($pos, 2) _GUIToolTip_TrackPosition($hTool, $x+25, $y+15) _GUIToolTip_UpdateTipText($hTool, 0, 0, "Pos: " & $x & " x " & $y) EndSwitch Return _WinAPI_CallNextHookEx($hook, $nCode, $wparam, $lparam) EndFunc from help file. ; Create callback function Local $handle = DllCallbackRegister("_EnumWindowsProc", "int", "hwnd;lparam") ; Call EnumWindows DllCall("user32.dll", "int", "EnumWindows", "ptr", DllCallbackGetPtr($handle), "lparam", 10) ; Delete callback function DllCallbackFree($handle) ; Callback Procedure Func _EnumWindowsProc($hWnd, $lParam) If WinGetTitle($hWnd) <> "" And BitAND(WinGetState($hWnd), 2) Then Local $res = MsgBox(1, WinGetTitle($hWnd), "$hWnd=" & $hWnd & @CRLF & "lParam=" & $lParam & @CRLF & "$hWnd(type)=" & VarGetType($hWnd)) If $res = 2 Then Return 0 ; Cancel clicked, return 0 to stop enumeration EndIf Return 1 ; Return 1 to continue enumeration EndFunc ;==>_EnumWindowsProc regards Edited January 4, 2013 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Steurendo Posted January 4, 2013 Author Posted January 4, 2013 Sorry but I have not figured yet how the function works : Can someone explain me the concept?
trancexx Posted January 4, 2013 Posted January 4, 2013 (edited) Sorry but I have not figured yet how the function works : Can someone explain me the concept?When you call DllCallbackRegister then AutoIt performs "just in time" compilation (aka JIT) and gives you back the handle that you can use to get pointer to compiled code.Other functions that make use of the callback functions will ask you for that pointer and will redirect execution to your callback code as defined by their documentation.For example see documentation for EnumWindows function (Danyfirex's second and help file example) . Edited January 4, 2013 by trancexx ♡♡♡ . eMyvnE
JohnOne Posted January 4, 2013 Posted January 4, 2013 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now