Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AHK_L Compiled EXE/BIN Icon Changer v1.1 UPDATED


  • Please log in to reply
9 replies to this topic
Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
"Version is 1.1" UPDATED !

!Download Compiled Exe!

Preview :

Posted Image

Main Ahk :
#NoTrayIcon
#NoEnv
#Include SetBtnTxtColor.ahk
#Include IconChanger.ahk
Gui, -E0x10
Gui, Add, CheckBox, x240 y155 h15 Checked vbackup, Make Backup
Gui, Add, CheckBox, x20 y275 h20 Checked vmain, Main Icon
Gui, Add, CheckBox, x20 y300 h20 vtray, Tray Icon(for _L)
Gui, Add, CheckBox, x125 y275 h20 vsus1, Suspend (Green)
Gui, Add, CheckBox, x125 y300 h20 vsus2, Suspend (Red)
Gui, Add, CheckBox, x235 y285 h20 vpause, Pause Icon
Gui, Add, GroupBox, x10 y250 w325 h75 +Theme , Which icon to replace
Gui, Font, s8 cFF0000 w700
Gui, Add, Text, x10 y365 w325 h30 vmust, Source EXE must be uncompressed !`nOtherwise It will crash your exe file.
Gui, Font, s8 c000000 w0
Gui, Add, Text, x15 y165 w180 h15, ICO File :
Gui, Add, Text, x15 y65 w180 h15, EXE/BIN File :
Gui, Font, s10 w700, Tahoma
Gui, Add, Button, x10 y330 w100 h30 vstr hwndChangeA +E0x1 gGo, Change !
SetBtnTxtColor(ChangeA, "0066B3")
Gui, Font, s8 w0
Gui, Add, Button, x235 y330 w100 h30 vext hwndChangeB +E0x1, Exit
SetBtnTxtColor(ChangeB, "6B006B")
Gui, Add, Button, x235 y365 w100 h30 hwndChangeC +E0x1 gAbout, About
SetBtnTxtColor(ChangeC, "917C00")
Gui, Font, s14 c00A2F9 w700 Q5
Gui, Add, Text, x10 y80 w325 h70 Center +0x200 +E0x20210 vdragexe, DRAG .EXE or .BIN TO HERE
Gui, Add, Text, x10 y180 w325 h65 Center +0x200 +E0x20210 vdragico, DRAG .ICO TO HERE
Gui, Font, s16 c00DB4C w700 Q5
Gui, Add, Text, x10 y10 w325 h45 +Center, Icon Changer (for All version)
Gui, Show, w344 h400, Icon Changer (for Autohotkey)
OnExit, GuiClose
OnMessage(0x233, "OnGuiDropFiles")
Return

ButtonExit:
GuiClose:
GuiEscape:
ExitApp

About:
SetTimer, chngetxt, 5
MsgBox, 4160, About, Ahk_L Exe Icon Changer by Sky92 v1.1 (2012)
SetTimer, chngetxt, Off
Return

chngetxt:
ControlSetText, Button1, Ok :), About
return


OnGuiDropFiles(wParam) { 
global
  WS_EX_ACCEPTFILES := 0x10
  VarSetCapacity($DropedFile, 256, 0)
  IF DllCall("Shell32\DragQueryFileA", "UInt", wParam, "UInt", 0, "Str", $DropedFile, "UInt", 256) {
    VarSetCapacity($DropedFile, -1)
;Start --------------------------------

SplitPath, $DropedFile, outfname
IfInString, outfname, .exe
{
	Exe = %$DropedFile%
    ExeName = %outfname%
    SplitPath, $DropedFile,, ExeDir
	GuiControl,, dragexe, %outfname%
	return
}

IfInString, outfname, .bin
{
	Exe = %$DropedFile%
    ExeName = %outfname%
    SplitPath, $DropedFile,, ExeDir
	GuiControl,, dragexe, %outfname%
	return
}

IfInString, outfname, .ico
{
	Ico = %$DropedFile%
	GuiControl,, dragico, %outfname%
	return
}

;Finish -------------------------------
  }
  DllCall("Shell32\DragFinish", "Uint", wParam)
  Return 0
}
return

Go:
Gui, Submit, Nohide

if (Exe="" || Ico="") {
  MsgBox, 262192, Operation Cancelled, Please drag valid files on the dialog...
  return
}

if backup {
  FileCopy, %Exe%, %ExeDir%\BACKUP_%ExeName%
}

if main {
  module := DllCall("BeginUpdateResource", "str", Exe, "uint", 0, "ptr")
  ReplaceAhkIcon(module, Ico, Exe, 159)
  DllCall("EndUpdateResource", "ptr", module, "uint", 0)
}

if tray {
  module := DllCall("BeginUpdateResource", "str", Exe, "uint", 0, "ptr")
  ReplaceAhkIcon(module, Ico, Exe, 230)
  DllCall("EndUpdateResource", "ptr", module, "uint", 0)
}

if sus1 {
  module := DllCall("BeginUpdateResource", "str", Exe, "uint", 0, "ptr")
  ReplaceAhkIcon(module, Ico, Exe, 206)
  DllCall("EndUpdateResource", "ptr", module, "uint", 0)
}

if sus2 {
  module := DllCall("BeginUpdateResource", "str", Exe, "uint", 0, "ptr")
  ReplaceAhkIcon(module, Ico, Exe, 208)
  DllCall("EndUpdateResource", "ptr", module, "uint", 0)
}

if pause {
  module := DllCall("BeginUpdateResource", "str", Exe, "uint", 0, "ptr")
  ReplaceAhkIcon(module, Ico, Exe, 207)
  DllCall("EndUpdateResource", "ptr", module, "uint", 0)
}
MsgBox, 4160, `t, Done!
return

