Jump to content

_GUIImageList_AddIcon, TraySetIcon


delray
 Share

Recommended Posts

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.

Syntax : FileInstall ( 'C:0.ico', @ScriptDir & '0.ico' )

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

adding on to the SciTE wrapper directives guinness pointed you to.

;add path if icons not in script path
#AutoIt3Wrapper_res_icon_add=0.ico
#AutoIt3Wrapper_res_icon_add=1.ico
#AutoIt3Wrapper_res_icon_add=2.ico
#AutoIt3Wrapper_res_icon_add=3.ico

If Not @Compiled Then MsgBox(262144, "TraySetIcon", "Must be compiled first")

For $x = 0 To 8
    TraySetIcon(@ScriptFullPath, -$x)
    If $x < 5 Then ;AutoIt compiled EXE icons
      TrayTip("Default Icon", "Index: " & -$x, 3)
    Else ;your resource icons 0 to 3
      TrayTip("New Icon", "Index: " & - $x, 3)
    EndIf
    Sleep(2000)
Next
Edited by rover

I see fascists...

Link to comment
Share on other sites

rover thanks, I had to back off for awhile, but I used your code and it worked. I have worked with AutoIt long enough to know there was a simple answer:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Icon_Add=0.ico
#AutoIt3Wrapper_Res_Icon_Add=1.ico
#AutoIt3Wrapper_Res_Icon_Add=2.ico
#AutoIt3Wrapper_Res_Icon_Add=3.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
A system tray util to indicate the state of the Caps Lock & Num Lock Keys
Amended to only indicate the state of the Caps & Numlock keys along with
updated and clearer icons
Includes the clode code suggested
the result is that it now looks a lot better and you can close it without having to kill it
#ce ----------------------------------------------------------------------------
#include <Constants.au3>
Opt("TrayAutoPause", 0)
Global Const $VK_NUMLOCK = 0x90
Global Const $VK_SCROLL = 0x91
Global Const $VK_CAPITAL = 0x14
$Apps="KeyState 1.1"
main()
Func main()
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
;~ If GetScrollLock() <>0 Then
;~  $keystate= $keystate  + 4
;~ EndIf

Select
Case $keystate = 1
  TraySetIcon(@ScriptFullPath, -6)
Case $keystate = 2
  TraySetIcon(@ScriptFullPath, -7)
Case $keystate = 3
  TraySetIcon(@ScriptFullPath, -8)
Case $keystate = 4
  TraySetIcon(@ScriptFullPath, -9)
Case Else
  TraySetIcon(@ScriptFullPath, -5)
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
Func GetScrollLock()
    Local $ret
    $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_SCROLL)
    Return $ret[0]
EndFunc
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...