Jump to content

Help here pls


Recommended Posts

Im trying to make an autoit that :

Presses 'E' for 3 times every 140 seconds interval with hotkeys..

What's wrong with my script below? :">

HotKeySet("{F10}", "Start1")
HotKeySet("{F11}", "Terminate")

Dim $Timer_One
One()


While 1
    If TimerDiff($Timer_One) >= (12000) Then
            One()
    EndIf
    Sleep(20)
WEnd        

Func Start1()
    Send("{S 30}");Sends 30 'S' characters
    $Timer_One = TimerInit()
EndFunc



Func Terminate()
  $i = 0
EndFunc
Link to comment
Share on other sites

hi!

i see many error in you script! i have tryed to mark all error! but some part are missing!

HotKeySet("{F10}", "Start1")
HotKeySet("{F11}", "Terminate"); the function terminated don't terminated the script because missing "EXIT"
; you forget to calculate the number of time you send your key 


Global $Timer_One
Global $i
One();no function one()


While 1
    If TimerDiff($Timer_One) >= (12000) Then
            One();no function one() check this
    EndIf
    Sleep(20)
WEnd        

Func Start1()
    Send("{S 30}");Sends 30 'S' characters
    $i = $i + 1; to count how many time you excute this function when 3 you sould exit try implement this
    $Timer_One = TimerInit()
EndFunc



Func Terminate()
  $i = 0
; should add EXIT here
EndFunc

i don't rewrite you a code because it is a simple very simple code! i think you have your chance to learn much if you do your self!

just ask again if you need more help it will be a pleasure!

Edited by Greenseed

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Link to comment
Share on other sites

you really should not copy if you don't understand

the function One() is counting 1 to $i

i don't think you need the timer so

$Timer_One = TimerInit()

and

If TimerDiff($Timer_One) >= (12000) Then
            One()
    EndIf

are only for checking the time used to get to this point

Link to comment
Share on other sites

i see you are very newbie! and a little off the hook! hehe :P

than i change my mind and i wrote you a little script wich explain line by line what is hapening!

i hope this will help you understand a little more autoit!

this is the code you looking for

HotKeySet("{F10}", "Start"); call function start when pressed
HotKeySet("{F11}", "Terminate");call function terminated when F11 is pressed

Global $count = 0; create a global variable to be used as a counter

while 1;create a empty loop to wait for hotkey press
 sleep(10);put a pause in the loop to not jam the CPU
WEnd


Func Start()
    while $count < 4; excute if $count is less than 3
    sleep(140000); wait 140 secondes
        Send("{E 3}");Sends "E" 3 time
        $count = $count + 1; count how many time this function is excuted
    WEnd
EndFunc; after is excuted the script return in the empty loop above you have to press F11 to quit the script



Func Terminate(); call this function when you press F11
    Exit; exit the script
EndFunc

don't boder you self to thx me! my paid come when you learn something from me! then if it is the case! im a very happy man!

bye bye! and hope this help!

P.S. hotkeyset() capture the key! before it send to the system! then when the script run! you will not be able to press all HOTkeySet() in another program! until the process autoit quit.

Edited by Greenseed

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Link to comment
Share on other sites

Yay!! I finally get it to work.. was busy these few days too ..

At first i thought it doesnt work but then i alter the timer a bit for testing and voila.. thx! :P

*Update : I modified the code a bit here finally got the marco i wanted :lmao::) of course, with your help :(

HotKeySet("{F10}", "Start"); call function start when pressed
HotKeySet("{F11}", "Terminate");call function terminated when F11 is pressed

Global $i = 0; create a global variable to be used as a counter

while 1;create a empty loop to wait for hotkey press
sleep(1000);put a pause in the loop to not jam the CPU
WEnd


Func Start()
      $i = 1
  While $i = 1
    Send("{E 3}");Sends "E" 3 time
        sleep(2000); wait 140 secondes
    WEnd
EndFunc; after is excuted the script return in the empty loop above you have to press F11 to quit the script



Func Terminate(); call this function when you press F11
      $i = 0
EndFunc
Edited by ivanchin99
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...