ReaImDown Posted October 12, 2007 Share Posted October 12, 2007 is there a way for autoit to detect the status of a specific key? Example, CODE#include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep ( 250 ) If _IsPressed("26", $dll) Then MsgBox(0,"_IsPressed", "End Key Pressed") Do sleep(1) Until (The key is released) EndIf WEnd DllClose($dll) [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
Achilles Posted October 12, 2007 Share Posted October 12, 2007 is there a way for autoit to detect the status of a specific key?Example,CODE#include <Misc.au3>$dll = DllOpen("user32.dll")While 1 Sleep ( 250 ) If _IsPressed("26", $dll) Then MsgBox(0,"_IsPressed", "End Key Pressed") Do sleep(1) Until (The key is released) EndIfWEndDllClose($dll)Looks like your example script answers most of your question. Just change "Until (The key is released)" to "Until Not _IsPressed("26", $dll)" My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
ReaImDown Posted October 12, 2007 Author Share Posted October 12, 2007 Looks like your example script answers most of your question. Just change "Until (The key is released)" to "Until Not _IsPressed("26", $dll)"true, but...I have many many many different possibilities for _IsPressed, not just "26" [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
aslani Posted October 12, 2007 Share Posted October 12, 2007 Check Here [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
ReaImDown Posted October 12, 2007 Author Share Posted October 12, 2007 Check Herevery helpful, thanks...but...It'll be hard for me to add it in... I have _ispressed used in my program about 75 times, and, Func _WaitRelease() doesnt seem to work because _ispressed is used so many different times, it doesnt stay a constant [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
aslani Posted October 13, 2007 Share Posted October 13, 2007 (edited) Come on, you can do it. Basically what you want is, if any of my $keysArray _IsPressed(), _waitRelease() for that key. Edited October 13, 2007 by aslani [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
ReaImDown Posted October 13, 2007 Author Share Posted October 13, 2007 Come on, you can do it. Basically what you want is, if any of my $keysArray _IsPressed(), _waitRelease() for that key.aha shit...I went and coppied / pasted, then deleted all of the _ispressed things, but, do you have a faster way? lol, it'd make my program faster, and would be appreciated, lol [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
LarryDalooza Posted October 13, 2007 Share Posted October 13, 2007 Get DLLCallBack ... http://www.autoitscript.com/forum/index.ph...st&p=384128And try this...expandcollapse popup#include "DllCallBack.au3" Global $KEY = 0 Global Const $WH_KEYBOARD_LL = 13 Global Const $WK_DOWN = 256 Global Const $WK_UP = 257 Global $hHook, $pStub_KeyProc Global $pStub_KeyProc = _DllCallBack ("_KeyProc","int;ptr;ptr") Global $hmod = DllCall("kernel32.dll","hwnd","GetModuleHandle","ptr",0) Global $hHook = DllCall("user32.dll","hwnd","SetWindowsHookEx","int",$WH_KEYBOARD_LL, _ "ptr",$pStub_KeyProc,"hwnd",$hmod[0],"dword",0) Global $buffer = "" While 1 Sleep(10) WEnd Func _KeyProc($nCode, $wParam, $lParam) Local $ret,$KEYHOOKSTRUCT If $nCode < 0 Then $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _ "int",$nCode,"ptr",$wParam,"ptr",$lParam) Return $ret[0] EndIf $KEYHOOKSTRUCT = DllStructCreate("dword;dword;dword;dword;ptr",$lParam) If $KEY = 0 Then If $wparam = $WK_DOWN Then $KEY = DllStructGetData($KEYHOOKSTRUCT,1) SplashTextOn("AutoIt3 Yahoo Group",$KEY & " DOWN" & @LF & Chr($KEY) & " DOWN",200,60) EndIf Else If $wparam = $WK_UP And (DllStructGetData($KEYHOOKSTRUCT,1) = $KEY) Then SplashTextOn("AutoIt3 Yahoo Group",$KEY & " UP" & @LF & Chr($KEY) & " UP",200,60) $KEY = 0 EndIf EndIf $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _ "int",$nCode,"ptr",$wParam,"ptr",$lParam) Return $ret[0] EndFunc Func OnAutoItExit() DllCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hHook[0]) EndFunc AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
Zedna Posted October 13, 2007 Share Posted October 13, 2007 Get DLLCallBack ... http://www.autoitscript.com/forum/index.ph...st&p=384128And try this...Very educative Larry Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
aslani Posted October 13, 2007 Share Posted October 13, 2007 Get DLLCallBack ... http://www.autoitscript.com/forum/index.ph...st&p=384128 And try this... expandcollapse popup#include "DllCallBack.au3" Global $KEY = 0 Global Const $WH_KEYBOARD_LL = 13 Global Const $WK_DOWN = 256 Global Const $WK_UP = 257 Global $hHook, $pStub_KeyProc Global $pStub_KeyProc = _DllCallBack ("_KeyProc","int;ptr;ptr") Global $hmod = DllCall("kernel32.dll","hwnd","GetModuleHandle","ptr",0) Global $hHook = DllCall("user32.dll","hwnd","SetWindowsHookEx","int",$WH_KEYBOARD_LL, _ "ptr",$pStub_KeyProc,"hwnd",$hmod[0],"dword",0) Global $buffer = "" While 1 Sleep(10) WEnd Func _KeyProc($nCode, $wParam, $lParam) Local $ret,$KEYHOOKSTRUCT If $nCode < 0 Then $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _ "int",$nCode,"ptr",$wParam,"ptr",$lParam) Return $ret[0] EndIf $KEYHOOKSTRUCT = DllStructCreate("dword;dword;dword;dword;ptr",$lParam) If $KEY = 0 Then If $wparam = $WK_DOWN Then $KEY = DllStructGetData($KEYHOOKSTRUCT,1) SplashTextOn("AutoIt3 Yahoo Group",$KEY & " DOWN" & @LF & Chr($KEY) & " DOWN",200,60) EndIf Else If $wparam = $WK_UP And (DllStructGetData($KEYHOOKSTRUCT,1) = $KEY) Then SplashTextOn("AutoIt3 Yahoo Group",$KEY & " UP" & @LF & Chr($KEY) & " UP",200,60) $KEY = 0 EndIf EndIf $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _ "int",$nCode,"ptr",$wParam,"ptr",$lParam) Return $ret[0] EndFunc Func OnAutoItExit() DllCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hHook[0]) EndFunc I like it! [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now