Jump to content

Latest Beta


jpm
 Share

Recommended Posts

  • Administrators

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

Link to comment
Share on other sites

  • Replies 641
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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
:P 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 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

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
OMG!! THANKYOU! YAYYYYYYYYYYYYYYY! :P;) This is awesome! :)
Link to comment
Share on other sites

OMG !

With piccaso's DllCallBack UDF = 67 ms

With new autoit included dllcallback functions = 13 ms...

with the following code :

#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 :P

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

  • Administrators

Need a download link? :P

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.
Link to comment
Share on other sites

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

  • Administrators

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

  • Administrators

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.

Link to comment
Share on other sites

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

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 by SkinnyWhiteGuy
Link to comment
Share on other sites

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

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