vsny Posted March 27, 2010 Share Posted March 27, 2010 I am trying to add a window handle into a scripting dictionary. I have all my controls stored but I cannot store the window handle. Is there a way to store the handle in some way. $ctrls = ObjCreate('Scripting.Dictionary') Func _createWnd() Local $wnd = GUICreate("My GUI edit") $ctrls.add("wnd", $wnd) ; also have tried Ptr($wnd) EndFunc A typical error I get with or without the Ptr() is: C:\testControls.au3 (151) : ==> The requested action with this object has failed.: $ctrls.add("wnd", ptr($wnd)) $ctrls.add("wnd", ptr($wnd))^ ERROR I assume there is a way to do this since it works with controls and almost everything else. Can't I store the pointer to the window? or will I lose the window once it goes out of scope. In case anyone asks - like any good programming style I'm trying to eliminate global variables and I have to pass all the public window controls between included modules. Link to comment Share on other sites More sharing options...
Yoriz Posted March 27, 2010 Share Posted March 27, 2010 Global $ctrls = ObjCreate('Scripting.Dictionary') _createWnd() MsgBox(0,"Handle",_GetWnd("wnd")) Func _createWnd() Local $wnd = GUICreate("My GUI edit") _AddWnd("wnd",$wnd) EndFunc Func _AddWnd($sKey, $sItem) $ctrls.add($sKey, string($sItem)) EndFunc Func _GetWnd($sKey) Return HWnd($ctrls.item($sKey)) EndFunc GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 27, 2010 Moderators Share Posted March 27, 2010 vsny,Welcome to the AutoIt forum. I get it to work if I convert the Hex window handle to either a decimal number or a string first:$ctrls = ObjCreate('Scripting.Dictionary') _createWnd() Func _createWnd() Local $wnd = GUICreate("My GUI edit") ConsoleWrite($wnd & @CRLF) $ctrls.add("Wnd_1", Dec(StringTrimleft($wnd, 2))) ConsoleWrite("0x" & Hex($ctrls.item("Wnd_1"), 8) & @CRLF) $ctrls.add("Wnd_2", String($wnd)) ConsoleWrite($ctrls.item("Wnd_2") & @CRLF) EndFuncWhy, I have no idea - I just thought I would try it! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ProgAndy Posted March 27, 2010 Share Posted March 27, 2010 Same error we discovered when testing AutoItObject, it seems that no dev wants to fix it. #1410 *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...
Moderators Melba23 Posted March 27, 2010 Moderators Share Posted March 27, 2010 ProgAndy, Do not lose hope - the bug is still open and we know that there is a bit of a pause in development at the moment. And even if it does not get fixed, we know the work-around. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
vsny Posted March 27, 2010 Author Share Posted March 27, 2010 Wow, you guys are fast! I went to the backyard for a few minutes and the answer was waiting for me! I tried Yoriz's String() solution and it seems to work. Thanks! Are there any drawbacks or dangers to doing this? Is this an unsupported hack that will break in future versions? Do the dev's have any feedback on this? Maybe there was a reason they didn't implement this? Link to comment Share on other sites More sharing options...
wraithdu Posted March 28, 2010 Share Posted March 28, 2010 It a better idea to just use Number($wnd) instead of any string conversions. A window handle is just a 32/64-bit number anyway, it's just that AutoIt internally designates it a 'handle' and AutoIt's implementation of objects does not allow it to work with 'handle'. This is also the solution that the AutoItObject examples use. 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