Jump to content

Need short macro


 Share

Recommended Posts

Sleep() must be placed correctly.

original:

#Include <Misc.au3>

HotKeySet("`", "TogglePause")

Global $Paused = 1

While 1
If _IsPressed("44") Then 
    Sleep(10)
    Send("dd")
EndIf
WEnd

Func TogglePause()
$Paused =Not $Paused
While $Paused
Wend
EndFuncoÝ÷ Újøu«­¢+Ø%¹±Õ±Ðí5¥Í¹ÔÌÐì()!½Ñ-åMÐ ÅÕ½ÐìäØìÅÕ½Ðì°ÅÕ½ÐíQ½±AÕÍÅÕ½Ðì¤()±½°ÀÌØíAÕÍôÄ()]¡¥±Ä(%}%ÍAÉÍÍ ÅÕ½ÐìÐÐÅÕ½Ðì¤Q¡¸M¹ ÅÕ½ÐíÅÕ½Ðì¤(M±À ÄÀ¤)]¹()Õ¹Q½±AÕÍ ¤(ÀÌØíAÕÍõ9½ÐÀÌØíAÕÍ)]¡¥±ÀÌØíAÕÍ(M±À ÄÀ¤)]¹)¹Õ¹
Link to comment
Share on other sites

Alright, I've taken it all in, ran tests, and this is what works. (Zedna, your modification didn't work, so I did another edit on it.)

#Include <Misc.au3>

HotKeySet("`", "TogglePause")

Global $Paused = 1

While 1
If _IsPressed("57") Then 
    Sleep(10)
    Send("ww")
EndIf
WEnd

Func TogglePause()
$Paused =Not $Paused
While $Paused
  Sleep(10)
Wend
EndFuncoÝ÷ Ù«­¢+Ø%¹±Õ±Ðí5¥Í¹ÔÌÐì()!½Ñ-åMÐ ÅÕ½ÐìäØìÅÕ½Ðì°ÅÕ½ÐíQ½±AÕÍÅÕ½Ðì¤()±½°ÀÌØíAÕÍôÄ()]¡¥±Ä)%}%ÍAÉÍÍ ÅÕ½ÐìÔÌÅÕ½Ðì¤Q¡¸(%M±À ÄÀ¤(%M¹ ÅÕ½ÐíÍÌÅÕ½Ðì¤)¹%)]¹()Õ¹Q½±AÕÍ ¤(ÀÌØíAÕÍõ9½ÐÀÌØíAÕÍ)]¡¥±ÀÌØíAÕÍ(M±À ÄÀ¤)]¹)¹Õ¹oÝ÷ Ù«­¢+Ø%¹±Õ±Ðí5¥Í¹ÔÌÐì()!½Ñ-åMÐ ÅÕ½ÐìäØìÅÕ½Ðì°ÅÕ½ÐíQ½±AÕÍÅÕ½Ðì¤()±½°ÀÌØíAÕÍôÄ()]¡¥±Ä)%}%ÍAÉÍÍ ÅÕ½ÐìÐÄÅÕ½Ðì¤Q¡¸(%M±À ÄÀ¤(%M¹ ÅÕ½ÐíÅÕ½Ðì¤)¹%)]¹()Õ¹Q½±AÕÍ ¤(ÀÌØíAÕÍõ9½ÐÀÌØíAÕÍ)]¡¥±ÀÌØíAÕÍ(M±À ÄÀ¤)]¹)¹Õ¹oÝ÷ Ù«­¢+Ø%¹±Õ±Ðí5¥Í¹ÔÌÐì()!½Ñ-åMÐ ÅÕ½ÐìäØìÅÕ½Ðì°ÅÕ½ÐíQ½±AÕÍÅÕ½Ðì¤()±½°ÀÌØíAÕÍôÄ()]¡¥±Ä)%}%ÍAÉÍÍ ÅÕ½ÐìÐÐÅÕ½Ðì¤Q¡¸(M±À ÄÀ¤(M¹ ÅÕ½ÐíÅÕ½Ðì¤)¹%)]¹()Õ¹Q½±AÕÍ ¤(ÀÌØíAÕÍõ9½ÐÀÌØíAÕÍ)]¡¥±ÀÌØíAÕÍ(M±À ÄÀ¤)]¹)¹Õ¹oÝ÷ Ù«­¢+Ø%¹±Õ±Ðí5¥Í¹ÔÌÐì()!½Ñ-åMÐ ÅÕ½ÐìäØìÅÕ½Ðì°ÅÕ½ÐíQ½±AÕÍÅÕ½Ðì¤()±½°ÀÌØíAÕÍôÄ()]¡¥±Ä(%}%ÍAÉÍÍ ÌäìÀÄÌäì¤Q¡¸(M±À Ô¤(M¹ ÅÕ½Ðí|ÅÕ½Ðì¤(¹%)]¹()Õ¹Q½±AÕÍ ¤(ÀÌØíAÕÍõ9½ÐÀÌØíAÕÍ)]¡¥±ÀÌØíAÕÍ(M±À ÄÀ¤)]¹)¹Õ¹

