AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Child GUI only on specific tab?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Calimaw



Joined: 25 Aug 2006
Posts: 128
Location: Iowa, USA

PostPosted: Sat Feb 02, 2008 9:25 pm    Post subject: Child GUI only on specific tab? Reply with quote

Okay, so I've been working on a little macro app. and would like to display some HTML in the "About" tab on the main GUI, what I've done here is create a GUI which parents itself onto the main GUI (GUI 3 becomes the child of GUI 1, GUI 2 is an in-game overlay).

The problem is that I'm not able to figure out how to check what tab I'm on to be able to hide or show GUI 3 (the one with the HTML) appropriately.

Code:
#SingleInstance, Force
#NoEnv
#InstallKeybdHook

SetTitleMatchMode, 3
DetectHiddenWindows, On
hModule := DllCall("LoadLibrary", "str", "cwebpage.dll")




;;VARIABLES

GUINAME = Auto-Fire GUI Control 2.0d
GUINAMESTATUS = Auto-Fire In-Game Overlay
AFHTMLGUI = Auto-Fire HTML Object
HTML = %A_WorkingDir%\auto-fire.html

AFTIME = 0
AFTOLERANCE = 0
ARVPIXELS = 0
ARHPIXELS = 0
GAMENAME = The Specialists




;;G.U.I. CONSTRUCTION 1

;Menu, Tray, Icon, %A_ScriptName%,, 1
Menu, Tray, Color, 777777
Menu, Tray, NoStandard
Menu, Tray, Add, Control GUI, ShowGUI
Menu, Tray, Add
Menu, Tray, Add, Exit Macro, ExitApp

Gui, Color, 777777
Gui, +ToolWindow
Gui, Add, Tab,, Game|Auto-Fire|Anti-Recoil|About||
Gui, Tab, 1
Gui, Add, Text, X24 Y40 W112 H32, Game Window Name (ALT-TAB To Check)
Gui, Add, Text, X152 Y40 W112 H128, Welcome`r`rSee the 'about' section for information...
Gui, Add, Edit, X21 Y82 W96 H24 vGNEDIT, The Specialists
Gui, Add, Text, X24 Y112 W96 H24 vGNTEXTVAR, %GAMENAME%
Gui, Add, Button, X10 Y196 W270 H32 gGUISubmit, SUBMIT
Gui, Tab, 2
Gui, Add, Text, X24 Y40 W112 H32, Auto-Fire Iteration in Milliseconds
Gui, Add, Edit, X21 Y82 W96 H24 vAFEDIT +Limit +Number, 0
Gui, Add, Text, X24 Y112 W96 H24 vAFTEXTVAR, %AFTIME% Milliseconds
Gui, Add, Text, X152 Y40 W112 H32, Auto-Fire Tolerance in Milliseconds
Gui, Add, Edit, X149 Y82 W96 H24 vAFEDIT2 +Limit +Number, 0
Gui, Add, Text, X152 Y112 W96 H24 vAFTEXTVAR2, %AFTOLERANCE% Milliseconds
Gui, Add, Button, X10 Y196 W270 H32 gGUISubmit, SUBMIT
Gui, Tab, 3
Gui, Add, Text, X24 Y40 W112 H32, Anti-Recoil in Verticle Pixels
Gui, Add, Edit, X21 Y82 W96 H24 vARVEDIT +Limit, 0
Gui, Add, Text, X24 Y112 W96 H24 vARVTEXTVAR, %ARVPIXELS% V-Pixels
Gui, Add, Text, X152 Y40 W112 H32, Anti-Recoil in Horizontal Pixels
Gui, Add, Edit, X149 Y82 W96 H24 vARHEDIT +Limit, 0
Gui, Add, Text, X152 Y112 W96 H24 vARHTEXTVAR, %ARHPIXELS% H-Pixels
Gui, Add, Text, X24 Y172 W246 H32 +Center, NEGATIVE VALUES ACCEPTED
Gui, Add, Button, X10 Y196 W270 H32 gGUISubmit, SUBMIT
Gui, Tab, 4
Gui, Show, AutoSize, %GUINAME%
Gui, 3: +ToolWindow -Caption +Border
Gui, 3: Show, X24 Y40 W242 H172, %AFHTMLGUI%
HWND_AFHTMLGUI := WinExist(AFHTMLGUI)
HWND_GUINAME := WinExist(GUINAME)
DllCall("SetParent", "uint", HWND_AFHTMLGUI, "uint", HWND_GUINAME)

