change AutoHotkey's 4 systray icons

Post your working scripts, libraries and tools
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

change AutoHotkey's 4 systray icons

23 Mar 2018, 18:52

- This is a proof of concept script to change the images for the systray icons in the AutoHotkey exe, *live*, i.e. while the script is running.
- I had thought that I might need to apply #NoTrayIcon initially, or run the function when the script began using the static var := Func() trick, however both of these appeared to be unnecessary.
GeekDude's tips and tricks - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=74&t=7190
- I exported the icons from AutoHotkey.exe to separate ico files using NirSoft IconsExtract. I obtained the hex data for the icons and the AutoHotkey exe, and searched for the icon data within the AutoHotkey exe, to make sure it was there. The data from the Suspend icon file (green S) was present in the exe (apart from the first 22 bytes of the icon file).
- To understand where structs began/end within the icon data, I used this link:
graphics: create icons from scratch - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=35758

Code: Select all

;proof of concept: change systray icon

;the script changes the icon image data
;for the Suspend icon, to all grey pixels

;#NoTrayIcon
;Menu, Tray, Icon
AhkTraySetIcon()
Suspend
MsgBox, % "check the systray for a grey icon"
return

;unfinished function
AhkTraySetIcon(vPID:="")
{
	;static vDummy := AhkTraySetIcon()
	if !vPID
	{
		vPID := DllCall("kernel32\GetCurrentProcessId", UInt)
		SplitPath, A_AhkPath, vAhkName
	}
	else
	{
		vDHW := A_DetectHiddenWindows
		DetectHiddenWindows, On
		WinGet, vAhkName, ProcessName, % "ahk_pid " vPID
		DetectHiddenWindows, % vDHW
	}
	vRet := 0
	;MAX_PATH := 260
	vMaxPath := 260
	;PROCESS_QUERY_INFORMATION := 0x400 ;PROCESS_VM_WRITE := 0x20
	;PROCESS_VM_READ := 0x10 ;PROCESS_VM_OPERATION := 0x8
	if !hProc := DllCall("kernel32\OpenProcess", UInt,0x438, Int,0, UInt,vPID, Ptr)
		return 0
	VarSetCapacity(MEMORY_BASIC_INFORMATION, A_PtrSize=8?48:28, 0)
	vAddress := 0
	Loop
	{
		if !DllCall("kernel32\VirtualQueryEx", Ptr,hProc, Ptr,vAddress, Ptr,&MEMORY_BASIC_INFORMATION, UPtr,A_PtrSize=8?48:28, UPtr)
			break
		vMbiBaseAddress := NumGet(&MEMORY_BASIC_INFORMATION, 0, "Ptr")
		vMbiRegionSize := NumGet(&MEMORY_BASIC_INFORMATION, A_PtrSize=8?24:12, "UPtr")
		vMbiState := NumGet(&MEMORY_BASIC_INFORMATION, A_PtrSize=8?32:16, "UInt")
		vMbiType := NumGet(&MEMORY_BASIC_INFORMATION, A_PtrSize=8?40:24, "UInt")

		vName := ""
		if (vMbiState & 0x1000) ;MEM_COMMIT := 0x1000
		&& (vMbiType & 0x1000000) ;MEM_IMAGE := 0x1000000
		{
			vPath := ""
			VarSetCapacity(vPath, vMaxPath*2)
			DllCall("psapi\GetMappedFileName", Ptr,hProc, Ptr,vMbiBaseAddress, Str,vPath, UInt,vMaxPath*2, UInt)
			if !(vPath = "")
				SplitPath, vPath, vName
		}
		if (vName = vAhkName)
		{
			VarSetCapacity(vData, vMbiRegionSize, 1)
			DllCall("kernel32\ReadProcessMemory", Ptr,hProc, Ptr,vMbiBaseAddress, Ptr,&vData, UPtr,vMbiRegionSize, Ptr,0)
			vHex := JEE_BinDataToHex(&vData, vMbiRegionSize)
			vNeedleGreenS := "00000000307830C32D752DFF297329FF267026FF236E23FF206B20FF1D681DFF1A651AFF166316FF136013FF105D10FF0C5A0CFF095809FF065506C300000000377E37AB4E914EFF62A362FF5C9D5CFF559855FF4F924FFF488D48FF428742FF3B823BFF357C35FF2E772EFF277127FF216C21FF1A661AFF146114FF065506C33A813AFF6FAE6FFF69A869FF62A362FF5C9D5CFF549754FF3E823EFF286C28FF206420FF1D611DFF1C621CFF266D26FF277127FF226C22FF1B671BFF0A580AFF3E843EFF77B477FF70AE70FF6AA96AFF65A465FF86AE86FFE1EAE1FFFFFFFFFFFFFFFFFFE7EEE7FF6D996DFF1D611DFF226822FF287228FF226C22FF0D5B0DFF418741FF7DB97DFF77B477FF70AE70FFD5E6D5FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF98B898FF1A5F1AFF2D752DFF297329FF115E11FF458A45FF84BF84FF7EBA7EFF8FC18FFFFFFFFFFFEEF5EEFF7BB17BFF5D9E5DFF579957FF68A268FFEEF4EEFFFFFFFFFF317031FF327832FF307830FF146114FF488C48FF8BC58BFF84BF84FF7EBA7EFF77B477FF71AF71FF65A465FF4D8E4DFF377937FF488248FFEBF1EBFFFFFFFFFF478147FF3D843DFF377E37FF176417FF4C904CFF92CB92FF8CC68CFF85C085FF7FBB7FFF74AD74FF8FB38FFFD3E1D3FFF9FBF9FFFFFFFFFFFFFFFFFFCCDDCCFF498D49FF448944FF3D843DFF1B661BFF4F924FFF99D199FF92CB92FF8CC68CFFA4D0A4FFFAFBFAFFFFFFFFFFFFFFFFFFFFFFFFFFF5F9F5FFACCDACFF5D9D5DFF529552FF4B8F4BFF458A45FF1E691EFF539553FFA0D7A0FF9AD19AFF93CC93FFE6F2E6FFFFFFFFFFACC7ACFF90BF90FF7DB67DFF6CAB6CFF599959FF2D6F2DFF2E712EFF529552FF4B8F4BFF226C22FF569856FFA7DCA7FFA0D7A0FF9AD19AFFEEF7EEFFFFFFFFFF619561FF3D7C3DFF3A7A3AFF629462FFFFFFFFFFECF2ECFF4C8D4CFF599B59FF539653FF256F25FF5A9B5AFFAEE2AEFFA8DDA8FFA1D7A1FFC0E2C0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9CC29CFF66A666FF60A060FF599B59FF297229FF5D9E5DFFB5E8B5FFAEE2AEFFA8DDA8FFA1D7A1FFB6DEB6FFEAF5EAFFFFFFFFFFFFFFFFFFE4F0E4FFA0CBA0FF74B274FF6EAC6EFF67A767FF61A161FF2C752CFF60A160FFBCEEBCFFB5E9B5FFAFE3AFFFA8DEA8FFA2D8A2FF9BD39BFF95CD95FF8EC88EFF88C288FF81BD81FF7BB77BFF74B274FF6EAC6EFF67A767FF307830FF64A464C391CA91FFBCEEBCFFB5E9B5FFAFE3AFFFA8DEA8FFA2D8A2FF9BD39BFF95CD95FF8EC88EFF88C288FF82BD82FF7BB87BFF75B275FF529552FF337B33C30000000064A464C361A161FF5E9F5EFF5A9C5AFF579957FF549654FF519451FF4D914DFF4A8E4AFF478B47FF448944FF408640FF3D833DFF3A803AC300000000"
			if vPos := InStr(vHex, vNeedleGreenS)
			{
				vOffset := (vPos - 1)//2
				vDataNew := ""
				vSizeNew := 1024
				VarSetCapacity(vDataNew, vSizeNew, 128)

				;PAGE_EXECUTE_READWRITE := 0x40
				;DllCall("kernel32\VirtualProtect", Ptr,vMbiBaseAddress+vOffset, UPtr,vSizeNew, UInt,0x40, UIntP,0)
				DllCall("kernel32\VirtualProtectEx", Ptr,hProc, Ptr,vMbiBaseAddress+vOffset, UPtr,vSizeNew, UInt,0x40, UIntP,0)
				if DllCall("kernel32\WriteProcessMemory", Ptr,hProc, Ptr,vMbiBaseAddress+vOffset, Ptr,&vDataNew, UPtr,vSizeNew, Ptr,0)
					vRet := 1
				break
			}
		}
		vAddress += vMbiRegionSize
		;if (vAddress > 2**32-1) ;4 gigabytes
		;	break
	}
	DllCall("kernel32\CloseHandle", Ptr,hProc)
	return vRet
}

