fmen Posted June 12, 2010 Share Posted June 12, 2010 I am trying to get a gui to show when the program, "JellyFish" is active and hide when it is not active. The hidden part works fine but the gui flashes off and on when "JellyFish" is active. expandcollapse popupOpt("SendKeyDelay", '.01') Opt("WinTitleMatchMode", 2) Opt("TrayIconDebug", 1) #include <GUIConstants.au3> HotKeySet("{ESC}", "Terminate") ;_______________________________________________ If Not WinExists("JellyFish") Then Run("J:\RS\JF\jfp3032.exe") WinWaitActive("JellyFish") WinMove("JellyFish","", 32 ,182, 981, 710) ;______________________________________________________________________________ $GuiWidth = 100 $GuiHeight = 520 $xPos = 880 $yPos = 137 $Gui = GUICreate("Jelly", 100, 100,$xpos, $yPos, $WS_POPUP, _ BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $Swap = GUICtrlCreateButton ("Swap", 15, 20 ,75 ,15) $Finish = GUICtrlCreateButton ("Finish", 15, 40 ,75 ,15) $Manual = GUICtrlCreateButton ("Manual", 15, 60 ,75 ,15) $Roll = GUICtrlCreateButton ("Roll", 15, 80 ,75 ,15) GUISetState(@SW_SHOW) ;_______________________________________________________________________________ Do Sleep(10) $msg = GUIGetMsg() If Not WinExists("JellyFish") Then Call("Terminate") If Not WinActive("JellyFish") Then GUISetState(@SW_HIDE) Else GUISetState(@SW_SHOW) Endif Select Case $msg= $Swap WinActivate("JellyFish") Send("^w") Case $msg= $Finish WinActivate("JellyFish") Send("^a") Case $msg= $Manual WinActivate("JellyFish") Send("!sd") Case $msg= $Roll Run ("J:\RS\JF\Roll.exe") ;Terminate() Case $msg= $GUI_EVENT_CLOSE MsgBox(0,"You clicked on", "Close") EndSelect Until $msg = $GUI_EVENT_CLOSE ;_______________________________________________ Func Terminate() Exit 0 EndFunc This part is obviously the part that stinks: If Not WinActive("JellyFish") Then GUISetState(@SW_HIDE) Else GUISetState(@SW_SHOW) Endif Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 12, 2010 Moderators Share Posted June 12, 2010 fmen,It flashes because you activate the script window when you @SW_SHOW it, which means that your JellyFish window is no longer active and so the next pass hides it and reactivates the JellyFish window, which on the next pass shows the script window........... You get the idea. You need to check both windows on each pass and use @SW_SHOWNOACTIVATE to get the script Window to display. Here is your script modified (I had to use Notepad rather than Jellyfish, but I am sure the principle is the same:expandcollapse popupOpt("SendKeyDelay", '.01') Opt("WinTitleMatchMode", 2) Opt("TrayIconDebug", 1) #include <GUIConstants.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Terminate") ;_______________________________________________ If Not WinExists("Untitled") Then Run("Notepad") WinWaitActive("Untitled") WinMove("Untitled", "", 32, 182, 981, 710) ;______________________________________________________________________________ $GuiWidth = 100 $GuiHeight = 520 $xPos = 880 $yPos = 137 $Gui = GUICreate("Jelly", 100, 100, $xPos, $yPos, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $Swap = GUICtrlCreateButton("Swap", 15, 20, 75, 15) $Finish = GUICtrlCreateButton("Finish", 15, 40, 75, 15) $Manual = GUICtrlCreateButton("Manual", 15, 60, 75, 15) $Roll = GUICtrlCreateButton("Roll", 15, 80, 75, 15) GUISetState(@SW_SHOW) ;_______________________________________________________________________________ Do If Not WinExists("Untitled") Then Terminate() ; <<<<<<<<<<<<<<<<<<<<<<<<< No need to use Call here If BitAND(WinGetState("Untitled"), 8) = 8 And BitAND(WinGetState($Gui), 2) <> 2 Then GUISetState(@SW_SHOWNOACTIVATE, $Gui) ElseIf BitAND(WinGetState("Untitled"), 8) <> 8 And BitAND(WinGetState($Gui), 2) = 2 Then GUISetState(@SW_HIDE, $Gui) EndIf $msg = GUIGetMsg() Select Case $msg = $Swap WinActivate("JellyFish") Send("^w") Case $msg = $Finish WinActivate("JellyFish") Send("^a") Case $msg = $Manual WinActivate("JellyFish") Send("!sd") Case $msg = $Roll Run("J:\RS\JF\Roll.exe") ;Terminate() ;Case $msg = $GUI_EVENT_CLOSE ; <<<<<<<<<<<<<<<< You do not have an [X] to click! ; MsgBox(0, "You clicked on", "Close") EndSelect Until $msg = $GUI_EVENT_CLOSE ;_______________________________________________ Func Terminate() Exit 0 EndFunc ;==>TerminateI also added in the missing #include file and made a couple of other small suggestions. I hope that now works as you want. 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...
fmen Posted June 12, 2010 Author Share Posted June 12, 2010 Thank you very much for that, Melba.... I would not have figured that out. The gui shows and hides appropriately now, but the gui buttons no longer function. For example, Case $msg = $Swap WinActivate("Untitled") Send("!fx") will not close Notepad. I am not sure why. Thanks again..... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 12, 2010 Moderators Share Posted June 12, 2010 fmen,Sorry about that - there are many ways to stop the flashing, but you have to pick the right one to let you use the GUIs correctly. This version (which does not look terribly different from the other) seems to work correctly and closes Notepad when you press "Finish":expandcollapse popupOpt("SendKeyDelay", '.01') Opt("WinTitleMatchMode", 2) Opt("TrayIconDebug", 1) #include <GUIConstants.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Terminate") ;_______________________________________________ If Not WinExists("Untitled") Then Run("Notepad") WinWaitActive("Untitled") WinMove("Untitled", "", 32, 182, 981, 710) ;______________________________________________________________________________ $GuiWidth = 100 $GuiHeight = 520 $xPos = 880 $yPos = 137 $Gui = GUICreate("Jelly", 100, 100, $xPos, $yPos, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $Swap = GUICtrlCreateButton("Swap", 15, 20, 75, 15) $Finish = GUICtrlCreateButton("Finish", 15, 40, 75, 15) $Manual = GUICtrlCreateButton("Manual", 15, 60, 75, 15) $Roll = GUICtrlCreateButton("Roll", 15, 80, 75, 15) GUISetState(@SW_SHOW) ;_______________________________________________________________________________ Do If Not WinExists("Untitled") Then Terminate() If BitAND(WinGetState("Untitled"), 8) <> 8 And BitAND(WinGetState($Gui), 2) <> 2 Then GUISetState(@SW_HIDE, $Gui) ElseIf BitAND(WinGetState("Untitled"), 8) = 8 And BitAND(WinGetState($Gui), 2) = 2 Then GUISetState(@SW_SHOW, $Gui) WinActivate("Untitled") EndIf $msg = GUIGetMsg() Select Case $msg = $Swap WinActivate("JellyFish") Send("^w") Case $msg = $Finish WinActivate("Untitled") Send("!f") Sleep(100) Send("x") Case $msg = $Manual WinActivate("JellyFish") Send("!sd") Case $msg = $Roll Run("J:\RS\JF\Roll.exe") EndSelect Until $msg = $GUI_EVENT_CLOSE ;_______________________________________________ Func Terminate() Exit 0 EndFunc ;==>TerminateNote that I have separated the 2 elements of the Send command - I have always found it works better that way! I hope that solves your problem. 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...
fmen Posted June 13, 2010 Author Share Posted June 13, 2010 (edited) Wow, I see that the small changes made to the "BitAND(WinGetState" allowed the buttons to function, but gui no longer goes to a hidden state when Notepad is inactive.... Sorry... Edited June 13, 2010 by fmen Link to comment Share on other sites More sharing options...
DW1 Posted June 13, 2010 Share Posted June 13, 2010 (edited) The logic for hiding is wrong. You want to hide IF -app(notepad/jellyfish) is not focused AND -GUI is not focused (don't want to hide the gui if the user is using it actively) AND -gui is not already hidden. ( no need to hide a hidden window ) You want to show the GUI IF -Notepad/Jellyfish is Active (The user needs the gui again) AND -The GUI is currently hidden (no need to re show an already visible window) expandcollapse popupOpt("SendKeyDelay", '.01') Opt("WinTitleMatchMode", 2) Opt("TrayIconDebug", 1) #include <GUIConstants.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Terminate") ;_______________________________________________ If Not WinExists("Untitled") Then Run("Notepad") WinWaitActive("Untitled") WinMove("Untitled", "", 32, 182, 981, 710) ;______________________________________________________________________________ $GuiWidth = 100 $GuiHeight = 520 $xPos = 880 $yPos = 137 $Gui = GUICreate("Jelly", 100, 100, $xPos, $yPos, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $Swap = GUICtrlCreateButton("Swap", 15, 20, 75, 15) $Finish = GUICtrlCreateButton("Finish", 15, 40, 75, 15) $Manual = GUICtrlCreateButton("Manual", 15, 60, 75, 15) $Roll = GUICtrlCreateButton("Roll", 15, 80, 75, 15) GUISetState(@SW_SHOW) ;_______________________________________________________________________________ Do If Not WinExists("Untitled") Then Terminate() If BitAND(WinGetState("Untitled"), 8) <> 8 And BitAND(WinGetState($Gui), 8) <> 8 And BitAND(WinGetState($Gui), 2) = 2 Then GUISetState(@SW_HIDE, $Gui) ElseIf BitAND(WinGetState("Untitled"), 8) = 8 And BitAND(WinGetState($Gui), 2) <> 2 Then GUISetState(@SW_SHOW, $Gui) WinActivate("Untitled") EndIf $msg = GUIGetMsg() Select Case $msg = $Swap WinActivate("JellyFish") Send("^w") Case $msg = $Finish WinActivate("Untitled") Send("!f") Sleep(100) Send("x") Case $msg = $Manual WinActivate("JellyFish") Send("!sd") Case $msg = $Roll Run("J:\RS\JF\Roll.exe") EndSelect Until $msg = $GUI_EVENT_CLOSE ;_______________________________________________ Func Terminate() Exit 0 EndFunc ;==>Terminate Edited June 17, 2010 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 13, 2010 Moderators Share Posted June 13, 2010 danwilli, Thanks for that helping hand. Too much emotion after the game last evening! (Or at least that is my excuse! ) 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...
fmen Posted June 13, 2010 Author Share Posted June 13, 2010 Danwilli, thank you much for the fix. I understood the logic, but unfortunately could not translate it into code. Still not sure how adding $a and $a+ accomplished the feat but I will continue trying to figure it out . Link to comment Share on other sites More sharing options...
DW1 Posted June 17, 2010 Share Posted June 17, 2010 Danwilli, thank you much for the fix. I understood the logic, but unfortunately could not translate it into code. Still not sure how adding $a and $a+ accomplished the feat but I will continue trying to figure it out . LMAO... sorry... foot in mouth moment here. The $a and $a+ have nothing to do with the fix. you can remove them. They were there for testing only. I have edited the above code to rid them. The fix was in the logic here: If BitAND(WinGetState("Untitled"), 8) <> 8 And BitAND(WinGetState($Gui), 8) <> 8 And BitAND(WinGetState($Gui), 2) = 2 Then GUISetState(@SW_HIDE, $Gui) ElseIf BitAND(WinGetState("Untitled"), 8) = 8 And BitAND(WinGetState($Gui), 2) <> 2 Then GUISetState(@SW_SHOW, $Gui) WinActivate("Untitled") EndIf AutoIt3 Online Help 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