Avix Posted September 1, 2009 Share Posted September 1, 2009 I'm trying to code this program which will hide the current window by pressing the hot keys defined. So if i have IE currently up and i want to hid it ill press F5 and if i want to hide another ill do the same. Than when i want to unhide the first one ill press f5 and so no so forth. Although this inst working. Anyone tell me why? And a way to optimize so it doesn't take 55% of the CPU? =/ Thanks!!! #NoTrayIcon while 1 HotKeySet("{F4}", "show") HotKeySet("{F5}", "hide") wend Func show() WinSetState("[current title]", "", @SW_SHOW) EndFunc Func hide() WinSetState("[current title]", "", @SW_HIDE) EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 1, 2009 Moderators Share Posted September 1, 2009 Avix,First, welcome to the AutoIt forums.Where to start? A question, perhaps....How does Autoit know which window to show when you press the HotKey to show it? I guarantee it will not be the "current title" as you have already hidden it and another window is now current! AutoIt cannot read your mind, however much we might like it to on occasion. Basically, you need to store the handles and titles of the windows you are hiding and then, when you try to show them again, display a list of the hidden windows from which you can choose the one you want to show.Look in the Help file under:WinGetTitle - How to get the title of the active windowWinGetHandle - How to get the handle of that windowDim - How to store the handle and titleGUICreate - How to make a GUI to display the GUICtrlCreateCombo or GUICtrlCreateList - How to display the hidden window titlesGUICtrlRead - How to get the window chosen in the combo/list you have createdIf all this sounds like Klingon, then I strongly recommend reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) - this will help you enormously. You should also try the excellent tutorials that you will find here and here. Do NOT get disheartened - have a go at producing something yourself and, if you run into problems, post again. M23 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 Link to comment Share on other sites More sharing options...
IchBistTod Posted September 3, 2009 Share Posted September 3, 2009 here you go, 0% CPU Usage. #NoTrayIcon global $old Global $hidden = 0 HotKeySet("{F4}", "show") HotKeySet("{F5}", "hide") while 1 sleep(2000) wend Func show() if $hidden = 1 Then $hidden = 0 WinSetState($old, "", @SW_SHOW) EndIf EndFunc Func hide() if $hidden = 0 Then $win = WinGetTitle(WinGetHandle("")) $old = $win $hidden = 1 WinSetState($win, "", @SW_HIDE) EndIf EndFunc [center][/center][center]=][u][/u][/center][center][/center] Link to comment Share on other sites More sharing options...
IchBistTod Posted September 3, 2009 Share Posted September 3, 2009 (edited) this code will hide/show multiple windows. This is untested, should work though. Edit: Added more error checking. #NoTrayIcon dim $old[50] Global $hidden = 0 $old[0] = 0 HotKeySet("{F4}", "show") HotKeySet("{F5}", "hide") while 1 sleep(2000) wend Func show() if $old[0] > 0 Then WinSetState($old[$old[0]], "", @SW_SHOW) WinActivate($old[$old[0]]) $old[0]-=1 EndIf EndFunc Func hide() if $old[0] < 49 Then $win = WinGetTitle(WinGetHandle("")) if $win <> "" Then $old[0]+=1 $old[$old[0]] = $win WinSetState($win, "", @SW_HIDE) EndIf EndIf EndFunc Edited September 3, 2009 by IchBistTod [center][/center][center]=][u][/u][/center][center][/center] 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