Sign in to follow this  
Followers 0
Mouse

_IsPressed Help?

5 posts in this topic

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

Share this post


Link to post
Share on other sites



Mouse,

Merry Christmas! :party:

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Mouse

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