Administrators Jon Posted November 17, 2007 Administrators Share Posted November 17, 2007 3.2.9.12 (17th November, 2007) (Beta) - Added: DllCallbackRegister(), DllCallbackGetPtr() and DllCallbackFree() Works on both x86 and x64. ; Create callback function $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 $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 Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Administrators Jon Posted November 17, 2007 Administrators Share Posted November 17, 2007 Slight bug with the callback if it's interrupted by the tray icon. I think it's because the script auto-pauses and the callback hangs and never returns. Looking into it. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
GaryFrost Posted November 17, 2007 Share Posted November 17, 2007 (edited) 3.2.9.12 (17th November, 2007) (Beta) - Added: DllCallbackRegister(), DllCallbackGetPtr() and DllCallbackFree() Works on both x86 and x64. ; Create callback function $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 $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 Been waiting for this one for a long time.... Minor type-o in return type of DllCallbackRegister he return type and calling convention of the function (see DllCall). should be The return type and calling convention of the function (see DllCall). Edited November 17, 2007 by GaryFrost duh, forgot to type which function SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
BrettF Posted November 17, 2007 Share Posted November 17, 2007 3.2.9.12 (17th November, 2007) (Beta) - Added: DllCallbackRegister(), DllCallbackGetPtr() and DllCallbackFree() Works on both x86 and x64. ; Create callback function $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 $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 EndFuncOMG!! THANKYOU! YAYYYYYYYYYYYYYYY! This is awesome! Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
arcker Posted November 18, 2007 Share Posted November 18, 2007 OMG ! With piccaso's DllCallBack UDF = 67 ms With new autoit included dllcallback functions = 13 ms... with the following code : expandcollapse popup#include "DllCallBack.au3" $Timer = TimerInit() ; Create Stub $hStub_EnumWindows = _DllCallBack ("_EnumWindowsProc", _ ; Name of the function "hwnd;ptr") ; DllStruct like parameter definition ; Only 32 and 64bit datatypes supported ; Call EnumWindows DllCall("user32.dll", "int", "EnumWindows", "ptr", $hStub_EnumWindows, "long", 0) ; Callback Procedure Func _EnumWindowsProc($hWnd, $lParam) $hWnd = HWnd($hWnd) ConsoleWrite($hWnd & @CRLF) ; " -> " & WinGetTitle($hWnd) & @CRLF) Return 1 EndFunc ;==>_EnumWindowsProc ; Free Stub _DllCallBack_Free ($hStub_EnumWindows) ConsoleWrite("=" & TimerDiff($timer) & @CRLF) $Timer = TimerInit() ; Create callback function $handle = DLLCallbackRegister ("_EnumWindowsProc2", "int", "hwnd;lparam") ; Call EnumWindows DllCall("user32.dll", "int", "EnumWindows", "ptr", DllCallbackGetPtr($handle), "lparam", 10) ; Delete callback function DllCallbackFree($handle) ConsoleWrite("=" & TimerDiff($timer)) ; Callback Procedure Func _EnumWindowsProc2($hWnd, $lParam) $hWnd = HWnd($hWnd) ConsoleWrite($hWnd & @CRLF) ; " -> " & WinGetTitle($hWnd) & @CRLF) Return 1 ; Return 1 to continue enumeration EndFunc a great thx to both of you -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
ptrex Posted November 18, 2007 Share Posted November 18, 2007 (edited) @Jon / Piccaso Indead this is bringing AU3 to a next level !! Great, thanks !! regards ptrex Edited November 18, 2007 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Lazycat Posted November 18, 2007 Share Posted November 18, 2007 Excellent! The one of most awaited features! Thanks! *going to test* Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Administrators Jon Posted November 18, 2007 Administrators Share Posted November 18, 2007 Need a download link? What are the odds of someday coming up with a Zip file that only includes AutoIt without all the third party stuff?Even without the examples would be okay.You're adding a lot of weight with the non-AutoIt components. I think those should be handled as add-ons.Not great. It's much easier to upload in one go, my upload speed is 25 times slower than my download so if I split up the files I'd end up having to upload much more. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
GEOSoft Posted November 18, 2007 Share Posted November 18, 2007 (edited) Not great. It's much easier to upload in one go, my upload speed is 25 times slower than my download so if I split up the files I'd end up having to upload much more.That's about the same ratio as I'm getting. No problem. I was just thinking of the people that don't have hi-speed internet or are on dialup. Edited November 18, 2007 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Administrators Jon Posted November 19, 2007 Administrators Share Posted November 19, 2007 3.2.9.13 (19th November, 2007) (Beta) - Fixed: DllCallbacks crashing when tray icon is clicked. (Note: Callbacks now cannot be paused). - Added: DllCall() and DllCallbackRegister() now accept doubles, int64 and uint64 types. $handle = DllCallbackRegister ("_CopyProgressRoutine", "dword", "uint64;uint64;uint64;uint64;dword;dword;ptr;ptr;ptr") DllCall("kernel32.dll", "int", "CopyFileExA", "str", @AutoItExe, "str", "CopyFileEx_dummy", "ptr", DllCallbackGetPtr($handle), "ptr", 0, "int", 0, "int", 0) Func _CopyProgressRoutine($TotalFileSize, $TotalBytesTransferred, $StreamSize, $StreamBytesTransferred, $dwStreamNumber, $dwCallbackReason, $hSourceFile, $hDestinationFile, $lpData) MsgBox(0, "", $TotalFileSize & " " & $TotalBytesTransferred); ;ConsoleWrite(StringFormat("%05.1f %%\n",$TotalBytesTransferred/$TotalFileSize*100)) Return 0 ; Continue EndFunc ;==>_CopyProgressRoutine Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
therks Posted November 20, 2007 Share Posted November 20, 2007 Hmm... your example is not working for me. It appears to copy the file, then hangs with 100% CPU and won't release the file. I even tried to force it to quit by adding If $TotalBytesTransferred = $TotalFileSize Then Exit to the top of the function... but it still froze. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
jvanegmond Posted November 20, 2007 Share Posted November 20, 2007 Hmm... your example is not working for me. It appears to copy the file, then hangs with 100% CPU and won't release the file. I even tried to force it to quit by adding If $TotalBytesTransferred = $TotalFileSize Then Exit to the top of the function... but it still froze.I have the same problem. You can't Exit it by tray either. github.com/jvanegmond Link to comment Share on other sites More sharing options...
therks Posted November 20, 2007 Share Posted November 20, 2007 I presumed that was part of "- Fixed: DllCallbacks crashing when tray icon is clicked. (Note: Callbacks now cannot be paused)." My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Administrators Jon Posted November 20, 2007 Administrators Share Posted November 20, 2007 Does it do it if you ditch the messagebox (do a ConsoleWrite or something). MessageBox is a bit of a hack on AutoIt because it kicks off another thread - it might be playing a part in this. No crash here though. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
MadBoy Posted November 20, 2007 Share Posted November 20, 2007 Does it do it if you ditch the messagebox (do a ConsoleWrite or something). MessageBox is a bit of a hack on AutoIt because it kicks off another thread - it might be playing a part in this. No crash here though. +>20:22:48 AU3Check ended.rc:0 >Running:(3.2.9.13):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Projects\Project.AU3\Weird.Tests\ciekawe.au3" 000.0 % 012.4 % 024.8 % 037.2 % 049.6 % 062.0 % 074.3 % 086.7 % 099.1 % 100.0 % and it stays like that forever and ever $handle = DllCallbackRegister ("_CopyProgressRoutine", "dword", "uint64;uint64;uint64;uint64;dword;dword;ptr;ptr;ptr") DllCall("kernel32.dll", "int", "CopyFileExA", "str", @AutoItExe, "str", "CopyFileEx_dummy", "ptr", DllCallbackGetPtr($handle), "ptr", 0, "int", 0, "int", 0) Func _CopyProgressRoutine($TotalFileSize, $TotalBytesTransferred, $StreamSize, $StreamBytesTransferred, $dwStreamNumber, $dwCallbackReason, $hSourceFile, $hDestinationFile, $lpData) ;MsgBox(0, "", $TotalFileSize & " " & $TotalBytesTransferred); ConsoleWrite(StringFormat("%05.1f %%\n",$TotalBytesTransferred/$TotalFileSize*100)) Return 0 ; Continue EndFunc ;==>_CopyProgressRoutine My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
Administrators Jon Posted November 20, 2007 Administrators Share Posted November 20, 2007 Hmm, can't get it to crash here on x64 or x86. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
GaryFrost Posted November 20, 2007 Share Posted November 20, 2007 Doesn't crash but it maxes out the cpu and never quits SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Valik Posted November 20, 2007 Share Posted November 20, 2007 Jon, disable one of your cores or set that process to only run on a single core... (That's a random guess as to why Jon can't reproduce the issue, if I'm right, I demand cookies). Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted November 20, 2007 Share Posted November 20, 2007 (edited) Not working here either, set return to 1 (User Cancled, Delete File) it stops after the first call (000.0%) and hangs just like it does when it's done. *Edit* File Deleted just right, though, so it did what it was supposed to, just didn't end like it should. Edited November 20, 2007 by SkinnyWhiteGuy Link to comment Share on other sites More sharing options...
arcker Posted November 21, 2007 Share Posted November 21, 2007 i had got this problem with this function when i wanted to use it with piccaso's UDF. He had made some corrections and it works after this (done after 100%, no more block). Maybe you can ask him how he did. -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
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