Sign in to follow this  
Followers 0
suxxor

_IsPressed

6 posts in this topic

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!

Share this post


Link to post
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]

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
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()

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