Now, given all of that. Who can put them altogether? :P

Link to comment
Share on other sites

  • Moderators

Example:

What you have:

While 1
    If _IsPressed('01') Then
        Sleep(5)
        Send("_")
    EndIf
WEndoÝ÷ ÙhZ·­ëÊ)àjëh×6While 1
    If _IsPressed('01') Then
        Sleep(100);<<< Note this is 100, so you are not getting it to repeat several times
        Send("_")
    EndIf
    Sleep(10);<<< Note this "inside" the loop not the Conditional "If" statement
WEnd

The way you had it, it would put unnecessary strain on the CPU.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

The reason I have it the way I do is because I want Send("_") almost instant after I click.

Sigh...but that's not what your script does. It loops as fast as it can, making the CPU-usage

close to 100%, and when you press the key it waits a 10 milliseconds before it sends "xx".

Move the Sleep() to the loop instead of inside the If-statement and your CPU-usage will lower

AND it will send "xx" instantly. Mkay !? :P

Read it upside-down, backwards or in a mirror...study the the above text and you will have

a working script.

Edited by Helge
Link to comment
Share on other sites

  • Moderators

It won't just send xx more than likely without the sleep(100)... it's more like it will send xxxxxxxx ... put the Sleep(100) after the Send('xx') it's the same effect as the way I put it there.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

It won't just send xx more than likely without the sleep(100)... it's more like it will send xxxxxxxx ... put the Sleep(100) after the Send('xx') it's the same effect as the way I put it there.

Damn, I guess it's that time again for me. Ok, so to make it send it instantly

and to not make it spam just add the Sleep after the Send then :P

Edit : typo... I need some Sleep too now I guess.

Edited by Helge
Link to comment
Share on other sites

I knew this I'd get that reply.. Read my post again, ALMOST instantly. I don't want as soon as I click, I want a small delay. And Smoke, I don't care if it repeats and sends xxxxxxxx it doesn't really matter because of the way I'm using the script. No more posts about "It'll lag your CPU". I already stated that I knew that, and I already said what I want done about it, but no-one has done so and is just repeating themselves. All I need now is all those scripts put together.

Link to comment
Share on other sites

  • Moderators

I knew this I'd get that reply.. Read my post again, ALMOST instantly. I don't want as soon as I click, I want a small delay. And Smoke, I don't care if it repeats and sends xxxxxxxx it doesn't really matter because of the way I'm using the script. No more posts about "It'll lag your CPU". I already stated that I knew that, and I already said what I want done about it, but no-one has done so and is just repeating themselves. All I need now is all those scripts put together.

If you don't want "Experienced" advice, then maybe you should figure it out on your own, I for one will never attempt to help you again.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks to all who helped, AzKay's code was what I needed.

EDIT: Ok so I learnt a bit from AzKay's code and did this:

#Include <Misc.au3>

HotKeySet("`", "TogglePause")

Global $Paused = 1

While 1
If _IsPressed("57") Then 
    Sleep(10)
    Send("ww")
EndIf
WEnd

Func TogglePause()
$Paused =Not $Paused
While $Paused
Wend
EndFunc
;et cetera
oÝ÷ Øíz·hx-«Hµë-yÛazf¥«mëëbæ§v+ly鬶Zl¢jnµêÒ ³
'uêâ"­¶¦jYbÚ#ºËu±Êâ¦Ûh¦·¯z{ej(r¥vÊ&zÞ¦ëmé­¢­êéæ¬{ú®¢×)è¶;¬µ«­¢+Ø(%¹±Õ±Ðí5¥Í¹ÔÌÐì)]¡¥±Ä(%%}%ÍAÉÍÍ ÅÕ½ÐìÔÜÅÕ½Ðì¤Q¡¸($%M±À ÄÀ¤($%M¹ ÅÕ½ÐíÝÜÅÕ½Ðì¤($%¹%(%%}%ÍAÉÍÍ ÅÕ½ÐìÔÌÅÕ½Ðì¤Q¡¸($%M±À ÄÀ¤($%M¹ ÅÕ½ÐíÍÌÅÕ½Ðì¤($%¹%(%%}%ÍAÉÍÍ ÅÕ½ÐìÐÄÅÕ½Ðì¤Q¡¸($%M±À ÄÀ¤($%M¹ ÅÕ½ÐíÅÕ½Ðì¤($%¹%(%%}%ÍAÉÍÍ ÅÕ½ÐìÐÐÅÕ½Ðì¤Q¡¸($%M±À ÄÀ¤($%M¹ ÅÕ½ÐíÅÕ½Ðì¤$($%¹%)]¹(

With your pause stuff there too, I haven't tried this...

Piano_Man

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

No ? What the heck is that supposed to mean ? Reconfigure your telepathic abilities kid..

"No" to your implication that the code he posted was my style, followed by an example of how my style of it is, in contrast to his.

Link to comment
Share on other sites

  • 2 weeks later...

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...