Dethredic 0 Posted July 25, 2007 (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 July 25, 2007 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
mikehunt114 0 Posted July 25, 2007 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
DW1 102 Posted July 25, 2007 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? AutoIt3 Online Help Share this post Link to post Share on other sites
Generator 0 Posted July 25, 2007 (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 July 25, 2007 by Generator Share this post Link to post Share on other sites
Dethredic 0 Posted July 25, 2007 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
DW1 102 Posted July 25, 2007 @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 AutoIt3 Online Help Share this post Link to post Share on other sites
mikehunt114 0 Posted July 25, 2007 I just wish there was like a _isreleasedDllCall("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
Generator 0 Posted July 25, 2007 (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 July 25, 2007 by Generator Share this post Link to post Share on other sites
DW1 102 Posted July 25, 2007 the only way around that, that I know, is the use of the timer AutoIt3 Online Help Share this post Link to post Share on other sites
qazwsx 0 Posted July 25, 2007 (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 July 25, 2007 by sccrstvn93 Share this post Link to post Share on other sites
DW1 102 Posted July 25, 2007 Good idea sccrstvn93 AutoIt3 Online Help Share this post Link to post Share on other sites
qazwsx 0 Posted July 25, 2007 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
Generator 0 Posted July 25, 2007 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
DW1 102 Posted July 25, 2007 you read it wrong. He said If Not _IsPressed was the same as _isreleased ( a figurative function ) That or I read your post wrong AutoIt3 Online Help Share this post Link to post Share on other sites
Generator 0 Posted July 25, 2007 you read it wrong.He said If Not _IsPressed was the same as _isreleased ( a figurative function )That or I read your post wrongOf 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
qazwsx 0 Posted July 26, 2007 (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 July 26, 2007 by sccrstvn93 Share this post Link to post Share on other sites
Dethredic 0 Posted July 26, 2007 This is wat i was thinkingIf _ispressed () Then While 1 If not _ispressed () Then watever exitloop Endif WendEndifThere is probably an easier way to do this.Edit: and i think while not _ispressed is the better wayI 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