IconChanger.ahk :
ReplaceAhkIcon(re, IcoFile, ExeFile, iconID)
{

	global _EI_HighestIconID
	;static iconID := 230
	
	ids := EnumIcons(ExeFile, iconID)
	if !IsObject(ids)
		return false
	
	f := FileOpen(IcoFile, "r")
	if !IsObject(f)
		return false
	
	VarSetCapacity(igh, 8), f.RawRead(igh, 6)
	if NumGet(igh, 0, "UShort") != 0 || NumGet(igh, 2, "UShort") != 1
		return false
	
	wCount := NumGet(igh, 4, "UShort")
	
	VarSetCapacity(rsrcIconGroup, rsrcIconGroupSize := 6 + wCount*14)
	NumPut(NumGet(igh, "Int64"), rsrcIconGroup, "Int64") ; fast copy
	
	ige := &rsrcIconGroup + 6
	
	; Delete all the images
	Loop, % ids._MaxIndex()
		DllCall("UpdateResource", "ptr", re, "ptr", 3, "ptr", ids[A_Index], "ushort", 0x409, "ptr", 0, "uint", 0, "uint")
	
	Loop, %wCount%
	{
		thisID := ids[A_Index]
		if !thisID
			thisID := ++ _EI_HighestIconID
		
		f.RawRead(ige+0, 12) ; read all but the offset
		NumPut(thisID, ige+12, "UShort")
		
		imgOffset := f.ReadUInt()
		oldPos := f.Pos
		f.Pos := imgOffset
		
		VarSetCapacity(iconData, iconDataSize := NumGet(ige+8, "UInt"))
		f.RawRead(iconData, iconDataSize)
		f.Pos := oldPos
		
		DllCall("UpdateResource", "ptr", re, "ptr", 3, "ptr", thisID, "ushort", 0x409, "ptr", &iconData, "uint", iconDataSize, "uint")
		
		ige += 14
	}
	
	DllCall("UpdateResource", "ptr", re, "ptr", 14, "ptr", iconID, "ushort", 0x409, "ptr", &rsrcIconGroup, "uint", rsrcIconGroupSize, "uint")
	return true
}

EnumIcons(ExeFile, iconID)
{
	; RT_GROUP_ICON = 14
	; RT_ICON = 3
	global _EI_HighestIconID
	static pEnumFunc := RegisterCallback("EnumIcons_Enum")
	
	hModule := DllCall("LoadLibraryEx", "str", ExeFile, "ptr", 0, "ptr", 2, "ptr")
	if !hModule
		return
	
	_EI_HighestIconID := 0
	if DllCall("EnumResourceNames", "ptr", hModule, "ptr", 3, "ptr", pEnumFunc, "uint", 0) = 0
	{
		DllCall("FreeLibrary", "ptr", hModule)
		return
	}
	
	hRsrc := DllCall("FindResource", "ptr", hModule, "ptr", iconID, "ptr", 14, "ptr")
	hMem := DllCall("LoadResource", "ptr", hModule, "ptr", hRsrc, "ptr")
	pDirHeader := DllCall("LockResource", "ptr", hMem, "ptr")
	pResDir := pDirHeader + 6
	
	wCount := NumGet(pDirHeader+4, "UShort")
	iconIDs := []
	
	Loop, %wCount%
	{
		pResDirEntry := pResDir + (A_Index-1)*14
		iconIDs[A_Index] := NumGet(pResDirEntry+12, "UShort")
	}
	
	DllCall("FreeLibrary", "ptr", hModule)
	return iconIDs
}

