komalo Posted October 3, 2008 Share Posted October 3, 2008 (edited) i am trying to create a struct of LPCREATESTRUCT and HWND types but i always get @error = 2 because they are unknown Data Type Creates a C/C++ style structure to be used in DllCall. DllStructCreate ( "Struct" [,Pointer] ) Parameters "Struct" A string representing the structure to create (See Remarks). Pointer If supplied the struct will not allocate memory but use the pointer supplied. Return Value Success: A variable for use with DllStruct calls. Failure: 0. @Error: 0 = No Error. 1 = Variable passed to DllStructCreate was not a string. 2 = There is an unknown Data Type in the string passed. 3 = Failed to allocate the memory needed for the struct, or Pointer = 0. 4 = Error allocating memory for the passed string. is there's a solution for this problem ? Edited October 3, 2008 by komalo [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] Link to comment Share on other sites More sharing options...
BrettF Posted October 3, 2008 Share Posted October 3, 2008 Post your code. I personally have no idea what you need to do until I see the code, but the type is not the same as C++. You need to read the helpfile and look a DllCall. 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...
komalo Posted October 3, 2008 Author Share Posted October 3, 2008 as an example $Struct = DllStructCreate("LPCREATESTRUCT lpcs;HWND hwndInsertAfter;") MsgBox("","",$Struct & " " & @error ) $Struct = 0 the problem is when i try to create the struct , it is not created and @error set to 2 which is @Error: 0 = No Error. 1 = Variable passed to DllStructCreate was not a string. 2 = There is an unknown Data Type in the string passed. 3 = Failed to allocate the memory needed for the struct, or Pointer = 0. 4 = Error allocating memory for the passed string. [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] Link to comment Share on other sites More sharing options...
rasim Posted October 3, 2008 Share Posted October 3, 2008 komaloLPCREATESTRUCT is not a valid type. Read the DllCall description in the help file. Link to comment Share on other sites More sharing options...
komalo Posted October 3, 2008 Author Share Posted October 3, 2008 (edited) no you don't understandLPCREATESTRUCT is a user-defined type but it is no defined in autoitsee : http://msdn.microsoft.com/en-us/library/ms644962(VS.85).aspx Edited October 3, 2008 by komalo [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] Link to comment Share on other sites More sharing options...
rasim Posted October 3, 2008 Share Posted October 3, 2008 komalo$CBT_CREATEWND = DllStructCreate("ptr lpcs;hwnd hwndInsertAfter") Link to comment Share on other sites More sharing options...
komalo Posted October 3, 2008 Author Share Posted October 3, 2008 (edited) no i can't use that , the data types must be identical like in this structbecause i am using it with a pointer to this structso using ptr type doesn't solve the problem Edited October 3, 2008 by komalo [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] Link to comment Share on other sites More sharing options...
komalo Posted October 4, 2008 Author Share Posted October 4, 2008 any one ? [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] Link to comment Share on other sites More sharing options...
martin Posted October 4, 2008 Share Posted October 4, 2008 no i can't use that , the data types must be identical like in this structbecause i am using it with a pointer to this structso using ptr type doesn't solve the problemDon't be silly. If I take a cow to France it becomes une vache, but the cow itself hasn't changed has it?Since the data types are identical it's very difficult to understand your problem. The link you gave to the struct states the the first element is a pointer. So in AutoIt that's called "ptr". The only thing you have to worry about is if you are working in a 64 bit OS and then you can use "long_ptr" which ensures that it is the correct size, but your link was for WIn32 so that seems unlikely to be needed. 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...
komalo Posted October 5, 2008 Author Share Posted October 5, 2008 i told you that because i tried using "ptr" and "long_ptr' Before and then it create it and i can use DllStructGetPtr but when using DllStructGetData an error happens so my guess that i have to use the same types [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] Link to comment Share on other sites More sharing options...
BrettF Posted October 5, 2008 Share Posted October 5, 2008 Post your EXACT code you are using. If you haven't looked into DllCalls and stuff before, you might want to do some reading on it... 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...
komalo Posted October 5, 2008 Author Share Posted October 5, 2008 that's okay , i gave up with this struct and found another way for my script , thank you all . [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] Link to comment Share on other sites More sharing options...
ProgAndy Posted October 5, 2008 Share Posted October 5, 2008 (edited) Well, I have the solution now. Structures in structures are just inserted in place of the name: Global Const $tagCREATESTRUCT = "ptr lpCreateParams;hwnd hInstance;hwnd hMenu; HWND hwndParent; int cy; int cx; int y; int x; LONG style; ptr lpszName; ptr lpszClass; DWORD dwExStyle" ; lpCreateParams is a lpvoid ; lpszName is a pointer to a string ( LPCTSTR ) ; lpszClass is a pointer to a string ( LPCTSTR ) Global Const $tagCBT_CREATEWND = $tagCREATESTRUCT & ";hwnd hwndInsertAfter" $CBT_CREATEWND = DllStructCreate($tagCBT_CREATEWND) MsgBox("","",$CBT_CREATEWND & " " & @error ) $CBT_CREATEWND = 0 Edited October 5, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
komalo Posted October 5, 2008 Author Share Posted October 5, 2008 (edited) well your seems code seems write but my problem continues on DllStructGetDatai am using setwindowshook in my code , one of the messages of it is $HCBT_CREATEWND which returns a pointer to CBT_CREATEWND structin the LParam , i want to get the data in that structure , so i used DllStructCreate with LParam as the pointer parameterand get the data DllStructGetData but it always returns an error (the memory couldn't be "read" ) on DllStructGetData Edited October 5, 2008 by komalo [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] Link to comment Share on other sites More sharing options...
komalo Posted October 5, 2008 Author Share Posted October 5, 2008 and here's the code of callback function$CBT_CREATEWND = DllStructCreate("LPCREATESTRUCT lpcs;HWND hwndInsertAfter;",$LParam)FileWriteLine("NewWinLog.txt", DllStructGetData($CBT_CREATEWND, 1)) [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] Link to comment Share on other sites More sharing options...
rasim Posted October 5, 2008 Share Posted October 5, 2008 ProgAndyStructures in structures are just inserted in place of the nameHi! You think your solution correct? But I think this type should be a pointer(ptr) to a CREATESTRUCT structure. Your solution right for this example, see a hdr type. Link to comment Share on other sites More sharing options...
ProgAndy Posted October 5, 2008 Share Posted October 5, 2008 (edited) Hmm, this works? CODE#include <WinAPI.au3> Const $HCBT_CREATEWND = 3 Global Const $tagCREATESTRUCT = "ptr lpCreateParams;hwnd hInstance;hwnd hMenu; HWND hwndParent; int cy; int cx; int y; int x; LONG style; ptr lpszName; ptr lpszClass; DWORD dwExStyle" ; lpCreateParams is a lpvoid ; lpszName is a pointer to a string ( LPCTSTR ) ; lpszClass is a pointer to a string ( LPCTSTR ) Global Const $tagCBT_CREATEWND = "ptr lpcs;hwnd hwndInsertAfter" $ShellCallb = DllCallbackRegister("CBTProc","long_ptr","int;wparam;lparam") $HookHwnd = _WinAPI_SetWindowsHookEx($WH_CBT,DllCallbackGetPtr($ShellCallb),0,_WinAPI_GetCurrentThreadId()) MsgBox(0, '', $HookHwnd) While 1 Sleep(1000) WEnd Func OnAutoItExit() _WinAPI_UnhookWindowsHookEx($HookHwnd) EndFunc Func CBTProc($nCode,$wParam,$lParam) ;~ int nCode, ;~ WPARAM wParam, ;~ LPARAM lParam If $nCode = $HCBT_CREATEWND Then $CBT_CREATEWND = DllStructCreate($tagCBT_CREATEWND,$lParam) $CREATESTRUCT = DllStructCreate($tagCREATESTRUCT,DllStructGetData($CBT_CREATEWND,1)) ConsoleWrite(DllStructGetData($CREATESTRUCT,"y") & @CRLF) EndIf _WinAPI_CallNextHookEx($WH_CBT,$nCode,$wParam,$lParam) EndFunc //Edit: You are right. The values are strange ... I changed to the ptr solution and it works. Thx Edited October 5, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
komalo Posted October 5, 2008 Author Share Posted October 5, 2008 i am still getting the problem with my script but not yours well it seems that the problem that i a am using it with Larry's hook.dll i really don't get it why it doesn't work , i don't want to post my code so i will work with the the other [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] 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