AutoHotkey Community

It is currently May 27th, 2012, 6:38 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: February 28th, 2011, 9:40 pm 
oops.

A typo. Serves me right for not testing the whole thing. the water shild (3) was not working...

Sorry 'bout the double post. I should create an account so I can edit my posts.

Code:
#SingleInstance force

#NoEnv

Process,Priority,qmagicka,High
;This works!!! for using send
SetKeyDelay , 25, 75
SetMouseDelay, 50
;this is necessary because magicka expects keys to be pressed for a specific time, this is the smallest interval that works reliably, you can experment more if you want. It seems like you can do it slightly faster when doing it manually
;SetKeyDelay , 0, 65, Play
;http://www.autohotkey.com/forum/viewtopic.php?p=418841#418841

;Fix for Win7 with UAC
if not A_IsAdmin ;if code does not have admin rerun it with them
{
DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, A_AhkPath
, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
ExitApp
}

;settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Default keybindings - you can modify these if you have changed your settings
aoekey      = RButton ;for use with shift for aoe effect use on own for standard cast
selfcastkey = MButton
shiftkey    = LShift ;for use with aoe expression for aoe effect
water       = q
heal        = w
shield      = e
cold        = r
lightning   = a
arcane      = s
earth       = d
fire        = f
; the {@ 2} adds a delay that allows the combo to succeed as it needs a slightly longer delay
; not tested yet
ice         = qr{@ 2}
steam       = qf{@ 2}

;;spells
;From http://www.magickapedia.net/index.php?title=Magicks               
;Using default keyboard shortcuts
;you must have the corresponding magick for it to work, they are gained as described below
; also I've modified some combinations in here to make them work in game, because the delay timings weren't working out exactly. So if you change the delay timings or you computer behaves slightly differently you might have to rever to original combo for those spells.

;another good way I found to add a delay is to append a useless key sequence like so: {p 20}

GreaseInt   :=   false
Grease          =    qdw            ;Chapter 1: Found across the lake, shortly after hearing someone scream. Freeze the lake to get across.     Covers the floor with slippery grease. Burns longer than normal fire when lit.

ReviveInt   :=   false
Revive          =    wa             ;Chapter 1: Obtained at the end of the tutorial.     Revives human players.

HasteInt   :=   false
Haste           =    asf            ;Chapter 1: Required to complete the tutorial. Found on a bookshelf.     Increases the wizards's movement speed.

MeteorShowerInt    :=   false
MeteorShower    =    fdqfdf         ;Chapter 1: Obtained at the start of the ;Chapter. This magick is a DLC bonus for all purchases made before January 31st, 2011.    Conjures several meteors that impact random locations on the screen.

NullifyInt   :=   false
Nullify         =    se             ;Chapter 2: Found beside the altar where a goblin shaman is fought.     Removes status effects from the caster. In addition, this spell cancels some (but not all) spells and magicks cast by other players and creatures. Most notably, the "mirror image" cast by Grimnír after the mind duel.

RainInt      :=   false
Rain            =    qqqf           ;Chapter 2: Found in the first cave you come across that is guarded by goblins.     Causes it to rain, wetting all units on the screen except those with an active shield.

ThunderBoltInt   :=   false
ThunderBolt     =    fqasaa         ;Chapter 3: Found in a henge.     Conjures a bolt that damages the most elevated unit heavily.

TornadoInt   :=   false
Tornado         =    dqfqqqf        ;Chapter 4: Before entering the city on the left of the main path in the trees by a shipwrecked boat.     Summons a large tornado that flings everyone nearby up into the air, causing damage

ConflagrationInt :=   false
Conflagration   =    qffffffqfffq   ;Chapter 4: Inside a burning building you are forced to detour through.     Heat wave that deals 600 damage and sets on fire.

TimeWarpInt   :=   false
TimeWarp        =    re             ;Chapter 5: Head west immediately after leaving the camp.     Slows time down for everyone - including the caster, although possibly by a slightly smaller degree - allowing you to react faster. Doesn't affect M60.

BlizzardInt   :=   false
Blizzard        =    rrrqr          ;Chapter 6: At the beginning of the ;Chapter, go east to the small lake. Use  to get across the water.     Summons a mighty blizzard, chilling everyone - including the caster! - for as long as it lasts (roughly 10 seconds?).

TeleportInt   :=   false
Teleport        =    asa            ;Chapter 7: On the broken walkway, after being transported by Vlad. There's also a way to get this Magick, as early as ;Chapter 1. To do this, you must first place Arcane/Fire mines (  ) near the base of the walkway. Make sure you place them whilst facing away from it. Then, walk over them to get blown up into the air. Some trial and error is to be expected in order for this to work. For further instructions, please see this video of the exploit.     Instantly teleports the caster a short distance forward.

SummonPhoenixInt :=   false
SummonPhoenix   =    waf            ;Chapter 8: After fighting the waves of Goblins and Trolls on a large bridge, keep heading right.     Summons a Phoenix at the casters location, dealing fire damage to everyone nearby and reviving all fallen wizards.

ThunderstormInt   :=   false
Thunderstorm    =    fqfqasaa       ;Chapter 8: Just before the mines, after the first stone bridge (where you talk to Vlad) in a cave (hidden from view).     Thunderbolt, now with 900% more glorious carnage! Effectively a mix of Rain and Thunderbolt, it will begin to rain both water and thunder from the skies, striking at random positions on the battlefield. Use with caution.

RaiseDeadInt   :=   false
RaiseDead       =    qrdsr          ;Chapter 9: After defeating the necromancers in the run-down church.     Summons a few undead ghouls to fight for the caster.

FearInt      :=   false
Fear            =    rse            ;Chapter 9: Found in the first room of the Count's castle on the left sitting on a bookshelf.     Every enemie nearby is scared witless, running in random directions away from the caster for approximately 3 seconds.

CharmInt   :=   false
Charm           =    wed            ;Chapter 9: Found in the first room of the Count's castle on the right leaning on the wooden furniture next to the couches.     The targeted creature temporarily becomes your ally, attacking your enemies.

SummonDeathInt   :=   false
SummonDeath     =    srrqrs         ;Chapter 10: Given to the player after defeating Death.     Summons Death, who will proceed to instantly kill the nearest player or creature with the lowest amount of health remaining.

SummonElementalInt :=   false
SummonElemental =    sedqfs         ;Chapter 11: After defeating the small detachment of dwarves in the second room of the cathedral, go northwest over the narrow bridge. Open the door, and the book will be on a pedestal.     Summons an inactive elemental. To activate the elemental, simply attack it with any element. The elemental will take the form of whichever element touches it first, and will subsequently be healed by that same element.

