Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

TO: not-logged-in-daonlyfreez :) Quick question


  • Please log in to reply
8 replies to this topic
Andrews
  • Guests
  • Last active:
  • Joined: --
Pls. check my last post under:

http://www.autohotke...5305.html#85305

(for some reason my post didn't bubble to the top of the post stack, maybe there is a bug when multiple pages under the post exist) :)

Andrews
  • Guests
  • Last active:
  • Joined: --
Or can someone please see how this can work (to answer my question at the bottom of the other link) :D :D Best regards

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

Or can someone please see how this can work (to answer my question at the bottom of the other link)


Find the following part on that script:

Gui, 2: +LastFound 
DllCall("SetParent", "uint", WinExist(), "uint", mainGuiHandle)


Insert a line in between, like

Gui, 2: +LastFound 
[color=green]GUI2_ID := WinExist()[/color]
DllCall("SetParent", "uint", WinExist(), "uint", mainGuiHandle)


Now to ControlSend characters you may do it like:

ControlSend,,  {TAB}, ahk_id %GUI2_ID%

Hope I was clear...

:)
kWo4Lk1.png

Andrews
  • Guests
  • Last active:
  • Joined: --
Very clear and perfect :) :) Thank you! I had one related question I hope to work off of. What is the technique for determining which GUI is 'clicked on' or active at any given moment? What I hope to do is set some var x to 0 or 1 depending if GUI 1 is clicked, or GUI 2 is clicked, and use that VAR elsewhere in a IF then type routine. Hopefully my explanation and wish is understandable. :) Thank you for helping me. :)

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

What is the technique for determining which GUI is 'clicked on' or active at any given moment? What I hope to do is set some var x to 0 or 1 depending if GUI 1 is clicked, or GUI 2 is clicked, and use that VAR elsewhere in a IF then type routine.


I find the question a bit tricky! When you click a regular control ( like a button/text/picture etc ) AutoHotkey's built-in variable A_Gui will contain the GUI number!

But you cannot determine which GUI ( or none of them ) is active without clicking a control. A_GUI will be null then. I know of a way to automatically set a variable with the GUI number, which I have preserved for my TipsNTricks and I doubt whether anyone would really need it!

Please clarify your actual requirement!

:)
kWo4Lk1.png

Andrews
  • Guests
  • Last active:
  • Joined: --
Let's say you have

gui, 1:
....

gui, 2:
....

gui, 3:
....

In my scenario, if someone clicks on a GUI control , and then issues a hotkey command, like:

Esc::
If GUI1 = clicked
{
do something
}
If GUI2 = clicked
{
do something
}
If GUI3 = clicked
{
do something
}
Return

It would work in the above sort-of-theory, or something like it to achieve the effect :) :?:

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
GUI, 1:Show, x10  y10 w300 h300, GUI #1
GUI, 2:Show, x320 y10 w300 h300, GUI #2
GUI, 3:Show, x630 y10 w300 h300, GUI #3

GUI# := 3
OnMessage(0x06, "WM_ACTIVATE")
Return

^F2::MsgBox, 64, Active GUI, Active GUI: %GUI#%

WM_ACTIVATE(wParam) {
Global GUI#
GUI# := A_GUI
IfWinNotActive, % "ahk_pid " DllCall("GetCurrentProcessId")
  GUI# := 0
GoSub, Routine
Return
}

Routine:
/*
Your if statements go here

If (Gui# = 1)
   .........
If (Gui# = 2)
   .........
If (Gui# = 3)
   .........
*/
Return

GuiClose:
2GuiClose:
3GuiClose:
 ExitApp
Return

Active-GUI status will be always available in variable named GUI# which you can view by pressing ^F2
As said earlier, I had saved this for my TipsNTricks, but decided to post it here!

Regards, :)
kWo4Lk1.png

daonlyfreez
  • Members
  • 995 posts
  • Last active: Jan 23 2013 08:16 AM
  • Joined: 16 Mar 2005
Ah, thanks again, Goyyah! 8)
Posted Image mirror 1mirror 2mirror 3ahk4.me • PM or Posted Image

Andrews
  • Guests
  • Last active:
  • Joined: --
It's all good Goyyah thanks so much :p