EnumIcons_Enum(hModule, type, name, lParam)
{
	global _EI_HighestIconID
	if (name < 0x10000) && name > _EI_HighestIconID
		_EI_HighestIconID := name
	return 1
}


SetBtnTxtColor.ahk :
; ======================================================================================================================
; AHK 1.1.05+
; ======================================================================================================================
; Function:          "Draws" colored captions on pushbuttons.
; AHK version:       1.1.05+ (U32)
; Language:          English
; Tested on:         Win XPSP3 (ANSI), VistaSP2 (U32), 7 (U64)
; Version:           0.1.00.00/2012-04-05/just me
; Credits:           THX tic     for GDIP.AHK     : http://www.autohotkey.com/forum/post-198949.html
;                    THX tkoi    for ILBUTTON.AHK : http://www.autohotkey.com/forum/topic40468.html
;                    THX Lexikos for AHK_L
; Remarks:           The look of the colored caption depends on the font, its size and its weight.
; ======================================================================================================================
; This software is provided 'as-is', without any express or implied warranty.
; In no event will the authors be held liable for any damages arising from the use of this software.
; ======================================================================================================================
; ======================================================================================================================
; FUNCTION SetBtnTxtColor()
; ======================================================================================================================
SetBtnTxtColor(HWND, TxtColor) {
   Static HTML := {BLACK: "000000", GRAY: "808080", SILVER: "C0C0C0", WHITE: "FFFFFF", MAROON: "800000"
                , PURPLE: "800080", FUCHSIA: "FF00FF", RED: "FF0000", GREEN:  "008000", OLIVE:  "808000"
                , YELLOW: "FFFF00", LIME: "00FF00", NAVY: "000080", TEAL: "008080", AQUA: "00FFFF", BLUE: "0000FF"}
   Static BS_CHECKBOX := 0x2, BS_RADIOBUTTON := 0x4, BS_GROUPBOX := 0x7, BS_AUTORADIOBUTTON := 0x9
        , BS_LEFT := 0x100, BS_RIGHT := 0x200, BS_CENTER := 0x300, BS_TOP := 0x400, BS_BOTTOM := 0x800
        , BS_VCENTER := 0xC00, BS_BITMAP := 0x0080, SA_LEFT := 0x0, SA_CENTER := 0x1, SA_RIGHT := 0x2
        , WM_GETFONT := 0x31, BCM_SETIMAGELIST := 0x1602, IMAGE_BITMAP := 0x0, BITSPIXEL := 0xC
        , RCBUTTONS := BS_CHECKBOX | BS_RADIOBUTTON | BS_AUTORADIOBUTTON
        , BUTTON_IMAGELIST_ALIGN_LEFT := 0, BUTTON_IMAGELIST_ALIGN_RIGHT := 1, BUTTON_IMAGELIST_ALIGN_CENTER := 4
   ; -------------------------------------------------------------------------------------------------------------------
   ErrorLevel := ""
   GDIPDll := DllCall("Kernel32.dll\LoadLibrary", "Str", "Gdiplus.dll", "Ptr")
   VarSetCapacity(SI, 24, 0)
   Numput(1, SI)
   DllCall("Gdiplus.dll\GdiplusStartup", "PtrP", GDIPToken, "Ptr", &SI, "Ptr", 0)
   If (!GDIPToken) {
       ErrorLevel := "GDIPlus could not be started!`n`nSetBtnTxtColor won't work!"
       Return False
   }
   If !DllCall("User32.dll\IsWindow", "Ptr", HWND) {
      GoSub, CreateImageButton_GDIPShutdown
      ErrorLevel := "Invalid parameter HWND!"
      Return False
   }
   WinGetClass, BtnClass, ahk_id %HWND%
   ControlGet, BtnStyle, Style, , , ahk_id %HWND%
   If (BtnClass != "Button") || ((BtnStyle & 0xF ^ BS_GROUPBOX) = 0) || ((BtnStyle & RCBUTTONS) > 1) {
      GoSub, CreateImageButton_GDIPShutdown
      ErrorLevel := "You can use SetBtnTxtColor only for PushButtons!"
      Return False
   }
   PFONT := 0
   DC := DllCall("User32.dll\GetDC", "Ptr", HWND, "Ptr")
   BPP := DllCall("Gdi32.dll\GetDeviceCaps", "Ptr", DC, "Int", BITSPIXEL)
   HFONT := DllCall("User32.dll\SendMessage", "Ptr", HWND, "UInt", WM_GETFONT, "Ptr", 0, "Ptr", 0, "Ptr")
   DllCall("Gdi32.dll\SelectObject", "Ptr", DC, "Ptr", HFONT)
   DllCall("Gdiplus.dll\GdipCreateFontFromDC", "Ptr", DC, "PtrP", PFONT)
   DllCall("User32.dll\ReleaseDC", "Ptr", HWND, "Ptr", DC)
   If !(PFONT) {
      GoSub, CreateImageButton_GDIPShutdown
      ErrorLevel := "Couldn't get button's font!"
      Return False
   }
   VarSetCapacity(RECT, 16, 0)
   If !(DllCall("User32.dll\GetClientRect", "Ptr", HWND, "Ptr", &RECT)) {
      GoSub, CreateImageButton_GDIPShutdown
      ErrorLevel := "Couldn't get button's rectangle!"
      Return False
   }
   W := NumGet(RECT,  8, "Int"), H := NumGet(RECT, 12, "Int")
   BtnCaption := ""
   Len := DllCall("User32.dll\GetWindowTextLength", "Ptr", HWND) + 1
   If (Len > 1) {
      VarSetCapacity(BtnCaption, Len * (A_IsUnicode ? 2 : 1), 0)
      If !(DllCall("User32.dll\GetWindowText", "Ptr", HWND, "Str", BtnCaption, "Int", Len)) {
         GoSub, CreateImageButton_GDIPShutdown
         ErrorLevel := "Couldn't get button's caption!"
         Return False
      }
      VarSetCapacity(BtnCaption, -1)
   } Else {
      GoSub, CreateImageButton_GDIPShutdown
      ErrorLevel := "Couldn't get button's caption!"
      Return False
   }
   
   
   If HTML.HasKey(TxtColor)
      TxtColor := HTML[TxtColor]
   DllCall("Gdiplus.dll\GdipCreateBitmapFromScan0", "Int", W, "Int", H, "Int", 0
         , "UInt", 0x26200A, "Ptr", 0, "PtrP", PBITMAP)
   DllCall("Gdiplus.dll\GdipGetImageGraphicsContext", "Ptr", PBITMAP, "PtrP", PGRAPHICS)
   DllCall("Gdiplus.dll\GdipStringFormatGetGenericTypographic", "PtrP", PFORMAT)
   HALIGN := (BtnStyle & BS_CENTER) = BS_CENTER ? SA_CENTER : (BtnStyle & BS_CENTER) = BS_RIGHT ? SA_RIGHT
           : (BtnStyle & BS_CENTER) = BS_Left ? SA_LEFT : SA_CENTER
   DllCall("Gdiplus.dll\GdipSetStringFormatAlign", "Ptr", PFORMAT, "Int", HALIGN)
   VALIGN := (BtnStyle & BS_VCENTER) = BS_TOP ? 0 : (BtnStyle & BS_VCENTER) = BS_BOTTOM ? 2 : 1
   DllCall("Gdiplus.dll\GdipSetStringFormatLineAlign", "Ptr", PFORMAT, "Int", VALIGN)
   DllCall("Gdiplus.dll\GdipSetTextRenderingHint", "Ptr", PGRAPHICS, "Int", 3)
   NumPut(4, RECT, 0, "Float"), NumPut(2, RECT, 4, "Float")
   NumPut(W - 8, RECT, 8, "Float"), NumPut(H - 4, RECT, 12, "Float")
   DllCall("Gdiplus.dll\GdipCreateSolidFill", "UInt", "0xFF" . TxtColor, "PtrP", PBRUSH)
   DllCall("Gdiplus.dll\GdipDrawString", "Ptr", PGRAPHICS, "WStr", BtnCaption, "Int", -1, "Ptr", PFONT, "Ptr", &RECT
         , "Ptr", PFORMAT, "Ptr", PBRUSH)
   DllCall("Gdiplus.dll\GdipCreateHBITMAPFromBitmap", "Ptr", PBITMAP, "PtrP", HBITMAP, "UInt", 0X00FFFFFF)
   DllCall("Gdiplus.dll\GdipDisposeImage", "Ptr", PBITMAP)
   DllCall("Gdiplus.dll\GdipDeleteBrush", "Ptr", PBRUSH)
   DllCall("Gdiplus.dll\GdipDeleteStringFormat", "Ptr", PFORMAT)
   DllCall("Gdiplus.dll\GdipDeleteGraphics", "Ptr", PGRAPHICS)
   DllCall("Gdiplus.dll\GdipDeleteFont", "Ptr", PFONT)
   HIL := DllCall("Comctl32.dll\ImageList_Create", "UInt", W, "UInt", H, "UInt", BPP, "Int", 1, "Int", 0, "Ptr")
   DllCall("Comctl32.dll\ImageList_Add", "Ptr", HIL, "Ptr", HBITMAP, "Ptr", 0)
   VarSetCapacity(BIL, 20 + A_PtrSize, 0)
   NumPut(HIL, BIL, 0, "Ptr"), Numput(BUTTON_IMAGELIST_ALIGN_CENTER, BIL, A_PtrSize + 16, "UInt")
   GuiControl, , %HWND%
   SendMessage, BCM_SETIMAGELIST, 0, 0, , ahk_id %HWND%
   SendMessage, BCM_SETIMAGELIST, 0, &BIL, , ahk_id %HWND%
   GoSub, CreateImageButton_FreeBitmaps
   GoSub, CreateImageButton_GDIPShutdown
   Return True
   ; -------------------------------------------------------------------------------------------------------------------
   CreateImageButton_FreeBitmaps:
      DllCall("Gdi32.dll\DeleteObject", "Ptr", HBITMAP)
   Return    
   ; -------------------------------------------------------------------------------------------------------------------
   CreateImageButton_GDIPShutdown:
      DllCall("Gdiplus.dll\GdiplusShutdown", "Ptr", GDIPToken)
      DllCall("Kernel32.dll\FreeLibrary", "Ptr", GDIPDll)
   Return
}

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER


