kennycc Posted May 21, 2009 Posted May 21, 2009 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 postedbut 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
BrettF Posted May 21, 2009 Posted May 21, 2009 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 FuncHope that helps.Cheers,Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
kennycc Posted May 21, 2009 Author Posted May 21, 2009 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
kennycc Posted May 22, 2009 Author Posted May 22, 2009 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
BrettF Posted May 22, 2009 Posted May 22, 2009 Did I say use _IsPressed or Hotkeys... Use HotkeySet. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
kennycc Posted May 23, 2009 Author Posted May 23, 2009 (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 May 23, 2009 by kennycc
oMBRa Posted May 23, 2009 Posted May 23, 2009 While 1 TimerDiff(3000) send ("{8}")WEndread what the help file says about TimerDiff
kennycc Posted May 23, 2009 Author Posted May 23, 2009 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
oMBRa Posted May 23, 2009 Posted May 23, 2009 I dont get the point of TimerInit inside the loop, and I dont see how you are using it, is this the entire code?
Mat Posted May 23, 2009 Posted May 23, 2009 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... AutoIt Project Listing
kennycc Posted May 23, 2009 Author Posted May 23, 2009 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
kennycc Posted May 23, 2009 Author Posted May 23, 2009 Have u tried changing hotkey?yes and it don't work in game
Authenticity Posted May 23, 2009 Posted May 23, 2009 (edited) expandcollapse popup#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 May 24, 2009 by Authenticity
kennycc Posted May 25, 2009 Author Posted May 25, 2009 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now