satanttin Posted July 7, 2015 Posted July 7, 2015 (edited) Hello,Hope someone could help me out. I'm trying to open a gui with a hotkey and when it's already open to not open a new one.The code i have so far is:HotKeySet("+z", "Note") Func Note() If $Note = False Then $Note = GUICreate("Note", 633, 504, 346, 297) $dEdit = IniRead (@ScriptDir & "\Data\Note.ini" , "Note", "Note", @error) $Edit = GUICtrlCreateEdit("", 0, 0, 632, 503) GUICtrlSetData($Edit, StringReplace(IniRead(@ScriptDir & "\Data\Note.ini" , "Note", "Note", @error), "{ENTER}", @CRLF)) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "NoteFunc") ElseIf $Note = True Then GUIDelete($Note) EndIf EndFuncIf i press shift + z it will open the gui and a second press deletes it but when i use it a 3th time it doesn't do anything.So basicly want to toggle a gui with a hotkey. Edited July 7, 2015 by satanttin
Moderators Melba23 Posted July 7, 2015 Moderators Posted July 7, 2015 satanttin,I would just hide/show the GUI like this:#include <GUIConstantsEx.au3> HotKeySet("+z", "Note") $bShow = True $Note = GUICreate("Note", 633, 504, 346, 297) $dEdit = IniRead (@ScriptDir & "\Data\Note.ini" , "Note", "Note", @error) $Edit = GUICtrlCreateEdit("", 0, 0, 632, 503) GUICtrlSetData($Edit, StringReplace(IniRead(@ScriptDir & "\Data\Note.ini" , "Note", "Note", @error), "{ENTER}", @CRLF)) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Note() $bShow = Not $bShow If $bShow Then GUISetState(@SW_SHOW, $Note) Else GUISetState(@SW_HIDE, $Note) EndIf EndFuncM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
JohnOne Posted July 7, 2015 Posted July 7, 2015 (edited) What Melba posted is a better way to do this, but to answer your question.ElseIf $Note = True Then GUIDelete($Note) $Note = False EndIf Edited July 7, 2015 by JohnOne Code was incorrect AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
satanttin Posted July 7, 2015 Author Posted July 7, 2015 Thanks Melba23 ^^works like a charm :3 guess i will save this piece of code if i need it in the future
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