;==================================================

JEE_BinDataToHex(vAddr, vSize)
{
	;CRYPT_STRING_HEX := 0x4 ;to return space/CRLF-separated text
	;CRYPT_STRING_HEXRAW := 0xC ;to return raw hex (not supported by Windows XP)
	DllCall("crypt32\CryptBinaryToString", Ptr,vAddr, UInt,vSize, UInt,0x4, Ptr,0, UIntP,vChars)
	VarSetCapacity(vHex, vChars*2, 0)
	DllCall("crypt32\CryptBinaryToString", Ptr,vAddr, UInt,vSize, UInt,0x4, Str,vHex, UIntP,vChars)
	vHex := StrReplace(vHex, "`r`n")
	vHex := StrReplace(vHex, " ")
	return vHex
}

;==================================================

JEE_FileReadHex(vPath)
{
	if !oFile := FileOpen(vPath, "r")
		return
	oFile.Pos := 0
	oFile.RawRead(vData, vSize := oFile.Length)
	oFile.Close()
	;VarSetCapacity(vHex, vSize*2)
	;Loop, % vSize
	;	vHex .= Format("{:02X}", NumGet(&vData, A_Index-1, "UChar"))
	;return vHex
	return JEE_BinDataToHex(&vData, vSize)
}

;==================================================
Last edited by jeeswg on 24 Mar 2018, 20:11, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: proof of concept: change systray icon

24 Mar 2018, 20:08

OK, I have an essentially complete script now. The icons may be familiar to you, it depends how long you've been using AutoHotkey.

Code: Select all

;change the 4 AutoHotkey systray icons

;the script changes the icon image data
;for the 4 systray icons, to the AutoHotkey Basic icons

;you can set the regular icon at any time
;you can set the suspend/pause/suspend+pause icons any time,
;however, once an icon has been displayed, it can't be changed

;note: the data for the suspend/pause/suspend+pause
;must meet certain specifications:
;16x16 pixels, 4 bytes per pixel (BBGGRRAA) is 1024 bytes,
;plus optionally setting the 64 XOR mask bytes, to make 1088 bytes,

;note: XOR mask bytes are: 16 bits (2 bytes) for each row of 16 pixels,
;then 2 bytes of padding for each row,
;16x16 pixels, 1/8 byte + 1/8 pad byte per pixel is 64 bytes

;warning: in order to change an icon that has already been changed,
;the script has search for the icon image data in the address space,
;there is a small chance that it could find a match
;but which isn't the right icon image data

;warning: by similar logic, there may be issues
;to do with changing icons, where the same icon
;is used multiple times

;==================================================

#SingleInstance force

vXorMask := JEE_StrRept("0", 128)

;green H icon (data equivalent to an ico file)
vNewGH := "0000010001002020100001000400E802000016000000280000002000000040000000010004000000000000020000000000000000000010000000100000002668160076B66C00BDFABA004D8E40009ADA960061A257008CCC8600AFEEAD00397A2900FCFEFC002F711F0080C07800A4E4A10057984B006BAC620043843500EEE5555DDDD3333FFFF88888AAA000001EEE55555DDD33333FFFF888AAAA00001EEEE5555DDDD333F3FF8F888AAAA000111EEE55555DDDD333FFFF88888AAA0011E1EEE5005D5D3D3333F00F888AAA0A111E1EEE9905DDDDD333F99008888AAAB1B11EE9999055DDD33399990F888AAABB1111199990555DDDDD99990F888888BBBB11199990555D5D3D99990FFF888ABBBBB119999055555DDD99990FFFF8886BBBB1199990EE555D5D999903FFFF8866BBBBB99990EEE555D59999033FFFF8666BBBB999900005E55D9999033FFFFF66666BB999999990000099990D333FFF4666B6B999999999999999990D3333FF64666B6999999999999999990DDD33334464666999999999999999990DD3D33F444466699990B1199999999905DDDD33444646699990BB1111EE999905DDDD3D444446499990BBBB111199990555DDD3CC4444699990BBBB111E999905555DDDC4C44449999066BBBB1199990E5555DD7CC4444999906BBBBBB199990E5555D57CCCC44999906666BB1B99990EEE55557C7CCC499990666BBBBB999901E5E555777CCCC99994466666BB999911EEEE55777CCCCC9944646666BBB99111E1E5E527777CCCC44446466666BBBB111E1EEE227777CCCC444446666B6BBBB1111EEE27227777CCCC44444666B6BBBBB11E1E22277777CCCC4444646666B6BB11111E2222277777CCC4444446666BBBBBB1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

