dromenox Posted April 18, 2014 Share Posted April 18, 2014 (edited) I'm trying to create a function that toggles between Hide and Show when I press F1. My code hides not only back to normal when I press F1 again. #include <Array.au3> #include <Misc.au3> Global $boxes[10] Global $host = 'Calculadora' $boxes[0] = GuiCreate('', 100, 200, 10, 10, 0x80000000, BitOR(0x00000008, 0x00000100)) GUISetBkColor($boxes[0]) GUISetState(@SW_SHOW, $boxes[0]) ;$boxes[1] = GuiCreate('', 100, 200, 120, 10, 0x80000000, 0x00000008) ;GUISetBkColor($boxes[1]) ;GUISetState(@SW_SHOW, $boxes[1]) HotKeySet('{F1}', 'write_show_0') Global $show = 1 While True WEnd Func write_show_0() if $show = 1 Then WinSetState($boxes[0], '', '@SW_HIDE') $show = 0 ElseIf $show = 0 Then WinSetState($boxes[0], '', '@SW_SHOW') $show = 1 EndIf EndFunc Edited April 18, 2014 by dromenox Link to comment Share on other sites More sharing options...
reb Posted April 18, 2014 Share Posted April 18, 2014 (edited) This works for me #include <Array.au3> #include <Misc.au3> Global $boxes[10] Global $host = 'Calculadora' $boxes[0] = GUICreate('', 100, 200, 10, 10, 0x80000000, BitOR(0x00000008, 0x00000100)) GUISetBkColor($boxes[0]) GUISetState(@SW_SHOW, $boxes[0]) ;$boxes[1] = GuiCreate('', 100, 200, 120, 10, 0x80000000, 0x00000008) ;GUISetBkColor($boxes[1]) ;GUISetState(@SW_SHOW, $boxes[1]) HotKeySet('{F1}', 'write_show_0') Global $show = 1 While True WEnd Func write_show_0() If $show = 1 Then WinSetState($boxes[0], '', @SW_HIDE) $show = 0 Else ;If $show = 0 Then WinSetState($boxes[0], '', @SW_SHOW ) $show = 1 EndIf EndFunc ;==>write_show_0 REB Edited April 18, 2014 by reb MEASURE TWICE - CUT ONCE Link to comment Share on other sites More sharing options...
SirJohann Posted April 18, 2014 Share Posted April 18, 2014 (edited) Yes, the problem is in WinSetState($boxes[0], '', '@SW_HIDE'). It's just WinSetState($boxes[0], '', @SW_HIDE) Edit: The same with @SW_SHOW. Edited April 18, 2014 by SirJohann Codes codes codes. Link to comment Share on other sites More sharing options...
Belini Posted April 18, 2014 Share Posted April 18, 2014 Why do not you use GUISetState? #include <Array.au3> #include <Misc.au3> Global $boxes[10] Global $host = 'Calculadora' $boxes[0] = GUICreate('', 100, 200, 10, 10, 0x80000000, BitOR(0x00000008, 0x00000100)) GUISetBkColor($boxes[0]) GUISetState(@SW_SHOW, $boxes[0]) ;$boxes[1] = GuiCreate('', 100, 200, 120, 10, 0x80000000, 0x00000008) ;GUISetBkColor($boxes[1]) ;GUISetState(@SW_SHOW, $boxes[1]) HotKeySet('{F1}', 'write_show_0') Global $show = 1 While True WEnd Func write_show_0() If $show = 1 Then GUISetState(@SW_HIDE, $boxes[0]) $show = 0 ElseIf $show = 0 Then GUISetState(@SW_SHOW, $boxes[0]) $show = 1 EndIf EndFunc ;==>write_show_0 My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
dromenox Posted April 20, 2014 Author Share Posted April 20, 2014 thank you all, problem solved! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now