VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Page 1 of 1
  • You cannot start a new topic
  • Reply Reply

Using My.Computer - error When using the Sendkeys statement, the word My is not recognized. Rate Topic: -----

#1 dllso5959  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-November 07


Dream Kudos: 0

Share |

Using My.Computer - error

Post icon  Posted 28 November 2007 - 06:15 AM

 Private Sub butPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles butPrint.Click

		My.computer.Keyboard.SendKeys("^%(p)", True)	'   Ctrl + Alt + p
		CaptureScreen()
		printDocument1.Print()

	End Sub


This post has been edited by PsychoCoder: 28 November 2007 - 09:59 PM

Was This Post Helpful? 0
  • +
  • -


#2 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • Icon

Reputation: 10
  • View blog
  • Posts: 1,953
  • Joined: 03-August 06


Dream Kudos: 755

Re: Using My.Computer - error

Posted 28 November 2007 - 06:38 AM

:code:
Was This Post Helpful? 0
  • +
  • -

#3 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • Icon

Reputation: 137
  • View blog
  • Posts: 4,622
  • Joined: 26-November 04


Dream Kudos: 2825

Expert In: J2ME, 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

Re: Using My.Computer - error

Posted 28 November 2007 - 09:44 PM

Does it recognize the Microsoft.VisualBasic Namespace?
This should work:
Dim x As New Microsoft.VisualBasic.Devices.Keyboard()
x.SendKeys("^%(p)", True)

Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • iHater.Init(this);
  • Icon

Reputation: 1364
  • View blog
  • Posts: 19,696
  • Joined: 26-July 07


Dream Kudos: 12925

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

Re: Using My.Computer - error

Posted 28 November 2007 - 10:07 PM

You can solve this by adding Imports Microsoft.VisualBasic to the top of your class (if not already there), also, Click Project > Add Reference then in the .Net tab select Microsoft.VisualBasic from the list and click OK.Hope that helps :)
Was This Post Helpful? 0
  • +
  • -

#5 dllso5959  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-November 07


Dream Kudos: 0

Re: Using My.Computer - error

Posted 29 November 2007 - 06:26 AM

View Postborn2c0de, on 28 Nov, 2007 - 10:44 PM, said:

Does it recognize the Microsoft.VisualBasic Namespace?
This should work:
Dim x As New Microsoft.VisualBasic.Devices.Keyboard()
x.SendKeys("^%(p)", True)


Thanks, this did work but I am curious why my.computer does not work. The microsoft documentation uses my.computer in many examples. Also, this is not the only case where MS examples do not work. Many of there examples need a namespace associated with them and they do not show how to declare them as in this case. MS docs are frustating. Thanks for your help.
Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • iHater.Init(this);
  • Icon

Reputation: 1364
  • View blog
  • Posts: 19,696
  • Joined: 26-July 07


Dream Kudos: 12925

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

Re: Using My.Computer - error

Posted 29 November 2007 - 12:13 PM

Thats because in the Microsoft examples it takes for granted that you've added a reference to the Microsoft.VisualBasic Namespace that I described in my solution :)

They should probably put a disclaimer on the Namespaces needed when following one of their tutorials, I always show what Namesaces are needed with all tutorials I write
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1
  • You cannot start a new topic
  • Reply Reply


Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users