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 

How to check window's activity?

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



Joined: 23 Aug 2008
Posts: 3

PostPosted: Sat Aug 23, 2008 11:38 am    Post subject: How to check window's activity? Reply with quote

Here is my first AHK script Very Happy
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
View user's profile Send private message
Guest






PostPosted: Sat Aug 23, 2008 1:07 pm    Post subject: Re: How to check window's activity? Reply with quote

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
Smile
Back to top
zcriniex



Joined: 23 Aug 2008
Posts: 3

PostPosted: Sat Aug 23, 2008 1:23 pm    Post subject: Reply with quote

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
Smile

Thanks for your reply... Anonymous Smile
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... Embarassed
Back to top
View user's profile Send private message
Guest






PostPosted: Sat Aug 23, 2008 2:11 pm    Post subject: Reply with quote

zcriniex wrote:

Thanks for your reply... Anonymous Smile
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... Embarassed[/quote]

My bad Sad

Code:
Replace:  if (UntitledList0 != 2) {
with:     if (UntitledList != 2) {


I tested it this time. Very Happy
Back to top
Krogdor



Joined: 18 Apr 2008
Posts: 1145
Location: The Interwebs

PostPosted: Sat Aug 23, 2008 4:16 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
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