AutoHotkey Community

It is currently May 27th, 2012, 5:29 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: March 11th, 2010, 6:59 pm 
Offline

Joined: February 16th, 2010, 8:01 am
Posts: 800
Location: SciTE
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



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 8:59 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
>>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 ... m#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()


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 9:44 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
You could use my random naming function for each new GUI.

See here (Last example): http://www.autohotkey.com/forum/viewtop ... 693#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

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 10:32 pm 
Offline

Joined: February 16th, 2010, 8:01 am
Posts: 800
Location: SciTE
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. 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 10:38 pm 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
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.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], dra, HotkeyStick, rbrtryn, Yahoo [Bot] and 74 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group