Terenz Posted March 5, 2015 Share Posted March 5, 2015 (edited) Hi guys, It's a couple of day i'm searching and studing some way to add an icon to a tray menu, there are some script like ModernMenu that use an external window but i'd like to use the "original" provided by the Windows in use. I need this script work on a machine with Xp (for this reason i'm still using 3.3.8.1) and one with 7, so both compatible. Looking around (also for other languages) i have found a very old script, 2004=11 years ago, and to my astonishment work on XP and also on Windows 7 at 64 Bit Another Tray Sample (with popup menu with images and a "button effect") The code is C++ 6.0. From that code the only things i need is the "icon" part of the tray item, if is possible directly to load from an EXE or/and a DLL instead of a file like in that version The executable ( compiled by me ) is in attachment if someone what to check the result. I know is not the best way to start a thread but i know only and not in a prefect way autoit. The only things i have understand ( maybe ) that code use CreatePopupMenu (is _GUICtrlMenu_CreatePopup?) and SetMenuItemBitmaps (_GUICtrlMenu_SetItemBitmaps?) for the icon part, for the rest seems it use a different callback for intercept messages but i think this part can be "skipped" using WM_COMMAND or similar. I think is all, if someone has spare time (the code isn't the biggest one, on the contrary) and want to help me, i can be only gratefully Thanks anyway Test.zip Edited March 5, 2015 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
UEZ Posted March 5, 2015 Share Posted March 5, 2015 Check out _GDIPlus_HICONCreateFromBitmap in the help file. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
orbs Posted March 5, 2015 Share Posted March 5, 2015 note: this is a somewhat old UDF, lately renewed - latest code is in post #289 which i linked above. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Terenz Posted March 5, 2015 Author Share Posted March 5, 2015 Orbs, I have explained why i prefer don't use that script UEZ, Before that (use a EXE/DLL instead of a real bitmap) need all the rest but thanks for the suggestion Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
UEZ Posted March 5, 2015 Share Posted March 5, 2015 (edited) The example shows a self generated bitmap but of course you can use ready created icons / images from any resources! Br, UEZ Edited March 5, 2015 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Terenz Posted March 5, 2015 Author Share Posted March 5, 2015 (edited) UEZ i have understood ( that example also use _WinAPI_Create32BitHBITMAP Vista+ for load the icon in the popup item, and i need something compatible with XP ) but the main problem is convert that C++ script to autoit, the trayitem with icon, and then check how to convert any resorces to bitmap but without the first part i can't see the second Thanks Edited March 5, 2015 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
UEZ Posted March 5, 2015 Share Posted March 5, 2015 (edited) I didn't check out the C++ code but I used the resources within the zip archive. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <TrayConstants.au3> #include <WindowsConstants.au3> #include <WinAPISys.au3> #include <WinAPIShellEx.au3> #include "ResourcesEx.au3" #AutoIt3Wrapper_Res_File_Add=TRAY.ICO, RT_ICON, ICO_1, 0 #AutoIt3Wrapper_Res_File_Add=APP.ICO, RT_ICON, ICO_2, 0 #AutoIt3Wrapper_Res_File_Add=menu_close.bmp, RT_BITMAP, BMP_1, 0 #AutoIt3Wrapper_Res_File_Add=menu_about.bmp, RT_BITMAP, BMP_2, 0 #AutoIt3Wrapper_Res_File_Add=MENU_CK.BMP, RT_BITMAP, BMP_3, 0 AutoItSetOption("TrayMenuMode", 11) AutoItSetOption("TrayIconHide", 1) Global Const $hIcon_GUI = _Resource_GetAsIcon('ICO_2') Global Const $hGUI = GUICreate("Popup Menu Demo", 320, 160) GUISetState() _WinAPI_SetClassLongEx($hGUI, $GCL_HICONSM, $hIcon_GUI) Global Enum $idAlwayaOnTop = 1500, $idMinToTray, $idCloseGUI, $idAbout Global Const $hPopupMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hPopupMenu, 0, "Always on top", $idAlwayaOnTop) _GUICtrlMenu_InsertMenuItem($hPopupMenu, 1, "Minimize to tray", $idMinToTray) _GUICtrlMenu_InsertMenuItem($hPopupMenu, 2, "", 0) _GUICtrlMenu_InsertMenuItem($hPopupMenu, 3, "Close", $idCloseGUI) _GUICtrlMenu_InsertMenuItem($hPopupMenu, 4, "", 0) _GUICtrlMenu_InsertMenuItem($hPopupMenu, 5, "About", $idAbout) Global Const $hHBITMAP_Close = _Resource_GetAsBitmap('BMP_1', $RT_BITMAP) Global Const $hHBITMAP_About = _Resource_GetAsBitmap('BMP_2', $RT_BITMAP) Global Const $hHBITMAP_Check = _Resource_GetAsBitmap('BMP_3', $RT_BITMAP) _GUICtrlMenu_SetItemBmp($hPopupMenu, 3, $hHBITMAP_Close) _GUICtrlMenu_SetItemBmp($hPopupMenu, 5, $hHBITMAP_About) Global Const $hIcon_Tray = _Resource_GetAsIcon('ICO_1') Global Const $iTrayAlwayaOnTop = TrayCreateItem("Always on top") Global Const $iTrayRestore = TrayCreateItem("Restore") TrayCreateItem("") Global Const $iTrayClose = TrayCreateItem("Close") TrayCreateItem("") Global Const $iTrayAbout = TrayCreateItem("About") DllCall("user32.dll", "int", "SetMenuItemBitmaps", "hwnd", TrayItemGetHandle(0), "int", 3, "int", 0x00000400, "handle", $hHBITMAP_Close, "handle", $hHBITMAP_Close) DllCall("user32.dll", "int", "SetMenuItemBitmaps", "hwnd", TrayItemGetHandle(0), "int", 5, "int", 0x00000400, "handle", $hHBITMAP_About, "handle", $hHBITMAP_About) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") Global $iDummy_Exit = GUICtrlCreateDummy(), $iTopmost = -1 Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $iDummy_Exit _Exit() EndSwitch Switch TrayGetMsg() Case $iTrayClose _Exit() Case $iTrayAbout MsgBox(0, "Test", "Demo code") Case $iTrayRestore TraySetState($TRAY_ICONSTATE_HIDE) GUISetState(@SW_SHOW, $hGUI) Case $iTrayAlwayaOnTop SwitchAlwayaOnTop() EndSwitch Until False Func SwitchAlwayaOnTop() Switch $iTopmost Case -1 _GUICtrlMenu_SetItemBmp($hPopupMenu, 0, $hHBITMAP_Check) DllCall("user32.dll", "int", "SetMenuItemBitmaps", "hwnd", TrayItemGetHandle(0), "int", 0, "int", 0x00000400, "handle", $hHBITMAP_Check, "handle", $hHBITMAP_Check) WinSetOnTop($hGUI, "", 1) Case 1 _GUICtrlMenu_SetItemBmp($hPopupMenu, 0, 0) DllCall("user32.dll", "int", "SetMenuItemBitmaps", "hwnd", TrayItemGetHandle(0), "int", 0, "int", 0x00000400, "handle", 0, "handle", 0) WinSetOnTop($hGUI, "", 0) EndSwitch $iTopmost *= -1 EndFunc ;==>SwitchAlwayaOnTop Func _Exit() GUIRegisterMsg($WM_COMMAND, "") GUIRegisterMsg($WM_CONTEXTMENU, "") _WinAPI_DestroyIcon($hIcon_Tray) _WinAPI_DestroyIcon($hIcon_GUI) _GUICtrlMenu_DestroyMenu($hPopupMenu) _WinAPI_DeleteObject($hHBITMAP_About) _WinAPI_DeleteObject($hHBITMAP_Check) _WinAPI_DeleteObject($hHBITMAP_Close) GUIDelete() Exit EndFunc ;==>_Exit Func _WinAPI_TraySetHIcon($hIcon) ;function by Mat Local Const $tagNOTIFYICONDATA = _ "dword Size;" & _ "hwnd hWnd;" & _ "uint ID;" & _ "uint Flags;" & _ "uint CallbackMessage;" & _ "ptr Icon;" & _ "wchar Tip[128];" & _ "dword State;" & _ "dword StateMask;" & _ "wchar Info[256];" & _ "uint Timeout;" & _ "wchar InfoTitle[64];" & _ "dword InfoFlags;" & _ "dword Data1;word Data2;word Data3;byte Data4[8];" & _ "ptr BalloonIcon" Local $tNOTIFY = DllStructCreate($tagNOTIFYICONDATA) DllStructSetData($tNOTIFY, "Size", DllStructGetSize($tNOTIFY)) DllStructSetData($tNOTIFY, "hWnd", WinGetHandle(AutoItWinGetTitle())) DllStructSetData($tNOTIFY, "ID", 1) DllStructSetData($tNOTIFY, "Icon", $hIcon) DllStructSetData($tNOTIFY, "Flags", BitOR($NIF_ICON, $NIF_MESSAGE)) DllStructSetData($tNOTIFY, "CallbackMessage", $WM_USER + 1) Local $aRet = DllCall("shell32.dll", "int", "Shell_NotifyIconW", "dword", $NIM_MODIFY, "struct*", $tNOTIFY) If (@error) Then Return SetError(1, 0, 0) Return $aRet[0] <> 0 EndFunc ;==>_WinAPI_TraySetHIcon Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch $wParam Case $idAbout MsgBox(0, "Test", "Demo code") Case $idAlwayaOnTop SwitchAlwayaOnTop() Case $idCloseGUI GUICtrlSendToDummy($iDummy_Exit) Case $idMinToTray GUISetState(@SW_HIDE, $hGUI) TraySetState($TRAY_ICONSTATE_SHOW) _WinAPI_TraySetHIcon($hIcon_Tray) EndSwitch Return "GUI_RUNDEFMSG" EndFunc ;==>WM_COMMAND Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam _GUICtrlMenu_TrackPopupMenu($hPopupMenu, $wParam) Return True EndFunc ;==>WM_CONTEXTMENU You need the resources (ICO and BMP files) and >ResourcesEx.au3 in the same dir as the script. Compile and run it to test it properly. Worked with WinXP properly in my vm. What you can also do is to embed the additional resources directly into your script and use it from memory. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <GDIPlus.au3> #include <TrayConstants.au3> #include <WindowsConstants.au3> #include <WinAPISys.au3> #include <WinAPIShellEx.au3> AutoItSetOption("TrayMenuMode", 11) AutoItSetOption("TrayIconHide", 1) _GDIPlus_Startup() Global Const $hBmp_App = _GDIPlus_BitmapCreateFromMemory(_APPICO()) Global Const $hIcon_GUI = _GDIPlus_HICONCreateFromBitmap($hBmp_App) _GDIPlus_BitmapDispose($hBmp_App) Global Const $hGUI = GUICreate("Popup Menu Demo", 320, 160) GUISetState() _WinAPI_SetClassLongEx($hGUI, $GCL_HICONSM, $hIcon_GUI) Global Enum $idAlwayaOnTop = 1500, $idMinToTray, $idCloseGUI, $idAbout Global Const $hPopupMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hPopupMenu, 0, "Always on top", $idAlwayaOnTop) _GUICtrlMenu_InsertMenuItem($hPopupMenu, 1, "Minimize to tray", $idMinToTray) _GUICtrlMenu_InsertMenuItem($hPopupMenu, 2, "", 0) _GUICtrlMenu_InsertMenuItem($hPopupMenu, 3, "Close", $idCloseGUI) _GUICtrlMenu_InsertMenuItem($hPopupMenu, 4, "", 0) _GUICtrlMenu_InsertMenuItem($hPopupMenu, 5, "About", $idAbout) Global Const $hHBITMAP_Close = _GDIPlus_BitmapCreateFromMemory(_menu_closebmp(), True) Global Const $hHBITMAP_About = _GDIPlus_BitmapCreateFromMemory(_menu_aboutbmp(), True) Global Const $hHBITMAP_Check = _GDIPlus_BitmapCreateFromMemory(_MENU_CKBMP(), True) _GUICtrlMenu_SetItemBmp($hPopupMenu, 3, $hHBITMAP_Close) _GUICtrlMenu_SetItemBmp($hPopupMenu, 5, $hHBITMAP_About) Global Const $hBmp_Tray = _GDIPlus_BitmapCreateFromMemory(_TRAYICO()) Global Const $hIcon_Tray = _GDIPlus_HICONCreateFromBitmap($hBmp_Tray) _GDIPlus_BitmapDispose($hBmp_Tray) Global Const $iTrayAlwayaOnTop = TrayCreateItem("Always on top") Global Const $iTrayRestore = TrayCreateItem("Restore") TrayCreateItem("") Global Const $iTrayClose = TrayCreateItem("Close") TrayCreateItem("") Global Const $iTrayAbout = TrayCreateItem("About") DllCall("user32.dll", "int", "SetMenuItemBitmaps", "hwnd", TrayItemGetHandle(0), "int", 3, "int", 0x00000400, "handle", $hHBITMAP_Close, "handle", $hHBITMAP_Close) DllCall("user32.dll", "int", "SetMenuItemBitmaps", "hwnd", TrayItemGetHandle(0), "int", 5, "int", 0x00000400, "handle", $hHBITMAP_About, "handle", $hHBITMAP_About) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") Global $iDummy_Exit = GUICtrlCreateDummy(), $iTopmost = -1 Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $iDummy_Exit _Exit() EndSwitch Switch TrayGetMsg() Case $iTrayClose _Exit() Case $iTrayAbout MsgBox(0, "Test", "Demo code") Case $iTrayRestore TraySetState($TRAY_ICONSTATE_HIDE) GUISetState(@SW_SHOW, $hGUI) Case $iTrayAlwayaOnTop SwitchAlwayaOnTop() EndSwitch Until False Func SwitchAlwayaOnTop() Switch $iTopmost Case -1 _GUICtrlMenu_SetItemBmp($hPopupMenu, 0, $hHBITMAP_Check) DllCall("user32.dll", "int", "SetMenuItemBitmaps", "hwnd", TrayItemGetHandle(0), "int", 0, "int", 0x00000400, "handle", $hHBITMAP_Check, "handle", $hHBITMAP_Check) WinSetOnTop($hGUI, "", 1) Case 1 _GUICtrlMenu_SetItemBmp($hPopupMenu, 0, 0) DllCall("user32.dll", "int", "SetMenuItemBitmaps", "hwnd", TrayItemGetHandle(0), "int", 0, "int", 0x00000400, "handle", 0, "handle", 0) WinSetOnTop($hGUI, "", 0) EndSwitch $iTopmost *= -1 EndFunc ;==>SwitchAlwayaOnTop Func _Exit() GUIRegisterMsg($WM_COMMAND, "") GUIRegisterMsg($WM_CONTEXTMENU, "") _WinAPI_DestroyIcon($hIcon_Tray) _WinAPI_DestroyIcon($hIcon_GUI) _GUICtrlMenu_DestroyMenu($hPopupMenu) _WinAPI_DeleteObject($hHBITMAP_About) _WinAPI_DeleteObject($hHBITMAP_Check) _WinAPI_DeleteObject($hHBITMAP_Close) _GDIPlus_Shutdown() GUIDelete() Exit EndFunc ;==>_Exit Func _WinAPI_TraySetHIcon($hIcon) ;function by Mat Local Const $tagNOTIFYICONDATA = _ "dword Size;" & _ "hwnd hWnd;" & _ "uint ID;" & _ "uint Flags;" & _ "uint CallbackMessage;" & _ "ptr Icon;" & _ "wchar Tip[128];" & _ "dword State;" & _ "dword StateMask;" & _ "wchar Info[256];" & _ "uint Timeout;" & _ "wchar InfoTitle[64];" & _ "dword InfoFlags;" & _ "dword Data1;word Data2;word Data3;byte Data4[8];" & _ "ptr BalloonIcon" Local $tNOTIFY = DllStructCreate($tagNOTIFYICONDATA) DllStructSetData($tNOTIFY, "Size", DllStructGetSize($tNOTIFY)) DllStructSetData($tNOTIFY, "hWnd", WinGetHandle(AutoItWinGetTitle())) DllStructSetData($tNOTIFY, "ID", 1) DllStructSetData($tNOTIFY, "Icon", $hIcon) DllStructSetData($tNOTIFY, "Flags", BitOR($NIF_ICON, $NIF_MESSAGE)) DllStructSetData($tNOTIFY, "CallbackMessage", $WM_USER + 1) Local $aRet = DllCall("shell32.dll", "int", "Shell_NotifyIconW", "dword", $NIM_MODIFY, "struct*", $tNOTIFY) If (@error) Then Return SetError(1, 0, 0) Return $aRet[0] <> 0 EndFunc ;==>_WinAPI_TraySetHIcon Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch $wParam Case $idAbout MsgBox(0, "Test", "Demo code") Case $idAlwayaOnTop SwitchAlwayaOnTop() Case $idCloseGUI GUICtrlSendToDummy($iDummy_Exit) Case $idMinToTray GUISetState(@SW_HIDE, $hGUI) TraySetState($TRAY_ICONSTATE_SHOW) _WinAPI_TraySetHIcon($hIcon_Tray) EndSwitch Return "GUI_RUNDEFMSG" EndFunc ;==>WM_COMMAND Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam _GUICtrlMenu_TrackPopupMenu($hPopupMenu, $wParam) Return True EndFunc ;==>WM_CONTEXTMENU ;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2015-03-02 Func _TRAYICO($bSaveBinary = False, $sSavePath = @ScriptDir) Local $TRAYICO $TRAYICO &= 'bLBIAAABABAQEAFwCAAAaAUAABYAAMwAKAAYAJAAIAAYAVzxGQAzmf8aPv8BPwA/AD8/AD8APwA/AD8ABQD///j/AAENAEsE5AHmAv8Bf/8B/wH6AWoV/wHtGdAdfyD+AAB8fn8AQAYHZwBhBgEA' $TRAYICO = _WinAPI_Base64Decode($TRAYICO) If @error Then Return SetError(1, 0, 0) Local $tSource = DllStructCreate('byte[' & BinaryLen($TRAYICO) & ']') DllStructSetData($tSource, 1, $TRAYICO) Local $tDecompress _WinAPI_LZNTDecompress($tSource, $tDecompress, 1406) If @error Then Return SetError(3, 0, 0) $tSource = 0 Local Const $bString = Binary(DllStructGetData($tDecompress, 1)) If $bSaveBinary Then Local Const $hFile = FileOpen($sSavePath & "\TRAY.ICO", 18) If @error Then Return SetError(2, 0, $bString) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_TRAYICO Func _APPICO($bSaveBinary = False, $sSavePath = @ScriptDir) Local $APPICO $APPICO &= 'Y7BIAAABABAQEAFwCAAAaAUAABYAAMwAKAAYAJAAIAAYAVzxGQAzmf8aPv8BPwA/AD8/AD8APwA/AD8ABQD//+P/fgQAAQEB/wH/Af8BP/8BYQEFAP8BfyBjAP4/GX8A4ANnAOUG' $APPICO = _WinAPI_Base64Decode($APPICO) If @error Then Return SetError(1, 0, 0) Local $tSource = DllStructCreate('byte[' & BinaryLen($APPICO) & ']') DllStructSetData($tSource, 1, $APPICO) Local $tDecompress _WinAPI_LZNTDecompress($tSource, $tDecompress, 1406) If @error Then Return SetError(3, 0, 0) $tSource = 0 Local Const $bString = Binary(DllStructGetData($tDecompress, 1)) If $bSaveBinary Then Local Const $hFile = FileOpen($sSavePath & "\APP.ICO", 18) If @error Then Return SetError(2, 0, $bString) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_APPICO Func _menu_closebmp($bSaveBinary = False, $sSavePath = @ScriptDir) Local $menu_closebmp $menu_closebmp &= 'SbMgQk0GBQACADYEKAAAKABwDQQYAQBaCAK40AN4EACAAggAHICAAwwBAgAQwMDAAADA3MAA8Mqm0AAAIEAABmAABgAwFCCgAAbAAAbgAACxACwAQCAABgAQQAAfqkAAH0AAH0AAH0AAH6kAEgBgAB9gAB9gAAyqYAAfYAAfYAAfYAAfawJwAB+AAB+AAB8BeIA1AB+AAB+AAB8ACgCgVQAfoAAfoAAfoAAfoDUAFKAAH6AAHwAGAMDVAB/AAB/AgA/AAVyAD5mAXQDAgA8AAQDggA+q4IAP4IAP4IAP4IAPkuCAD+DgA18AIIABVYEAYIABgIABoIABwLeAAYAPAW0ggA+Af0CAf6pAgH9AgH9AgH9AgH+rAnsAEkAABECAf0CAf+pAgH9AgH9AgH8CiYB/qkCAf0CAf0CAf0CAf7pAgH9AgH8Cl4B/QIB/qkCAf0CAf0CAf0CAf65AgH8CpYB/QIB/QIB/qkCAf0CAf0CAf0CAf6sCs4B/QIB/QMA/QMA/akDAP0DAP0DAP4FgQFXAP0DAP0DAP0DAP0C1wD9AwD9AwD/DeyBCPa6AwD/CfsA/gMA/gMA/q4JmwD+AwD+AwD+AwD/qgMA/gMA/gMA/gm3AP6qAwD+AADuAADSAAC26gAAmgAAfgnTAP4DAP6qAwD+AwD+AwD+AwD+ugMA/gnsAGYAAEoAAC9aAwaDAP4DAP4DAP4KCVcA/gMA/gMA/gMA/gHXAP4DAP4DAP4KJwD+AVcA/gMA/gMA/gMA/gK3AP4DAP4GQgMA/gMA/qoDAP4DAP4DAP4DAP96AwD+Cj8A/QXvAwD9BPX7AwD9AvkAAwAeBlsA/wFXAP8DAP8DAP8DAP8BdwD/AwD+CncA/wMA/wFXAP8DAP8DAP8DAP8BXwD+CpMA/wMA/wMA/wNXAP8DAP8DAP8DAP4KrVcA/wMA/wMA/wMA/wHUAPcAANsAAL4KywD/AVcA/wMA/wMA/wMA/wF3AP8DAP4K5ACnAACLAFYANwAAKwIAG8Pv/TACk4SQBLAD/QgAA/P//wwAhAEEC4QEJAGED/Pn5YwHhAOMBAgLCAOQB/yABowBCCkEBwwHjAQQC5Qn/BALmC+4D7AftC+8P6xPsFw==' $menu_closebmp = _WinAPI_Base64Decode($menu_closebmp) If @error Then Return SetError(1, 0, 0) Local $tSource = DllStructCreate('byte[' & BinaryLen($menu_closebmp) & ']') DllStructSetData($tSource, 1, $menu_closebmp) Local $tDecompress _WinAPI_LZNTDecompress($tSource, $tDecompress, 1286) If @error Then Return SetError(3, 0, 0) $tSource = 0 Local Const $bString = Binary(DllStructGetData($tDecompress, 1)) If $bSaveBinary Then Local Const $hFile = FileOpen($sSavePath & "\menu_close.bmp", 18) If @error Then Return SetError(2, 0, $bString) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_menu_closebmp Func _menu_aboutbmp($bSaveBinary = False, $sSavePath = @ScriptDir) Local $menu_aboutbmp $menu_aboutbmp &= 'PbMgQk0GBQACADYEKAAAKABwDQQYAQBaCAK40AN4EACAAggAHICAAwwBAgAQwMDAAADA3MAA8Mqm0AAAIEAABmAABgAwFCCgAAbAAAbgAACxACwAQCAABgAQQAAfqkAAH0AAH0AAH0AAH6kAEgBgAB9gAB9gAAyqYAAfYAAfYAAfYAAfawJwAB+AAB+AAB8BeIA1AB+AAB+AAB8ACgCgVQAfoAAfoAAfoAAfoDUAFKAAH6AAHwAGAMDVAB/AAB/AgA/AAVyAD5mAXQDAgA8AAQDggA+q4IAP4IAP4IAP4IAPkuCAD+DgA18AIIABVYEAYIABgIABoIABwLeAAYAPAW0ggA+Af0CAf6pAgH9AgH9AgH9AgH+rAnsAEkAABECAf0CAf+pAgH9AgH9AgH8CiYB/qkCAf0CAf0CAf0CAf7pAgH9AgH8Cl4B/QIB/qkCAf0CAf0CAf0CAf65AgH8CpYB/QIB/QIB/qkCAf0CAf0CAf0CAf6sCs4B/QIB/QMA/QMA/akDAP0DAP0DAP4FgQFXAP0DAP0DAP0DAP0C1wD9AwD9AwD/DeyBCPa6AwD/CfsA/gMA/gMA/q4JmwD+AwD+AwD+AwD/qgMA/gMA/gMA/gm3AP6qAwD+AADuAADSAAC26gAAmgAAfgnTAP4DAP6qAwD+AwD+AwD+AwD+ugMA/gnsAGYAAEoAAC9aAwaDAP4DAP4DAP4KCVcA/gMA/gMA/gMA/gHXAP4DAP4DAP4KJwD+AVcA/gMA/gMA/gMA/gK3AP4DAP4GQgMA/gMA/qoDAP4DAP4DAP4DAP96AwD+Cj8A/QXvAwD9BPX7AwD9AvkAAwAeBlsA/wFXAP8DAP8DAP8DAP8BdwD/AwD+CncA/wMA/wFXAP8DAP8DAP8DAP8BXwD+CpMA/wMA/wMA/wNXAP8DAP8DAP8DAP4KrVcA/wMA/wMA/wMA/wHUAPcAANsAAL4KywD/AVcA/wMA/wMA/wMA/wF3AP8DAP4K5ACnAACLAFYANwAAKwIAG8Pv/TACk4SQBLAD/QgAA/P//wwAhAEEC4QEJAEIE5AnIAQAACeUBAgLCAW//Af8B8AtAAgnCA+cFAA/5Be0LwQfmBw==' $menu_aboutbmp = _WinAPI_Base64Decode($menu_aboutbmp) If @error Then Return SetError(1, 0, 0) Local $tSource = DllStructCreate('byte[' & BinaryLen($menu_aboutbmp) & ']') DllStructSetData($tSource, 1, $menu_aboutbmp) Local $tDecompress _WinAPI_LZNTDecompress($tSource, $tDecompress, 1286) If @error Then Return SetError(3, 0, 0) $tSource = 0 Local Const $bString = Binary(DllStructGetData($tDecompress, 1)) If $bSaveBinary Then Local Const $hFile = FileOpen($sSavePath & "\menu_about.bmp", 18) If @error Then Return SetError(2, 0, $bString) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_menu_aboutbmp Func _MENU_CKBMP($bSaveBinary = False, $sSavePath = @ScriptDir) Local $MENU_CKBMP $MENU_CKBMP &= 'TbMgQk0GBQACADYEKAAAKABwDQQYAQBaCAK40AN4EACAAggAHICAAwwBAgAQwMDAAADA3MAA8Mqm0AAAIEAABmAABgAwFCCgAAbAAAbgAACxACwAQCAABgAQQAAfqkAAH0AAH0AAH0AAH6kAEgBgAB9gAB9gAAyqYAAfYAAfYAAfYAAfawJwAB+AAB+AAB8BeIA1AB+AAB+AAB8ACgCgVQAfoAAfoAAfoAAfoDUAFKAAH6AAHwAGAMDVAB/AAB/AgA/AAVyAD5mAXQDAgA8AAQDggA+q4IAP4IAP4IAP4IAPkuCAD+DgA18AIIABVYEAYIABgIABoIABwLeAAYAPAW0ggA+Af0CAf6pAgH9AgH9AgH9AgH+rAnsAEkAABECAf0CAf+pAgH9AgH9AgH8CiYB/qkCAf0CAf0CAf0CAf7pAgH9AgH8Cl4B/QIB/qkCAf0CAf0CAf0CAf65AgH8CpYB/QIB/QIB/qkCAf0CAf0CAf0CAf6sCs4B/QIB/QMA/QMA/akDAP0DAP0DAP4FgQFXAP0DAP0DAP0DAP0C1wD9AwD9AwD/DeyBCPa6AwD/CfsA/gMA/gMA/q4JmwD+AwD+AwD+AwD/qgMA/gMA/gMA/gm3AP6qAwD+AADuAADSAAC26gAAmgAAfgnTAP4DAP6qAwD+AwD+AwD+AwD+ugMA/gnsAGYAAEoAAC9aAwaDAP4DAP4DAP4KCVcA/gMA/gMA/gMA/gHXAP4DAP4DAP4KJwD+AVcA/gMA/gMA/gMA/gK3AP4DAP4GQgMA/gMA/qoDAP4DAP4DAP4DAP96AwD+Cj8A/QXvAwD9BPX7AwD9AvkAAwAeBlsA/wFXAP8DAP8DAP8DAP8BdwD/AwD+CncA/wMA/wFXAP8DAP8DAP8DAP8BXwD+CpMA/wMA/wMA/wNXAP8DAP8DAP8DAP4KrVcA/wMA/wMA/wMA/wHUAPcAANsAAL4KywD/AVcA/wMA/wMA/wMA/wF3AP8DAP4K5ACnAACLAFYANwAAKwIAG8Pv/TACk4SQBLAD/QgAA/P//wwAhAEEC4QEJAEIEZfABCesBCdgEAuMBCfjg4OADAuIBwQEEAuUB/yUE4wGgBwEC5wdjCMAA6A8PYgzpEeYH+xU=' $MENU_CKBMP = _WinAPI_Base64Decode($MENU_CKBMP) If @error Then Return SetError(1, 0, 0) Local $tSource = DllStructCreate('byte[' & BinaryLen($MENU_CKBMP) & ']') DllStructSetData($tSource, 1, $MENU_CKBMP) Local $tDecompress _WinAPI_LZNTDecompress($tSource, $tDecompress, 1286) If @error Then Return SetError(3, 0, 0) $tSource = 0 Local Const $bString = Binary(DllStructGetData($tDecompress, 1)) If $bSaveBinary Then Local Const $hFile = FileOpen($sSavePath & "\MENU_CK.BMP", 18) If @error Then Return SetError(2, 0, $bString) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_MENU_CKBMP Func _WinAPI_Base64Decode($sB64String) Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "") Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]") $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "") Return DllStructGetData($bBuffer, 1) EndFunc ;==>_WinAPI_Base64Decode Func _WinAPI_LZNTDecompress(ByRef $tInput, ByRef $tOutput, $iBufferSize) $tOutput = DllStructCreate("byte[" & $iBufferSize & "]") If @error Then Return SetError(1, 0, 0) Local $aRet = DllCall("ntdll.dll", "uint", "RtlDecompressBuffer", "ushort", 0x0002, "struct*", $tOutput, "ulong", $iBufferSize, "struct*", $tInput, "ulong", DllStructGetSize($tInput), "ulong*", 0) If @error Then Return SetError(2, 0, 0) If $aRet[0] Then Return SetError(3, $aRet[0], 0) Return $aRet[6] EndFunc ;==>_WinAPI_LZNTDecompress Edited March 6, 2015 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Terenz Posted March 8, 2015 Author Share Posted March 8, 2015 Sorry UEZ for this late answer, actually i have many problem with my internet provider. I can't test your code for now ( i'll study a bit after all my problem with internet are solved ) but i can't embed the file inside the exe because the menu is dinamically created by the user, so i need to "extract" the icon by a phisical exe files Hope we see soon on the forum Nothing is so strong as gentleness. Nothing is so gentle as real strength 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