Sign in to follow this  
Followers 0
SaphuA

Substract icon from window

12 posts in this topic

Hello,

Is it possible to substract/use the icon that a window uses? I do not need the actual file; I just want to use the icon in my GUI.

Thank you!

Share this post


Link to post
Share on other sites



I've been looking around a little and I guess I have to use something along the lines of 'SendMessageTimeout' or DLL-calls. The only problem is that I'm not that advanced with AutoIt yet. Anyone got some tips for me?

Share this post


Link to post
Share on other sites

Do you wish just to have the icon of something els to use in your program, or do you actually want something for autoit to take and use temporarily?

If you just want an icon to compile with, look up the resource hacker thing


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

If I understand you right then use Scite4AutoIt3 and

#AutoIt3Wrapper_Icon=your_app_icon.ico

#AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Icons\au3.ico

#AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Icons\filetype1.ico

...

Share this post


Link to post
Share on other sites

No you're both wrong.

I want to use the icon of any window handle, and use that icon in my gui.

Perhaps it's possible to see what executable file opened the window and use the icon from that executable?

Thank you!

Share this post


Link to post
Share on other sites

You have to use WM_GETICON :Phttp://msdn.microsoft.com/en-us/library/ms632625(VS.85).aspx

Then you get a handle, whih represents the Icon and you can use it With WM_SETICON for your gui :P


*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

Share this post


Link to post
Share on other sites

SaphuA

This?

#include <WindowsConstants.au3>

Global $GCL_HICONSM = -34
Global $GCL_HICON = -14

$hGUI = GUICreate("Test", 300, 200)

GUISetState()

Run("notepad.exe", "", @SW_MINIMIZE)
WinWait("[Class:Notepad]")
$hNotepad = WinGetHandle("[Class:Notepad]")

MsgBox(0, "", "Change GUI icon")

$hIcon = DllCall("user32.dll", "int", "GetClassLong", "hwnd", $hNotepad, "int", $GCL_HICON)
$hIcon = $hIcon[0]

If $hIcon = 0 Then
    $hIcon = DllCall("user32.dll", "int", "GetClassLong", "hwnd", $hNotepad, "int", $GCL_HICONSM)
    $hIcon = $hIcon[0]
EndIf

DllCall("user32.dll", "int", "SendMessage", "hwnd", $hGUI, "int", $WM_SETICON, "int", 1, "int", $hIcon)

DllCall("User32.dll", "int", "DestroyIcon", "hwnd", $hIcon)

WinClose($hNotepad)

Do
Until GUIGetMsg() = -3

Share this post


Link to post
Share on other sites

Btw, I was just wondering, how do you guys know what functions these DLL's contain and how to use them?

Share this post


Link to post
Share on other sites

E.g. from Microsoft :P

MSDn -> WinAPI : http://msdn.microsoft.com/en-us/library/aa383749(VS.85).aspx

or from examples in other languages like VB, delphi, ...


*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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0