 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
zcriniex
Joined: 23 Aug 2008 Posts: 3
|
Posted: Sat Aug 23, 2008 11:38 am Post subject: How to check window's activity? |
|
|
Here is my first AHK script
| Code: | $F7::
Loop
{
if GetKeyState("F8", "P")
break
ControlSend, , 2, Untitled - Notepad
Sleep, 100
}
Return |
What will happen is, if you hit F7, the 'Untitled - Notepad' will constantly typing out the word 'Apple' until you hit F8 to stop it.
The question is, if I have two 'Untitled - Notepad', one is active, the other is not. How to command it to send the word 'Apple' to the non-active 'Untitled - Notepad' only?
Please help |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Aug 23, 2008 1:07 pm Post subject: Re: How to check window's activity? |
|
|
| zcriniex wrote: | The question is, if I have two 'Untitled - Notepad', one is active, the other is not. How to command it to send the word 'Apple' to the non-active 'Untitled - Notepad' only?
Please help |
This should do it (sorry but no time to test it). | Code: | WinGet, UntitledList, List, Untitled - Notepad
if (UntitledList0 != 2) {
MsgBox, There must be exactly 2 windows titled "Untitled - Notepad" for this script to work
ExitApp
}
$F7::
if IfWinNotActive, ahk_id %UntitledList1%
InActive := UntitledList1
else
InActive := UntitledList2
loop
{
if GetKeyState("F8", "P")
break
ControlSend, Edit1 , Apple, ahk_id %InActive%
Sleep, 100
}
Return
|  |
|
| Back to top |
|
 |
zcriniex
Joined: 23 Aug 2008 Posts: 3
|
Posted: Sat Aug 23, 2008 1:23 pm Post subject: |
|
|
| Anonymous wrote: | | zcriniex wrote: | The question is, if I have two 'Untitled - Notepad', one is active, the other is not. How to command it to send the word 'Apple' to the non-active 'Untitled - Notepad' only?
Please help |
This should do it (sorry but no time to test it). | Code: | WinGet, UntitledList, List, Untitled - Notepad
if (UntitledList0 != 2) {
MsgBox, There must be exactly 2 windows titled "Untitled - Notepad" for this script to work
ExitApp
}
$F7::
if IfWinNotActive, ahk_id %UntitledList1%
InActive := UntitledList1
else
InActive := UntitledList2
loop
{
if GetKeyState("F8", "P")
break
ControlSend, Edit1 , Apple, ahk_id %InActive%
Sleep, 100
}
Return
|  |
Thanks for your reply... Anonymous
But, when I start your code (with 2 untitled notepads opened), the MsgBox came up straight away, then the script exited when I click 'Ok'...
I need your help again...  |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Aug 23, 2008 2:11 pm Post subject: |
|
|
Thanks for your reply... Anonymous
But, when I start your code (with 2 untitled notepads opened), the MsgBox came up straight away, then the script exited when I click 'Ok'...
I need your help again... [/quote]
My bad
| Code: | Replace: if (UntitledList0 != 2) {
with: if (UntitledList != 2) { |
I tested it this time.  |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Sat Aug 23, 2008 4:16 pm Post subject: |
|
|
| Code: | $F7::
Loop
{
if GetKeyState("F8", "P")
break
ActiveWindow := WinExist("A") ;gets id of active window
ControlSend, , 2, Untitled - Notepad, , ahk_id %ActiveWindow% ;exludes the active window
Sleep, 100
}
Return |
This one will basically never send to the active window. |
|
| 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
|