;green S icon (image data plus XOR mask)
vNewGS := "6BAC62FF6BAC62FF61A257FF61A257FF57984BFF57984BFF4D8E40FF4D8E40FF438435FF397A29FF397A29FF397A29FF2F711FFF266816FF266816FF266816FF76B66CFF6BAC62FF6BAC62FF61A257FF61A257FF4D8E40FF438435FF438435FF438435FF438435FF438435FF397A29FF2F711FFF2F711FFF266816FF266816FF76B66CFF76B66CFF6BAC62FF61A257FF4D8E40FF6BAC62FF6BAC62FF6BAC62FF6BAC62FF397A29FF397A29FF438435FF397A29FF397A29FF2F711FFF266816FF80C078FF76B66CFF76B66CFF76B66CFFBDFABAFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFBDFABAFF8CCC86FF2F711FFF438435FF397A29FF397A29FF2F711FFF80C078FF80C078FF76B66CFF8CCC86FFFCFEFCFFFCFEFCFFAFEEADFFBDFABAFFBDFABAFFFCFEFCFFFCFEFCFF8CCC86FF397A29FF438435FF397A29FF397A29FF8CCC86FF80C078FF80C078FF76B66CFF80C078FF76B66CFF61A257FF61A257FF57984BFF8CCC86FFFCFEFCFFFCFEFCFF397A29FF438435FF438435FF397A29FF8CCC86FF8CCC86FF80C078FF80C078FF76B66CFF76B66CFF76B66CFF76B66CFF61A257FF61A257FFFCFEFCFFBDFABAFF438435FF4D8E40FF438435FF438435FF8CCC86FF8CCC86FF8CCC86FF80C078FF76B66CFF76B66CFF8CCC86FF76B66CFF80C078FFBDFABAFFFCFEFCFFFCFEFCFF4D8E40FF4D8E40FF4D8E40FF438435FF9ADA96FF9ADA96FF8CCC86FF80C078FF9ADA96FFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFF80C078FF57984BFF57984BFF4D8E40FF4D8E40FF9ADA96FF9ADA96FF9ADA96FF8CCC86FFFCFEFCFFFCFEFCFFBDFABAFFAFEEADFFAFEEADFFA4E4A1FF6BAC62FF61A257FF61A257FF57984BFF57984BFF4D8E40FFA4E4A1FF9ADA96FF9ADA96FF9ADA96FFFCFEFCFFFCFEFCFF61A257FF76B66CFF76B66CFF6BAC62FF6BAC62FF6BAC62FF61A257FF61A257FF57984BFF57984BFFA4E4A1FFA4E4A1FF9ADA96FF9ADA96FFBDFABAFFFCFEFCFFBDFABAFF61A257FF6BAC62FF61A257FF61A257FF6BAC62FF6BAC62FF61A257FF61A257FF61A257FFAFEEADFFAFEEADFFA4E4A1FFA4E4A1FF9ADA96FFBDFABAFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFF6BAC62FF6BAC62FF6BAC62FF61A257FF61A257FFAFEEADFFAFEEADFFA4E4A1FFA4E4A1FF9ADA96FF9ADA96FFAFEEADFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFF80C078FF6BAC62FF76B66CFF6BAC62FF6BAC62FFBDFABAFFBDFABAFFAFEEADFFAFEEADFFA4E4A1FFA4E4A1FF9ADA96FF9ADA96FF8CCC86FF80C078FF80C078FF80C078FF80C078FF76B66CFF76B66CFF6BAC62FFBDFABAFFBDFABAFFAFEEADFFAFEEADFFA4E4A1FFA4E4A1FF9ADA96FF9ADA96FF9ADA96FF8CCC86FF8CCC86FF80C078FF80C078FF76B66CFF76B66CFF76B66CFF" vXorMask

;red H icon (image data plus XOR mask)
vNewRH := "2120B1FF2120B1FF2120B1FF2120B1FF1C1EA4FF1C1EA4FF1C1EA4FF14128DFF0D0E82FF0D0E82FF0C0A79FF0C0A79FF04056DFF04056DFF04056DFF04056DFF2120B1FF2120B1FF2120B1FF2120B1FF1C1EA4FF1C1EA4FF1C1EA4FF1C1EA4FF14128DFF0D0E82FF0C0A79FF0C0A79FF0C0A79FF04056DFF04056DFF04056DFF2426BEFF2120B1FF2120B1FF2120B1FF04056DFF1C1EA4FF1C1EA4FF1C1EA4FF1C1EA4FF1C1EA4FF04056DFF04056DFF0C0A79FF0C0A79FF04056DFF04056DFF2426BEFF2426BEFF2426BEFFFCFEFCFFFCFEFCFF04056DFF1C1EA4FF1C1AA0FF1C1EA4FF1C1EA4FFFCFEFCFFFCFEFCFF04056DFF0C0A79FF0C0A79FF04056DFF2426BEFF2426BEFF2426BEFFFCFEFCFFFCFEFCFF04056DFF1C1EA4FF1C1EA4FF1C1EA4FF1C1EA4FFFCFEFCFFFCFEFCFF04056DFF0D0E82FF0C0A79FF0C0A79FF2C2AC7FF2C2AC7FF2C2AC7FFFCFEFCFFFCFEFCFF04056DFF1C1EA4FF1C1EA4FF1C1EA4FF1C1EA4FFFCFEFCFFFCFEFCFF04056DFF0D0E82FF0D0E82FF0C0A79FF2C2AC7FF2C2AC7FF2C2AC7FFFCFEFCFFFCFEFCFF04056DFF04056DFF04056DFF04056DFF04056DFFFCFEFCFFFCFEFCFF04056DFF1C1AA0FF14128DFF0D0E82FF3030D8FF2C2ECCFF2C2ECCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFF04056DFF1C1AA0FF1C1AA0FF0D0E82FF3030D8FF3030D8FF3030D8FFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFF04056DFF1C1AA0FF1C1AA0FF14128DFF3030D8FF3030D8FF3030D8FFFCFEFCFFFCFEFCFF04056DFF2C2ECCFF2426BEFF2C2AC7FF2C2AC7FFFCFEFCFFFCFEFCFF04056DFF2120B1FF1C1AA0FF1C1AA0FF3436E6FF3436E6FF3436E6FFFCFEFCFFFCFEFCFF04056DFF2C2ECCFF2C2AC7FF2C2AC7FF2C2AC7FFFCFEFCFFFCFEFCFF04056DFF2120B1FF2120B1FF1C1AA0FF3436E6FF3436E6FF3C3AEFFFFCFEFCFFFCFEFCFF04056DFF2C2ECCFF2C2ECCFF2C2AC7FF2C2AC7FFFCFEFCFFFCFEFCFF04056DFF2120B1FF2120B1FF2120B1FF3C3AEFFF3C3AEFFF3436E6FFFCFEFCFFFCFEFCFF04056DFF2C2ECCFF2C2ECCFF2C2AC7FF2C2AC7FFFCFEFCFFFCFEFCFF1C1EA4FF2120B1FF2120B1FF2120B1FF3C3AEFFF3C3AEFFF3436E6FF3436E6FFFCFEFCFF3436E6FF3030D8FF2C2ECCFF2C2AC7FF2C2ECCFFFCFEFCFF2C2AC7FF2426BEFF2426BEFF2120B1FF2120B1FF3D3EF8FF3C3AEFFF3C3AEFFF3436E6FF3436E6FF3436E6FF3030D8FF3030D8FF2C2ECCFF2C2AC7FF2C2ECCFF2426BEFF2426BEFF2426BEFF2426BEFF2120B1FF3D3EF8FF3D3EF8FF3C3AEFFF3C3AEFFF3C3AEFFF3436E6FF3436E6FF3030D8FF3030D8FF2C2ECCFF2C2ECCFF2C2AC7FF2426BEFF2426BEFF2426BEFF2426BEFF" vXorMask

;red S icon (image data plus XOR mask)
vNewRS := "2120B1FF2120B1FF1C1AA0FF1C1AA0FF141696FF141696FF14128DFF14128DFF0D0E82FF04056DFF04056DFF04056DFF04056DFF04056DFF04056DFF04056DFF2C2AC7FF2120B1FF2120B1FF1C1AA0FF1C1AA0FF14128DFF0D0E82FF0D0E82FF0D0E82FF0D0E82FF0D0E82FF04056DFF04056DFF04056DFF04056DFF04056DFF2C2AC7FF2C2AC7FF2120B1FF1C1AA0FF14128DFF2120B1FF2120B1FF2120B1FF2120B1FF04056DFF04056DFF0D0E82FF04056DFF04056DFF04056DFF04056DFF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FFC8D0FFFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFC8D0FFFF2C2AC7FF04056DFF0D0E82FF04056DFF04056DFF04056DFF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFF2C2AC7FF04056DFF0D0E82FF04056DFF04056DFF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FFC8D0FFFFFCFEFCFFFCFEFCFF04056DFF0D0E82FF0D0E82FF04056DFF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FFFCFEFCFFFCFEFCFF0D0E82FF14128DFF0D0E82FF0D0E82FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF3D3EF8FFFCFEFCFFFCFEFCFF14128DFF14128DFF14128DFF0D0E82FF3030D8FF3030D8FF2C2AC7FF2C2AC7FF3030D8FFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFF2C2AC7FF141696FF141696FF14128DFF14128DFF3030D8FF3030D8FF3030D8FF2C2AC7FFFCFEFCFFFCFEFCFFC8D0FFFFC8D0FFFFC8D0FFFFC8D0FFFF2120B1FF1C1AA0FF1C1AA0FF141696FF141696FF14128DFF3030D8FF3030D8FF3030D8FF3030D8FFFCFEFCFFFCFEFCFF1C1AA0FF2C2AC7FF2C2AC7FF2120B1FF2120B1FF2120B1FF1C1AA0FF1C1AA0FF141696FF141696FF3030D8FF3030D8FF3030D8FF3030D8FFC8D0FFFFFCFEFCFFC8D0FFFF1C1AA0FF1C1AA0FF1C1AA0FF1C1AA0FF2120B1FF2120B1FF1C1AA0FF1C1AA0FF1C1AA0FF3D3EF8FF3D3EF8FF3030D8FF3030D8FF3030D8FFC8D0FFFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFF1C1AA0FF2120B1FF2120B1FF1C1AA0FF1C1AA0FF3D3EF8FF3D3EF8FF3030D8FF3030D8FF3030D8FF3030D8FFC8D0FFFFFCFEFCFFFCFEFCFFFCFEFCFFFCFEFCFF2C2AC7FF2120B1FF2C2AC7FF2120B1FF2120B1FF3D3EF8FF3D3EF8FF3D3EF8FF3D3EF8FF3030D8FF3030D8FF3030D8FF3030D8FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2120B1FF3D3EF8FF3D3EF8FF3D3EF8FF3D3EF8FF3030D8FF3030D8FF3030D8FF3030D8FF3030D8FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF2C2AC7FF" vXorMask

;==================================================

InputBox, vInput,, % "icons not yet set"

AhkTraySetIcon(, vNewGH, vNewGS, vNewRH, vNewRS)

InputBox, vInput,, % "icons have been set"

;will work if the Suspend icon hasn't been used yet
vNewGS := JEE_StrRept("EFCDABFF", 256) vXorMask ;BBGGRRAA
AhkTraySetIcon(,, vNewGS)

InputBox, vInput,, % "attempt made to change Suspend icon to one colour,`n" "it will have failed if the Suspend icon has already been viewed"

InputBox, vInput,, % "script will end"
return

;==================================================

AhkTraySetIcon(vPID:="", vNewGH:="", vNewGS:="", vNewRH:="", vNewRS:="")
{
	;static vDummy := AhkTraySetIcon()
	;16x16 icon, 4 bytes per pixel (hex: BBGGRRAA)
	;16*16*4 bytes = 1024 bytes
	;G/R/H/S (green/red/H/S)
	static vNeedleGH := "00000000307830C32D752DFF297329FF267026FF236E23FF206B20FF1D681DFF1A651AFF166316FF136013FF105D10FF0C5A0CFF095809FF065506C300000000377E37AB4E914EFF62A362FF5C9D5CFF4F924FFF448744FF438843FF428742FF3B823BFF357C35FF2E772EFF226B22FF1D671DFF1A661AFF146114FF065506C33A813AFF6FAE6FFF69A869FF75AE75FF72A372FF437E43FF3A7E3AFF498D49FF428842FF3C823CFF649B64FF4D824DFF135A13FF226C22FF1B671BFF0A580AFF3E843EFF77B477FF70AE70FFB4D4B4FFFFFFFFFF95B695FF3F813FFF4F934FFF498D49FF428842FFFFFFFFFFFFFFFFFF175C17FF287228FF226C22FF0D5B0DFF418741FF7DB97DFF77B477FFB7D6B7FFFFFFFFFF97B897FF448644FF579957FF509350FF4A8E4AFFFFFFFFFFFFFFFFFF1A5F1AFF307830FF297329FF115E11FF458A45FF84BF84FF7EBA7EFFBBD9BBFFFFFFFFFF98B998FF3C7E3CFF498A49FF4B8D4BFF4E914EFFFFFFFFFFFFFFFFFF1D621DFF367D36FF307830FF146114FF488C48FF8BC58BFF84BF84FFBEDCBEFFFFFFFFFFCDDDCDFF85AC85FF639463FF337333FF2A6D2AFFFFFFFFFFFFFFFFFF216521FF3D843DFF377E37FF176417FF4C904CFF92CB92FF8CC68CFFC2DFC2FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEAF0EAFFFFFFFFFFFFFFFFFF246724FF448944FF3D843DFF1B661BFF4F924FFF99D199FF92CB92FFC5E2C5FFFFFFFFFFCEDECEFFBFD7BFFFDFECDFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF276A27FF4B8F4BFF458A45FF1E691EFF539553FFA0D7A0FF9AD19AFFC9E5C9FFFFFFFFFF9FBF9FFF5E9B5EFF79B679FF73B073FF87BA87FFFFFFFFFFFFFFFFFF2A6D2AFF529552FF4B8F4BFF226C22FF569856FFA7DCA7FFA0D7A0FFCCE8CCFFFFFFFFFFA1C0A1FF629F62FF80BB80FF79B679FF73B173FFFFFFFFFFFFFFFFFF2E6F2EFF599B59FF539653FF256F25FF5A9B5AFFAEE2AEFFA8DDA8FFD0EBD0FFFFFFFFFFA2C1A2FF67A467FF87C187FF80BC80FF7AB67AFFFFFFFFFFFFFFFFFF317231FF60A060FF599B59FF297229FF5D9E5DFFB5E8B5FFAEE2AEFFD3EED3FFFFFFFFFFB8D5B8FF80BA80FF8DC78DFF87C187FF80BC80FFFFFFFFFFFFFFFFFF5B9A5BFF67A767FF61A161FF2C752CFF60A160FFBCEEBCFFB5E9B5FFC3EAC3FFD3EED3FFB9E1B9FF9BD39BFF95CD95FF8EC88EFF88C288FF9ECC9EFFA6CEA6FF74B274FF6EAC6EFF67A767FF307830FF64A464C391CA91FFBCEEBCFFB5E9B5FFAFE3AFFFA8DEA8FFA2D8A2FF9BD39BFF95CD95FF8EC88EFF88C288FF82BD82FF7BB87BFF75B275FF529552FF337B33C30000000064A464C361A161FF5E9F5EFF5A9C5AFF579957FF549654FF519451FF4D914DFF4A8E4AFF478B47FF448944FF408640FF3D833DFF3A803AC300000000"
	static vNeedleGS := "00000000307830C32D752DFF297329FF267026FF236E23FF206B20FF1D681DFF1A651AFF166316FF136013FF105D10FF0C5A0CFF095809FF065506C300000000377E37AB4E914EFF62A362FF5C9D5CFF559855FF4F924FFF488D48FF428742FF3B823BFF357C35FF2E772EFF277127FF216C21FF1A661AFF146114FF065506C33A813AFF6FAE6FFF69A869FF62A362FF5C9D5CFF549754FF3E823EFF286C28FF206420FF1D611DFF1C621CFF266D26FF277127FF226C22FF1B671BFF0A580AFF3E843EFF77B477FF70AE70FF6AA96AFF65A465FF86AE86FFE1EAE1FFFFFFFFFFFFFFFFFFE7EEE7FF6D996DFF1D611DFF226822FF287228FF226C22FF0D5B0DFF418741FF7DB97DFF77B477FF70AE70FFD5E6D5FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF98B898FF1A5F1AFF2D752DFF297329FF115E11FF458A45FF84BF84FF7EBA7EFF8FC18FFFFFFFFFFFEEF5EEFF7BB17BFF5D9E5DFF579957FF68A268FFEEF4EEFFFFFFFFFF317031FF327832FF307830FF146114FF488C48FF8BC58BFF84BF84FF7EBA7EFF77B477FF71AF71FF65A465FF4D8E4DFF377937FF488248FFEBF1EBFFFFFFFFFF478147FF3D843DFF377E37FF176417FF4C904CFF92CB92FF8CC68CFF85C085FF7FBB7FFF74AD74FF8FB38FFFD3E1D3FFF9FBF9FFFFFFFFFFFFFFFFFFCCDDCCFF498D49FF448944FF3D843DFF1B661BFF4F924FFF99D199FF92CB92FF8CC68CFFA4D0A4FFFAFBFAFFFFFFFFFFFFFFFFFFFFFFFFFFF5F9F5FFACCDACFF5D9D5DFF529552FF4B8F4BFF458A45FF1E691EFF539553FFA0D7A0FF9AD19AFF93CC93FFE6F2E6FFFFFFFFFFACC7ACFF90BF90FF7DB67DFF6CAB6CFF599959FF2D6F2DFF2E712EFF529552FF4B8F4BFF226C22FF569856FFA7DCA7FFA0D7A0FF9AD19AFFEEF7EEFFFFFFFFFF619561FF3D7C3DFF3A7A3AFF629462FFFFFFFFFFECF2ECFF4C8D4CFF599B59FF539653FF256F25FF5A9B5AFFAEE2AEFFA8DDA8FFA1D7A1FFC0E2C0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9CC29CFF66A666FF60A060FF599B59FF297229FF5D9E5DFFB5E8B5FFAEE2AEFFA8DDA8FFA1D7A1FFB6DEB6FFEAF5EAFFFFFFFFFFFFFFFFFFE4F0E4FFA0CBA0FF74B274FF6EAC6EFF67A767FF61A161FF2C752CFF60A160FFBCEEBCFFB5E9B5FFAFE3AFFFA8DEA8FFA2D8A2FF9BD39BFF95CD95FF8EC88EFF88C288FF81BD81FF7BB77BFF74B274FF6EAC6EFF67A767FF307830FF64A464C391CA91FFBCEEBCFFB5E9B5FFAFE3AFFFA8DEA8FFA2D8A2FF9BD39BFF95CD95FF8EC88EFF88C288FF82BD82FF7BB87BFF75B275FF529552FF337B33C30000000064A464C361A161FF5E9F5EFF5A9C5AFF579957FF549654FF519451FF4D914DFF4A8E4AFF478B47FF448944FF408640FF3D833DFF3A803AC300000000"
	static vNeedleRH := "00000000070795C3040492FF000091FF00008EFF00008BFF000088FF000085FF000082FF000081FF00007EFF00007BFF00007AFF000078FF000075C30000000010109BAB2828ACFF3D3DBDFF3737B7FF2929ADFF1E1EA2FF1D1DA4FF1C1CA3FF14149FFF0E0E99FF060695FF000089FF000085FF000085FF00007FFF000075C313139EFF4D4DC8FF4747C2FF5555C5FF5757B7FF222296FF15159AFF2424A9FF1A1AA3FF14149DFF4545B1FF3C3C97FF000077FF00008AFF000086FF000078FF16169FFF5656CDFF4D4DC7FFA3A3E1FFFFFFFFFF8383C4FF1B1B9CFF2A2AAFFF2424A9FF1A1AA3FFFFFFFFFFFFFFFFFF000078FF000090FF00008AFF00007BFF1919A2FF5B5BD1FF5656CDFFA6A6E3FFFFFFFFFF8585C5FF2020A1FF3333B4FF2A2AAEFF2525AAFFFFFFFFFFFFFFFFFF00007BFF070795FF000091FF00007CFF1F1FA6FF6363D7FF5C5CD2FFAAAAE6FFFFFFFFFF8686C7FF181899FF2424A4FF2727A8FF2828ACFFFFFFFFFFFFFFFFFF00007EFF0F0F9AFF070795FF00007FFF2323A8FF6A6ADCFF6363D7FFADADE8FFFFFFFFFFC4C4E3FF6F6FBCFF4848A8FF10108DFF040488FFFFFFFFFFFFFFFFFF000081FF1616A1FF10109BFF000082FF2727ACFF7272E2FF6B6BDDFFB1B1EBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE6E6F3FFFFFFFFFFFFFFFFFF000082FF1E1EA5FF1616A1FF000083FF2929ADFF7B7BE8FF7272E2FFB5B5EEFFFFFFFFFFC6C6E5FFB2B2E1FFD7D7F2FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF010185FF2626ABFF1F1FA6FF000086FF2F2FB0FF8181EDFF7B7BE7FFB9B9F1FFFFFFFFFF8E8ECCFF3D3DB4FF5858CFFF5252C9FF6C6CCFFFFFFFFFFFFFFFFFFF040488FF2C2CB0FF2626ABFF00008AFF3232B3FF8989F1FF8181EDFFBDBDF3FFFFFFFFFF8F8FCCFF4141B8FF5F5FD3FF5858CFFF5050CAFFFFFFFFFFFFFFFFFF090989FF3535B6FF2D2DB1FF00008DFF3535B5FF9191F7FF8A8AF2FFC1C1F6FFFFFFFFFF9191CEFF4646BDFF6666D8FF5E5ED4FF5858CEFFFFFFFFFFFFFFFFFF0C0C8CFF3D3DBAFF3535B6FF010190FF3838B8FF9A9AFEFF9191F7FFC4C4F8FFFFFFFFFFA7A7E1FF5F5FD1FF6C6CDEFF6666D8FF5E5ED4FFFFFFFFFFFFFFFFFF3939B4FF4444C1FF3E3EBBFF040493FF3B3BBBFFA0A0FFFF9898FEFFADADF9FFC4C4F9FFA2A2F2FF7D7DEAFF7777E4FF6D6DDFFF6767D9FF8484DEFF8F8FDEFF5151CBFF4B4BC5FF4444C1FF070795FF4141BEC37171E1FFA0A0FFFF9898FEFF9292F8FF8A8AF4FF8484EEFF7D7DEAFF7777E4FF6D6DDFFF6767D9FF6161D5FF5A5AD1FF5454CBFF2C2CB0FF0A0A98C3000000004141BEC33E3EBBFF3939B9FF3636B7FF3333B4FF3030B1FF2B2BAFFF2828ADFF2525AAFF2222A7FF1E1EA5FF1818A1FF15159EFF12129BC300000000"
	static vNeedleRS := "00000000070795C3040492FF000091FF00008EFF00008BFF000088FF000085FF000082FF000081FF00007EFF00007BFF00007AFF000078FF000075C30000000010109BAB2828ACFF3D3DBDFF3737B7FF2F2FB3FF2929ADFF2222A9FF1C1CA3FF14149FFF0E0E99FF060695FF00008FFF000089FF000085FF00007FFF000075C313139EFF4D4DC8FF4747C2FF3D3DBDFF3737B7FF2E2EB2FF19199EFF030388FF000080FF00007DFF00007DFF00008AFF00008FFF00008AFF000086FF000078FF16169FFF5656CDFF4D4DC7FF4848C3FF4242BEFF6E6EBFFFDCDCEEFFFFFFFFFFFFFFFFFFE4E4F1FF5B5BABFF04047DFF000083FF000090FF00008AFF00007BFF1919A2FF5B5BD1FF5656CDFF4D4DC7FFCDCDECFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8A8AC5FF00007BFF040492FF000091FF00007CFF1F1FA6FF6363D7FF5C5CD2FF7474D6FFFFFFFFFFEAEAF8FF5E5EC7FF3838B8FF3333B4FF4848B9FFEAEAF6FFFFFFFFFF171789FF0A0A93FF070795FF00007FFF2323A8FF6A6ADCFF6363D7FF5C5CD2FF5656CDFF4E4EC8FF4343BEFF2828A8FF131394FF282899FFE8E8F3FFFFFFFFFF27279AFF1616A1FF10109BFF000082FF2727ACFF7272E2FF6B6BDDFF6464D8FF5D5DD3FF5454C4FF7A7AC2FFCBCBE7FFF8F8FBFFFFFFFFFFFFFFFFFFC2C2E4FF2424A9FF1E1EA5FF1616A1FF000083FF2929ADFF7B7BE8FF7272E2FF6B6BDDFF8B8BE1FFF9F9FCFFFFFFFFFFFFFFFFFFFFFFFFFFF3F3FAFF9999DBFF3A3AB7FF2C2CB0FF2626ABFF1F1FA6FF000086FF2F2FB0FF8181EDFF7B7BE7FF7373E3FFE0E0F7FFFFFFFFFF9D9DD2FF7676D2FF5F5FCDFF4A4AC5FF3636B3FF09098AFF08088CFF2C2CB0FF2626ABFF00008AFF3232B3FF8989F1FF8181EDFF7B7BE7FFE9E9FAFFFFFFFFFF4545ABFF1B1B96FF171794FF4747A9FFFFFFFFFFE9E9F4FF2727A7FF3535B6FF2D2DB1FF00008DFF3535B5FF9191F7FF8A8AF2FF8383EDFFADADF1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8787D1FF4343C0FF3D3DBAFF3535B6FF010190FF3838B8FF9A9AFEFF9191F7FF8A8AF2FF8383EDFFA0A0EFFFE4E4F9FFFFFFFFFFFFFFFFFFDCDCF5FF8787DCFF5151CBFF4B4BC5FF4444C1FF3E3EBBFF040493FF3B3BBBFFA0A0FFFF9898FEFF9292F8FF8A8AF4FF8484EEFF7D7DEAFF7777E4FF6D6DDFFF6767D9FF5F5FD5FF5959CFFF5151CBFF4B4BC5FF4444C1FF070795FF4141BEC37171E1FFA0A0FFFF9898FEFF9292F8FF8A8AF4FF8484EEFF7D7DEAFF7777E4FF6D6DDFFF6767D9FF6161D5FF5A5AD1FF5454CBFF2C2CB0FF0A0A98C3000000004141BEC33E3EBBFF3939B9FF3636B7FF3333B4FF3030B1FF2B2BAFFF2828ADFF2525AAFF2222A7FF1E1EA5FF1818A1FF15159EFF12129BC300000000"

	if !(vNewGH = "")
	{
		JEE_HexToBinData(vDataGH, vNewGH)
		vAddr := &vDataGH
		hIcon := DllCall("user32\CreateIconFromResourceEx", Ptr,vAddr+22, UInt,NumGet(vAddr, 14, "UInt"), Int,1, UInt,0x30000, Int,16, Int,16, UInt,0, Ptr)
		Menu, Tray, Icon, % "HICON:*" hIcon
	}

	if !vPID
	{
		vPID := DllCall("kernel32\GetCurrentProcessId", UInt)
		SplitPath, A_AhkPath, vAhkName
	}
	else
	{
		vDHW := A_DetectHiddenWindows
		DetectHiddenWindows, On
		WinGet, vAhkName, ProcessName, % "ahk_pid " vPID
		DetectHiddenWindows, % vDHW
	}
	vRet := 0
	;MAX_PATH := 260
	vMaxPath := 260
	;PROCESS_QUERY_INFORMATION := 0x400 ;PROCESS_VM_WRITE := 0x20
	;PROCESS_VM_READ := 0x10 ;PROCESS_VM_OPERATION := 0x8
	if !hProc := DllCall("kernel32\OpenProcess", UInt,0x438, Int,0, UInt,vPID, Ptr)
		return 0
	VarSetCapacity(MEMORY_BASIC_INFORMATION, A_PtrSize=8?48:28, 0)
	vAddress := 0
	Loop
	{
		if !DllCall("kernel32\VirtualQueryEx", Ptr,hProc, Ptr,vAddress, Ptr,&MEMORY_BASIC_INFORMATION, UPtr,A_PtrSize=8?48:28, UPtr)
			break
		vMbiBaseAddress := NumGet(&MEMORY_BASIC_INFORMATION, 0, "Ptr")
		vMbiRegionSize := NumGet(&MEMORY_BASIC_INFORMATION, A_PtrSize=8?24:12, "UPtr")
		vMbiState := NumGet(&MEMORY_BASIC_INFORMATION, A_PtrSize=8?32:16, "UInt")
		vMbiType := NumGet(&MEMORY_BASIC_INFORMATION, A_PtrSize=8?40:24, "UInt")

		vName := ""
		if (vMbiState & 0x1000) ;MEM_COMMIT := 0x1000
		&& (vMbiType & 0x1000000) ;MEM_IMAGE := 0x1000000
		{
			vPath := ""
			VarSetCapacity(vPath, vMaxPath*2)
			DllCall("psapi\GetMappedFileName", Ptr,hProc, Ptr,vMbiBaseAddress, Str,vPath, UInt,vMaxPath*2, UInt)
			if !(vPath = "")
				SplitPath, vPath, vName
		}
		if (vName = vAhkName)
		{
			VarSetCapacity(vData, vMbiRegionSize, 1)
			DllCall("kernel32\ReadProcessMemory", Ptr,hProc, Ptr,vMbiBaseAddress, Ptr,&vData, UPtr,vMbiRegionSize, Ptr,0)
			vHex := JEE_BinDataToHex(&vData, vMbiRegionSize)
			if vPos := InStr(vHex, vNeedleGH)
			{
				;note: offsets can change after the first they are retrieved
				vOffsetGS := InStr(vHex, vNeedleGS)//2, vNeedleGS := vNewGS
				vOffsetRH := InStr(vHex, vNeedleRH)//2, vNeedleRH := vNewRH
				vOffsetRS := InStr(vHex, vNeedleRS)//2, vNeedleRS := vNewRS
				vSizeGS := vSizeRS := vSizeRH := 0
				if !(vNewGS = "")
					vSizeGS := JEE_HexToBinData(vDataGS, vNewGS)
				if !(vNewRH = "")
					vSizeRH := JEE_HexToBinData(vDataRH, vNewRH)
				if !(vNewRS = "")
					vSizeRS := JEE_HexToBinData(vDataRS, vNewRS)
				if !vMax := Max(vSizeGS, vSizeRS, vSizeRH)
					break

				;PAGE_EXECUTE_READWRITE := 0x40
				;DllCall("kernel32\VirtualProtect", Ptr,vMbiBaseAddress+vOffset, UPtr,vMax, UInt,0x40, UIntP,0)
				DllCall("kernel32\VirtualProtectEx", Ptr,hProc, Ptr,vMbiBaseAddress+vOffsetGS, UPtr,vMax, UInt,0x40, UIntP,0)
				vRet1 := vRet2 := vRet3 := 1
				if vSizeGS
					vRet1 := DllCall("kernel32\WriteProcessMemory", Ptr,hProc, Ptr,vMbiBaseAddress+vOffsetGS, Ptr,&vDataGS, UPtr,vSizeGS, Ptr,0)
				if vSizeRS
					vRet2 := DllCall("kernel32\WriteProcessMemory", Ptr,hProc, Ptr,vMbiBaseAddress+vOffsetRS, Ptr,&vDataRS, UPtr,vSizeRS, Ptr,0)
				if vSizeRH
					vRet3 := DllCall("kernel32\WriteProcessMemory", Ptr,hProc, Ptr,vMbiBaseAddress+vOffsetRH, Ptr,&vDataRH, UPtr,vSizeRH, Ptr,0)
				vRet := vRet1 && vRet2 && vRet3
				break
			}
		}
		vAddress += vMbiRegionSize
		;if (vAddress > 2**32-1) ;4 gigabytes
		;	break
	}
	DllCall("kernel32\CloseHandle", Ptr,hProc)
	return vRet
}

;==================================================

JEE_BinDataToHex(vAddr, vSize)
{
	;CRYPT_STRING_HEX := 0x4 ;to return space/CRLF-separated text
	;CRYPT_STRING_HEXRAW := 0xC ;to return raw hex (not supported by Windows XP)
	DllCall("crypt32\CryptBinaryToString", Ptr,vAddr, UInt,vSize, UInt,0x4, Ptr,0, UIntP,vChars)
	VarSetCapacity(vHex, vChars*2, 0)
	DllCall("crypt32\CryptBinaryToString", Ptr,vAddr, UInt,vSize, UInt,0x4, Str,vHex, UIntP,vChars)
	vHex := StrReplace(vHex, "`r`n")
	vHex := StrReplace(vHex, " ")
	return vHex
}

;==================================================

JEE_HexToBinData(ByRef vData, vHex)
{
	vChars := StrLen(vHex)
	;CRYPT_STRING_HEX := 0x4
	;CRYPT_STRING_HEXRAW := 0xC ;(not supported by Windows XP)
	DllCall("crypt32\CryptStringToBinary", Ptr,&vHex, UInt,vChars, UInt,0x4, Ptr,0, UIntP,vSize, Ptr,0, Ptr,0)
	VarSetCapacity(vData, vSize, 0)
	DllCall("crypt32\CryptStringToBinary", Ptr,&vHex, UInt,vChars, UInt,0x4, Ptr,&vData, UIntP,vSize, Ptr,0, Ptr,0)
	return vSize
}

;==================================================

JEE_StrRept(vText, vNum)
{
	if (vNum <= 0)
		return
	return StrReplace(Format("{:" vNum "}", ""), " ", vText)
	;return StrReplace(Format("{:0" vNum "}", 0), 0, vText)
}

;==================================================
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 4664
Joined: 17 Jul 2016, 01:02
Contact:

Re: change AutoHotkey's 4 systray icons

25 Mar 2018, 07:05

Nice, thanks for sharing :thumbup:.
- I had thought that I might need to apply #NoTrayIcon initially
If you do not want to see a flash of the original icon you should. The flash might be long if used in a script which doesn't reach the auto execute section quick.

Cheers.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: change AutoHotkey's 4 systray icons

11 Apr 2018, 03:39

- Hey np, thanks for testing many of my scripts. :thumbup:
- I wanted something like this for a long time, and I had tried things like freezing the icon. And I always felt like editing the actual exe file permanently didn't feel like the right thing to do, and that it could be done within a script. (And that by doing it by script, you didn't have to edit the exe each time you installed a new release. Or keep track of edited and unedited scripts, or have 1 exe per script.)
- The principle of just editing data in the address space is fairly simple, I'd tried that as well with changing AutoHotkey's GUI class name, and InputBox parameters. I'm not sure why nobody had done it before, because a lot of people wanted something like this.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 4664
Joined: 17 Jul 2016, 01:02
Contact:

Re: change AutoHotkey's 4 systray icons

11 Apr 2018, 03:50

Thanks for making many scripts :thumbup:.
I'm not sure why nobody had done it before, because a lot of people wanted something like this.
I guess it is not trivial :)

Cheers.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: change AutoHotkey's 4 systray icons

11 Apr 2018, 03:58

- Yeah, it's a general thing. Some great things beyond what you might have hoped for, get done. And some relatively simple things, no-one does them.
- Getting the path of Notepad was a classic. A lot of people talked about it. One person even provided the main clue re. an address space location on the old AutoHotkey forum.
- Listing and looping through the address space, and grabbing the data isn't particularly difficult. A lot of the key ideas are here:
[list memory regions (+ details) for a process's address space][+ generate map of address space][enumerate memory regions]
Read information about any application directly from RAM - Utilities - AutoHotkey Community
https://autohotkey.com/board/topic/3482 ... -from-ram/
- There were lots of subtle icon-related points I had to look up, one-by-one.
- Re. things that never got done, I'm still surprised that we don't have a StrRept function. Half the time when I want to do a demo script, I want to use some repeated text for testing purposes.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Scripts and Functions”

Who is online

Users browsing this forum: JoeWinograd and 25 guests