Sign in to follow this  
Followers 0
Chobyhy

Autoit Script and Forum Help

18 posts in this topic

#1 ·  Posted (edited)

Forum help first: nvm im not having them anymore

Autoit Script Help:

im new to autoit and i just learned to start scripting today so i need some basic helps.

I wrote a script where when i press the "delete" key in a game that it would hit "enter" then type messages then hit back "enter" to send it. But the problem is, script doesnt even start up or show a tray icon and it doesnt work since it's not running. Can you help fix it.

Global $Paused

HotKeySet ( "{DELETE}", "msgone")
HotKeySet ( "{PGUP}", "quit")

Func msgone()
Send ( "{ENTER}")
Send ( "MESSAGES")
Send ( "{ENTER}")
EndFunc

Func quit()
Exit 0
EndFunc

Second Autoit Help:

Is there anyways for autoit to detect key presses and key releases it. I want to make a script where i press and hold "a" key, it will do what i tell it to and keep looping until i release "a" key. How would i make Autoit detect presses/releases of a key.

Third Autoit Help:

How can you make a script so when a key is held down. the following thing occurs

When Key is HELD DOWN:

Send( "x") (Hits this once)

then holds...

Send( "{SHIFT}") (make it hold shift some how)

Mouse click and hold cordinate.

When Key is released

Send(" Y")

Shift + Mousecoordinate thats been held down is released

Edited by Chobyhy

Share this post


Link to post
Share on other sites



Second Autoit Help:

Is there anyways for autoit to detect key presses and key releases it. I want to make a script where i press and hold "a" key, it will do what i tell it to and keep looping until i release "a" key. How would i make Autoit detect presses/releases of a key.

While (_IsPressed(41)) ;"A" pressed
 
 ;do whatever
 
WEnd

You need the beta version for this.

Nomad :D


Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

you must put in a loop in your code somewhere so that the interpriter wont hit the end, Like so:

Global $Paused

HotKeySet ( "{DELETE}", "msgone")
HotKeySet ( "{PGUP}", "quit")
;Start New Code
while 1
sleep(100)
wend
;End New Code
Func msgone()
Send ( "{ENTER}")
Send ( "MESSAGES")
Send ( "{ENTER}")
EndFunc

Func quit()
Exit 0
EndFunc

Now, it will stay resident.

EDIT

Did you read the helpfile yet? Also, it would be a good idea to download the Beta.

Edited by spyrorocks

Share this post


Link to post
Share on other sites

wutt? what beta? im lost i downloaded the Autoit v3 i think. and what does

While 1

Sleep(100)

WEnd

exactly do

Share this post


Link to post
Share on other sites

wutt? what beta? im lost i downloaded the Autoit v3 i think. and what does

While 1

Sleep(100)

WEnd

exactly do

There's a help file included with AutoIt that you are supposed to reference before posting questions here that can be answered there. I suggest looking in the help file and using the examples, then examining the examples until you understand how and why they work. Then try searching the forums if you still don't completely understand. Then post questions here along with your script when all else fails.

Beta is the "Beta" version of AutoIt, and it's the only way you can use the _IsPressed function, and you're going to need it to accomplish what you asked.

Nomad :D


Share this post


Link to post
Share on other sites

There's a help file included with AutoIt that you are supposed to reference before posting questions here that can be answered there. I suggest looking in the help file and using the examples, then examining the examples until you understand how and why they work. Then try searching the forums if you still don't completely understand. Then post questions here along with your script when all else fails.

Beta is the "Beta" version of AutoIt, and it's the only way you can use the _IsPressed function, and you're going to need it to accomplish what you asked.

Nomad :D

i did. i wrote the script after reading the whole manual. took me an hour or two. anyways isnt Sleep like pause? it says pause for 0.1 sec?

is beta version like a newer version and where do i dl it?

Share this post


Link to post
Share on other sites

downloads page>>> very bottom. says "Download Beta" in a big red button

Share this post


Link to post
Share on other sites

this should be what u want: http://www.autoitscript.com/autoit3/files/...-beta-Setup.exe

about the code:

while 1
sleep(100)
wend

The loop thyere will force autoit to stay open, thus allowing you to carry out your hotkey actions.

The sleep(100) command is optional, but it will help reduce stress on your CPU because tight loops like this:

while 1
wend

will slow down your compuer while the script is running.

Share this post


Link to post
Share on other sites

i went and it went to some weird page

http://www.autoitscript.com/autoit3/files/beta/

is the dl link broken? how do i dl or something?

Chobyhy,

Welcome to the AutoIt forum. :D

To download the latest beta, go here:

http://www.autoitscript.com/autoit3/files/beta/autoit/

Then click on:

autoit-v3.1.1.130-beta-Setup.exe

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

isnt 100 still pretty fast? wouldnt it still slow my comp by alot?

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

should be OK. Increase it if you like. it doesent matter.

edit

actually, i guess you could just put this coede insted:

sleep(999999999999999999999)

insted i guess. even better for your cpu.

Edited by spyrorocks

Share this post


Link to post
Share on other sites

so higher it is the less lag? cuz i play game while running script. is 15000 good enuff?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

how long do you play the game for?

If your computer is crap, just put this in:

sleep(99999999999999999999999999999999999)

insted of the loop.

it doesent really matter if you put a huage value in a loop. i would just use that sleep function i just sayed. its easyer and thewre is like NO cpu usage. If you play it constantly, paste it in there a few times.

Edited by spyrorocks

Share this post


Link to post
Share on other sites

isnt 100 still pretty fast? wouldnt it still slow my comp by alot?

Chobyhy,

You can always go to your 'Windows Task Manager' (CTRL-ALT-DEL) and click on the 'Processes' tab. Then locate 'AutoIt3.exe' under the 'Image Name' column. This will show you the CPU and memory usage. You can then adjust your sleep time to see what effect it has.

I recently started using 'OnEvent' mode, instead of the message loop, and it has greatly reduced my CPU usage from over 30% down to around 3%. But you may want to stick with the message loop method until this becomes an issue with your scripts.

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

hmm strange so CPU is at 0 but when i click the key that sets the trigger it goes up to 40 is that too high?

Share this post


Link to post
Share on other sites

No.... not unless your game takes up more then 80% of cpu, but even then it will be OK. i run stuff on my computer at full cpu all the time and it works perfecly with no ill effects.

Share this post


Link to post
Share on other sites

Sleep is just a delay to keep your script from hogging all the cpu. Without a sleep command, the script runs as fast as it possibly can, and this usually means as fast as your cpu can process. There are some functions which automatically sleep, like GUIGetMsg(). I believe it automatically sleeps 10 milliseconds.

Unless you have an absolute ancient cpu, a sleep time of 10-15 should be about the maximum you will need to prevent a script from lagging your computer (unless you have the cpu already at a very high load). On a 266 Mhz processor, which is what I use when scripting, I can run scripts for Diablo II with Sleep(10) and have no script related lag.

This is why I like using an older machine to script. If it'll run on this processor, it should run on any modern computer with ease. :wacko:

Nomad :D


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