Jump to content

Need help with _ispressed


aRd78
 Share

Recommended Posts

Hi there,

I´m trying to remap a keypad

Posted Image

My sample code looks like this..

HotKeySet("{Esc}","_Exit_app")
#include <Misc.au3>
$dll = DllOpen("user32.dll")


While 1

    if ( _IsPressed("6A", $dll)) Then
        ToolTip("test")
        sleep(500)
        ToolTip("")
    EndIf


sleep(100)
WEnd

Func _Exit_app()
DllClose($dll)
Exit
EndFunc

My problem is that when pressing the * key my "hot key" works but i also get a * sent to the application. I want to stop the sending of the *.

Hope you guys understand my problem.. :graduated:

Edited by aRd78
Link to comment
Share on other sites

Try telling it to send something else.

I described a little bit crazy. I want to capture the real key press in order to replace it with another one. Normally, I would be able to use hotkeyset but it does not work on asterisk (*). :graduated:

Link to comment
Share on other sites

Im not sure I follow, you know what the real ispressed is, its "6A".

I'll try to explain better. I want to achieve: when I press the asterisk (*) on the numpad, AutoIt would stop that press and send backspace instead. But right now I just manage to accomplish the following, when I for example in notepad, press the asterisk (*) asterisk symbol will occur in notepad (not what I want) and then my script sends a backspace. :graduated:

The reason I use _ispressed is that I never had a Hotkeyset to work with asterisk!

see new example code!!!

HotKeySet("{Esc}","_Exit_app")
#include <Misc.au3>
$dll = DllOpen("user32.dll")


While 1

    if ( _IsPressed("6A", $dll)) Then
        send("{BACKSPACE}")
    EndIf


sleep(100)
WEnd



func _Exit_app()
DllClose($dll)
Exit
EndFunc
Link to comment
Share on other sites

The reason I use _ispressed is that I never had a Hotkeyset to work with asterisk!

Try this:

HotKeySet("+8", "_msg")

while 1
    sleep( 10) ;idle around
wend    

func _msg()
    msgbox(0, "", "* pressed!")
EndFunc

Or this:

HotKeySet("*", "_msg")

while 1
    sleep( 10) ;idle around
wend    

func _msg()
    msgbox(0, "", "* pressed!")
EndFunc

Both will work on SHIFT&8, but will not work on the asterisk key.

edit: This is an interesting problem. I'm looking around to see how to solve this.

Edited by MPH
Link to comment
Share on other sites

This will work on the asterisk key in question. It is referred to as the "Multiply" key

#include <Misc.au3> 
$dll = DllOpen("user32.dll")
 While 1
     Sleep ( 250 )
     If _IsPressed("6A", $dll) Then
         MsgBox(0,"_IsPressed", "End Key Pressed")
         ExitLoop
     EndIf
 WEnd
Link to comment
Share on other sites

I think that is basically the code the OP has to begin with.

I'm thinking he wants a function more like hotkeyset(), because that will intercept the sending of the asterix and send some other character, where as

#include <Misc.au3>
$dll = DllOpen("user32.dll")
 While 1
     Sleep ( 250 )
     If _IsPressed("6A", $dll) Then
         Send("a")
         ExitLoop
     EndIf
 WEnd

will send both

If something like HotKeySet("6A","_func") were possible, would be a solution.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

@MPH & @aRd78

To get a hotkeyset to work for the numberpad * to work, you need to use {NUMPADMULT}.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Spot on BrewManNH

HotKeySet("{NUMPADMULT}","_run")

While 1
    Sleep(10)
WEnd

Func _run()
    Send("x")
EndFunc

Hopefully this solves my problem! But I'm still curious

if it is possible to prevent the letter / character from being sent when you use _ispressed?

I´ll give it a try at work tomorrow...

Thx!!! :graduated:

Edited by aRd78
Link to comment
Share on other sites

if it is possible to prevent the letter / character from being sent when you use _ispressed?

Maybe playing with sendkeydelay - then next onto getting it to only backspace over a single character

#Include <Misc.au3>

Opt("SendKeyDelay", 30)          ;5 milliseconds

While 1
    If _IsPressed("6A") Then
        send ("{BS 1}")
        sleep (50)
    EndIf
WEnd

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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...