martin Posted September 3, 2007 Share Posted September 3, 2007 Hey Jon this would be FANTASTIC!!! Sorry for my reaction to question asked to picasso but I can't help myself to express my mind ;-) I agree with Zedna. This is amazing piccaso. I've just tried playing with it and here is a hurried example, in my usual untidy style, of how to overcome the problem when you need more than one AdLibEnable. expandcollapse popup#include <GUIConstants.au3> #include <dllcallback.au3> Global $msg, $retval ;we will have 3 timers $pt = DllStructCreate("int64;int64;int64");int64 found by trial and error DllStructSetData($pt, 1, 1);set the timer ref numbers DllStructSetData($pt, 2, 2);these could be any number DllStructSetData($pt, 3, 3) $pnID1 = DllStructGetPtr($pt, 1);ptrs to the timer ref nos $pnID2 = DllStructGetPtr($pt, 2) $pnID3 = DllStructGetPtr($pt, 3) Global $gui = GUICreate("test") GUISetState() $hStub_T = _DllCallBack ("_TimerProc", "hwnd;int;ptr;int") ;set up the timers $retval = DllCall("user32.dll", "int", "SetTimer", "hwnd", $gui, "int", $pnID1, "int", 5000, "ptr", $hStub_T) Sleep(2000); delay so timers are spaced apart $retval = DllCall("user32.dll", "int", "SetTimer", "hwnd", $gui, "ptr", $pnID2, "int", 10000, "ptr", $hStub_T) $retval = DllCall("user32.dll", "int", "SetTimer", "hwnd", $gui, "ptr", $pnID3, "int", 2000, "ptr", $hStub_T) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE $retval = DllCall("user32.dll", "int", "KillTimer", "hwnd", $gui, "ptr", $pnID1) $retval = DllCall("user32.dll", "int", "KillTimer", "hwnd", $gui, "ptr", $pnID2) $retval = DllCall("user32.dll", "int", "KillTimer", "hwnd", $gui, "ptr", $pnID3) _DllCallBack_Free ($hStub_T) Func _TimerProc($h, $a, $b, $c) Local $ts = DllStructCreate("int", $b) Local $TimerNumber = DllStructGetData($ts, 1) Switch $TimerNumber Case 1 ConsoleWrite("T1 fired" & @CRLF) ; Case 2 ConsoleWrite("T2 fired" & @CRLF) ; Case 3 ConsoleWrite("T3 fired" & @CRLF) ; EndSwitch $ts = 0 EndFunc ;==>_TimerProc ;error checking to be added but the above is just to show the idea Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
piccaso Posted September 4, 2007 Author Share Posted September 4, 2007 (edited) piccaso, would it be worth adding this natively into AutoIt? I'm not totally sure because it is a very advanced and niche function. So it depends on what I'd need to add and how much space it would need? Also, I'm guessing it requires some assembly - we've stil not solved the 64bit DllCall problems because of the assembly. ( Awesome work btw )That would be great! Windows doesn't seem to like the detour over the message queue in every situation (that's why there is a subclassing option/workaround) so i really would welcome a native implementation. If it isn't a big problem to call user functions from 'inside' because the rest is quite simple. I guess you dont want to waste your time studying the udf so i'll try to explain: Allocate some (23bytes) executable memory and put this in there: $ ==> > 8D4424 04 LEA EAX,DWORD PTR SS:[ESP+4] ; Load pointer to first parameter into eax $+4 > 50 PUSH EAX ; Parameter 2 - Stack pointer $+5 > 68 01010101 PUSH 1010101 ; Parameter 1 - Internal identifier $+A > B8 02020202 MOV EAX,2020202 ; mov eax, <Absolute address of handler function> $+F > FFD0 CALL EAX ; Call Callback Handler function $+11 > 83C4 08 ADD ESP,8 ; if handler is 'cdecl' - free stack $+14 > C2 0000 RETN 0 ; if callback is 'cdecl' - Retn 0 ; if callback is 'stdcall' - Retn <nr of parameter*4> I'm sure there are equivalent opcodes for 64bit, but sorry i dont know them (but i'll do some research) Of course the Internal id, the address of the handler function and amount of bytes to remove from stack have to be set too. the rest can be done in c/c++:void* CallBackHandler (unsigned long ulInternalId, void* pParameters) { // pParameters = pointer to first parameter // pParameters+4 = pointer to second parameter // ... // Lookup & Call User Function and return value } If you want to keep it small it could look like this: The user function takes as much parameters as defined in $sParameters and the Return value is converted as specified. I'll go and see if i can find some info on 64bit opcodes Edited June 22, 2012 by Jon CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
piccaso Posted September 4, 2007 Author Share Posted September 4, 2007 Ok i made an uneducated guess above. I just learned that parameters are passed via registers on 64bit. Which means the 64bit solution looks completely different. Something like: Allocate some extra space, copy all registers there and forward that pointer to the handler function... Too bad i dont have a 64bit os to play around with it But now i know what kind of problems you have with DllCall() :"> CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
ValeryVal Posted September 4, 2007 Share Posted September 4, 2007 Maybe it can help:Moving to Windows Vista x64 The point of world view Link to comment Share on other sites More sharing options...
Zedna Posted September 5, 2007 Share Posted September 5, 2007 (edited) Congrats to sticky post piccaso Edited September 5, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
piccaso Posted September 6, 2007 Author Share Posted September 6, 2007 All of the examples are working just fine on my vista.good...Thanks for testing CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
JRSmile Posted September 6, 2007 Share Posted September 6, 2007 my regards too, this is the most powerfull udf i've seen so far here, but your other funcs are also very far above my knowledge border thanks for developing and a healty and lucky life. $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-) Link to comment Share on other sites More sharing options...
Valuater Posted September 6, 2007 Share Posted September 6, 2007 Congrats to sticky post piccaso Ditto!!!Nice work piccaso!8) Link to comment Share on other sites More sharing options...
ptrex Posted September 7, 2007 Share Posted September 7, 2007 (edited) @piccaso I have ran the examples and it's very impressive. Neverthelesss even if I don't understand a bit of this I can smell some opportunities. Does this now mean that some of the previous limitations, relating to callback functions of the SQLite DLL, are now gone ? Great job !! regards, ptrex Edited September 7, 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...
Zedna Posted September 8, 2007 Share Posted September 8, 2007 (edited) Here are some results on my WIN98 SE: With version 6.4 there was problems: EnumWindows returned too little windows and script don't stopped automatically, Subclass crashed after start but new version 6.5 seems to be OK. Subclass is perfect!! But some examples don't return expected results: CopyFileEx.au3 - nothing happens EnumChildProc.au3 - no result Richedit.au3 - nothing happens EDIT: I will make some tests also on WIN XP to compare results later I made some more tests: On WINXP SP2 all examples works OK On WIN98 SE two examples needs tweak to work OK. EnumChildProc.au3 ;~ $hWnd_Desktop = DllCall("user32.dll", "hwnd", "GetDesktopWindow") $hWnd_Desktop = WinGetHandle("Ttitle of your desired app") Richedit.au3 ... Global $RTFClassName If @OSTYPE = "WIN32_WINDOWS" Then; 95/98/Me DllOpen("RICHED20.DLL") $RTFClassName = "RichEdit20A" Else; NT/2000/XP/2003/Vista DllOpen("MSFTEDIT.DLL") $RTFClassName = "RichEdit50W" EndIf ; $RTFClassName used later in CreateWindowEx ... I'm not sure if versions of RichEdit will be the same also on WIN2000/NT, so this part must be maybe tweaked also for these OS versions. So result is: All is working fine also on WIN98, (two examples after tweaking). Thank you very much for this very good functionality brought to AutoIt Edited September 8, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
piccaso Posted September 8, 2007 Author Share Posted September 8, 2007 Ptrex, you're right, all limitations are gone now. But sqlite's api is giving me a headache, and i dont have a concept on how to provide this functionality without making it awfully complicated. I also found a way to load dll's from memory in autoit, but using this in the sqlite wrapper would require changing all dllcalls... This should take some time until i have it all pieced together Thank you for your tests Zedna. I'll add your fixes to the example. And martin, you're right, the example is messy But timers are useful so i'll add some simple example on next update... Wow, this really got more popular than i taught CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
ihope Posted September 12, 2007 Share Posted September 12, 2007 very handful script, piccaso . i would to ask you what about proc-wide (proc-cross) usage is is possible and how ? Link to comment Share on other sites More sharing options...
piccaso Posted September 12, 2007 Author Share Posted September 12, 2007 No, that's not what it was made for but search the forum for WM_COPYDATA or some other alternatives like pipes, memory mapped files or something like that... CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
MrCreatoR Posted September 25, 2007 Share Posted September 25, 2007 (edited) piccasoHi,I using the subclassing to disable the context menu, but in the example there is one problem - it's not disabling the context menu when you press the Win key (or Shift F10), so the solution is to change a litle first line in the _WindowProc() function:Func _WindowProc($hWnd, $uiMsg, $wParam, $lParam) ; Disable the context menu and show your own menu If $uiMsg = 0x007B Then Return 0 ; 0x007B = WM_CONTEXTMENU ; Returning a Pointer to the original WindowProc means: We did not process this message. ; Do not call CallWindowProc() api yourself, the stub will do that for you! Return $OriginalWindowProc EndFuncThanks again for the great tool! (CallBacks).Added: Please look at example here, maybe you could add it to the example of subclassing (as second example of it's usage). Edited September 26, 2007 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
ValeryVal Posted September 26, 2007 Share Posted September 26, 2007 It's valid line: Return $pOriginalWindowProc I think... The point of world view Link to comment Share on other sites More sharing options...
Armand Posted October 8, 2007 Share Posted October 8, 2007 any hard-core guide for the pure retard maybe ?! - i don't know a thing about DLLs and i realy have to use a call-back function for my TCP-download-manager to work propperly however i can't seem to realize how can i convert my normal script (which uses no dlls) to a DLL based script such as your examples... - if there are any guides for the moron i'd love it !!! - also about you're other UDF -> 'CoProc' (which seems by far more easier to use and i can't seem to realize the difference), i'm having some difficulties with using it with multiple args for the function call... seems like it works perfect with 1 arg though... {P.S- also wrote ya in that UDF's thread!!!} [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
jpm Posted November 14, 2007 Share Posted November 14, 2007 it looks like the latest beta 3.2.9.10 or perhaps a little before broke the DllCallBack.au3 the enumicons.au3 in Example\Gui\advanced is not working anymore with it Link to comment Share on other sites More sharing options...
Administrators Jon Posted November 14, 2007 Administrators Share Posted November 14, 2007 The only 2 things that changed were long_ptr and int_ptr were removed and the default alignment of structs was changed to 8 rather than 1. I can't see any _ptr references in there so it probably needs some "align 1" prefixes in the structs. 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...
piccaso Posted November 21, 2007 Author Share Posted November 21, 2007 Awesome, i wasnt here for some time and now i come here and see that Callback is built in and even execute is unlimited now I have to play with it right away, thanks Jon Can someone (who has the rights) please unsticky & lock this thread please? To avoid confusion... I'll translate the existing examples to new callback functions and post them as example. thanks CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 21, 2007 Moderators Share Posted November 21, 2007 Awesome, i wasnt here for some time and now i come here and see that Callback is built in and even execute is unlimited now I have to play with it right away, thanks Jon Can someone (who has the rights) please unsticky & lock this thread please?To avoid confusion...I'll translate the existing examples to new callback functions and post them as example.thanksDone... Go play! Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts