Sign in to follow this  
Followers 0
kennycc

EU game auto key press

15 posts in this topic

i have been try to write scrip but since i'm new at scrip write i was wondering if someone can give big hand.

well the scrip i want to make is some what same as the scrip of What this person posted

but my game is not RF online but EU (Entropia Universe).

basicily what my scrip want to do is that press key 8 every 2 to 3 sec and still have funtion to pause it and start again by press - for stop = to start.

from the link i show you i can see that how to set the hotkey but i have no idea on how to write what key that it should be pushing and how fast.

and thanks for your help

Share this post


Link to post
Share on other sites



Welcome,

Can you try a few things first.

- Experiment. Have you full explored the help file? Have you seen functions like HotkeySet, TimerInit/TimerDiff, Sleep, etc... ?

- Searched? Have you done a thorougher search of the forums? Seen other bots?

If the answer is yes and you still can't work it out, here is some persudo code to how I would go about doing what you have described. (Remember, it is persudo code, so you will have to rewrite it in AutoIt with this in mind):

Declare state;a global variable so we can store the "state" i.e started or stopped.  We'll call it false for now.
Declare timer

Assign Hotkeys for 2 different functions 1 Start, one stop.

Set timer = TimerInit

Start While loop.
    If state is true then
        If TimerDiff(timer) >= 2000 Then; if the timer is greater or equal to 2*1000 (2 seconds)
            send (key)
        Else
            Sleep (100);So we can Conserve CPU
        Endif
    Else
        Sleep(100);So we can Conserve CPU
    EndIf
End while loop
    
Start Func: start
    set state to True
End Func
    
Start Func: stop
    set state to False
End Func

Hope that helps.

Cheers,

Brett

Share this post


Link to post
Share on other sites

Welcome,

Can you try a few things first.

- Experiment. Have you full explored the help file? Have you seen functions like HotkeySet, TimerInit/TimerDiff, Sleep, etc... ?

- Searched? Have you done a thorougher search of the forums? Seen other bots?

If the answer is yes and you still can't work it out, here is some persudo code to how I would go about doing what you have described. (Remember, it is persudo code, so you will have to rewrite it in AutoIt with this in mind):

Declare state;a global variable so we can store the "state" i.e started or stopped.  We'll call it false for now.
Declare timer

Assign Hotkeys for 2 different functions 1 Start, one stop.

Set timer = TimerInit

Start While loop.
    If state is true then
        If TimerDiff(timer) >= 2000 Then; if the timer is greater or equal to 2*1000 (2 seconds)
            send (key)
        Else
            Sleep (100);So we can Conserve CPU
        Endif
    Else
        Sleep(100);So we can Conserve CPU
    EndIf
End while loop
    
Start Func: start
    set state to True
End Func
    
Start Func: stop
    set state to False
End Func

Hope that helps.

Cheers,

Brett

thanks very much thats what i was looking i try help in programe but i got lost and did serch but well not what i needed.

i will try it from here and if i get lost again i will ask for help :)

Share this post


Link to post
Share on other sites

sorry but i have been trying to find how to fix the problem i have and i did more search on bot in here but they were all use different code then how i'm working on so i need some help again.

this is how far i got.

$myTargetColor = 0x52DBD6
$targetIsSelected = 0
$Paused = 1; Paused in default
$PauseHotKey = 60;- Stop
$StartHotKey = 61;= Start


$Timer = TimerInit()

 Start While loop
    If state is true then
        If TimerDiff(2000) >= 2000 Then; if the timer is greater or equal to 2*1000 (2 seconds)
            send ("{8}")
            Else
            Sleep (100);So we can Conserve CPU
        Endif
    Else
        Sleep(100);So we can Conserve CPU
    EndIf
 End while loop
    
Func Start()
    If _IsPressed(61) Then
    $Paused = 0
    EndIf
EndFunc
    
Func Paused()
    If _IsPressed(60) Then
        $Paused = 1
    EndIf
    EndFunc

i'm keep getting the error at Start while loop. and i try to use help from the program but it didn't help much so can' some pro help me out in here

Thanks

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Did I say use _IsPressed or Hotkeys... Use HotkeySet.

Cheers,

Brett

thanks again Brett

now i have new problem.

my scrip is working on everything else like MSN, noteped and so on but in game it seem it don't work at all it just don't do anything but when i tap out to other programs its working so i know its running but in game (EU) it seem it don't at all any help on this Brett?

oh and with the code you gave about Start while loop this part of code i was keep getting error saying i was missing something so i remove the start and loop and use while 1 just like the help part from the help under hotkeyset and it start to run

this is my new code now after look into help setting under HotkeySet and useing that as my basic set up

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{=}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage");Shift-Alt-d

;;;; Body of program would go here;;;;
While 1
    TimerDiff(3000) 
    send ("{8}")
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc
Edited by kennycc

Share this post


Link to post
Share on other sites

While 1

TimerDiff(3000)

send ("{8}")

WEnd

read what the help file says about TimerDiff

Share this post


Link to post
Share on other sites

thanks now its working the way it should be but just one last questions tho.

it some how in the game my paused key don't work so i always have to tab out to paused and start again is there different code for that or is my game (eu) is blocking it?

here is the code again

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{del}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

;;;; Body of program would go here;;;;
While 1
    $begin = TimerInit()
    sleep(1000)
    $dif= TimerDiff($begin) 
    send ("{numpad1}")
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

i just change keys that i felt like better to use but still i can't pause my script while in game so i hope someone can help me with this one

Share this post


Link to post
Share on other sites

I dont get the point of TimerInit inside the loop, and I dont see how you are using it, is this the entire code?

Share this post


Link to post
Share on other sites

Its going to return about 1sec every time, I think he meant:

$begin = TimerInit()
While 1
    sleep(1000)
    $dif= TimerDiff($begin)
    send ("{numpad1}")
WEnd

And heis still not doing anything with it still... :)

Share this post


Link to post
Share on other sites

thanks now its working the way it should be but just one last questions tho.

it some how in the game my paused key don't work so i always have to tab out to paused and start again is there different code for that or is my game (eu) is blocking it?

here is the code again

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{del}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage");Shift-Alt-d

;;;; Body of program would go here;;;;
While 1
    $begin = TimerInit()
    sleep(1000)
    $dif= TimerDiff($begin) 
    send ("{numpad1}")
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

i just change keys that i felt like better to use but still i can't pause my script while in game so i hope someone can help me with this one

what i mean is that while in game i can't use pause for my script so i have to tap out from the game by alt+tap to other window then use my pause key to pause so i'm wondering if my game was blocking that or is there different code for using it in the game to use the hotkey

Share this post


Link to post
Share on other sites

Have u tried changing hotkey?

Share this post


Link to post
Share on other sites

Have u tried changing hotkey?

yes and it don't work in game

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global Const $VK_DELETE = 0x2E
Global Const $VK_ESCAPE = 0x1B

Global $hFunc, $pFunc
Global $hHook
Global $hMod
Global $fPauseBot = False

$hFunc = DllCallbackRegister('_KeyboardHook', 'lresult', 'int;uint;uint')
$pFunc = DllCallbackGetPtr($hFunc)

$hMod = _WinAPI_GetModuleHandle(0)
$hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, $pFunc, $hMod)

While 1
    If $fPauseBot Then
        _UnsetHotKeys()
        While $fPauseBot
            Sleep(20)
        WEnd
        _ResetHotKeys()
    EndIf
    Sleep(20)
WEnd


Func OnAutoItExit()
    _WinAPI_UnhookWindowsHookEx($hHook)
    DllCallbackFree($hFunc)
EndFunc


Func _UnsetHotKeys()
    HotKeySet("+!d")
EndFunc


Func _ResetHotKeys()
    HotKeySet("+!d", "ShowMessage");Shift-Alt-d
EndFunc


Func ShowMessage()
    MsgBox(0x40, 'Title', 'Text')
EndFunc


Func _KeyboardHook($iCode, $iwParam, $ilParam)
    Local $tKBDLLHS = DllStructCreate($tagKBDLLHOOKSTRUCT, $ilParam)
    Local $iVkCode
    
    If $iCode > -1 Then
        $iVkCode = DllStructGetData($tKBDLLHS, 'vkCode')
        If $iwParam = $WM_KEYUP Then
            Switch $iVkCode
                Case $VK_ESCAPE
                    Exit
                Case $VK_DELETE
                    $fPauseBot = Not $fPauseBot ; Was $fPauseBot = True.
            EndSwitch
        EndIf
    EndIf
    
    Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
EndFunc

You don't need this stupid function, it could as well be possible just to do as BrettF suggested, though, it's for testing purpose to see if the game is trying to take over the keyboard when it's focused.

Edited by Authenticity

Share this post


Link to post
Share on other sites

Thanks for all your help

its working as i wanted thanks Authenticity, BrettF, oMBRa and mdiesel

sorry for slow reply i was busy for while but yes its working now thanks you all

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