Shaggi Posted June 30, 2012 Share Posted June 30, 2012 Been stuck in this for a day now. As far as i know, the desktop's a syslistview32 control, where icons on the desktop is items, right?Therefore i should be able to get the icon text using LVM_GETITEMTEXT?using this code:for item in GetListViewItems(hList) debugout(consolewrite, GetItemText(hList, item)) nextwhere GetItemText is:expandcollapse popup#cs GetItemText(hList, item) @param1 = handle to the listview (hWnd) @param2 = index of the item @ret = on error, "", on success, the item's text. #ce Func GetItemText(hList, item) ; the one in structureconstants.au3 seems to be wrong const LVITEM = "UINT mask;int iItem;int iSubItem;UINT state;UINT stateMask; ptr pszText;" & _ "int cchTextMax;int iImage;LPARAM lParam;int iIndent;int iGroupId;UINT cColumns;" & _ "UINT puColumns;int piColFmt;int iGroup;" ; Create and fill the buffer. Local lvitem_buf = DllStructCreate(LVITEM) DllStructSetData(lvitem_buf, "iSubItem", 0) DllStructSetData(lvitem_buf, "cchTextMax", 0xFF) DllStructSetData(lvitem_buf, "mask", $LVIF_TEXT) DllStructSetData(lvitem_buf, "iItem", item) Local size = DllStructGetSize(lvitem_buf) ; Open process and allocate a buffer large enough for the lvitem and the text (appended at back) Local hMem = ProcOpen(hList), buf = AllocMemory(hMem, size + 0xFF) if not buf then return "" ; Calc pointer to text, and set it in the lvitem, and write it to the process Local pText = buf + size DllStructSetData(lvitem_buf, "pszText", pText) WriteMemory(hMem, buf, size) ; Send the message and collect the amount of characters written Local chars = _SendMessage(hList, $LVM_GETITEMTEXTW, DllStructGetData(lvitem_buf, "iItem"), buf, 0) ; Collect a binary string (for debug) Local bytes = ReadMemory(hMem, buf, "byte[" & size + 0xFF & "]") ; Calc pointer to text to be sure, and get the string. Local ptextout = ReadMemory(hMem, buf + offsetof(lvitem_buf, "pszText"), "ptr") Local stext = ReadMemory(hMem, ptextout, "wchar[256]") ; Debug stuff debugout(consolewrite, bytes) debugout(consolewrite, "[chars = " & chars & "]" & stext) debugout(consolewrite, _WinApi_GetLastErrorMessage()) ; Clean up FreeMemory(hMem, buf, size + 0xFF) CloseHandle(hMem) return stext EndFuncAnd hList is a class SysListView32 belonging to the progman window.Output is:0x01000000 + item + 000000000000000000000000000000 3C007D06FF (pointer to buffer at end) ... (zero'es) [chars = 0] The operation completed successfully. [empty string]Does anybody know what's going on? I'll admit i dont have a lot of knowledge about listviews, but this is the way that both msdn and general searching suggests (check out this link: http://social.msdn.microsoft.com/Forums/eu/winforms/thread/d7df8a4d-fc0f-4b62-80c9-7768756456e6)Using autoit beta x64 (irrelevant though, tried in other languages too), and windows 7 x64.Any help appreciated .. Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
abberration Posted June 30, 2012 Share Posted June 30, 2012 I think you are making it more complicated than it needs to be. Why not just do something like this: #include <file.au3> #include <array.au3> $list = _FileListToArray(@DesktopDir, "*.lnk", 1) _ArrayDisplay($list) Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
Shaggi Posted July 1, 2012 Author Share Posted July 1, 2012 I think you are making it more complicated than it needs to be. Why not just do something like this: #include <file.au3> #include <array.au3> $list = _FileListToArray(@DesktopDir, "*.lnk", 1) _ArrayDisplay($list) I need to be able to get/set the icons positions, get the icon etc.. Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
John Posted July 1, 2012 Share Posted July 1, 2012 You can use FileGetShortcut returns an array with all that info. Link to comment Share on other sites More sharing options...
Shaggi Posted July 1, 2012 Author Share Posted July 1, 2012 You can use FileGetShortcut returns an array with all that info.only works for shortcuts, and i would still need to arrange the icons on the desktop Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
BrewManNH Posted July 1, 2012 Share Posted July 1, 2012 It sounds like you're looking to do something similar to what you might want to take a look at how he did it and adapt to your needs. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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