SirDrake

Detect pressed key on other application

4 posts in this topic

#1 ·  Posted

Hi, I'm trying to detect determinated key, when pressed,  when I'm on other application, I tried hotkeyset and _isPressed functions but didn't work...or maybe I wrong something...There is a way to detect the numpad keyboard when I'm using other applications? 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

9 minutes ago, SirDrake said:

or maybe I wrong something..

Show your code so we can see what you did... and which application are you using when the hotkey doesn't work?

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted

Spoiler

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <Array.au3>
#include <GuiEdit.au3>
#include <ScrollBarConstants.au3>
#include <GUIListView.au3>
#include <ColorConstants.au3>
$Form1 = GUICreate("test", 218, 276, 192, 124)
$Group1 = GUICtrlCreateGroup("Test Key list", 8, 8, 201, 257)
GUICtrlSetColor(-1, $COLOR_RED)
$Label1 = GUICtrlCreateLabel("1 = Test1", 24, 72, 69, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label2 = GUICtrlCreateLabel("3 = Test2", 24, 96, 55, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label3 = GUICtrlCreateLabel("2 = Test3", 120, 72, 69, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label4 = GUICtrlCreateLabel("4 = Test4", 120, 96, 57, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label5 = GUICtrlCreateLabel("5 = Test5", 24, 120, 55, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label6 = GUICtrlCreateLabel("6 = Test6", 120, 120, 67, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label7 = GUICtrlCreateLabel("7 = Test7", 24, 144, 67, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label8 = GUICtrlCreateLabel("8 = Test8", 120, 144, 54, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label9 = GUICtrlCreateLabel("9 = Test9", 24, 168, 55, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label10 = GUICtrlCreateLabel("/ = Test10", 120, 168, 66, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label11 = GUICtrlCreateLabel("* = Test11", 24, 192, 85, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label12 = GUICtrlCreateLabel("- = Test12", 120, 192, 57, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label13 = GUICtrlCreateLabel("+ = Test13", 24, 216, 76, 17)
GUICtrlSetColor(-1, $COLOR_RED)
;$Label14 = GUICtrlCreateLabel(". = Test14" 120, 216, 76, 17) Error??
GUICtrlSetColor(-1, $COLOR_RED)
$Label15 = GUICtrlCreateLabel("0 = Test 15", 24, 240, 83, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Label16 = GUICtrlCreateLabel("Canc = Exit ", 120, 240, 87, 17)
GUICtrlSetColor(-1, $COLOR_RED)
$Group2 = GUICtrlCreateGroup("Legenda", 16, 24, 185, 41)
GUICtrlSetColor(-1, $COLOR_RED)
$Label17 = GUICtrlCreateLabel("Work Color", 32, 40, 70, 17)
GUICtrlSetColor(-1, $COLOR_GREEN)
$Label18 = GUICtrlCreateLabel("No Work Color", 112, 40, 72, 17)
GUICtrlSetColor(-1, $COLOR_RED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
 #cs
 HotKeySet("{NUMPAD1}", "Test1")
 HotKeySet("{NUMPAD2}", "Test2")
 HotKeySet("{NUMPAD3}", "Test3")
 HotKeySet("{NUMPAD4}", "Test4")
 HotKeySet("{NUMPAD5}", "Test5")
 HotKeySet("{NUMPAD6}", "Test6")
 HotKeySet("{NUMPAD7}", "Test7")
 HotKeySet("{NUMPAD8}", "Test8")
 HotKeySet("{NUMPAD9}", "Test9")
 HotKeySet("{NUMPADDIV}", "Test10")
 HotKeySet("{NUMPADMULT}", "Test11")
 HotKeySet("{NUMPADSUB}", "Test12")
 HotKeySet("{NUMPADADD}", "Test13")
 HotKeySet("{NUMPADDOT}", "Test14")
 HotKeySet("{NUMPAD0}", "Test15)
 HotKeySet("{DEL}", "Exiting")
 #ce
While 1
 If _IsPressed("61") Then
 Test1()
 EndIf
WEnd
Func Test1()
 MsgBox(0,"1 work",0.5)
 GUICtrlSetColor($Label1, $COLOR_GREEN)
EndFunc
Func Test2()
 MsgBox(0,"2 work",0.5)
 GUICtrlSetColor($Label2, $COLOR_GREEN)
EndFunc
Func Test3()
 MsgBox(0,"3 work",0.5)
 GUICtrlSetColor($Label3, $COLOR_GREEN)
EndFunc
Func Test4()
 MsgBox(0,"4 work",0.5)
 GUICtrlSetColor($Label4, $COLOR_GREEN)
EndFunc
Func Test5()
 MsgBox(0,"5 work",0.5)
 GUICtrlSetColor($Label5, $COLOR_GREEN)
EndFunc
Func Test6()
 MsgBox(0,"6 work",0.5)
 GUICtrlSetColor($Label6, $COLOR_GREEN)
EndFunc
Func Test7()
 MsgBox(0,"7 work",0.5)
 GUICtrlSetColor($Label7, $COLOR_GREEN)
EndFunc
Func Test8()
 MsgBox(0,"8 work",0.5)
 GUICtrlSetColor($Label8, $COLOR_GREEN)
EndFunc
Func Test9()
 MsgBox(0,"9 work",0.5)
 GUICtrlSetColor($Label9, $COLOR_GREEN)
EndFunc
Func Test10()
 MsgBox(0,"/ work",0.5)
 GUICtrlSetColor($Label10, $COLOR_GREEN)
EndFunc
Func Test11()
 MsgBox(0,"* work",0.5)
 GUICtrlSetColor($Label11, $COLOR_GREEN)
EndFunc
Func Test12()
 MsgBox(0,"- work",0.5)
 GUICtrlSetColor($Label12, $COLOR_GREEN)
EndFunc
Func Test13()
 MsgBox(0,"+ work",0.5)
 GUICtrlSetColor($Label13, $COLOR_GREEN)
EndFunc
;Func Test14()
; MsgBox(0,". work",0.5)
 ;GUICtrlSetColor($Label14, $COLOR_GREEN)
;EndFunc
Func Test15()
 MsgBox(0,"0 work",0.5)
 GUICtrlSetColor($Label15, $COLOR_GREEN)
EndFunc
Func  Exiting()
 MsgBox(0,"1 work",0.5)
 Exit
 EndFunc

 

This is the code where i test all numpad and a test of _IsPressed, i'm trying for example in a game which when i press a key, like 1, Says what time it is and after a few seconds close it, or to fastly open Google Chrome

Share this post


Link to post
Share on other sites

#4 ·  Posted

49 minutes ago, SirDrake said:

i'm trying for example in a game

That is likely the key thing here were most have some protection against this. 
Either way: Please read our forumrules now as we have a section in there that explicitly states we don;t want to see any game automation threads.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.