Armand Posted March 17, 2015 Share Posted March 17, 2015 Hi, I'd like to know if it's possible to change the icon of window other then my own created one. For example - notepad's icon into some other icon. Thanks in advance, SK. [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
guinness Posted March 17, 2015 Share Posted March 17, 2015 You will need to change it a little bit >> but since you have 500+ posts I guess you're not looking for a ready made solution. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Armand Posted March 17, 2015 Author Share Posted March 17, 2015 doesn't seem to work on anything other then AU3 GUIS... I want to change other applications window's icon... like notepad's... trying this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> HotKeySet("+!t", "ChangeWindowTitle") Global $CurrentActiveWindow, $PreviousActiveWindow While 1 Sleep(1000) CheckTitles() WEnd Func CheckTitles() If WinGetTitle("[ACTIVE]") <> $CurrentActiveWindow Then $PreviousActiveWindow = $CurrentActiveWindow $CurrentActiveWindow = WinGetTitle("[ACTIVE]") EndIf EndFunc Func ChangeWindowTitle() WinSetTitle("[ACTIVE]", "", $PreviousActiveWindow) $hWnd = WinGetHandle("[ACTIVE]") If Not IsHWnd($hWnd) Then MsgBox(0, "ERROR", "") _GUISetIcon($hWnd, "H:\Programming\AU3 in progress\Failure.ico", "") EndFunc Func _GUISetIcon($hWnd, $sFilePath, $iName) If Not IsHWnd($hWnd) Then Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) If @error Then Return SetError(@error, 0 * GUICtrlDelete($iLabel), 0) EndIf GUICtrlDelete($iLabel) EndIf Local $hIcon = _WinAPI_LoadImage(_WinAPI_GetModuleHandle($sFilePath), $iName, 1, 32, 32, 0) Return _SendMessage($hWnd, $WM_SETICON, 1, $hIcon) EndFunc ;==>_GUISetIcon [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
guinness Posted March 17, 2015 Share Posted March 17, 2015 As I said you will need to tweak it. It's no surprise it doesn't work. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
johnmcloud Posted March 17, 2015 Share Posted March 17, 2015 ; Author: Mikell #include <WinAPI.au3> Run("notepad.exe") Do Sleep(10) Until WinExists("[CLASS:Notepad]") Local $hWnd = WinGetHandle("[CLASS:Notepad]") _WinSetIcon($hWnd, "shell32.dll", 25) ;~ _WinSetIcon($hWnd, "X:\Path\Icon.ico") WinSetTitle($hWnd, "", "Testing") ;========================================= Func _WinSetIcon($hWnd, $sFile, $iIndex = 0) Local $tIcons = DllStructCreate("ptr Data") DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sFile, "int", $iIndex, "struct*", 0, "struct*", $tIcons, "uint", 1) If @error Then Return SetError(1, 0, 0) Local $hIcon = DllStructGetData($tIcons, "Data") _SendMessage($hWnd, 0x0080, 1, $hIcon ) ;$WM_SETICON = 0x0080 _WinAPI_DestroyIcon($hIcon) Return 1 EndFunc Link to comment Share on other sites More sharing options...
Armand Posted March 17, 2015 Author Share Posted March 17, 2015 Awesome ! johnmcloud Thanks for the quick solution p.s. thank you too guinness [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
aVen9er Posted July 28, 2020 Share Posted July 28, 2020 It checked and it works on 32-bit applications. How to make it work on 64-bit applications? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 28, 2020 Moderators Share Posted July 28, 2020 aVen9er, Stick to just the one thread please - I have deleted your duplicate post. 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...
Nine Posted July 28, 2020 Share Posted July 28, 2020 There may be something wrong with your code. Using this : #include <WinAPI.au3> #include <WinAPIIcons.au3> #include <WindowsConstants.au3> Const $sTitle = "Testing" ;Run ("Testing.exe") Do Sleep(10) Until WinExists($sTitle) Local $hWnd = WinGetHandle($sTitle) Sleep(1000) _WinSetIcon($hWnd, "shell32.dll", 41) Func _WinSetIcon($hWnd, $sFile, $iIndex = 0) Local $hIcon = _WinAPI_ExtractIcon($sFile, $iIndex, True) _SendMessage($hWnd, $WM_SETICON, 1, $hIcon) ConsoleWrite(_WinAPI_DestroyIcon($hIcon) & @CRLF) EndFunc ;==>_WinSetIcon With a compiled x64 AutoIt GUI : #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Testing") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example Works fine even if first script is x86. Works also if second script.exe is ran inside or outside first script. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
aVen9er Posted July 31, 2020 Share Posted July 31, 2020 (edited) Your example works, but I am trying to change the Total Commander (x64) icon and it doesn't work. (Interestingly works on x86 Total Commander) #include <WinAPI.au3> #include <WinAPIIcons.au3> #include <WindowsConstants.au3> Const $sTitle = "[Title:Total Commander (x64);Class:TTOTAL_CMD]" Do Sleep(10) Until WinExists($sTitle) Local $hWnd = WinGetHandle($sTitle) Sleep(1000) _WinSetIcon($hWnd, "shell32.dll", 41) Msgbox(0, @ScriptName, WinExists($sTitle)) ; checked: Window exists Func _WinSetIcon($hWnd, $sFile, $iIndex = 0) Local $hIcon = _WinAPI_ExtractIcon($sFile, $iIndex, True) _SendMessage($hWnd, $WM_SETICON, 1, $hIcon) ConsoleWrite(_WinAPI_DestroyIcon($hIcon) & @CRLF) EndFunc ;==>_WinSetIcon How to change the icon in Total Commander (x64)? Edited August 1, 2020 by aVen9er Link to comment Share on other sites More sharing options...
Developers Jos Posted July 31, 2020 Developers Share Posted July 31, 2020 Did you run the script with AutoIt3_x64.exe ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
aVen9er Posted July 31, 2020 Share Posted July 31, 2020 I clicked "Run Script (x64)" it showed Msgbox, but didn't change the icon. I also clicked "Compile Script (x64)", and then doubleclicked exe file. It also showed Msgbox, but didn't change the icon. 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