Sign in to follow this  
Followers 0
XiaolinDraconis

saving variables to ini

11 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



I guess you have to put it into loop.

Case are checked once. It dont loop for more checks

Share this post


Link to post
Share on other sites

$var += 1

Share this post


Link to post
Share on other sites

Oh, didnt saw that func are reapeated with hotkeys.

 

$var += 1

 That should work now

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks guys.

Anyone know why my tray function isn't working?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Look at my previous post  :)

Edit

I definitely need a beer

$item = TrayCreateItem("Exit")
TrayItemSetOnEvent($item,"quit")
Edited by mikell

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

 

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

I don't see a switch syntax problem. What I see is you changed it from a switch to a select. Seems not the same to me. But again, it works and that's the focus, thank you for the help.

Share this post


Link to post
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
Sign in to follow this  
Followers 0