|
-
January 20th, 2010, 10:41 PM
#1
[RESOLVED] Touch Enable / Disable Script.
Hello,
I'm new to this forum.
I don't have much experience writing programs for the computer, but I know how to do some fairly simple stuff. I do write code for microprocessors (PICs). I do not have a visual basic compiler on any computer.
I want to make a program that turns on/off the "Use your finger as an input device" checkbox in the control panel. Currently, I'm doing it by opening the .cpl file and sending some keystrokes to it with vbs, to change the settings. This works fine, but you see the dialogue box come up.
I've originally tried to do this by changing the following registry entries:
"HKEY_CURRENT_USER\Software\Microsoft\Wisp\Touch\TouchGate"
- DWORD, 1 = Touch Enabled, 0 =Touch Disabled
"HKEY_CURRENT_USER\Software\Microsoft\Wisp\MultiTouch"
- DWORD, 1 = Multi-Touch Gestures Enabled, 0 =Multi-Touch Gestures Disabled
And then refreshing explorer.exe by killing it and then starting it. The only problem is that the Notification Area Icons then have problems, and won't re-appear.
I've read some things on this forum, and it appears that people are using "WM_SETTINGCHANGE" message to update explorer.exe.
Will this work? Is there a better alternative? How do I implement it? Do I have to download a vb6.0 compiler? Or can I use vbs?
See this thread here:
http://www.gottabemobile.com/forum/d...le-script.html
Thanks in advance for any responses.
-
January 21st, 2010, 05:21 PM
#2
Re: Touch Enable / Disable Script.
Please Move this thread to the Visual Basic.NET forum.
I have just install Microsoft Visual Basic Express Edition 2008.
This is what I have:
Public Class Form1
Private Const HWND_BROADCAST = &HFFFF
Private Const WM_SETTINGCHANGE = &H1A
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Object)
Declare Function SendMessageTimeout Lib "user32" Alias "SendMessageTimeoutA" (ByVal hwnd As Int32, ByVal msg As Int32, ByVal wParam As Int32, ByVal lParam As String, ByVal fuFlags As Int32, ByVal uTimeout As Int32, ByVal lpdwResult As Int32) As Int32
Private Sub Touch_ON_Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Touch_ON_Button.Click
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0)
End Sub
End Class
I'm not sure what I'm doing wrong here. I'm geting a
A first chance exception of type 'System.Runtime.InteropServices.MarshalDirectiveException' occurred in WindowsApplication1.exe
error.
-
January 21st, 2010, 08:39 PM
#3
Re: Touch Enable / Disable Script.
try declaring sendmessage in one of these way:
(for more details see:
http://pinvoke.net/default.aspx/user32.SendMessage )
Code:
Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
or
Declare Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer,
ByVal wParam As IntPtr, ByRef lParam As StringBuilder) As IntPtr
or
Declare Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer,
ByVal wParam As IntPtr, ByRef RECT As IntPtr) As IntPtr
or
Declare Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer,
ByVal wParam As IntPtr, ByRef POINT As IntPtr) As IntPtr
Last edited by Cimperiali; January 21st, 2010 at 09:08 PM.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
January 21st, 2010, 10:13 PM
#4
Re: Touch Enable / Disable Script.
Thankyou very much for the quick response.
I will try that now.
Thanks again.
Edit: The results are:
Way 1 (the first one you mentioned):
- No Visual Basic Debugger error, but application crashes.
Way 2
- "Stringbuilder" invalid.
Way 3
- Error: Unable to find an entry point named 'SendMessage' in DLL 'user32.dll'.
Way 4
- Error: Unable to find an entry point named 'SendMessage' in DLL 'user32.dll'.
From this I am assuming that Way 1 is correct, except I'm using the SendMessage function insted of the SendMessageTimeout.
Last edited by xnederlandx; January 21st, 2010 at 10:55 PM.
-
January 21st, 2010, 10:57 PM
#5
Re: Touch Enable / Disable Script.
I think this is way overcomplicating things.
Does anyone know a place where I can download an .exe which will refresh explorer (without killing it and restarting it). I think that would be simplest...
I've done a google search, but that returned nothing.
-
January 22nd, 2010, 07:51 AM
#6
Re: Touch Enable / Disable Script.
SendMessageTimeOut is the appropriate API to use here, try this :
Code:
Declare Auto Function SendMessageTimeout Lib "User32" ( _
ByVal hWnd As Integer, _
ByVal Msg As UInt32, _
ByVal wParam As Integer, _
ByVal lParam As Integer, _
ByVal fuFlags As UInt32, _
ByVal uTimeout As UInt32, _
ByRef lpdwResult As IntPtr _
) As Long
Private Const HWND_BROADCAST = &HFFFF&
Private Const WM_SETTINGCHANGE = &H1A
Private Const SMTO_ABORTIFHUNG = &H2
Public Sub EnvRefresh()
Dim dwResult As IntPtr '
SendMessageTimeout(HWND_BROADCAST, _
Convert.ToUInt32(WM_SETTINGCHANGE), _
0, 0, _
Convert.ToUInt32(SMTO_ABORTIFHUNG), _
Convert.ToUInt32(2000), _
dwResult)
End Sub
Private Sub Touch_ON_Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Touch_ON_Button.Click
EnvRefresh()
End Sub
-
January 22nd, 2010, 11:50 PM
#7
Re: Touch Enable / Disable Script.
It appears to be working.
Just tested it on my Windows 7 64-bit, and I can see explorer.exe pinging the processor for a moment when I push the button.
Thankyou very much for your assistance.
-
January 23rd, 2010, 02:01 AM
#8
Re: Touch Enable / Disable Script.
That is great news!
Good work! 
Please just remember when your thread is answered and solved, to mark it as Resolved, as outlined here :
http://www.codeguru.com/forum/showthread.php?t=403073
-
January 23rd, 2010, 03:13 AM
#9
Re: [RESOLVED] Touch Enable / Disable Script.
Done.
Thankyou very much for your assistance.
Credit has been given to you, HanneSThEGreaT, and Cimperiali.
See here:
http://www.gottabemobile.com/forum/d...html#post54412
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|