Jump to content

_IsPressed


Recommended Posts

I'm wondering why code won't work. nothing appears to happen when I press control (11). here is a code snippet

#include <Misc.au3>
While 1
    If _IsPressed("11") Then
        Teef()
    EndIf   
WEnd

Func Teef()
    $ItemSearch = PixelSearch(250, 150, 550, 450, 0xA08D6D, 8)
    If Not @error Then
        MouseMove($ItemSearch[0], $ItemSearch[1], 0)
    EndIf
EndFunc

thanks!

Link to comment
Share on other sites

I'm wondering why code won't work. nothing appears to happen when I press control (11). here is a code snippet

#include <Misc.au3>
While 1
    If _IsPressed("11") Then
        Teef()
    EndIf   
WEnd

Func Teef()
    $ItemSearch = PixelSearch(250, 150, 550, 450, 0xA08D6D, 8)
    If Not @error Then
        MouseMove($ItemSearch[0], $ItemSearch[1], 0)
    EndIf
EndFunc

thanks!

It actually does work... your Teef() function must not be working right. I just added a console write in the teef function and it does get called when you press Ctrl.

Also, add a sleep in your main loop, just like Sleep(10) or something.

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

Okay, you're right it does work. I've found an issue though.

Sometimes when I press it down and release the key too quickly, it the loop continues until i hit CTRL again. What should I change to make it behave better, that is, only be active while the key is being pressed down?

Link to comment
Share on other sites

Okay, you're right it does work. I've found an issue though.

Sometimes when I press it down and release the key too quickly, it the loop continues until i hit CTRL again. What should I change to make it behave better, that is, only be active while the key is being pressed down?

Try this

#include <Misc.au3>
While 1
    If _IsPressed("11") Then
        Teef()
    Else
        _Pause()
    EndIf   
WEnd

Func Teef()
    ConsoleWrite ("sup")
EndFunc

Func _Pause()
    Sleep (10)
EndFunc
Link to comment
Share on other sites

Okay, you're right it does work. I've found an issue though.

Sometimes when I press it down and release the key too quickly, it the loop continues until i hit CTRL again. What should I change to make it behave better, that is, only be active while the key is being pressed down?

It could help with a faster loop

#include <Misc.au3>
$dll = DllOpen("user32.dll")

While 1
    If _IsPressed("11", $dll) Then
    $ItemSearch = PixelSearch(250, 150, 550, 450, 0xA08D6D, 8)
        If Not @error Then MouseMove($ItemSearch[0], $ItemSearch[1], 0)
    EndIf
WEnd
DllClose($dll)

But you may also want to try HotKeySet() and/or GUISetAccelerators()

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...