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 

Ok killers another Question!

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



Joined: 19 Jun 2004
Posts: 36

PostPosted: Sun Jun 20, 2004 3:53 pm    Post subject: Ok killers another Question! Reply with quote

Is it possible to send keystrokes to a specific program. For example, I play Shadowbane I duel log on one machine, could I write it into my script to only send keystrokes to just one client, so I could keep it minimized and play on other account. To do this I know for sure I will make two different directorys and name the Shadowbane EXEs to different names. I know it can be done just not sure hows it done with AHk.
Also great work on AHK guys this is a great free program better than some you have to pay for great works and keep it up. I am gonna be getting alot of the macroers on sb to start using this app.

Oh forgot to ask something is there anyway to hot key the scripts to activate on command. I think the answer would be to put a looping program that looks for certain keystroke then activates desired script name its directory is that close?
Back to top
View user's profile Send private message
silentblood



Joined: 19 Jun 2004
Posts: 36

PostPosted: Sun Jun 20, 2004 5:18 pm    Post subject: Reply with quote

Ok I answermyself on the very last question +t:: would cause the sscript to launch when shift+t is keyed.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sun Jun 20, 2004 8:28 pm    Post subject: Reply with quote

Quote:
Is it possible to send keystrokes to a specific program.

The first thing to try is ControlSend, in this order:
ControlSend, , text to send .... ; leave first param blank to send to topmost control.
ControlSend, ahk_parent, text to send ... ; Send directly to the parent window
(You'll need to fill in the other params for the above commands)

If neither of the above work, you can try using PostMessage as in this (working) example:
Code:
Run, wordpad
WinWait, Document -
WinActivate
ControlGetFocus, focused_control
start = 0
Loop
{
   PostMessage, 0x102, %start%, 1, %focused_control%
   ++start
   if start > 600
      break
}

Some games are resistant to automation and might not work with any of the above methods. They might not even work with the Send command itself. All you can do is experiment.

Edit: Uses ControlFocus now since control names vary in different versions of WordPad.


Last edited by Chris on Sun Jul 18, 2004 12:29 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
jamestr



Joined: 05 Apr 2004
Posts: 96
Location: Connecticut USA

PostPosted: Mon Jun 21, 2004 2:52 am    Post subject: Reply with quote

if you have the same program running under 2 different names,
you shold be able to identify them using window ID.

http://www.autohotkey.com/docs/commands/WinGet.htm


Code:

^,::
WinGet, active_id, ID, A
WinGetClass, this_class, ahk_id %active_id%
WinGetTitle, this_title, ahk_id %active_id%
MsgBox, 0, , id - %active_id%`nclass - %this_class%`nName - %this_title%`n
Back to top
View user's profile Send private message
silentblood



Joined: 19 Jun 2004
Posts: 36

PostPosted: Fri Jun 25, 2004 2:56 am    Post subject: Reply with quote

Ok I am getting most things you guys are telling me. This is one that is not making much sense. Someone Show me example of sending keystrokes just to shadowbane. Its name is sb.exe. I need to be able to send keystrokes only it will recieve.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Fri Jun 25, 2004 3:19 am    Post subject: Reply with quote

The examples I gave above are the best ways I know how to do it (if it's possible at all with this particular game). You'll need to find out the title, class, or ID of the target window to use those examples. Most of that info can be discovered with Window Spy, which can be launched from the tray menu. If it's a full screen game, create a hotkey that runs WinGetClass and/or WinGetTitle when you press a hotkey and puts the text on the clipboard:

#z::WinGetClass, clipboard, A

Then press the hotkey while in the game, and the class name should now be on the clipboard.

If you have two windows that have the same title, text, and class, you'll need to get their IDs with WinGet as jamestr mentioned above.

Of course, you can also use the Send command to send keystrokes directly to the active window.
Back to top
View user's profile Send private message Send e-mail
silentblood



Joined: 19 Jun 2004
Posts: 36

PostPosted: Fri Jun 25, 2004 6:02 am    Post subject: Reply with quote

^,::
WinGet, active_id, ID, A
WinGetClass, this_class, ahk_id %active_id%
WinGetTitle, this_title, ahk_id %active_id%
MsgBox, 0, , id - %active_id%`nclass - %this_class%`nName - %this_title%`n



Ok I ran that and it gave me the following information

id-0x80050
class-opengl
name-shadowbane




Now I know this is proably a dumb question but what do I do with that information.
Back to top
View user's profile Send private message
beardboy



Joined: 02 Mar 2004
Posts: 444
Location: SLC, Utah

PostPosted: Fri Jun 25, 2004 6:52 am    Post subject: Reply with quote

If you have two instances of shadowbane running you are going to have to decide which one to send the key strokes to. I have a script that ends up having two windows that are the same name and same class so I also had to seperate them by ID. Here is an example of how to send seperate key strokes to the different windows.

Code:
WinGet, windowlist, list, shadowbane ; Get list of shadowbane Window ID's
Loop, %windowlist%
{
  StringTrimRight, windowid, windowlist%a_index%, 0
  if a_index = 1
    ControlSend,, abc, ahk_id %windowid%; Send abc to first shadowbane window
  if a_index = 2
    ControlSend,, def, ahk_id %windowid%; Send def to second shadowbane window
}

thanks,
beardboy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Fri Jun 25, 2004 12:52 pm    Post subject: Reply with quote

Quote:
what do I do with that information

Experiment with these (the first was illustrated above by beardboy):
ControlSend, , text to send .... ; leave first param blank to send to topmost control.
ControlSend, ahk_parent, text to send ... ; Send directly to the parent window
(You'll need to fill in the other params for the above commands)

If neither of the above work, you can try using PostMessage as in this (working) example (see my earlier post above).
Back to top
View user's profile Send private message Send e-mail
silentblood



Joined: 19 Jun 2004
Posts: 36

PostPosted: Sat Jun 26, 2004 10:53 pm    Post subject: Reply with quote

ControlSend,,%Stance% , Shadowbane



That is a copy of the command I am using now it does pretty much what I want it to using that. Only thing it did so far I didn't like was I was on the website called shadowbane and it froze my macro till I left the site. Any Ideas.
Back to top
View user's profile Send private message
jamestr



Joined: 05 Apr 2004
Posts: 96
Location: Connecticut USA

PostPosted: Sun Jun 27, 2004 12:34 am    Post subject: Reply with quote

you want to distinguish between the website vs the game?

(both named shadowbane)?

you should be able to identify the website browser window and then use a ifwinactive command.

ifwinactive, Shadowbane -


the '-' makes the window unique

Back to top
View user's profile Send private message
silentblood



Joined: 19 Jun 2004
Posts: 36

PostPosted: Mon Jun 28, 2004 4:37 am    Post subject: Reply with quote

Ok I got it working just how I needed it to. Here is how I ended up doing it just for reference.


WinGet,SBID, ID,A

This is outside of my infinite loop in the top of my macro so it only checks once when you first start the macro. You must be in the the client you want to bind the macro to when you hotkey start the macro. It will then bind to the current SB Client windows ID number. You can then use the following to do direct input to the windows ID number.

ControlSend,,%CombatKey% , ahk_id %SBID%

This enters whatever the person has set as there combat key in the ini file and sends it to binded client. You can do as many client ahk binds as you want just got to do one at a time.
Back to top
View user's profile Send private message
jantzen05



Joined: 20 Aug 2004
Posts: 8

PostPosted: Fri Aug 20, 2004 12:37 pm    Post subject: Reply with quote

I am trying to make a macro like yours, is it possible that I could get yours?
Back to top
View user's profile Send private message MSN Messenger
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