AutoHotkey Community

It is currently May 24th, 2012, 6:24 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: February 17th, 2007, 9:41 am 
How can i call this ? Anyone with an example script ..


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2007, 5:38 pm 
Anyone ?? help please..


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2007, 7:44 pm 
This seems to work:
Code:
Gui, Show, h100 w100, Test                  ;Simple GUI for a handle

WinGet, hWnd, ID, Test                      ;Get hWnd to window

IconPath = %A_WinDir%Shell32\Shell32.dll    ;Path to any Dll
PathSize := StrLen(IconPath)                ;Length of the path above

Index := 1                                  ;Pre-selected icon number

Dlg := DllCall("Shell32.dll\PickIconDlg", "UInt", hWnd, "UInt*", "IconPath", "UInt", "PathSize", "Int*", Index)

If !Dlg
  {
     MsgBox Call Failed!
     ExitApp
  }

;--- On return, IconPath will hold the Path\Dll name and Index will hold the icon number

MsgBox Icon Path: %IconPath%`nIcon Selected: %Index%


I didn't test it with anything but Shell32.dll tho, so might want do test it well.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2007, 8:05 pm 
Nvm, IconPath isn't getting updated.

Always hated working with Dlls from AHK Image

I'll play with it some more :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2007, 12:41 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Try this:

Code:
Gui, Show, h100 w100, PickIconDlg

WinGet, hWnd, ID, PickIconDlg

sIconPath := A_WinDir . "\system32\shell32.dll"
nIndex := 0

VarSetCapacity(wIconPath, 260 * 2)
DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "str", sIconPath, "int", -1, "str", wIconPath, "int", 260)

DllCall("shell32\PickIconDlg", "Uint", hWnd, "str", wIconPath, "Uint", 260, "intP", nIndex)

VarSetCapacity(sIconPath, 260)
DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wIconPath, "int", -1, "str", sIconPath, "int", 260, "Uint", 0, "Uint", 0)

MsgBox % sIconPath . "," . nIndex




Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2007, 1:38 am 
Glad you posted that. I was about to put my shoes on and go looking for Bill Gates after I did all the Unicode stuff and it wouldn't work on paths with spaces :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2007, 10:58 am 
Sean wrote:
Try this:

Code:
Gui, Show, h100 w100, PickIconDlg

WinGet, hWnd, ID, PickIconDlg

sIconPath := A_WinDir . "\system32\shell32.dll"
nIndex := 0

VarSetCapacity(wIconPath, 260 * 2)
DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "str", sIconPath, "int", -1, "str", wIconPath, "int", 260)

DllCall("shell32\PickIconDlg", "Uint", hWnd, "str", wIconPath, "Uint", 260, "intP", nIndex)

VarSetCapacity(sIconPath, 260)
DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wIconPath, "int", -1, "str", sIconPath, "int", 260, "Uint", 0, "Uint", 0)

MsgBox % sIconPath . "," . nIndex





THANKS VERY MUCH Sean :D :D :D :D :D :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2007, 10:59 am 
BTW, why the Gui Show line ?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2007, 11:01 am 
Oh.. to get the window handle... but the script works without that :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2008, 12:01 pm 
Offline

Joined: July 14th, 2006, 12:31 am
Posts: 290
Location: Berlin
Code:
If !DllCall("shell32\PickIconDlg" , "Uint" , hWnd , "str" , wSourceFile , "Uint" , 260 , "intP" , nIndex)
   Return ; cancel was clicked or something else failed


Report this post
Top
 Profile  
Reply with quote  
 Post subject: No Window
PostPosted: August 25th, 2009, 3:50 pm 
If you don't want to deal with the random blank window, you CAN specify null as the hWnd, just like in the Win32 API:
Code:
sIconPath := A_WinDir . "\system32\shell32.dll"
nIndex := 0
VarSetCapacity(wIconPath, 260 * 2)
DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "str", sIconPath, "int", -1, "str", wIconPath, "int", 260)
DllCall("shell32\PickIconDlg", "Uint", null, "str", wIconPath, "Uint", 260, "intP", nIndex)
VarSetCapacity(sIconPath, 260)
DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wIconPath, "int", -1, "str", sIconPath, "int", 260, "Uint", 0, "Uint", 0)
MsgBox % sIconPath . "," . nIndex


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 25th, 2009, 3:53 pm 
Online
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8643
Location: Salem, MA
Why are you bringing up this old topic?

In general, I would point to majkinetor's excellent Dlg module: http://www.autohotkey.com/forum/viewtopic.php?t=17230

It directly handles the icon box code for you.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Kgalv, Kirtman, kwfine, LazyMan, mc-lemons, Ohnitiel, rbrtryn, Yahoo [Bot] and 76 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group