4 Replies - 4927 Views - Last Post: 01 October 2008 - 04:55 PM Rate Topic: -----

#1 Zander  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 02-June 08

Multiple key presses + non visible form

Posted 30 September 2008 - 04:15 PM

Hi,

I am making a macro that runs a series of tasks. I have it so that you can make the form invisible with a simple Me.visible = false button. I can't seem to find a way to make it return for invisible by pressing ctrl + home.

does the form have to be visible for me to send a key?

How do you send multiple keys?

any help is much appreciated :)

	Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
		If e.KeyCode = Keys.Home Then 'add a second key here?
			Me.Visible = True
			e.Handled = True
		End If
	End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: Multiple key presses + non visible form

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8948
  • View blog
  • Posts: 33,544
  • Joined: 12-June 08

Re: Multiple key presses + non visible form

Posted 30 September 2008 - 06:01 PM

The biggest problem is the form has to have focus.. unless you hook farther up the line in the key press events..
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Multiple key presses + non visible form

Posted 30 September 2008 - 06:08 PM

The form has to have focus in order to send any key commands to it, or you can use Low level keyboard hooks to accomplish this.
Was This Post Helpful? 0
  • +
  • -

#4 Zander  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 02-June 08

Re: Multiple key presses + non visible form

Posted 01 October 2008 - 04:41 PM

hmmm Ok, thanks.

I think i can do this is GetAsyncKeyState.

Ill try it out.

-Zander
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Multiple key presses + non visible form

Posted 01 October 2008 - 04:55 PM

@Zander, with an invisible form that isnt going to help you any. You have two options:
  • Don't do it because your form has to have focus to be able to send keys to it
  • Follow the article I provided for low level keyboard hooks
That's the only way to send keys to an invisible form since it doesn't have focus :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1