XIM Community

First time writing script, can't figure out whats wrong.  (Read 378 times)

Offline Sweetbam

  • Member
  • *
  • Posts: 7
    • View Profile
Hey guys I'm trying to write a simple script with autohotkey and sandhawc. the script is as follows:

SetKeyDelay , 50, 50 ;


Q::
ControlSend, , {1}, A
ControlSend, , {e}, A

End

All I am trying to do is when I press the 'q' key I want it to press 1 and then 50 ms later press 'e'. It seems to work outside of the game. however in game the button does nothing..Is there something else I have to do to get the scripts working ingame? or is it written poorly?

edit: Scripts are activated in sandhawc and scripts are placed in the script folder.

Online Od1n

  • Global Moderator
  • MVP
  • *
  • Posts: 27774
    • View Profile
Re: First time writing script, can't figure out whats wrong.
« Reply #1 on: 04:30 PM - 03/20/18 »
try something like this

Code: [Select]
Q::

Send {1 Down}
sleep 25
Send {1 up}
sleep 50
Send {E down}
Sleep 25
Send {E up}
return

PS4 & X1 | C: MS | XIM4 | FW: the latest ofc! :) | Mon: BenQ XL2420Z | Pad: Zowie G-SR | KB: Ducky DK1008L Cherry Red O-Rings| A: AKG K701 Creative X7 Antlion Modmic | M: Zowie EC1-A | D: 3200 | P: 1000hz | BF4 4 HIP: 35 ADS: 20

Check out my Youtube Channel: XIMGameplay
Du sprichst Deutsch? Hier gehts zum deutschen Forum

Offline Sweetbam

  • Member
  • *
  • Posts: 7
    • View Profile
Re: First time writing script, can't figure out whats wrong.
« Reply #2 on: 05:24 PM - 03/20/18 »
try something like this

Code: [Select]
Q::

Send {1 Down}
sleep 25
Send {1 up}
sleep 50
Send {E down}
Sleep 25
Send {E up}
return


Thanks I'll give it a shot. I wasn't sure what the difference was between setkeydelay and sleep, but I thought I read somewhere that someone liked the setkeydelay better for some reason so I thought It would work. I'll update with results.

Edit: I just tried your recommendation and a couple variations, The script works when testing in notepad (when i press q, it types 1e) but when I activate sandhawc for ingame controls it doesn't register the keystrokes in game. there must be a setting or something i have wrong?

Edit 2: I figured out the problem, I was missing the #UseHook at the beginning of the script.

thanks for the help @Od1n
« Last Edit: 08:20 PM - 03/20/18 by Sweetbam »