Sign in to follow this  
Followers 0
SXGuy

sendkey Headache

5 posts in this topic

before i start id just like to say that im quite new to this and i have only created whats below through reading various articles and explanations of what things do.

i would really be greatful if somebody could point out what i may be doing wrong.

i wanted to create a script that will send a certain key on a keyboard in a game for 1000 key presses.

which would be activated by a hotkey.

for example if i wanted to continuously use the attack key in a game i could by starting off the function by pressing my hotkey.

the problem i am getting is sending the key to be repeated, from what i can tell, the hotkey works, its the rest that doesnt.

for arguments sake lets suggest i do need to use the games "classname" for the script to focus on the game window. and i will call it "AGameClassName" plus the window text is called "WindowName"

and i need to make sure the repeated key press acts human like by setting a delay in sending each repeated keypress.

Opt ("WinTitleMatchMode" , 4)

WinWait("classname=AGameClassName" , "WindowName" , 5)

Global $sendKey=9

HotKeySet("9", "hit" ) ;9 is the key used to activate the script

While 1

Sleep(5000)

WEnd

Func Hit()

$sendKey = NOT $sendKey

While $sendKey

opt ("SendKeyDelay", 10)

Send("(h 1000)" , 1) ; h is the key used to "attack, 1000 is the amount of times to attack.

WEnd

EndFunc

Should this work, or am i doing somthing wrong?

Share this post


Link to post
Share on other sites



$i=1
Do
Send("h")
$i = $i+1
Until $i = 1000

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

use...

Opt ("WinTitleMatchMode" , 4)

WinWait("classname=AGameClassName" , "WindowName" , 5)

Global $sendKey=9

HotKeySet("9", "hit" ) ;9 is the key used to activate the script

While 1

Sleep(5000)

WEnd

Func Hit()

$sendKey = NOT $sendKey

While $sendKey

$times = 0

While $times <= 1000

opt ("SendKeyDelay", 10)

Send("h" , 1) ; h is the key used to "attack, 1000 is the amount of times to attack.

$times = $times + 1

WEnd

WEnd

EndFunc

thanks for posting code, and welcome to the forum. the send function doesn't work the way you were thinking it did... (or so i think) so I made a loop, to make it send over and over again

EDIT: seems code got done b4 me. :lmao:

Edited by Kickassjoe

What goes around comes around... Payback's a bitch.

Share this post


Link to post
Share on other sites

Hi,

this should work

Global $sendKey=0
HotKeySet("9", "hit") ;9 is the key used to activate the script


While 1
    Sleep(5000)
WEnd

Func Hit()
    $sendKey = Not $sendKey

    While $sendKey
        Opt("SendKeyDelay", 10)
        Send("{h 10}") ; h is the key used to "attack, 1000 is the amount of times to attack.
    WEnd
EndFunc   ;==>Hit

I set in h to 10 so you can test to pause the script.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Thanks for all your helps peeps i shall try them later and let you know how it went

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0