res := DLLCall("cwebpage\EmbedBrowserObject", UInt, HWND_AFHTMLGUI)
If (res != 0 Or ErrorLevel != 0) ; error
  Goto, ExitApp

res := DLLCall("cwebpage\DisplayHTMLPage", UInt, HWND_AFHTMLGUI, Str, HTML)
If (res != 0 Or ErrorLevel != 0) ; error
  Goto, ExitApp
Return




;;G.U.I. CONSTRUCTION 2

Gui, 2: Color, 000000
Gui, 2: Font, cFFFFFF s12, Arial
Gui, 2: +Disabled +ToolWindow -Caption
Gui, 2: Add, Text, XCenter YTop +Center W%A_ScreenWidth% H32 vStatusOL, Iteration: %AFTIME% | Tolerance: %AFTOLERANCE% | Anti-Recoil-V: %ARVPIXELS% | Anti-Recoil-H: %ARHPIXELS%
Gui, 2: Show, Hide XCenter YTop W%A_ScreenWidth% H16, %GUINAMESTATUS%
Return




;;MAIN SUBS

;;WINDOW CHECK SUB

WindowCheck:
Loop
{
    IfWinActive, %GAMENAME%
    break
}
Return




;;MOUSE ATTACK SUB

*~$LButton::
GoSub, WindowCheck
Sleep, %AFTOLERANCE%
Loop
{
    GetKeyState, LButtonState, LButton, P
    If LButtonState = U
   break
    Send, {Blind}{LButton}
    MouseMove, %ARHPIXELS%, %ARVPIXELS%, 0, R
    Sleep, %AFTime%
}
Return








;;G.U.I. SUBMIT SUBS.

GUISubmit:
GoSub, GNSubmit
GoSub, AFSubmit
GoSub, ARSUbmit
Return

GNSubmit:
Gui, Submit, NoHide
GAMENAME = %GNEDIT%
GoSub, CheckGNExist
Return

CheckGNExist:
IfWinNotExist, %GAMENAME%
MsgBox, 0, Cannot Find Game, The window you have input does not exist.
else
GoSub, GNSubmitChecked
Return

GNSubmitChecked:
GoSub, SetParent
GuiControl,, GNTEXTVAR, %GAMENAME%
WinSet, ReDraw
Return

AFSubmit:
Gui, Submit, NoHide
AFTIME = %AFEDIT%
AFTOLERANCE = %AFEDIT2%
GuiControl,, AFTEXTVAR, %AFTIME% Milliseconds
GuiControl,, AFTEXTVAR2, %AFTOLERANCE% Milliseconds
WinSet, ReDraw
Return

ARSubmit:
Gui, Submit, NoHide
ARVPIXELS = %ARVEDIT%
ARHPIXELS = %ARHEDIT%
GuiControl,, ARVTEXTVAR, %ARVPIXELS% V-Pixels
GuiControl,, ARHTEXTVAR, %ARHPIXELS% H-Pixels
WinSet, ReDraw
Return




;;DLL CALLS

;;USER32

SetParent:
HWND_GUINAMESTATUS := WinExist(GUINAMESTATUS)
HWND_GAMENAME := WinExist(GAMENAME)
DllCall("SetParent", "uint", HWND_GUINAMESTATUS, "uint", HWND_GAMENAME)
Return








;;OVERLAY SUBS.

StatusSubOL:
;;Showing the GUI causes application focus shift & minimizes the full-screen parent...

IfWinActive, %GAMENAME%
Gui, 2: Show, NA
GuiControl, 2:, StatusOL, Iteration: %AFTIME% | Tolerance: %AFTOLERANCE% | Anti-Recoil-V: %ARVPIXELS% | Anti-Recoil-H: %ARHPIXELS%
SetTimer, HideStatus, 5000
Return

HideStatus:
SetTimer, HideStatus, Off
Gui, 2: Hide
Return




;;MISC.

ShowGUI:
Gui, Show
Return

