Could somebody help me out a little please.
I have entered the code below and I only want to get the toggle text on the Tray Menu to read the ini file when it is first opened, but it always seems to revert back to the default (of ...on) and ignores the ini file.
Could somebody show me where i have gone wrong?
Code:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
#Persistent
SetTitleMatchMode, Slow
IniRead, t_MenuItemHide, C:\Hotkey.ini, Section, Key
;---------------------------------------------------------
; Names for the tray menu items:
t_MenuItemHide = Ignore Word On
t_MenuItemShow = Ignore Word Off
;---------------------------------------------------------
Menu, Tray, Add, %t_MenuItemHide%, t_ShowHide
Menu, Tray, Default, %t_MenuItemHide%
Menu, Tray, Add ;Separator
Menu, Tray, Add, Pause Script..., Pause
Menu, Tray, Add, Exit..., Exit
Menu, Tray, NoStandard
t_IsVisible = y
;---------------------------------------------------------
SetTimer, KeepAlive, 250
return
;---------------------------------------------------------
KeepAlive:
IfWinExist,Untitled - Notepad
{
WinActivate
SendInput Add some text here
Sleep, 400
WinWaitClose,Untitled - Notepad
}
else
if t_IsVisible = y
{
ifWinExist, Document1 - Microsoft Word
{
WinActivate
SendInput Add some pictures here
WinWaitClose, Document1 - Microsoft Word
}
}
Run, Calc.exe
Sleep, 1000
WinWaitClose, Calculator
return
;---------------------------------------------------------
t_ShowHide:
>^f11::
if t_IsVisible = y
{
Menu, Tray, Rename, %t_MenuItemHide%, %t_MenuItemShow%
t_IsVisible = n
IniWrite, %t_MenuItemShow%, C:\Hotkey.ini,Section, Key
}
else
{
Menu, Tray, Rename, %t_MenuItemShow%, %t_MenuItemHide%
t_IsVisible = y
IniWrite, %t_MenuItemShow%, C:\Hotkey.ini,Section, Key
}
return
;---------------------------------------------------------
Pause:
Pause
return
t_MenuExit:
Exit:
Msgbox, 4372, Warning , Are you sure you wish to Exit.
ifMsgBox, No
return
ExitApp