Jump to content

saving variables to ini


Go to solution Solved by mikell,

Recommended Posts

Thanks for getting the function working guys, now I'm trying to figure out why the tray exit function isn't working.

HotKeySet ("-", "test")
Opt("TrayOnEventMode", 1)
Opt("TrayAutoPause", 0)
Opt("TrayMenuMode", 3)
TrayCreateItem("Exit")
TrayItemSetOnEvent("Exit","quit")
$var=IniRead("au3script.ini", "Variables", "var1", "error")

While 1
   Sleep(100)
WEnd

Func test()
Switch $var
Case $var=1
   $var+=1
ToolTip("1")
Case $var=2
   $var+=1
ToolTip("2")
Case $var=3
   $var=1
ToolTip("3")
Case $var>3
   ToolTip("error")
EndSwitch
EndFunc

Func quit()
   IniWrite("au3script.ini", "Variables", "var1", $var)
   Exit
EndFunc
Edited by XiaolinDraconis
Link to comment
Share on other sites

I forgot to mention the syntax error in the Switch

This does work  :)

HotKeySet ("a", "test")
HotKeySet ("{ESC}", "quit")

$var=IniRead("au3script.ini", "Variables", "var1", "error")

While 1
   Sleep(100)
WEnd

Func test()
Select
Case $var=1
   $var+=1
ToolTip("1")
Case $var=2
   $var+=1
ToolTip("2")
Case $var=3
   $var=1
ToolTip("3")
Case $var>3
   ToolTip("error")
EndSelect
EndFunc

Func quit()
   IniWrite("au3script.ini", "Variables", "var1", $var)
   Exit
EndFunc
Link to comment
Share on other sites

 

I forgot to mention the syntax error in the Switch

This does work  :)

HotKeySet ("a", "test")
HotKeySet ("{ESC}", "quit")

$var=IniRead("au3script.ini", "Variables", "var1", "error")

While 1
   Sleep(100)
WEnd

Func test()
Select
Case $var=1
   $var+=1
ToolTip("1")
Case $var=2
   $var+=1
ToolTip("2")
Case $var=3
   $var=1
ToolTip("3")
Case $var>3
   ToolTip("error")
EndSelect
EndFunc

Func quit()
   IniWrite("au3script.ini", "Variables", "var1", $var)
   Exit
EndFunc

Seems that switch is meant for more a advanced task?

Link to comment
Share on other sites

 

Look at my previous post  :)

Edit

I definitely need a beer

$item = TrayCreateItem("Exit")
TrayItemSetOnEvent($item,"quit")

I am, you changed the tray function to a normal function. I'm trying to make it save when I click exit.

Didn't catch the edit, I see what you did, I think. It works, that's what matters. Now I need to read some and figure out why it works.

Edited by XiaolinDraconis
Link to comment
Share on other sites

  • Solution

The syntax problem was :

Switch <expression>
    Case <value>
         statement

Select
    Case <expression>
         statement
 

The tray works in this one, the tray click saves and exits

HotKeySet ("a", "test")

Opt("TrayMenuMode", 3)
Opt("TrayOnEventMode", 1)
$item = TrayCreateItem("Exit")
TrayItemSetOnEvent($item,"quit")

$var=IniRead("au3script.ini", "Variables", "var1", "error")

While 1
   Sleep(100)
WEnd

Func test()
Select
Case $var=1
   $var+=1
ToolTip("1")
Case $var=2
   $var+=1
ToolTip("2")
Case $var=3
   $var=1
ToolTip("3")
Case $var>3
   ToolTip("error")
EndSelect
EndFunc

Func quit()
   IniWrite("au3script.ini", "Variables", "var1", $var)
   Exit
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...