Jump to content


Photo

Getting only UP state (solved)


  • Please log in to reply
12 replies to this topic

#1 Klark92

Klark92
  • Members
  • 854 posts

Posted 14 May 2012 - 05:36 PM

loop
{
   Stroke := Chr(a_index)
   Matchlist := Matchlist . Stroke . ","
   if (a_index==255)
      break
}

Loop
{
   Input, UserInput, V,, %Matchlist%
   msgbox % UserInput
}

How can I get messagebox while I up any key ?

#2 Ohnitiel

Ohnitiel
  • Members
  • 664 posts

Posted 14 May 2012 - 06:11 PM

This worked for me.

loop 255
{
	var := Chr(A_Index)
	Hotkey, %var%, sub
}

Sub:
KeyWait, %A_ThisHotkey%
Msgbox
return

!x::
ExitApp

EDIT:
Added a keywait to the code.

#3 Klark92

Klark92
  • Members
  • 854 posts

Posted 14 May 2012 - 06:40 PM

some ansi keys is not support for this method .. and gives warning after start..

#4 Ohnitiel

Ohnitiel
  • Members
  • 664 posts

Posted 14 May 2012 - 07:30 PM

Well I had not given it to much though, this one goes blocking all keys including mouse ones:

SetFormat, Integer, Hex

loop 255
{
;	If (A_index = 0x02 or 0x01)
;		continue
	var = vk%A_Index%
	Hotkey, %var%, sub
}

Sub:
KeyWait, %A_ThisHotkey%
Msgbox
return

!x::
ExitApp

Uncomment the commented lines if you want to unblock mouse buttons. (Left and Right only)

#5 Klark92

Klark92
  • Members
  • 854 posts

Posted 14 May 2012 - 08:19 PM

what is that dude ?

I only want to show message when the key is up .. not down ^^

#6 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 14 May 2012 - 08:25 PM

Have you looked at GetKeyState? Hint, look at state = U:
<!-- m -->http://www.autohotke...GetKeyState.htm<!-- m -->

#7 Ohnitiel

Ohnitiel
  • Members
  • 664 posts

Posted 15 May 2012 - 10:40 PM

Rechecked the code and tested it this time:

loop 255
{
	If (A_index = 0x2) or (A_Index = 0x1)
		continue
	var = vk%A_Index%
	Hotkey, %var%, sub
}
return

Sub:
KeyWait, %A_ThisHotkey%
Msgbox
return

!x::
ExitApp

It blocks all but left and right mouse buttons.

#8 Frankie

Frankie
  • Members
  • 2930 posts

Posted 15 May 2012 - 11:31 PM

You may be able to use this function: [stdlib] Anykey!! What? Where is my AnyKey??

#9 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 16 May 2012 - 07:23 AM

Try this:
#Persistent

#SingleInstance Force

#NoEnv  						; Recommended for performance and compatibility with future AutoHotkey releases.

SetBatchLines -1 				; maximum speed for loops



loop

{

   Stroke := Chr(a_index)

   Matchlist := Matchlist . Stroke . ","

   if (a_index==255)

      break

}



Loop

{

   Input, UserInput, V,, %Matchlist%

   while GetKeyState(UserInput)

		sleep 10 ; meaning while the key is depressed, do nothing

	msgbox % UserInput

}


#10 Klark92

Klark92
  • Members
  • 854 posts

Posted 16 May 2012 - 07:29 AM

Thanks solved ^^

#11 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 16 May 2012 - 11:50 AM

How did you end up solving it?

#12 Klark92

Klark92
  • Members
  • 854 posts

Posted 16 May 2012 - 02:36 PM

I tested your code then solved ? no problem mate.

#13 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 16 May 2012 - 08:03 PM

Ah, ok, glad I could help, you're welcome.