AutoHotkey Community

It is currently May 27th, 2012, 9:09 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 70 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject:
PostPosted: February 14th, 2006, 4:13 pm 
Offline

Joined: February 12th, 2006, 11:55 pm
Posts: 16
I saw your link from wcreplays.com (this is grom_icecream). I'm glad to see I'm not the only one interested in advanced hotkeys, so excuse this post if it seems like an overload of questions :)

Do you still need help with

Quote:
1. add a selected unit to control group 1 by pressing LAlt-1. Never mind ... pressing Shift-1 already works in the game.

2. highlight units nearby the mouse cursor key by pressing one key. Autohotkey script could probably use LButton and move mouse to highlight a box of 200 pixels width and height around the original cursor location. Maybe a second key to do it with a larger box.

3. highlight units nearby a selected unit by pressing one key (Ctrl-c centers on the unit temporarily). Autohotkey script could probably press Ctrl-C, center the mouse and then use a similar feature in (2) above.


? I'm still trying to understand what you are trying to accomplish with this. Basically the point is for your script to accomodate keeping your mouse near the center of the screen? I'm wondering if maybe your mouse speed isn't set high enough if this is that important, but maybe I just never noticed how much time I waste moving my mouse.

Although I doubt this will be of concern for your script, one thing to keep in mind about wc3 when it centers on a unit: the exact pixel coordinates of the unit after centering will vary significantly with small changes in height and location. I can''t find a reliable way to, say, move the mouse exactly onto a particular unit that is known to the script only by a hotkey.

I see you are using 1234/QWER for your main fingers with Tab replacing control. I used to do the exact same thing since I figured such a position was ideal for minimizing finger movement. I found though that I had to leave the desired "Tab-Q-W-E" finger position too often to reach shift or building keys though. Recently I tried abandoning the keys 1-9 all together. I'm using (with my ring and middle finger) the keys A, S, Q, W, E for 1-5 and nothing for 6-0. D, X, C, F are used for all "grid key" buttons (only the important ones). Shift works as Shift, Control and other functions (although I'm not so sure if I want to keep it like that). I've also found a way to make all building hotkeys QWER, ASDF, ZXC without interfering with everything else.

I've been thinking lately on how to improve control group keys. 99% of the time when I assign a control group it is because I want to add one more unit to the group (i.e., a freshly made unit that is rallied to my hero). I also noticed that instead of shift clicking the new unit into the group (which is the way I always imagine myself doing it when I write my scripts) in practice I often find myself just double click/control clicking any unit of that unit's type so I don't even have to *find* the new unit in the first place. I think this script will help streamline control group micro by using that idea:

Code:
1 & LButton::
Keywait, LButton
Send, {Shift down}
MouseClick, Left,,,2
Send, {Shift up}
Send, ^1
return


The only downside is that by making a "1 & something" hotkey you slow the responsiveness of just the "1" key by itself. If you have an extra Xbutton within finger reach that you aren't using then this script would work better:

Code:
XButton & LButton::
Keywait, LButton
Send, {Shift down}
MouseClick, Left,,,2
Send, {Shift up}
Send, ^%group%
return


where "group" is a variable which keeps track what control group is selected at all times (which is very handy for other things too).


Last edited by dosboot on February 15th, 2006, 1:11 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2006, 6:21 pm 
Offline

Joined: February 5th, 2006, 6:55 am
Posts: 35
Quote:
Do you still need help with ...

Yes, but not urgent. When units are moving fast, or in close proximity to each other, or hiding behind things, then selecting/finding them takes longer. Especially when I have to wait for the mouse left button to be released, not just pressed. I would not assign this feature to pressing the button down since that is already for highlighting with a box. Thanks for checking if the mouse has problems centering on the screen or not. Luckily, the center location does not have to be exact as long as a good size box highlights units nearby.

Your suggestion for 1-LButton is excellent. 1 by itself no longer works when pressed down, but can be used when 1 is released. Since we always release the numbers anyway before doing other things, then we have not wasted much time. If double pressing 1 still works too, then the feature is even better.

Like you, I love to double-click a unit to select many at once.

I use Tab 0-9 for replacements, but your suggestion for Tab-12345QWERT sounds like a good idea since closer. I use all ten groups because I access lots of units and buildings. Your suggestion to use %group% is clever too, but I feel safer if I actually press a number during an action so I do not accidently loose groups. Using Shift for things other than waypoints seems logical, but I feel safer not to. I found something that I could not do once I reassigned Shift, but I can not remember right now ...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2006, 1:45 am 
Offline

