Jump to content

Need Little Help With Toggleling


Recommended Posts

I've been messing with a hotkey which would hide tray when alt+t is pressed and then appear when alt+t is pressed again, but it just hides the tray, this is loosely based of Andrew Sparkes's code http://www.autoitscript.com/forum/index.php?showtopic=23371 i have no idea of any other ways, or why it doesn't work..

Global $trayiconhide="0"

HotKeySet("!t","_traytog")

Func _Traytog()
While 1
If $trayiconhide="0" Then
opt("trayiconhide",1)
If $trayiconhide=1 Then $trayiconhide="0"
Exitloop
EndIf
If $trayiconhide="1" Then
opt("trayiconhide",0)
If $trayiconhide=1 Then $trayiconhide="1"
Exitloop
EndIf
WEnd
EndFunc

while 1
    sleep(200)
wend
Edited by slightly_abnormal
Link to comment
Share on other sites

Global $trayiconhide = 0

HotKeySet("!t", "_Traytog")
HotKeySet("{ESC}", "_Terminate")

While 1
    Sleep(200)
    If $trayiconhide = 1 Then
        Opt("trayiconhide", 1)
    Else
        Opt("trayiconhide", 0)
    EndIf
WEnd

Func _Traytog()
    $trayiconhide = Not $trayiconhide
EndFunc  ;==>_Traytog

Func _Terminate()
    Exit
EndFunc  ;==>_Terminate

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Global $trayiconhide = 0

HotKeySet("!t", "_Traytog")
HotKeySet("{ESC}", "_Terminate")

While 1
    Sleep(200)
    If $trayiconhide = 1 Then
        Opt("trayiconhide", 1)
    Else
        Opt("trayiconhide", 0)
    EndIf
WEnd

Func _Traytog()
    $trayiconhide = Not $trayiconhide
EndFunc ;==>_Traytog

Func _Terminate()
    Exit
EndFunc ;==>_Terminate
ha, thanks gary!
Link to comment
Share on other sites

I've been messing with a hotkey which would hide tray when alt+t is pressed and then appear when alt+t is pressed again, but it just hides the tray, this is loosely based of Andrew Sparkes's code http://www.autoitscript.com/forum/index.php?showtopic=23371 i have no idea of any other ways, or why it doesn't work..

Global $trayiconhide="0"

HotKeySet("!t","_traytog")

Func _Traytog()
While 1
If $trayiconhide="0" Then
opt("trayiconhide",1)
If $trayiconhide=1 Then $trayiconhide="0"
Exitloop
EndIf
If $trayiconhide="1" Then
opt("trayiconhide",0)
If $trayiconhide=1 Then $trayiconhide="1"
Exitloop
EndIf
WEnd
EndFunc

while 1
    sleep(200)
wend
Maybe take the quotes off the numeric value in your If statements, and I'm not sure I follow your logic:

; Assuming $trayiconhide is only 0 or 1
Func _Traytog()
     If $trayiconhide=0 Then
          opt("trayiconhide",1)
          $trayiconhide=1
     Else
          opt("trayiconhide",0)
          $trayiconhide=0
     EndIf
EndFunc

I didn't understand why you needed the While() loop in your hotkey function. :)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I noticed the problems with the quotes also, here's a shortend version

Global $trayiconhide = 0

HotKeySet("!t", "_Traytog")
HotKeySet("{ESC}", "_Terminate")

While 1
    Sleep(200)
WEnd

Func _Traytog()
    $trayiconhide = Not $trayiconhide
    Opt("trayiconhide", $trayiconhide)
EndFunc  ;==>_Traytog

Func _Terminate()
    Exit
EndFunc  ;==>_Terminate

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I noticed the problems with the quotes also, here's a shortend version

Global $trayiconhide = 0

HotKeySet("!t", "_Traytog")
HotKeySet("{ESC}", "_Terminate")

While 1
    Sleep(200)
WEnd

Func _Traytog()
    $trayiconhide = Not $trayiconhide
    Opt("trayiconhide", $trayiconhide)
EndFunc ;==>_Traytog

Func _Terminate()
    Exit
EndFunc ;==>_Terminate
Nice, tight _Traytog() function! :mellow:

I'm always too wordy in mine... old dog... new tricks... etc. :)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...