Sign in to follow this  
Followers 0
slightly_abnormal

Need Little Help With Toggleling

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


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

 

Share this post


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

Share this post


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

Share this post


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

 

Share this post


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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I put while 1, so it wont exit out.

yeah.. very compact.. suprised at all the ways you can do one function :)

Edited by slightly_abnormal

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