Joined: February 12th, 2006, 11:55 pm
Posts: 16
Actually what I meant about the "Tab 1234/QWER" configuration was that you would map important command keys (hero spells, unit spells, unit abilities) to QWER. With 1234 and Tab nearby, this puts nearly all the commonly used hotkeys within close proximity.

Here is an improved version of the "1 & LButton" script that won't affect how 1 functions and won't cause any lag in either button (that I can tell). Basically I coded the hotkey in a stupid way. Instead of using the "1 & LButton" structure I manually check the state of "1" when LButton is pressed. The problem with the "1 & LButton" structure is that program wants to wait a few milliseconds after "1" is pressed to see if you are tyring to press "1 & LButton" or just 1 alone.

Code:
$*LButton::
MouseClick, Left, , , , , D
GetKeyState, state1, 1, P
GetKeyState, state2, 2, P
GetKeyState, state3, 3, P
GetKeyState, state4, 4, P
if(state1 == "D" or state2 == "D" or state3 == "D" or state4 == "D")
{
Send, {Shift down}
MouseClick, Left, , , , , U
Send, {LButton}
Send, {Shift up}
Send, ^%group%
}
return

$*LButton up::MouseClick, Left, , , , , U


If you don't want to use the group variable then replace that line with some IF blocks to send the right key. If you do want to use the group variable you need to add this to your script too:

Code:
~1::group = 1
~2::group = 2
~3::group = 3
~4::group = 4


I haven't tested the script with all ten "GetKeyState, state, X" lines, hopefully it won't affect the speed.

The reason I use the group variable is because it allows for some really cool burrow/hide micro (or even return lumber/stone form micro). With a single button click you single out one injured unit, order it to burrow/hide etc., optionally remove it from the control group, then reselect the original group with lightning speed!

Code:
;Quick Burrow Script

+MButton::
Keywait, MButton
Send, {LButton}
Send, c
Send, %group%
return

;Quick Hide Script (removes from control group)
;Note: This script was hard to get right.  If it doesn't work try tweaking
;the Sleep command
;The snag seems to be that if you press ^1 quickly followed by left click
;on a unit in group 1 then wc3 treats it as a double click on that unit

Space & MButton::
Keywait, MButton
Send, {Shift down}
MouseClick, left
Send, {Shift Up}
Send, ^%group%
Sleep, 500
MouseClick, left
Send, c
Send, %group%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2006, 5:10 am 
Offline

Joined: February 5th, 2006, 6:55 am
Posts: 35
The code is not stupid at all. Chris at tech support said that kind of method is good to avoid problems with prefixes. For example, see, http://www.autohotkey.com/forum/viewtopic.php?t=7688

The sleep between mouse clicks may be tricky as you noticed since the game sometimes ignored them. Try to add the "D|U" parameter to MouseClick to control the button more precisely. It helped me before.

Meanwhile, I will check it out the rest and see what's up. Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2006, 7:50 am 
Offline

Joined: February 12th, 2006, 11:55 pm
Posts: 16
You misunderstood. I didn't mean the original hotkey using the "1 & LButton" structure was stupid, I was saying that not doing it that way by manually creating a prefix key with the GetKeyState function would appear at first to be a stupid idea. I couldn't find in that link what potential problems could arise from this. I would think the only problem with making a prefix key like that is pressing LButton sends a mouse click first, then asks the question "is this a 1 & LButton press?" later. For this specific hotkey though the errant mouse click is of no consequence, and in fact it is incorporated as part of what we want "1 & LButton" script to do.

For that last piece of code, using down/up events didn't seem to help. I'm not 100% sure what you mean though, so maybe you could give it a try.

And while I'm at it: a heads up on the quick burrow script, it doesn't work properly. I actually didn't test it the way I wrote it up there. You see until yesterday it was just one block in a bigger MButton script. For some reason it is going too quickly now; what happens is sometimes (depending on whole long you held MButton apparently) you'll just select the fiend then select the whole group with no burrow in between. You need a pretty high Sleep, x to fix it too. The following script however is completely reliable and quick:

Code:
+MButton::
Keywait, MButton
BlockInput, On
Send, {Shift Up}
Send, {Shift Up}
Send, {Shift Up}
MouseClick, left
BlockInput, Off
Send, c
Send, %group%
return


I think the problem may just be the rest of my script. I'm using Shift for a lot of different functions so there may just be an unforseen interaction going on.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2006, 11:22 pm 
Offline

Joined: February 5th, 2006, 6:55 am
Posts: 35
Quote:
Points says, ScrollLock: holds down the left mouse button to follow (if you put the cursor over the heros picture for example you can then follow the hero, I use this in replays ...

The "Follow Code" idea is working well. Maybe expand it to include any selected units, shown in code below. Maybe there used to be other code for a Ctrl+C utility that no longer exists at,
http://www.wcreplays.com/forums/showthread.php?t=5423

Code:
; Scrolllock to follow the hero. Press again to stop following.
; Ctrl-C to follow selected unit while held. Mouse and right-button changes units direction (assuming only one unit is selected).

FollowOn := False
TrackCenterView := False
SetTimer, timer_centerview, off ; off until needed

;------------------------------
; Center view continuously
;------------------------------
timer_centerview:
{
  ifWinActive, Warcraft III
  {
    GetKeyState, tempstate, c, P
    If (tempstate = "D" and TrackCenterView == True) {
      Send, {blind}{c up}
      Send, {blind}{c down}
      ;Send, {blind}{Ctrl up} ; not needed

    } else {
      ; cancel
      SetTimer, timer_centerview, off
      Send, {blind}{c up}
      TrackCenterView := False
    }
  }
}
OnExit, ExitSub
return

;------------------------------
; Scroll Lock to toggle follow mode (useful in replays)
; The mouse must already be positioned over the hero icon.
;------------------------------
*ScrollLock::
; (same as the code you provided on Jan 17, 2006)
Send, {Blind}{ScrollLock} ; toggle the light
if FollowOn
  Send, {LButton Up}
else
  Send, {LButton Down}
FollowOn := not FollowOn
return

;------------------------------
; Ctrl-C to center view continuously while being held.
;------------------------------
^c::
if (TrackCenterView == False) { ; first call, since holding key repeats script continuously
  SetTimer, timer_centerview, 0 ; fast
  TrackCenterView := True
}
return


Last edited by jtbalogh on February 17th, 2006, 11:47 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2006, 11:31 pm 
Offline

Joined: February 5th, 2006, 6:55 am
Posts: 35
Quote:
dosboot says, heads up on the quick burrow script ...

Your quick burrow/hide/statue/root script is better now. Too bad it only works on a few units though. When a group is given another action, these few units luckily do not return to the group. Are we assuming all burrow/hide/statue/root are activated by pressing 'c'? Would have been nice to just tell any unit to run for their lives temporarily and come back when feeling better.

Quote:
dosboot says, "1 & LButton" script ...

Your "Add to Control Group" idea gave me an idea to build the following code. Press #, then #-LButton to add units. Press #, then #-RButton to add/remove units. Pressing # first helps show the affected group before changed accidently.

Code:
;------------------------------
; #, #-LButton to see group for verification and then add unit to group.
; #, #-RButton to see group for verification and then add/remove unit to group.
; # selects a group as usual, but only when released since it is a prefix.
; ## center on a group as usual.
;------------------------------
1 & LButton::L1routine(1) ; add to group
2 & LButton::L1routine(2)
3 & LButton::L1routine(3)
4 & LButton::L1routine(4)
5 & LButton::L1routine(5)
6 & LButton::L1routine(6)
7 & LButton::L1routine(7)
8 & LButton::L1routine(8)
9 & LButton::L1routine(9)
0 & LButton::L1routine(0)

1 & RButton::R1routine(1) ; add/remove to group
2 & RButton::R1routine(2)
3 & RButton::R1routine(3)
4 & RButton::R1routine(4)
5 & RButton::R1routine(5)
6 & RButton::R1routine(6)
7 & RButton::R1routine(7)
8 & RButton::R1routine(8)
9 & RButton::R1routine(9)
0 & RButton::R1routine(0)

*1::Send, {Blind}1 ; send prefix as is, after button is released though
*2::Send, {Blind}2
*3::Send, {Blind}3
*4::Send, {Blind}4
*5::Send, {Blind}5
*6::Send, {Blind}6
*7::Send, {Blind}7
*8::Send, {Blind}8
*9::Send, {Blind}9
*0::Send, {Blind}0

L1routine(group)
{
  MouseClick, Left ; highlight unit where cursor is
  Send, {Shift down}%group%{Shift up} ; add unit to group
  ;Sleep 100 ; not needed
  Send, %group% ; see resulting group

  ; remove from all other groups so no duplicates
  ; (not possible)
}
return

R1routine(group)
{
  Send, %group% ; select group so we do not loose it
  Send, {Shift down}
  MouseClick, Left ; toggle to highlight or deselect unit where cursor is
  Send, {Shift up}
  Send, ^%group% ; add result to group
  ;Send, {Ctrl down}%group%{Ctrl up} ; fails, since Ctrl sometimes stuck
  ;Sleep 100 ; not needed
  Send, %group% ; see resulting group
}
return


Quote:
dosboot says, The problem with the "1 & LButton" structure is that program wants to wait a few milliseconds after "1" is pressed to see if you are tyring to press "1 & LButton" or just 1 alone.

I do not understand. The FAQ does not mention a problem with combinations like "1 & LButton::". If "1" is a prefix, then programs ignore it until released. No waiting that I can see. See FAQ - Custom combinations at,
http://www.autohotkey.com/docs/Hotkeys.htm

Thanks for all your help.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2006, 6:23 am 
Offline

Joined: January 18th, 2006, 12:37 am
Posts: 290
On a related note:

The program Warkeys, which is supposed to act as a replacement for Keycraft, is now available for download here:

http://www.autohotkey.com/forum/viewtopic.php?p=46507

Here's a small taste:
Image

It's still in the alpha stages, but I welcome any feedback you may have. If you would like to report an error, please use the email link in the about window under help.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Ctrl+c
PostPosted: February 20th, 2006, 12:08 am 
Offline

Joined: February 20th, 2006, 12:00 am
Posts: 1
Points,

Awesome program man! I was actually writing a script in C++ to do this, but I think I'm going to trash that now ;) The one thing that would be nice would be the addition of a ctrl+c spammer for watching replays. When u spam ctrl-c replays become more like VoD's and so this is very desirable. I tried toggling the ScrLk key but it didn't do this. Any chance of adding this? If not, maybe I could learn the language you used and add it myself.

Thanks,

Sephrial


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2006, 5:34 am 
Offline

Joined: January 18th, 2006, 12:37 am
Posts: 290
I'm not exactly what Ctrl-C does in replays but if you wish to spam ctrl-c you can use autohotkey to write a script.

Code:
SetTimer, UpdateCtrlC, 250 ; updates every 250 msec

UpdateCtrlC:
Send, ^c
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2006, 8:06 am 
Offline

Joined: February 12th, 2006, 11:55 pm
Posts: 16
Nice work with warkeys, haven't tried it yet but I am planning to try it soon.

Quote:
Your quick burrow/hide/statue/root script is better now. Too bad it only works on a few units though. When a group is given another action, these few units luckily do not return to the group. Are we assuming all burrow/hide/statue/root are activated by pressing 'c'? Would have been nice to just tell any unit to run for their lives temporarily and come back when feeling better.


Yea, I'm assuming all those actions have been bound to 'c'. It might actually be possible to tell a unit to run home like this. All the user would need to do is define a "home" location on the minimap (via hotkey) at the start of the game.

Quote:
I do not understand. The FAQ does not mention a problem with combinations like "1 & LButton::". If "1" is a prefix, then programs ignore it until released. No waiting that I can see. See FAQ - Custom combinations at,


That makes much more sense now, I must have just been noticing the time difference between key press and key release.


Here is a new script of mine. When you double click on any hero you will select all heroes you control, a lot like double clicking on units. The difference is you will select all heroes, not just heroes on the screen. This is my first warcraft script using PixelGetColor to achieve new functionality.

Basic program outline: The program knows if you clicked a hero by looking for the "hero damage type" icon. The script shift clicks heroes using the portraits in the upper left corner. To check whether or not there actually is a hero portrait there it looks for a tooltip which appears on the lower right when you mouse over a hero portrait. This requires Advanced Tooltips to be checked ON in the options menu. Finally, the script determines if it added or removed that hero by looking at the portraits on the bottom HUD.

Code:
;;;;;;;;;;;;;;;;;;
;Function which returns 1 if x and y are approximately the same color,
;and 0 otherwise.  x and y are hexadecimal values in the form PixelGetColor
;spits out.  t is the tolerance, ranging from 0-256.  t=0 means x and y
;must be exactly the same, 256 means the function always returns 1

ColorEqual(x,y,t)
{
x += 0
y += 0

x1 := Floor(x/65536)
y1 := Floor(y/65536)
x2 := Floor((x-x1*65536)/256)
y2 := Floor((y-y1*65536)/256)
x3 := (x-x1*65536-x2*256)
y3 := (y-y1*65536-y2*256)

z1 := x1-y1
z1 := x2-y2
z1 := x3-y3

if (Abs(z1) <= t) and (Abs(z2) <= t) and (Abs(z2) <= t)
return 1
else
return 0
}


$LButton::
Send, {LButton down}
if (A_TimeSincePriorHotkey <= 150) and (A_PriorHotkey == "$LButton up")
{
PixelGetColor, color, 409, 679 ; looks at the damage type icon
if(color == 0x5FFAFF)
{
Keywait, LButton
MouseGetPos, X1, Y1
   i := 0
   Loop,3
   {
      y := 62 + i*65
      x := 418 + i*38
      MouseMove, 32, %y%, 0 ; move to a hero icon at the upper left
      PixelGetColor, color, 745, 540 ; look for the tooltip on the bottom right
      if(ColorEqual(color,0x238AAC,3) == 1)
      {
         Send, +{LButton}
         Sleep, 10
         PixelGetColor, color, %x%, 663 ; look at the bottom HUD portraits
         if(color == 0x000000) ; if black we removed someone from the group, so add them back in
            Send, +{LButton}
      }
      Sleep, 10
      i := i + 1
   }
MouseMove, %X1%, %Y1%, 0
}
}
return

$LButton up::
Send, {LButton up}


Since the program works by looking at pixels it needs to know the right reference colors. This could vary from user to user due to different gamma settings. Here is a test program to find your reference colors.


Code:
;;;;;Program to find your reference colors
;
;Select a hero and no other units.  Mouse over the hero portrait in the upper
;left so a tooltip appears in the lower right.  Press u.  Alt-Tab out,
;press Shift u, and write down the values.  Replace 0x5FFAFF with color 1
;and replace 0x238AAC with color 2
u::
PixelGetColor, color1, 409, 679
PixelGetColor, color2, 745, 540
return

+u::
MsgBox Color1 is: %color1%, Color2 is: %color2%
return


I'm thinking that using pixels will open up a brand new level of warcraft scripts. The quick burrow/hide ( /run home?) script, for example, could be comibined into one hotkey by looking at what type of unit was selected. I'm working on a "AMS everyone" script, and using pixels will be vital to know who is already AMS'ed.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2006, 7:44 pm 
Offline

Joined: January 18th, 2006, 12:37 am
Posts: 290
I recommend using Warkeys to change all of your home commands to 'c'. :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2006, 10:36 pm 
hi. good thread.
I actually downloaded this program for w3 also so I am pleased to see it is being discussed on the forums. I am trying to make my own script, specifically to do the space+wasd stuff mentioned halfway through this thread. I asked for some help in http://www.autohotkey.com/forum/viewtopic.php?t=8190

The question there isn't specific to warcraft because I wanted to keep it general. Can something like this not be done.
When space is pressed, do the following:

a::Left
s::Down ..etc

then when space is released:

a::a
s::s etc..


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2006, 10:44 pm 
something like this:

Code:
^Space::Space ; Ctrl-Space replaces Space to center on events.

Space::

w::up
a::left
s::down
d::right

return

Space up::
w::w
a::a
s::s
d::d
return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2006, 11:15 pm 
Offline

Joined: February 12th, 2006, 11:55 pm
Posts: 16
Autohotkey has a prefix structure to handle exactly this. So you would do

Code:
Space & w:: <action>


to make space w do something but leave w alone. ('common' prefixes like shift, control, alt and some others have their own special strucutres. You would write +w::, ^w::, and !w:: respectively for those prefixes.)

So I think what you are looking for is this (just a modified version of jtbalogh's code):

Code:
Space & w::   Send, {Up down}
Space & w up::Send, {Up up}
Space & a::   Send, {Left down}
Space & a up::Send, {Left up}
Space & s::   Send, {Down down}
Space & s up::Send, {Down up}
Space & d::   Send, {Right down}
Space & d up::Send, {Right up}


Here "Space & w up::" binds an action to the release of w while space is held down.

I think you would have to do

Code:
$^Space::Space


in order to make Ctrl-Space just Space. The $ tells the script to utilize a keyboard hook, which means that this hotkey cannot be simulated with other hotkeys (otherwise the space you are trying to send might get interpreted as a control space and you'd have an infinite loop).


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 70 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Rajat and 7 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group