CorporealizeInt :=   false
Corporealize    =    sqfaes         ;Chapter 11: Given to the player after defeating Fafnir.     Used when fighting Assatur. Also causes any ethereal daemons to materialize and become corporeal.

InvisibilityInt   :=   false
Invisibility    =    seqfs          ;Chapter 11: In the first area, head south along the cliff you find to the east instead of entering the fortress.     Makes the caster invisible. Enemies will no longer actively attack the caster, although arrows, charging enemies and other AoE attacks will still hit the caster. Invisibility ends after casting, attacking, taking damage or colliding with a foe.

VortexInt   :=   false
Vortex          =    qrsqreqr       ;Chapter 12: Given to you after defeating the final boss.     Summons a large vortex that sucks in and crushes anyone careless enough to wander close.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;attack/defence combos
;http://www.magickapedia.net/index.php?title=Spell_Combinations
; you can define them using keys or names;
; eg. surge_c = qqqqq or surge_c := water water water water water
; note the ':' before the equal in the second definition using names, thats to force it to evalue it as an expression
superwetsteamlightning_c = sfqfqfqar
supersteamlightning_c = sfqfqaa
surge_c = qqqqq
blizzardball_c = dqrqrqrqr
coldquake_c = drddd
barrierrock_c = edddd
barrierice_c = eqwd

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;other init
WinWait, Magicka,
IfWinNotActive, Magicka, , WinActivate, Magicka,
WinWaitActive, Magicka,
;selfcast(heal heal)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;;KeyStrings to activate Magicks:
;;These are the elemental combos that activate the Magicks. Users will have to press Space twice to use these, but after used once, the shortcuts will work for them.
::qdw::
    GreaseInt    :=   true
return
::wa::
    ReviveInt   :=   true
return
::asf::
    HasteInt   :=   true
return
::fdqfdf::
    MeteorShowerInt :=   true
return
::se::
    NullifyInt   :=   true
return
::qqf::
    RainInt   :=   true
return
::qfasa::
    ThunderBoltInt :=   true
return
::fqasa::
    ThunderBoltInt :=   true
return
::dqfqqf::
    TornadoInt   :=   true
return
::dfqqqf::
    TornadoInt   :=   true
return
::fqffqffq::
    ConflagrationInt := true
return
::qfffqffq::
    ConflagrationInt := true
return
::re::
    TimeWarpInt   :=   true
return
::rrrqr::
    BlizzardInt   :=   true
return
::asa::
    TeleportInt   :=    true
return
::waf::
    SummonPhoenixInt :=   true
return
::fqfqasa::
    ThunderstormInt :=   true
return
::qfqfasa::
    ThunderstormInt :=   true
return
::fqqfasa::
    ThunderstormInt :=   true
return
::qffqasa::
    ThunderstormInt :=   true
return
::qrdsr::
    RaiseDeadInt :=   true
return
::rqdsr::
    RaiseDeadInt :=   true
return
::rse::
    FearInt   :=   true
return
::wed::
    CharmInt   :=   true
return
::srrqrs::
    SummonDeathInt :=   true
return
::sedqfs::
    SummonElementalInt := true
return
::sedfqs::
    SummonElementalInt := true
return
::sqfaes::
    CorporealizeInt :=   true
return
::sfqaes::
    CorporealizeInt :=   true
return
::seqfs::
    InvisibilityInt :=   true
return
::rqsrqerq::
    VortexInt   :=   true
return
::qrsqreqr::
    VortexInt   :=   true
return
::qrsrqeqr::
    VortexInt   :=   true
return
::qrsrqerq::
    VortexInt   :=   true
return
::rqsqreqr::
    VortexInt   :=   true
return
::rqsrqeqr::
    VortexInt   :=   true
return
::qrsqreqr::
    VortexInt   :=   true
return
::qrsqrerq::
    VortexInt   :=   true
return


;;Shortcuts
#IfWinActive, ahk_class WindowsForms10.Window.8.app.0.33c0d9d

;;;combinations of various actions
; delays are necessary in combos, otherwise they don't work correctly, i've tested these and tweaked the delays a bit

