Sign in to follow this  
Followers 0
Dethredic

_ispressed Help

17 posts in this topic

#1 ·  Posted (edited)

Ok I have a function that is not working properly. It is below:

Dim $tooltip = @ScriptDir & "\tool tip.au3"

Func Auto_Bot() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$HomeLocKey = IniRead("config.ini", "Hotkeys", "HomeLocationKey", "74") ;Default = F5

$toggelKey = IniRead("config.ini", "Hotkeys", "toggelKey", "73") ;Default = F4

$autobotstatus = "Off"

$locationset = "False"

IniWrite("tooltip.ini", "options", "toggel", "Off")

IniWrite("tooltip.ini", "options", "locationset", "False")

While 1

If _IsPressed($HomeLocKey) Then ;Get Home Location

$locationset = "True"

IniWrite("tooltip.ini", "options", "locationset", "True")

Run(@AutoItExe & ' "' & $tooltip & '"')

Call("Homelocation")

EndIf

If _IsPressed($toggelKey) Then ;Togel it on and off

If $autobotstatus = "Off" Then

$autobotstatus = "On"

IniWrite("tooltip.ini", "options", "toggel", "On")

Run(@AutoItExe & ' "' & $tooltip & '"')

Else

$autobotstatus = "Off"

IniWrite("tooltip.ini", "options", "toggel", "Off")

Run(@AutoItExe & ' "' & $tooltip & '"')

EndIf

Sleep(100)

EndIf

If $autobotstatus = "On" Then ;If it is on and a location has been set then Look for low hp guys

If $locationset = "True" Then

Call("Sendlowhpguyshome")

EndIf

EndIf

Call("Checkbases")

Sleep(10)

WEnd

EndFunc ;==>Auto_Bot

Here is the tool tip.au3

$whichbot = IniRead("tooltip.ini", "options", "whichbot", "Autobot")
$toggel = IniRead("tooltip.ini", "options", "toggel", "Off")
$locationset = IniRead("tooltip.ini", "options", "locationset", "False")

ToolTip($whichbot & " is " & $toggel & ". Location set = " & $locationset, 0, 0)
Sleep(3000)

Now my problem is, whenever I press F4, I runs lots of tool tip.au3s. Well the longer i hold it down, the more get run. Is there an easy way to fix this without using Hotkeys?

EDIT: Anyone else notice the "Autoit tags" arn't working?

Edited by Dethredic

"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites



You're never leaving the while loop, and so long as you hold down the key, it tries to run your other script. Why can't you use a HotKey?


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

use a timer that inits after the key is first pressed... do not accept that key press if timer < 2 seconds

Are you looking for something like that?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

How was your _Auto_Bot() Function being called? If you don't want it to run twice then add this at the end of the func.

While _IsPressed($Key)
;Do Nothing
WEnd

So as long as you key is held down, it does nothing but once of your func, and if they want the func to be executed again they can press the key again.

Hope that helped.

P.S: For AutoIt Tag, type autoit and /autoit with brackets.

Edited by Generator

Share this post


Link to post
Share on other sites

Hey thanks, for the ideas.

Well the function is going to be the main part of my script. I just wish there was like a _isreleased


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

@Generator, wow, you should see some of the bullshit I have been doing to accomplish the same thing LOL, and a big DUH in my direction.

Thanks

Share this post


Link to post
Share on other sites

I just wish there was like a _isreleased

DllCall("user32.dll", "int", "GetAsyncKeyState", "int", $hexOfKey) will return 0 if the key is not pressed. Although that's not different than checking the value of _IsPressed. That is the _IsReleased function...


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

The While _IsPressed() do nothing actually works, i used it in my project.

But while the key is helddown the script can't do anything so yeh, downside.

Edited by Generator

Share this post


Link to post
Share on other sites

the only way around that, that I know, is the use of the timer

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

isreleased would be not _ispressed. So just put if not _ispressed in a loop and then put the rest of you code in the if statement.

Edited by sccrstvn93

Share this post


Link to post
Share on other sites

thx im trying to figure out how to make that into a udf but it giving me a headache

Share this post


Link to post
Share on other sites

If Not _IsPressed is the same thing as While _IsPressed which means the key is being held down and not released up.

Correct me if i am wrong.

Share this post


Link to post
Share on other sites

you read it wrong.

He said If Not _IsPressed was the same as _isreleased ( a figurative function )

That or I read your post wrong

Share this post


Link to post
Share on other sites

you read it wrong.

He said If Not _IsPressed was the same as _isreleased ( a figurative function )

That or I read your post wrong

Of course thats what he meant. So I assume you put your loop in the If Not _IsPressed and the rest in else?

Though While Not _IsPressed is the same thing.

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

This is wat i was thinking

If _ispressed () Then

While 1

If not _ispressed () Then

watever

exitloop

Endif

Wend

Endif

There is probably an easier way to do this.

Edit: and i think while not _ispressed is the better way

Edited by sccrstvn93

Share this post


Link to post
Share on other sites

This is wat i was thinking

If _ispressed () Then

While 1

If not _ispressed () Then

watever

exitloop

Endif

Wend

Endif

There is probably an easier way to do this.

Edit: and i think while not _ispressed is the better way

I tried this, and the same thing as before happened.


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

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