kenn
  • Members
  • 407 posts
  • Last active: Jan 14 2015 08:16 PM
  • Joined: 11 Oct 2010
You deserve a well done. I was looking for something like that, thank you very much.
My Scripts
Ain’t No Shame in Asking for Help!

Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
you're welcome..

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER


Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
THE OLD VERSION IS UPDATED ! Now It is the best ^^

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER


R3gX
  • Members
  • 307 posts
  • Last active: Dec 29 2013 04:50 PM
  • Joined: 28 Feb 2011
Hi !
OMG, I really like this script !
It saves us a lot of time plus it's easy to use.

You deserve a well done. I was looking for something like that, thank you very much.

+1 WELL DONE !

signature.png
Previously known as TomXIII
AutoHotkey version : 1.1.10


Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
Thanks. yeah you're right, other script compiler programs takes too much time .. :)

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER


R3gX
  • Members
  • 307 posts
  • Last active: Dec 29 2013 04:50 PM
  • Joined: 28 Feb 2011
Hi!
Maybe it's not the good topic but here are some Ahk icons that I created (with Inkscape).
I use them now in AutoHotkey.exe & AutoHotkeySC.bin

https://ahknet.autoh...X/Icons/AHK.ico https://ahknet.autoh...Icons/AHK_S.ico https://ahknet.autoh...Icons/AHK_P.ico https://ahknet.autoh...cons/AHK_SP.ico

signature.png
Previously known as TomXIII
AutoHotkey version : 1.1.10


Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
EDIT : Yes they are cool. you can use that icons and you can suggest your icons to the developer of autohotkey :)

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER


R3gX
  • Members
  • 307 posts
  • Last active: Dec 29 2013 04:50 PM
  • Joined: 28 Feb 2011

I don't get it dude. which is not good and whats ur problem?

:?:

signature.png
Previously known as TomXIII
AutoHotkey version : 1.1.10


Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
I said edit dude. why did not you see :)

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER