Jump to content
SugarplumChum

My first script, doesnt seem to work

Recommended Posts

SugarplumChum

Hey! I found out about autoit a couple days ago and been trying to learn how it works. I used Autohotkey before but now I wanna try out autoit for my basic macros. I've been trying to copy the exact same macro from AHK to Autoit, but failed kinda hard. But whenever i try to compile the autoit script to an exe, the exe won't open and the macro obviously wont work.

I would appreciate any help I could get =)

This is how one of my macros look like on AHK: 
3::
send, {a down}
send, {b down}
sleep, 50
send, {a up}
send, {a up}
return

My attempt on Autoit:

HotKeySet( "3", "test" )

Func test( )
Send("{a down}")
Sleep (50)
Send("{b down}")
Sleep (50)
Send("{a up}")
Sleep (50)
Send("{b up}")
EndFunc

 

Share this post


Link to post
Share on other sites
IAMK

You need to keep the script running.

The easiest way is to add:

While(1)
    Sleep(1000)
WEnd


Treat everything outside of "Func"s as the program that gets run.

  • Like 1

Share this post


Link to post
Share on other sites
Malkey

If using SciTE you can put the cursor over the "Send" command in an AutoIt .au3 file and the AutoIt help file will open in the Send command window when the "F1" key is pressed.   And most functions do have examples at the bottom of the their page.
You should notice there is no format that puts a letter inside (and at the front of) the curly bracket of a Send() command.

When this example is run, the "3" key, a HotKey, will need to be pressed for the "_Test()" (User Defined) function to run.

HotKeySet("3", "test")
HotKeySet("{ESC}", "Terminate") ; Press Esc key to exit script.

While (1)
    Sleep(100)
WEnd


Func _Test()
    Send("{a 4}")
    Send("{down 2}")
    Sleep(50)
    Send("b{down}")
    Sleep(50)
    Send("a{up}")
    Sleep(50)
    Send("b{up}")
EndFunc   ;==>_Test

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate

 

Share this post


Link to post
Share on other sites
SugarplumChum

Thank you so much for the quick replies =) Its kinda fun to learn new stuff. The script works now.

So will ''While (1) Sleep(1000) WEnd'' keep the script running permanently? What exactly is it doing, cuz i have no clue.

Share this post


Link to post
Share on other sites
Jos
4 minutes ago, SugarplumChum said:

What exactly is it doing, cuz i have no clue.

Did you actually try to read the helpfile's explanation of this function to understand?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
SugarplumChum
14 minutes ago, Jos said:

Did you actually try to read the helpfile's explanation of this function to understand?

Jos

Yes, but i didnt understand a single thing =/

Share this post


Link to post
Share on other sites
Jos

So let me see I understand this: You previously scripted with ahk and now started with AU3 and have no clue about any programming basics.
Guess you've only done Cut&Paste programming till now?

So, which part of the explanation in the Helpfile do you not understand? 

Jos

  • Like 1

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
SugarplumChum
1 minute ago, Jos said:

So let me see I understand this: You previously scripted with ahk and now started with AU3 and have no clue about any programming basics.
Guess you've only done Cut&Paste programming till now?

So, which part of the explanation in the Helpfile do you not understand? 

Jos

I have only done simple macros like the one I posted on top for my gaming. 

Share this post


Link to post
Share on other sites
Jos
2 minutes ago, SugarplumChum said:

gaming

You just mentioned the magic word for the forum as you appear to have missed the Forum rules on your way in. (there is also a link in my signature) 
Please read them now particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :naughty:

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.