delray Posted February 14, 2012 Share Posted February 14, 2012 I got part of this code out of the forum (did about 20 searches and could not get any results) and modified it so that the icons would be loaded as part of the program, but I am only getting 0.ico to work; why? expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GuiStatusBar.au3> #include <WinAPI.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> Opt("TrayAutoPause", 0) Global Const $VK_NUMLOCK = 0x90 Global Const $VK_SCROLL = 0x91 Global Const $VK_CAPITAL = 0x14 Global $Apps="KeyState 1.1" Global $hImage, $keystate main() Func main() ; Add icons $hImage = _GUIImageList_Create(32, 32) _GUIImageList_AddIcon($hImage, @ScriptDir & "0.ico") _GUIImageList_AddIcon($hImage, @ScriptDir & "1.ico") _GUIImageList_AddIcon($hImage, @ScriptDir & "2.ico") _GUIImageList_AddIcon($hImage, @ScriptDir & "3.ico") While 1 toggleKeys() sleep(100) WEnd EndFunc Func toggleKeys() $keystate=0 If GetCapsLock() <>0 Then $keystate= $keystate + 1 EndIf If getNumLock() <> 0 then $keystate= $keystate + 2 EndIf Select Case $keystate = 1 TraySetIcon($hImage, 0) Case $keystate = 2 TraySetIcon($hImage, 1) Case $keystate = 3 TraySetIcon($hImage, 2) Case $keystate = 4 TraySetIcon($hImage, 3) Case Else TraySetIcon("0.ico") EndSelect EndFunc ;Code from gafrost ==> http://www.autoitscript.com/forum/index.php?showtopic=12056 Func GetCapsLock() Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_CAPITAL) Return $ret[0] EndFunc Func GetNumLock() Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_NUMLOCK) Return $ret[0] EndFunc Link to comment Share on other sites More sharing options...
wakillon Posted February 14, 2012 Share Posted February 14, 2012 Try @ScriptDir & " AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
delray Posted February 14, 2012 Author Share Posted February 14, 2012 Try @ScriptDir & "\Thanks wakillon, but not work.This is the only thing that I can get to work is use the file name directly: TraySetIcon("0.ico") Link to comment Share on other sites More sharing options...
wakillon Posted February 14, 2012 Share Posted February 14, 2012 Thanks wakillon, but not work.This is the only thing that I can get to work is use the file name directly: TraySetIcon("0.ico")Add an index for each icon : _GUIImageList_AddIcon($hImage, @ScriptDir & "0.ico", 0 ) AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
delray Posted February 14, 2012 Author Share Posted February 14, 2012 Add an index for each icon : _GUIImageList_AddIcon($hImage, @ScriptDir & "0.ico", 0 ) This is what I have: $hImage = _GUIImageList_Create(32, 32) _GUIImageList_AddIcon($hImage, @ScriptDir & "0.ico", 0) _GUIImageList_AddIcon($hImage, @ScriptDir & "1.ico", 1) _GUIImageList_AddIcon($hImage, @ScriptDir & "2.ico", 2) _GUIImageList_AddIcon($hImage, @ScriptDir & "3.ico", 3) I looked at "@Error" to check to see if the icons are loading, but I haven't figured out how to use it. Link to comment Share on other sites More sharing options...
wakillon Posted February 14, 2012 Share Posted February 14, 2012 For me it works #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> Global $hGui, $listview, $hImage Global $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES) $hGui = GUICreate("ImageList AddIcon", 400, 300) $listview = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles) GUISetState() $hImage = _GUIImageList_Create(32, 32) _GUIImageList_AddIcon($hImage, @ScriptDir & "0.ico", 0 ) _GUIImageList_AddIcon($hImage, @ScriptDir & "1.ico", 0) _GUIImageList_AddIcon($hImage, @ScriptDir & "2.ico", 0) _GUIImageList_AddIcon($hImage, @ScriptDir & "3.ico", 0) _GUICtrlListView_SetImageList($listview, $hImage, 1) _GUICtrlListView_AddColumn($listview, "Column 1", 120) _GUICtrlListView_AddItem($listview, "Row 1: Col 1", 0) _GUICtrlListView_AddItem($listview, "Row 2: Col 1", 1) _GUICtrlListView_AddItem($listview, "Row 3: Col 1", 2) _GUICtrlListView_AddItem($listview, "Row 4: Col 1", 3) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
delray Posted February 14, 2012 Author Share Posted February 14, 2012 I looked at the example from the help file to work, but for some reason I can't get it into the tray. @error returns 0 for the first one (which does not display) and -1 for the rest. Link to comment Share on other sites More sharing options...
wakillon Posted February 14, 2012 Share Posted February 14, 2012 My previous post is adapted from helpfile Did you try it ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
delray Posted February 14, 2012 Author Share Posted February 14, 2012 My previous post is adapted from helpfileDid you try it ?Yes, and it works. How do I get from the "list" to the "tray"? Link to comment Share on other sites More sharing options...
wakillon Posted February 14, 2012 Share Posted February 14, 2012 Yes, and it works. How do I get from the "list" to the "tray"? Something like this ? #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> Global $hGui, $listview, $hImage, $_indexOld Global $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES) $hGui = GUICreate("ImageList AddIcon", 400, 300) $listview = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles) GUISetState() $hImage = _GUIImageList_Create(32, 32) _GUIImageList_AddIcon($hImage, @ScriptDir & "0.ico", 0 ) _GUIImageList_AddIcon($hImage, @ScriptDir & "1.ico", 0) _GUIImageList_AddIcon($hImage, @ScriptDir & "2.ico", 0) _GUIImageList_AddIcon($hImage, @ScriptDir & "3.ico", 0) _GUICtrlListView_SetImageList($listview, $hImage, 1) _GUICtrlListView_AddColumn($listview, "Column 1", 120) _GUICtrlListView_AddItem($listview, "Row 1: Col 1", 0) _GUICtrlListView_AddItem($listview, "Row 2: Col 1", 1) _GUICtrlListView_AddItem($listview, "Row 3: Col 1", 2) _GUICtrlListView_AddItem($listview, "Row 4: Col 1", 3) Do $_index = _GUICtrlListView_GetSelectedIndices($ListView) if $_index <> $_indexOld Then ConsoleWrite ( "$_index : " & $_index & @Crlf ) TraySetIcon ( @ScriptDir & "" & $_index & ".ico", 0) $_indexOld= $_index EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
delray Posted February 14, 2012 Author Share Posted February 14, 2012 wakillon, I tried it and it loaded the SciTE icon into the tray which is what I have been getting. This is what I don't understand, when I use the "external" icon, everything is fine, but when I try to load them in the program, it fails; they seem to display everywhere but in the tray - frustrating. Link to comment Share on other sites More sharing options...
wakillon Posted February 14, 2012 Share Posted February 14, 2012 wakillon, I tried it and it loaded the SciTE icon into the tray which is what I have been getting. This is what I don't understand, when I use the "external" icon, everything is fine, but when I try to load them in the program, it fails; they seem to display everywhere but in the tray - frustrating.How do you load them in the program ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
delray Posted February 14, 2012 Author Share Posted February 14, 2012 How do you load them in the program ?uh, I used your code the last time and the code I posted the first time... I am sure that something is wrong, but I am lost. Link to comment Share on other sites More sharing options...
wakillon Posted February 14, 2012 Share Posted February 14, 2012 it's a bit confuse ! when you said load them to the program, it's for integrate them to your executable or only "read" an external executable icon ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
delray Posted February 14, 2012 Author Share Posted February 14, 2012 it's a bit confuse !when you said load them to the program, it's for integrate them to your executable or only "read" an external executable icon ?Let be back up: I want to load the icons and compile them into the executable.I think I may have misunderstood the hellp file and I know that in most situations the binary file must be loaded - if this is true, is there a post somewhere that I can follow? The other issue I will run into is how to get the icon out of the binary (if this is how it works) without the header info. Like I said, I am in virgin territory. Link to comment Share on other sites More sharing options...
wakillon Posted February 14, 2012 Share Posted February 14, 2012 Let be back up: I want to load the icons and compile them into the executable.I think I may have misunderstood the hellp file and I know that in most situations the binary file must be loaded - if this is true, is there a post somewhere that I can follow? The other issue I will run into is how to get the icon out of the binary (if this is how it works) without the header info. Like I said, I am in virgin territory.Ok, so why not use fileinstall ?FileInstall ( 'C:0.ico', @ScriptDir & '0.ico' ) AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
delray Posted February 14, 2012 Author Share Posted February 14, 2012 (edited) Ok, so why not use fileinstall ?FileInstall ( 'C:0.ico', @ScriptDir & '0.ico' )Does this not copy the icon from one location to another as a file rather than insert it into the program? I am trying to prevent the icon from being altered. I noticed in AHK they use "join" with a binary to accomplish this. Edited February 14, 2012 by delray Link to comment Share on other sites More sharing options...
wakillon Posted February 14, 2012 Share Posted February 14, 2012 See help file The FileInstall function is designed to include files into a compiled AutoIt script. AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
guinness Posted February 14, 2012 Share Posted February 14, 2012 Why not have a look at this >> http://www.autoitscript.com/autoit3/scite/docs/AutoIt3Wrapper.htm and the section labelled Adding Extra Ico's to the program resources. So instead of using 0.ico you use -5 or -6 depending on the state etc... 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...
delray Posted February 14, 2012 Author Share Posted February 14, 2012 Ok guys, I quit. I have tried FileInstall and it gives me an "Invalid FileInstall() function". I tried to add a resource and it compiles but will not run. I appreciate the help; going to put this one in the trash. 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