fastmode_combo(){
    spellcast(TimeWarp,TimewarpInt)
    spellcast(Haste,HasteInt)
}
;any other ideas for good combos?
F1:: ;defense_combo() {
    selfcast(heal heal,100)
    ;selfcast(shield,100)
    selfcast(water shield,100)
    spellcast(Haste,HasteInt,500)
    ;spellcast(TimeWarp,TimeWarpInt,500)
    selfcast(barrierrock_c,200)
    ;loadcombo(superwetsteamlightning_c)
    forcebeam(blizzardball_c)
return
F2:: ;freeze_combo() {
    aoe(steam steam steam steam steam,100) ;wet
    aoe(cold cold cold cold cold,100) ;freeze
    aoe(superwetsteamlightning_c) ;destroy
return
F3:: ;freezeall_combo() ; have a shield on!
    selfcast(water shield,100)
    spellcast(Rain,RainInt,2500)
    selfcast(water shield, 100)
    spellcast(Blizzard,BlizzardInt,500)
return
F4:: ;thunder_combo() ;your own awesome thunderstorm!! hold down to continue using it! must have shield on before using it
    selfcast(water shield,100)
    spellcast(Rain,RainInt,2000)
    spellcast(ThunderBolt,ThunderBoltInt,500)
    ;continue casting spell as long as key is held down,
    ; your own thunderstorm!! without the self gibbing!
    While GetKeyState(A_ThisHotkey, "P")
    {
        spellcast(ThunderBolt,ThunderBoltInt,500)
    }   
return

F5::spellcast(Conflagration,ConflagrationInt)
F6::spellcast(Blizzard,BlizzardInt)
F7::spellcast(Tornado,TornadoInt)
F8::spellcast(Invisibility,InvisibilityInt)
F9::spellcast(Fear,FearInt)
F10::spellcast(Charm,CharmInt)
F12::run Z:\Games\Magicka\Magicka.exe
!^r::Reload
;Spells/Magicks
1::spellcast(Haste,HasteInt)
2::spellcast(TimeWarp,TimeWarpInt)
3::selfcast(water shield)
4::spellcast(Rain,RainInt)
5::spellcast(ThunderBolt,ThunderBoltInt)
6::spellcast(Teleport,TeleportInt)
7::spellcast(SummonElemental,SummonElementalInt)
8::spellcast(Corporealize,CorporealizeInt)
9::spellcast(RaiseDead,RaiseDeadInt)
0::spellcast(Vortex,VortexInt)

;attack/defence combos
z::forcebeam(supersteamlightning_c)
x::aoe(supersteamlightning_c)
c::selfcast(shield)
v::selfcast(heal heal)
b::forcebeam(blizzardball_c)
n::loadcombo(superwetsteamlightning_c)
m::forcebeam("sar")
,::resetkeys()

g::selfcast(barrierrock_c)
h::selfcast(barrierice_c)
j::aoe(surge_c)
k::aoe(coldquake_c)

; from  j-Factor @ http://www.reddit.com/r/magicka/comments/fcvi5/macroing_with_autohotkey_dont_do_this_unless_you/
; use with loadcombo
; Melee - mouse button 4
XButton1::
    If GetKeyState("LButton", "P")
        SendEvent {Click up}

    While GetKeyState("XButton1", "P")
    {
        SendEvent +{Click}
    }

    If GetKeyState("LButton", "P")
        SendEvent {Click down}
Return

; AOE - mouse button 5
XButton2::
    SendEvent {Shift down}{Click down right}
    While GetKeyState("XButton2", "P")
    {
    }
    SendEvent {Shift up}{Click up right}
Return


#IfWinActive

;;;typesofattack - utility functions
resetkeys(){
    send {LShift up}{Rbutton up}{Lbutton up}{Mbutton  up}
}

;no clicks - use with xbutton1(melee) or xbutton2(aoe) or right click
loadcombo(str){
    send %str%
}
;right click
forcebeam(str, delay = 0){
    send %str%{Rbutton down}
    sleep delay
}
;shift right click
aoe(str, delay = 25){
    send %str%{LShift down}{Rbutton down}
    sleep 65 ;the sleeps should no longer be necessary if setmousedelay works correctly
    send {Rbutton up}{Lshift up}
    sleep delay
}
;middle click
selfcast(str, delay = 25){
    send %str%{Mbutton down}
    sleep 65
    send {Mbutton up}
    sleep delay
}
;shift left click
imbueweapon(str, delay = 25){
    send %str%{LShift down}{Lbutton down}
    sleep 65
    send {Lbutton up}{Lshift up}
    sleep delay
}
;space
spellcast(str, active, delay = 25){
    if active
    {
        send %str%{Space down}
        sleep 65
        send {Space up}
        sleep delay
    }
}
;;;;;;
;;; End script


Report this post
Top
  
Reply with quote  
 Post subject: Great stuff
PostPosted: March 10th, 2011, 5:37 am 
Hey guys, these are great. I'm still having some trouble with them. They arn't consistant. They only work around 1/3 of the time.

I'm running an Alienware laptop with Win7.

Any advice?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2011, 5:39 am 
Offline

Joined: June 12th, 2008, 10:29 am
Posts: 52
Try playing around with the delays set in the script, that should help with the timings. I had the same problems as well, and lot of experimenting gave me something i was happy with.

The issue is if you make it too long, then there's now advantage. If you make it too short, sometimes it won't work :(.

Have you tried with UAC disabled?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Try this script
PostPosted: May 15th, 2011, 3:03 am 
Offline

Joined: May 15th, 2011, 2:25 am
Posts: 1
vixay wrote:
I have created my own combo list, try it below:


Good stuff here vixay, funny I just went about implementing something for myself and ended up in about the same place. For those of you looking for a boiled down version, maybe this will be helpful- I used a favorite technique of mine, the over-parametrized function, which gives me the illusion of clean code when it's still gross inside due to Magicka's delay reqs:

Code:
domagickaspell(formula,castmode,key)
{
if (castmode=5)
{
SetKeyDelay 75,75
}
else
{
SetKeyDelay 15,65
}
Send %formula%       
if (castmode=1)
{
Send {RButton down}
Keywait,%key%
Sleep,65
Send {RButton up} 
}
else if (castmode=2)
{
Send {Mbutton down}
Keywait,%key%
Sleep,65
Send {MButton up} 
}
else if (castmode=3)
{
Send {LShift down} {Rbutton down}
Keywait, %key%
Sleep,65
Send {LShift up} {Rbutton up} 
}
else if (castmode=4)
{
Send {Lshift down} {LButton down}
Sleep,65
Send {Lshift up} {LButton up}
Sleep,65
Send {Lshift down} {LButton down}
Sleep,65
Send {Lshift up} {LButton up} 
}
else if (castmode=5)
{
Send {Space}

return
}


The arguments are:
Formula: Spell formula as would be entered in game, IE "asf"
Castmode: Specifies normal cast (1), self cast (2), area cast (3), weapon cast (4), or spellbook spell (5).
Key: This is the hotkey used to trigger the event and holds the "casting" button until your hotkey is released. This is important for channeled spells like beams as well as charge-ups like rock or icy shotgun.

So for example I have
1::domagickaspell("sqfqfaa",1,1) to cast a super beam (hold 1 to sustain)
+1::domagickaspell("sqfqfaa",3,1) to cast an aura with the same formula
5::domagickaspell("arse",1,5) to cast ARSE mines
^5::domagickaspell("arse",4,5) to cast ARSE mines from my weapon (on key release)
F15::domagickaspell("fqffqffq",5,null) to cast conflagration (null because hold is irrelevant for special)
Etc...

Vixay- I find it hilarious that we ended up at more or less the same timings. Your script is a little more optimized by adding extra delays in the "spellbook" spells only where truly needed; I slowed them down a little across the board, saving some code breakout at the cost of a little speed.

My current hotkey implementation is this, with the F13-F17 being my keyboard's left-side macro keys. Next time I play with my buddy I'll probably fill out the standard spells a bit more- this is mainly a test:

Code:
F13::domagickaspell("asa",5,null)          ;Teleport
^F13::domagickaspell("asf",5,null)         ;Haste
F14::domagickaspell("qfasa",5,null)        ;Lightning
^F14::domagickaspell("qdw",5,null)         ;Grease
F15::domagickaspell("fqffqffq",5,null)     ;Conflag
^F15::domagickaspell("waf",5,null)         ;Phoenix
F16::domagickaspell("sedqfs",5,null)       ;Summon Ele
^F16::domagickaspell("qrdsr",5,null)       ;Raise Dead
F17::domagickaspell("dqfqqf",5,null)       ;Tornado
^F17::domagickaspell("srrqrs",5,null)      ;Summon death

                                 
1::domagickaspell("sqfqfaa",1,1)            ;Steamy Lightning Beam
^1::domagickaspell("sqfqfaa",4,1)           ;Steamy Lightning Weapon
+1::domagickaspell("sqfqfaa",3,1)           ;Steamy Lightning Nova
2::domagickaspell("eqrqrsa",1,2)            ;Lightning/Icewall
^2::domagickaspell("eqrqrsa",4,2)           ;Weapon Lightning/Iceway
+2::domagickaspell("eqrqrsa",3,2)           ;Lightning/Icewall Full Surround
3::domagickaspell("eqfa",1,3)               ;Steam Lightning Storm
^3::domagickaspell("eqfa",4,3)              ;Weapon Steamy Lightning
+3::domagickaspell("eqfa",3,3)              ;Steam Lightning Storm Full Surround
4::domagickaspell("qfsafe",2,4)             ;Great Shield
^4::domagickaspell("qfsafe",4,4)            ;Same combo on weapon. Why Not?
+4::domagickaspell("qfsafe",3,4)            ;Same combo nova- Mines. 
5::domagickaspell("arse",1,5)               ;Mine Type 1- Chill
+5::domagickaspell("arse",3,5)              ;Mine Type 1 Full Surround
^5::domagickaspell("eqsfa",4,5)             ;Mine Type 2- Kill
+^5::domagickaspell("eqsfa",4,5)            ;Mine Type 2- Full Surround


Cool stuff; I don't think I've done anything you haven't, but I want in on this discussion, so hopefully someone will find something useful here!

Any tips on optimization or further reduction appreciated.
Aes


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2011, 3:30 pm 
I'm a total newb with this program. I can't get the script recorder to recognize my logitech gamepad. I really do prefer gamepad control to mouse for this game, but I can't figure out how to make anything work.

If anyone has a bit of free time I would love if someone could make a sample script that included every axis and button from a logitech game pad. I want to bind the several most used combinations to my num pad.

I'm pretty sure I can edit the script to do what I need once I understand how the script treats the gamepad buttons.


Report this post
Top
  
Reply with quote  
 Post subject: combinations
PostPosted: September 9th, 2011, 12:25 pm 
Offline

Joined: March 13th, 2009, 9:36 pm
Posts: 56
Actually, what should be done here is different. Pressing keys one by one is wrong. It's slow. And often unreliable. Haste/Thunderbolt gets cast only 80% of times with both main scripts here. And we know that manually you can press them faster. Go ahead and try :) So, what's the difference in manual casting? This: you press 2nd key before you release 1st. Can you write it that way? Yup you can. I did it for
Code:
http://www.notdoppler.com/supercrazyguitarmaniacdeluxe3.php
and it works like a charm :)

I'll write few combos like that later on. But I gave ya the idea :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 9th, 2011, 2:10 pm 
Offline

Joined: March 13th, 2009, 9:36 pm
Posts: 56
I've done one :)

Code:
;; tested at chapter 5 - worked flawlessly for me
#NoEnv
#SingleInstance force
Process,Priority,Magicka,High
Process,Priority,Magicka.exe,High
Process,Priority,,Realtime
SetKeyDelay, -1, -1
SetMouseDelay, -1

;Fix for Win7 with UAC
if not A_IsAdmin ;if code does not have admin rerun it with them
{
DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, A_AhkPath
, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
ExitApp
}

;other init
WinWait, Magicka,
IfWinNotActive, Magicka, , WinActivate, Magicka,
WinWaitActive, Magicka,


x::supersteamlightning_c()

supersteamlightning_c(pressDuration=50, delayBetweenKeys=48, delayBetweenPresses=6) {
   ; end configuration: 2 steam, 2 lightning, 1 arcane
   Send, {s Down}
   Sleep, delayBetweenPresses
   Send, {f Down}
   Sleep, delayBetweenPresses
   Send, {q Down}
   Sleep, pressDuration
   Send, {s Up}
   Sleep, delayBetweenPresses
   Send, {f Up}
   Sleep, delayBetweenPresses
   Send, {q Up}
   
   Sleep, delayBetweenKeys
   
   Send, {f Down}
   Sleep, delayBetweenPresses
   Send, {q Down}
   Sleep, delayBetweenPresses
   Send, {a Down}
   Sleep, pressDuration
   Send, {f Up}
   Sleep, delayBetweenPresses
   Send, {q Up}
   Sleep, delayBetweenPresses
   Send, {a Up}
   
   Sleep, delayBetweenKeys
   
   Send, {a Down}
   Sleep, pressDuration
   Send, {a Up}
   
   Send, {LShift down}{Rbutton down}
    Sleep, pressDuration
    Send, {Rbutton up}{Lshift up}
}


My AoE version takes 346 ms to cast while the same AoE in the (2nd) script version already posted takes 765 ms.

That's more than twice as much !!!!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 9th, 2011, 2:56 pm 
Offline

Joined: March 13th, 2009, 9:36 pm
Posts: 56
Alright, here's some more !

Code:
#NoEnv
#SingleInstance force
Process,Priority,Magicka,High
Process,Priority,Magicka.exe,High
Process,Priority,,Realtime
SetKeyDelay, -1, -1
SetMouseDelay, -1

;Fix for Win7 with UAC
if not A_IsAdmin ;if code does not have admin rerun it with them
{
DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, A_AhkPath
, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
ExitApp
}

;other init
WinWait, Magicka,
IfWinNotActive, Magicka, , WinActivate, Magicka,
WinWaitActive, Magicka,


x::supersteamlightning_c()
v::spam3Heal()
z::icering()
c::lightningRay()
1::haste()
2::thunderbolt()

thunderbolt(pressDuration=60, delayBetweenKeys=60, delayBetweenPresses=25  ) {
   ; end configuration: 2 steam, 2 lightning, 1 arcane
   Send, {f Down}
   Sleep, delayBetweenPresses
   Send, {q Down}
   Sleep, delayBetweenPresses
   Send, {a Down}   
   Sleep, pressDuration
   Send, {f Up}   
   Sleep, delayBetweenPresses
   Send, {q Up}
   Sleep, delayBetweenPresses
   Send, {a Up}

   Sleep, delayBetweenKeys
   
   Send, {s Down}
   Sleep, pressDuration
   Send, {s Up}   
   
   Sleep, delayBetweenPresses
   
   Send, {a Down}
   Sleep, pressDuration
   Send, {a Up}   
   
    Sleep, delayBetweenKeys
   Send, {Space Down}
   Sleep, pressDuration
   Send, {Space Up}
   Sleep, 9
}

lightningRay(pressDuration=65, delayBetweenKeys=57, delayBetweenPresses=9) {
   ; end configuration: 2 steam, 2 lightning, 1 arcane
   Send, {s Down}
   Sleep, delayBetweenPresses
   Send, {f Down}
   Sleep, delayBetweenPresses
   Send, {q Down}
   Sleep, pressDuration
   Send, {s Up}
   Sleep, delayBetweenPresses
   Send, {f Up}
   Sleep, delayBetweenPresses
   Send, {q Up}
   
   Sleep, delayBetweenKeys
   
   Send, {f Down}
   Sleep, delayBetweenPresses
   Send, {q Down}
   Sleep, delayBetweenPresses
   Send, {a Down}
   Sleep, pressDuration
   Send, {f Up}
   Sleep, delayBetweenPresses
   Send, {q Up}
   Sleep, delayBetweenPresses
   Send, {a Up}
   
   Sleep, delayBetweenKeys
   
   Send, {a Down}
   Sleep, pressDuration
   Send, {a Up}
   
   ;Send, {Rbutton down}
   sleep, 9
}

haste(pressDuration=63, delayBetweenKeys=64, delayBetweenPresses=10) {
   ; end configuration: 2 steam, 2 lightning, 1 arcane
   Send, {a Down}
   Sleep, delayBetweenPresses
   Send, {s Down}
   Sleep, delayBetweenPresses
   Send, {f Down}   
   Sleep, pressDuration
   Send, {a Up}   
   Sleep, delayBetweenPresses
   Send, {s Up}
   Sleep, delayBetweenPresses
   Send, {f Up}

   Sleep, delayBetweenKeys

   Send, {Space Down}
   Sleep, pressDuration
   Send, {Space Up}
   Sleep, 9
}


icering(pressDuration=56, delayBetweenKeys=52, delayBetweenPresses=7) {
   ; end configuration: 2 steam, 2 lightning, 1 arcane
   Send, {q Down}
   Sleep, delayBetweenPresses
   Send, {r Down}
   Sleep, pressDuration
   Send, {q Up}
   Sleep, delayBetweenPresses
   Send, {r Up}
   Sleep, delayBetweenKeys

   Send, {q Down}
   Sleep, delayBetweenPresses
   Send, {r Down}
   Sleep, pressDuration
   Send, {q Up}
   Sleep, delayBetweenPresses
   Send, {r Up}
   Sleep, delayBetweenKeys
   
   Send, {q Down}
   Sleep, delayBetweenPresses
   Send, {r Down}
   Sleep, pressDuration
   Send, {q Up}
   Sleep, delayBetweenPresses
   Send, {r Up}
   Sleep, delayBetweenKeys
   
   Send, {q Down}
   Sleep, delayBetweenPresses
   Send, {r Down}
   Sleep, pressDuration
   Send, {q Up}
   Sleep, delayBetweenPresses
   Send, {r Up}
   Sleep, delayBetweenKeys
   
   Send, {q Down}
   Sleep, delayBetweenPresses
   Send, {r Down}
   Sleep, pressDuration
   Send, {q Up}
   Sleep, delayBetweenPresses
   Send, {r Up}
   Sleep, delayBetweenKeys
      
   Send, {LShift down}{Rbutton down}
   Sleep, pressDuration
   Send, {Rbutton up}{Lshift up}
   Sleep, 9
}

supersteamlightning_c(pressDuration=55, delayBetweenKeys=52, delayBetweenPresses=7) {
   ; end configuration: 2 steam, 2 lightning, 1 arcane
   Send, {s Down}
   Sleep, delayBetweenPresses
   Send, {f Down}
   Sleep, delayBetweenPresses
   Send, {q Down}
   Sleep, pressDuration
   Send, {s Up}
   Sleep, delayBetweenPresses
   Send, {f Up}
   Sleep, delayBetweenPresses
   Send, {q Up}
   
   Sleep, delayBetweenKeys
   
   Send, {f Down}
   Sleep, delayBetweenPresses
   Send, {q Down}
   Sleep, delayBetweenPresses
   Send, {a Down}
   Sleep, pressDuration
   Send, {f Up}
   Sleep, delayBetweenPresses
   Send, {q Up}
   Sleep, delayBetweenPresses
   Send, {a Up}
   
   Sleep, delayBetweenKeys
   
   Send, {a Down}
   Sleep, pressDuration
   Send, {a Up}
   
   Send, {LShift down}{Rbutton down}
   Sleep, pressDuration
   Send, {Rbutton up}{Lshift up}
   Sleep, 9
}

spam3Heal(pressDuration=70, delayBetweenKeys=126, delayBetweenPresses=70, wPressTime=40) {
   ; end configuration: 1 heal spammed 3 times ultra fast
   Send, {w Down}
   Sleep, wPressTime
   Send, {w Up}
   
   Sleep, delayBetweenPresses
   
   Send, {Mbutton down}
   Sleep, pressDuration
   Send, {Mbutton up}
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   Sleep, delayBetweenKeys
   Send, {w Down}
   Sleep, wPressTime
   Send, {w Up}
   
   Sleep, delayBetweenPresses
   
   Send, {Mbutton down}
   Sleep, pressDuration
   Send, {Mbutton up}
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   Sleep, delayBetweenKeys
   Send, {w Down}
   Sleep, wPressTime
   Send, {w Up}
   
   Sleep, delayBetweenPresses
   
   Send, {Mbutton down}
   Sleep, pressDuration
   Send, {Mbutton up}
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   Sleep, 9
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2011, 1:29 am 
Offline

Joined: September 27th, 2011, 12:49 am
Posts: 15
Hi,

Great thread!

I wanted to play a little with AutoHotKey and saw an opportunity to add a little something.

Basically, I like the idea of Tommmmm of pressing several keys down to accelerate the process of sending the formula. I thought of a way to automate what he is doing in his functions.

So I basically developed a new function called SendFormula that takes the usual formulas in input and automates the process of sending them as fast as possible by sending batches of "key down" events, followed by batches of "key up"events.

My key delays are far from definitive, I am still playing with this stuff.

If you want to compare the speed of this way of doing it, with the tweaked functions of Tommmmm, you should modify the key delays so they are the same in both cases.

If some of the stuff I wrote in in bad form, please do tell me, as I am just beginning to use AutoHotKey!

Code:
#NoEnv
#SingleInstance force
Process,Priority,Magicka,High
Process,Priority,Magicka.exe,High
Process,Priority,,Realtime
SetKeyDelay, -1, -1
SetMouseDelay, -1

;Fix for Win7 with UAC
if not A_IsAdmin ;if code does not have admin rerun it with them
{
DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, A_AhkPath
, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
ExitApp
}

;other init
WinWait, Magicka,
IfWinNotActive, Magicka, , WinActivate, Magicka,
WinWaitActive, Magicka,

pressDuration=40
delayBetweenKeys=40
delayBetweenPresses=25

c::supersteamlightning()
v::corporealize()

return
;end of auto-execute section


GetPressDuration()
{
   global pressDuration
   return pressDuration
}

GetDelayBetweenKeys()
{
   global delayBetweenKeys
   return delayBetweenKeys
}

GetDelayBetweenPresses()
{
   global delayBetweenPresses
   return delayBetweenPresses
}


SendFormula(formula)
{
   ;This function performs an improved version of the Send function.
   ;We try to simulate users that press down several keys really fast, then release them all,
   ;and that then proceed to repeat those 2 steps until their entire formula has been entered in input
   
   ;We do the same thing in this function. We send as many "key down" events as we can. When we detect that we need to reuse
   ;a key that has already been pressed down, we send a batch of corresponding "key up" events that we accumulated so far.
   ;After that, we can then start a new cycle of sending a bunch of "key down" events, followed by a bunch of "key up" events and so on.
   
   keyUpSequence=
   
   Loop, parse, formula
   {
      ;detect case where we are trying to press down a given key for the second time
      if(InStr(keyUpSequence, A_LoopField ) <> 0)
      {
         ;before sending a press down for a given key a second time, first send the "key up" events we accumulated so far
         Sleep, GetPressDuration()
         SendKeyUpSequence(keyUpSequence)
         keyUpSequence=
         Sleep, GetDelayBetweenKeys()
      }
      
      ;send key down event
      Send, {%A_LoopField% Down}
      keyUpSequence.= A_LoopField
      Sleep, GetDelayBetweenPresses()
   }
   
   ;we finished going through the formula, send the last batch of "key up" events we accumulated
   Sleep, GetPressDuration()
   SendKeyUpSequence(keyUpSequence)
}


SendKeyUpSequence(keySeq)
{
   ;iterate through our list of "key up" events and send them all
   Loop, parse, keySeq
   {
      Send, {%A_LoopField% Up}
      Sleep, GetDelayBetweenPresses()
   }
}

supersteamlightning()
{
   SendFormula("sfqafqa")
   Send, {LShift down}{Rbutton down}
    Sleep, GetPressDuration()
    Send, {Rbutton up}{Lshift up}
}

corporealize()
{
   SendFormula("sqfaes")
   Send, {Space down}
   Sleep, GetPressDuration()
   Send, {Space up}
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 29th, 2011, 9:33 pm 
Offline

Joined: September 27th, 2011, 12:49 am
Posts: 15
Here is a more complete script I have come up with, grabbing some features from the other scripts of the thread.

I obviously use my improved SendingFormula function.

I added the concept of specifying a slow or fast casting time, slow being for the formulas that should as exact as possible, spellbooks spells come to mind here. The fast casting should succeed most of time, but 2 elements might be switched around from time to time.

I made it easier for people that want to customize their controls in Magicka (mouse buttons, space bar, shift key).

I added of bunch of combos, some of which might be obsolete now. I am not sure as I have not played a lot with it, I mainly tested if it was working or not.

Have fun!

Code:
#NoEnv
#SingleInstance force
Process,Priority,Magicka,High
Process,Priority,Magicka.exe,High
Process,Priority,,Realtime
SetKeyDelay, -1, -1
SetMouseDelay, -1

;Fix for Win7 with UAC
if not A_IsAdmin ;if code does not have admin rerun it with them
{
DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, A_AhkPath
, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
ExitApp
}


;other init
WinWait, Magicka,
IfWinNotActive, Magicka, , WinActivate, Magicka,
WinWaitActive, Magicka,



;Key Delays                  ;My suggested minimal values for the delays
pressDurationSlow=40          ;min 40
delayBetweenKeysSlow=40       ;min 40
delayBetweenPressesSlow=25       ;min 25
pressDurationFast=40         ;min 40
delayBetweenKeysFast=40         ;min 40
delayBetweenPressesFast=15      ;min 10


;Key bindings, change them to reflect your in game key bindings
basicCastKey = RButton   ;Cast Force/Cast Area - RButton by default
selfCastKey = MButton   ;Cast Self - MButton by default
spellCastKey = Space   ;Boost/Cast magic - Space by default
modCastKey = LShift      ;Shift - LShift by default
attackKey = LButton      ;Move/Attack - LButton by default


;Cast Modes
basic = 1
self = 2
aoe = 3
imbue = 4
imbuse = 5   ;contraction for imbue and use
spell = 6


;Cast speeds
slow = true
fast = false


;Spellbook spells
Grease          =    qdw           
Revive          =    wa             
Haste           =    asf           
MeteorShower    =    fdfqdf         
Nullify         =    se             
Rain            =    qqf           
ThunderBolt     =    fqasa         
Tornado         =    dqfqqf       
Conflagration   =    fqffqffq   
TimeWarp        =    re             
Blizzard        =    rrqr         
Teleport        =    asa           
SummonPhoenix   =    waf           
Thunderstorm    =    fqfqasa       
RaiseDead       =    qrdsr         
Fear            =    rse           
Charm           =    wed           
SummonDeath     =    srrqrs         
SummonElemental =    sedqfs         
Corporealize    =    sqfaes         
Invisibility    =    seqfs         
Vortex          =    qrsqreqr       
CrashDesktop   =    aafw


;beams & novas
ArcaneSteamLightning = qfqfaas
SuperSteamLightning = qfqfqfsa
superWetSteamLightning = qfqfqfsar
SteamElectricExplosion = qfsssa
ArcaneColdLigthning = rsasa

;barriers
SuperExplodingElectricIceWall = eqrqrsa
ExplosiveSlowingLigthningIcicles = qraser
StoneWall = edddd
LigthningIcicles = qreaaa

;mines
ARSEMines = arse

;storms
FrostLigthningStorm = erara
SteamLigthningStorm = qfqfeaa   

;imbue

;general
WaterSurge = qqqqq
ArcaneWaterBall = qfsd
ArcaneColdBall = sdr
Waterquake = ddddq
Freezequake = ddddr

;projectiles
BlizzardBall = dqrqrqrqr
NeedleSpray = qrqrqrsa

;protect/heal
SuperSAFEResistAura = qfsafe
SuperDryAura = qfqfsaer
Heal = wwwww
HealingGlacierMines = qwer
Remedy = qwff
RemedyMines = qweff

; ************************ Hotkeys for magicks ****************************

;DomagickaSpell(formula, cast mode, speed of casting, "beam/charge key", after cast delay)
 
F1::DoMagickaSpell(Teleport,spell,slow,null,500) 
F2::DoMagickaSpell(Haste,spell,slow,null) 
;F3 see combos section for Bullet Time
F4::DoMagickaSpell(Invisibility,spell,slow,null) 
 
F5::DoMagickaSpell(Charm,spell,slow,null)   
F6::DoMagickaSpell(RaiseDead,spell,slow,null,700)     
F7::DoMagickaSpell(SummonElemental,spell,slow,null,700)
F8::DoMagickaSpell(SummonDeath,spell,slow,null,700) 

F9::DoMagickaSpell(Grease,spell,slow,null,1000)
F10::DoMagickaSpell(Conflagration,spell,slow,null,500) 
F11::DoMagickaSpell(Tornado,spell,slow,null,900)   
F12::DoMagickaSpell(Vortex,spell,slow,null,2750) 

t::DoMagickaSpell(ThunderBolt,spell,slow,null,700)       
y::DoMagickaSpell(Corporealize,spell,slow,null,500)     

1::DoMagickaSpell(Heal,self,fast,null)
!1::DoMagickaSpell(HealingGlacierMines,aoe,fast,null)
2::DoMagickaSpell(Remedy,self,fast,null)
!2::DoMagickaSpell(RemedyMines,aoe,fast,null)
3::DoMagickaSpell(SuperSAFEResistAura,self,fast,null)
!3::DoMagickaSpell(SuperDryAura,self,fast,null)

4::DoMagickaSpell(StoneWall,basic,fast,null)
!4::DoMagickaSpell(StoneWall,aoe,fast,null)
5::DoMagickaSpell(LigthningIcicles,basic,fast,null)
!5::DoMagickaSpell(LigthningIcicles,imbuse,fast,null)
6::DoMagickaSpell(ExplosiveSlowingLigthningIcicles,basic,fast,null)
!6::DoMagickaSpell(ExplosiveSlowingLigthningIcicles,aoe,fast,null)
7::DoMagickaSpell(ExplosiveSlowingLigthningIcicles,imbuse,fast,null)
8::DoMagickaSpell(FrostLigthningStorm,basic,fast,null)
!8::DoMagickaSpell(FrostLigthningStorm,aoe,fast,null)
9::DoMagickaSpell(SteamLigthningStorm,basic,fast,null)
!9::DoMagickaSpell(SteamLigthningStorm,aoe,fast,null)

n::DoMagickaSpell(ARSEMines,basic,fast,null)
m::DoMagickaSpell(ARSEMines,aoe,fast,null)



; ******************* Hotkeys for combos of spells **********************
F3::      ;Bullet Time
   DoMagickaSpell(TimeWarp,spell,slow,null,600)
   DoMagickaSpell(Haste,spell,slow,null)
   return

   
;AOE Storm + damage spam : click ALT-v, release ALT, keep pressing v
!v::DoMagickaSpell(FrostLigthningStorm,aoe,fast,null,100)      
v::DoMagickaSpell(SteamElectricExplosion,aoe,fast,null)


z::         ;AOE Spammable Freeze
   DoMagickaSpell(ArcaneWaterBall,aoe,fast,null,300)
   DoMagickaSpell(ArcaneColdBall,aoe,fast,null,300)
   return

!z::      ;AOE Knockdown-Wet-Freeze-Destroy
   DoMagickaSpell(Waterquake,aoe,fast,null,300)
   DoMagickaSpell(Freezequake,aoe,fast,null,300)
   DoMagickaSpell(SteamElectricExplosion,aoe,fast,null,300)
   return
   
^z::      ;Freeze All
   DoMagickaSpell("qe",self,fast,null,100)
   DoMagickaSpell(Rain,spell,slow,null,2750)
   DoMagickaSpell("re",self,fast,null,100)
   DoMagickaSpell(Blizzard,spell,slow,null)
   return
   
   
   
; ************************** Hotkeys for Special Cases ************************
; This section contains hotkeys that have quirky behavior. Because I use the same letter (with modifiers)
; for several hotkeys, and all those cases rely on the user holding a beam or charging key, and because
; I do have a tendancy to not hold the modifiers keys while the beam/charging is occuring, I was running
; into the problem of having several hotkeys trying to fire at the same time. Thus this temporary disabling
; of hotkeys in some of the cases below.
; Also, Shield boosting related hotkeys.


c::         ;Freeze and Cook in Line
   DoMagickaSpell(FrostLigthningStorm,imbuse,fast,null,300)
   DoMagickaSpell(superWetSteamLightning,basic,fast,"c")
   return
   
!c::      ;Freeze and Cook in Arc
   Hotkey, c, off
   DoMagickaSpell(FrostLigthningStorm,basic,fast,null,200)
   DoMagickaSpell(superWetSteamLightning,basic,fast,"c")
   Hotkey, c, on
   return
   
   
;Variations of the Arcane Steam Ligthning Beams
x::DoMagickaSpell(ArcaneSteamLightning,basic,fast,"x")

^x::
   Hotkey, x, off
   DoMagickaSpell(superWetSteamLightning,basic,fast,"x")
   Hotkey, x, on
   return
   
!x::
   Hotkey, x, off
   DoMagickaSpell(ArcaneColdLigthning,basic,fast,"x")
   Hotkey, x, on
   return
   
   
;Ice Projectiles
b::DoMagickaSpell(BlizzardBall,basic,fast,"b")

!b::
   Hotkey, b, off
   DoMagickaSpell(NeedleSpray,basic,fast,"b")
   Hotkey, b, on
   return

   
;Shield related hotkeys
g::         ;Full Bubble Shield
   DoMagickaSpell("e",aoe,fast,null,300)   
   
   ;Simulate a bunch of Boost key clicks
   Loop, 75
   {
      ;Simulate a really fast Boost key click
      SendSpellCastKeyDown()
      Sleep,GetDelayBetweenPresses(false)
      SendSpellCastKeyUp()
      Sleep,GetDelayBetweenPresses(false)
   }
   return
   
h::         ;Boost shield
   Loop
   {
      GetKeyState, state, h, P
      if state = D  ; The key is held down
      {
         ;Simulate a really fast Boost key click
         SendSpellCastKeyDown()
         Sleep,GetDelayBetweenPresses(false)
         SendSpellCastKeyUp()
         Sleep,GetDelayBetweenPresses(false)
      }
      else ;key released
         break
   }
   return
   
return
;end of auto-execute section




; ******************************** Main Functions ****************************

/*
DoMagickaSpell
   Arguments:
      formula: sequence of elements [sqf etc]
      castmode: basic[or 1] = basic cast, self[or 2] = self cast, aoe[or 3] = aoe cast,
               imbue[or 4] = imbue weapon, imbuse[or 5] = imbue weapon and use it, spell[or 6] = spellbook cast
      bSlow: true=slower but precise casting, false=faster but imprecise casting. Use slow[true] for spellbook casts.
      key: a key between double quotes , or null if no such key is needed
         This is the hotkey used to trigger the event and holds the "casting" button until
         your hotkey is released. This is important for channeled spells like beams
         as well as charge-ups like rock or icy shotgun.
      afterCastDelay: key delay after spell/effect has been invoked. Used to slow down casting when you want to spam multiple spells really fast.
*/
DoMagickaSpell(formula, castmode, bSlow, key, afterCastDelay = 25)
{

   SendFormula(formula, bSlow)     
   
   if (castmode=1) ; Cast Force/Cast Area  aka  Basic
   {
      SendBasicCastKeyDown()
      Keywait,%key%
      Sleep,GetPressDuration(bSlow)
      SendBasicCastKeyUp()
   }
   else if (castmode=2) ; Self Cast
   {
      SendSelfCastKeyDown()
      Keywait,%key%
      Sleep,GetPressDuration(bSlow)
      SendSelfCastKeyUp()
   }
   else if (castmode=3) ; AOE cast
   {
      SendModCastKeyDown()
      SendBasicCastKeyDown()
      Keywait, %key%
      Sleep,GetPressDuration(bSlow)
      SendModCastKeyUp()
      SendBasicCastKeyUp()
   }
   else if (castmode=4) ; Imbue Weapon
   {
      SendModCastKeyDown()
      SendAttackKeyDown()
      Sleep,GetPressDuration(bSlow)
      SendModCastKeyUp()
      SendAttackKeyUp()
   }
   else if (castmode=5) ; Imbue Weapon and Use it  aka Imbuse
   {
      SendModCastKeyDown()
      SendAttackKeyDown()
      Sleep,GetPressDuration(bSlow)
      SendModCastKeyUp()
      SendAttackKeyUp()
      
      Sleep,300
      
      SendModCastKeyDown()
      SendAttackKeyDown()
      Sleep,GetPressDuration(bSlow)
      SendModCastKeyUp()
      SendAttackKeyUp()
   }
   else if (castmode=6) ; Spellbook Cast
   {
      SendSpellCastKeyDown()
      Sleep,GetPressDuration(bSlow)
      SendSpellCastKeyUp()
   }
   
   Sleep, afterCastDelay
}



SendFormula(formula, bSlow = true)
{
   ;This function performs an improved version of the Send function.
   ;We try to simulate users that press down several keys really fast, then release them all,
   ;and that then proceed to repeat those 2 steps until their entire formula has been entered in input
   
   ;We do the same thing in this function. We send as many "key down" events as we can. When we detect that we need to reuse
   ;a key that has already been pressed down, we send a batch of corresponding "key up" events that we accumulated so far.
   ;After that, we can then start a new cycle of sending a bunch of "key down" events, followed by a bunch of "key up" events and so on.
   
   keyUpSequence=
   
   Loop, parse, formula
   {
      ;detect case where we are trying to press down a given key for the second time
      if(InStr(keyUpSequence, A_LoopField ) <> 0)
      {
         ;before sending a press down for a given key a second time, first send the "key up" events we accumulated so far
         Sleep, GetPressDuration(bSlow)
         SendKeyUpSequence(keyUpSequence, bSlow)
         keyUpSequence=
         Sleep, GetDelayBetweenKeys(bSlow)
      }
      
      ;send key down event
      Send, {%A_LoopField% Down}
      keyUpSequence.= A_LoopField
      Sleep, GetDelayBetweenPresses(bSlow)
   }
   
   ;we finished going through the formula, send the last batch of "key up" events we accumulated
   Sleep, GetPressDuration(bSlow)
   SendKeyUpSequence(keyUpSequence, bSlow)
}



SendKeyUpSequence(keySeq, bSlow = true)
{
   ;iterate through our list of "key up" events and send them all
   Loop, parse, keySeq
   {
      Send, {%A_LoopField% Up}
      Sleep, GetDelayBetweenPresses(bSlow)
   }
}



; ****************************  Utility functions ******************************

SendBasicCastKeyDown()   ;Cast Force/Cast Area - RButton by default
{
   global basicCastKey
   Send, {%basicCastKey% Down}
}

SendBasicCastKeyUp()   ;Cast Force/Cast Area - RButton by default
{
   global basicCastKey
   Send, {%basicCastKey% Up}
}

SendSelfCastKeyDown()   ;Cast Self - MButton by default
{
   global selfCastKey
   Send, {%selfCastKey% Down}
}

SendSelfCastKeyUp()      ;Cast Self - MButton by default
{
   global selfCastKey
   Send, {%selfCastKey% Up}
}

SendSpellCastKeyDown()   ;Boost/Cast magic - Space by default
{
   global spellCastKey
   Send, {%spellCastKey% Down}
}

SendSpellCastKeyUp()   ;Boost/Cast magic - Space by default
{
   global spellCastKey
   Send, {%spellCastKey% Up}
}

SendModCastKeyDown()   ;Shift - LShift by default
{
   global modCastKey
   Send, {%modCastKey% Down}
}

SendModCastKeyUp()      ;Shift - LShift by default
{
   global modCastKey
   Send, {%modCastKey% Up}
}

SendAttackKeyDown()      ;Move/Attack - LButton by default
{
   global attackKey
   Send, {%attackKey% Down}
}

SendAttackKeyUp()      ;Move/Attack - LButton by default
{
   global attackKey
   Send, {%attackKey% Up}
}


GetPressDuration(bSlow = true)
{
   global pressDurationSlow
   global pressDurationFast
   
   ifEqual, bSlow, true
   {
      return pressDurationSlow
   }
   else
   {
      return pressDurationFast
   }
}


GetDelayBetweenKeys(bSlow = true)
{
   global delayBetweenKeysSlow
   global delayBetweenKeysFast
   
   ifEqual, bSlow, true
   {
      return delayBetweenKeysSlow
   }
   else
   {
      return delayBetweenKeysFast
   }
}


GetDelayBetweenPresses(bSlow = true)
{
   global delayBetweenPressesSlow
   global delayBetweenPressesFast
      
   ifEqual, bSlow, true
   {
      return delayBetweenPressesSlow
   }
   else
   {
      return delayBetweenPressesFast
   }
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Problem with compiling
PostPosted: November 27th, 2011, 6:58 pm 
hey, thank you all for your nice scripts.. but i've got a problem, i can't compile even one of them. I always get following error text:

Code:
C:\Users\Username\Desktop\magicka.au3(6,8) : ERROR: syntax error
Process.
~~~~~~~^
C:\Users\Username\Desktop\magicka.au3 - 1 error(s), 0 warning(s)



i use autohotkey 3 and scite


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2011, 7:02 pm 
Offline

Joined: November 27th, 2011, 7:01 pm
Posts: 1
sorry for double post (wrote first post without account).

there's a comma behind the "Process" in the error text, not a dot.. i just copied the script of doppleganger


edit:

i'm such an idiot :D it's a loooooooong time ago i used hotkey scripts and i tried to compile with autoit oO


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: batto, Bing [Bot], Exabot [Bot], JSLover, sjc1000 and 60 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:
Powered by phpBB® Forum Software © phpBB Group