 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
jpjazzy
Joined: 16 Feb 2010 Posts: 799 Location: SciTE
|
Posted: Thu Mar 11, 2010 5:59 pm Post subject: Best way to check multiple GUIs for hidden properties? |
|
|
Ok I am going to making a script with multiple GUIs and I found how to detect if the script is shown or not using WinExist (Thank you jaco), however, using this method is not going to work for multiple GUIs because it is the same label in the WinExist using AHK class or name. My question, does anyone have another method or can they give me a little advice here how to distinguish between multiple GUIs in the AHK class or by some other means so I might not trigger one GUI if I really intended for another?
Sorry if this seems a bit confusing. What I am trying to do is make strips of transparent red cover the screen in certain places if the pixelsearch returns true in that region (A warning the blue is there...) By doing this I am going to have 13 "strips" of GUI which will be individually triggered by the pixelsearch and I don't want a GUI triggered if the blue isn't in that region.
This is my code for the first strip and it works fine, however it is only one strip and I am going to need to do 12 more. I have no idea how to get a handle on each of them to detect if they are hidden already or not. Thanks in advance for any assistance.
| Code: |
#SingleInstance
#Persistent
SetTitleMatchMode, 2
;################### MAKE ALL GUIs############
Gui, +LastFound -Caption +AlwaysOnTop
Gui, Color, Red
WinSet, Transparent, 100
hwnd1 := WinExist("ahk_class AutoHotkeyGUI")
SetTimer, Check, 5
;################# Check for pixel
Check:
hwnd1 := WinExist("ahk_class AutoHotkeyGUI")
IfWinActive, OMGPOP
{
PixelSearch, BalX, BalY, 561, 311, 1177, 366, 0xE5E216, 5, Fast ;search for blue color to trigger the GUI warning
If (ErrorLevel = 0)
{
Goto, ShowGUI
}
}
IfWinNotActive, OMGPOP
{
Goto, HideGUI
}
HideGUI:
If (hwnd1 = 0x0)
{
Return
}
Else
{
Gui, Hide
Return
}
ShowGUI:
If (hwnd1 = 0x0)
{
Gui, Show, x558 y310 w610 h44 +NoActivate
Return
}
Else
{
Return
}
F2::Reload
F3::ExitApp
|
|
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
Posted: Thu Mar 11, 2010 7:59 pm Post subject: |
|
|
>>I have no idea how to get a handle on each of them to detect if they are hidden already or not.
I suggest not trying to detect IF they are hidden/shown.
I suggest using a system of flags to keep track of which gui/window is shown or hidden.
If you hide a window, set the variable value to mean 'hidden'.
| Code: | If guivisible1 ; guivisible%index% could be used to pick one by number
{ ; gui is visible
}
else
{ ; gui is hidden
{ |
Since you are planning to code it with multiple guis then you need to read up, if you haven't already. http://www.autohotkey.com/docs/commands/Gui.htm#MultiWin
Concerning show/hide of window
| Code: | Gui, 2:Show
Gui, 2:Hide |
Alternately, you could use WinShow and WinHide
| Code: | WinShow, ahk_id %hwnd1%
WinHide, ahk_id %hwnd2% |
That is, after you got the id of the window, with WinGet or WinExist using the
http://www.autohotkey.com/docs/LastFoundWindow.htm
The next two lines store an ahk_id in hwnd1 using the LFW method.
| Code: | Gui, +LastFound -Caption +AlwaysOnTop
hwnd1 := WinExist()
|
|
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
Posted: Thu Mar 11, 2010 8:44 pm Post subject: |
|
|
You could use my random naming function for each new GUI.
See here (Last example): http://www.autohotkey.com/forum/viewtopic.php?p=332693#332693
I created this to do somewhat the same thing your trying to do. It was for multiple GUI's being used as graphs. I'm sure it would not be too hard to mod it for your use.
The 2 things to add would be GUI number increments and then perhaps assigning the new random name to an array that can be used as the GUI title.
hth _________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞ |
|
| Back to top |
|
 |
jpjazzy
Joined: 16 Feb 2010 Posts: 799 Location: SciTE
|
Posted: Thu Mar 11, 2010 9:32 pm Post subject: |
|
|
Once again leef, you're amazing. Don't know why I didn't think about flag variables before.... I used them in my last project....
Thank you also TLM, both of you guys are awesome.  |
|
| Back to top |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Thu Mar 11, 2010 9:38 pm Post subject: |
|
|
Your random function reminds me of mine: RandomVar() _________________ "Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried."
Antonio França
My stuff: Google Profile |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|