GuiClose:
Gui, Hide
TrayTip,Auto-Fire Information,Macro GUI is now hidden...`nThe GUI can be displayed again by selecting "Control GUI" from the tray options or by pressing the HOME key.,10,1
Return








;;HOTKEYS 1

;;INPUT ACTION

NumPad8::
If ARVPIXELS < 127
EnvAdd, ARVPIXELS, 1
   else
ARVPIXELS = 128
GoSub, StatusSubOL
Gui, Submit, NoHide
GuiControl,, ARVTEXTVAR, %ARVPIXELS% V-Pixels
Return

NumPad5::
If ARVPIXELS > -127
EnvSub, ARVPIXELS, 1
   else
ARVPIXELS = -128
GoSub, StatusSubOL
Gui, Submit, NoHide
GuiControl,, ARVTEXTVAR, %ARVPIXELS% V-Pixels
Return

NumPad6::
If ARHPIXELS < 127
EnvAdd, ARHPIXELS, 1
   else
ARHPIXELS = 128
GoSub, StatusSubOL
Gui, Submit, NoHide
GuiControl,, ARHTEXTVAR, %ARHPIXELS% H-Pixels
Return

NumPad4::
If ARHPIXELS > -127
EnvSub, ARHPIXELS, 1
   else
ARHPIXELS = -128
GoSub, StatusSubOL
Gui, Submit, NoHide
GuiControl,, ARHTEXTVAR, %ARHPIXELS% H-Pixels
Return

NumPadAdd::
If AFTIME < 995
EnvAdd, AFTIME, 5
   else
AFTIME = 1000
GoSub, StatusSubOL
Gui, Submit, NoHide
GuiControl,, AFTEXTVAR, %AFTIME% Milliseconds
Return

NumPadSub::
If AFTIME > 5
EnvSub, AFTIME, 5
   else
AFTIME = 0
GoSub, StatusSubOL
Gui, Submit, NoHide
GuiControl,, AFTEXTVAR, %AFTIME% Milliseconds
Return

;;HOTKEYS 2

;;APP. CONTROL

Home::
IfWinActive, %GAMENAME%
GoSub, StatusSubOL
else
Gui, Show
Return

End::
Suspend, Toggle
Return

Del::
ExitApp
Return

ExitApp:
DLLCall("cwebpage\UnEmbedBrowserObject", UInt, HWND_AFHTMLGUI)
DllCall("FreeLibrary", "UInt", hModule)
ExitApp


Any clean-up's in regards to any other portion of the script is appriciated as well, this was initially my first real project with AHK, over-all it works as needed, there are some obvious possible problems with it, such as typing "Tea Pot" where an integer would be, and accepting it, as well as the overlay not being dynamic enough for games set at different resolutions than the desktop, but the main problem is the GUI 3.
_________________
83% Noob, 17% Coached...
Put on your smart face, that one is getting old and tired...
Back to top
View user's profile Send private message AIM Address
Guest






PostPosted: Sun Feb 03, 2008 12:58 am    Post subject: Reply with quote

Any ideas on how to do this?
Back to top
skwire



Joined: 18 Jan 2006
Posts: 132
Location: Conway, Arkansas

PostPosted: Sun Feb 03, 2008 3:18 pm    Post subject: Reply with quote

Code:
GuiControlGet, CurrentTabName, , SysTabControl321


If this is the second tab control in your app, you will need to change "SysTabControl321" to "SysTabControl322" and so on.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Calimaw|NotLogged
Guest





PostPosted: Sun Feb 03, 2008 3:50 pm    Post subject: Reply with quote

Thank you, Ill try it out.
Back to top
Calimaw|NotLoggedIn
Guest





PostPosted: Mon Feb 04, 2008 6:46 pm    Post subject: Reply with quote

I've found a nice solution to this, here is an example for others who may run across this topic.

Code:
...
Gui, Add, Text, X16 Y33 W260 H190 vAFEBO
Gui, Show, AutoSize, %GUINAME%

;; Embed HTML Object

GuiControlGet, HWND_AFEBO, Hwnd, AFEBO

Res := DLLCall("cwebpage\EmbedBrowserObject", UInt, HWND_AFEBO)
If (Res != 0 Or ErrorLevel != 0)
GoTo, ExitApp

Res := DLLCall("cwebpage\DisplayHTMLStr", UInt, HWND_AFEBO, Str, HTML)
If (Res != 0 Or ErrorLevel != 0)
GoTo, ExitApp
Return
...


What I've done is create a Text control on Tab 4, which you can see done at the top. I've set the position and size of the control to what I want my embeded object to be sized as.

When adding the Text control on Tab 4 I gave it a variable name of AFEBO (Auto-Fire Embeded Browser Object), then I grabbed the HWND of that control and embeded the object directly to that.

This eliminates the need to create another GUI, embed the browser object to it, and then parent it to the application, since the Text control has already done that, hope this is helpful for others as well.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group