Mouse Posted December 25, 2012 Posted December 25, 2012 Well, lately i have been having this problem with _IsPressed everytime i hold down the button that i set with _Ispressed, it would spam. What i need help with, is how would i go to make it so it will execute the function ONE TIME when i press the button? -Heres a set up of "_Ispressed" and the button is set to "CTRL" and when "CTRL" is pressed it will execute the function called "lol"... but it spams it.- #include Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("11", $hDLL) Then lol() endif ;;;; WEnd Func lol() MouseClick("Left",987,702,1,1) endfunc
Moderators Melba23 Posted December 25, 2012 Moderators Posted December 25, 2012 Mouse, Merry Christmas! Just wait until the key is released before continuing: #include <Misc.au3> HotKeySet("{ESC}", "On_Exit") Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("11", $hDLL) Then lol() ; Now wait until the key is released While _IsPressed("11", $hDLL) Sleep(10) ; ; You need this to keep the CPU from overheating when in this inner loop WEnd EndIf Sleep(10) ; You also need this to keep the CPU from overheating when in this outer loop WEnd Func lol() ConsoleWrite("Firing" & @CRLF) EndFunc ;==>lol Func On_Exit() DllClose($hDLL) ; Do not forget to close the DLL Exit EndFunc All clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kylomas Posted December 25, 2012 Posted December 25, 2012 Mouse, Here's one way #include <misc.au3> Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("11", $hDLL) Then lol() EndIf WEnd Func lol() If Not _IsPressed('11') Then MouseClick("Left", 987, 702, 1, 1) EndFunc ;==>lol kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
kylomas Posted December 25, 2012 Posted December 25, 2012 M23 is too fast, Merry Christmas Melba! Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
Mouse Posted December 25, 2012 Author Posted December 25, 2012 (edited) Thank you guys sooooo much! Just wow, i've been having this problem for so long, and you just fixed it so fast! Merry Christmas! Edited December 25, 2012 by Mouse
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now