Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

WACOM tablet and switching between 2 monitors


  • Please log in to reply
9 replies to this topic
elerouxx
  • Members
  • 5 posts
  • Last active: Sep 10 2013 11:00 PM
  • Joined: 02 Nov 2009
Hi. This is my first post - i am new to AHK.

I wanted to use AHK to switch monitors for my Graphire wacom tablet.

I know this issue has been covered extensively in past. I remember to have used a couple well done apps, and one of them was an AHK script - But now I couldn't find the tools, working download links, or a new solution that works under windows 7, at least for me. So I decided to start fresh and make a very simple script.

The script below works, but requires the user to open the Wacom Tablet Properties (c:/windows/system32/wacomtablet.cpl), and set it on the Mapping tab, then minimize if needed.

I would really like to know why the following statements don't work in windows7:

Run, C:\Windows\System32\WacomTablet.cpl
(I can run other cpl and exe files in the same folder, just no WacomTablet.cpl and a couple others).

Run %WINDIR%\notepad.exe

This should launch the notepad but it doesn't. Does AHK recognize %WINDIR%?

Also, even if I bring out the Wacom Tablet window, the Mapping control is under a tab. These tabs don't appear as controls under Window Spy so I can not click on them.

Anyway, I'm posting here for sharing and for any information on how to improve this. Any comments are welcome! thanks!


;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <[email protected]>
;
; Script Function:
;	Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;Simple wacom switching using the keys WIN+SPACE

;The user must open Wacom Tablet Properties and leave it in the MAPPING tab for this to run.


;I'd like to Run c:\System32\WacomTablet.cpl , but that didn't work. 
;Then I'd like to go to the Mapping tab, but that doesn't work either 
;because the tabs don't appear like controls.



#space::
ifWinExist Wacom Tablet Properties
{
	
	ControlGet, mon, choice,,ComboBox2,Wacom Tablet Properties
		
	if (InStr(mon,1))
	{
		Control, Choose,4,ComboBox2,Wacom Tablet Properties
		
	}
	Else
	{
		Control, Choose,3,ComboBox2,Wacom Tablet Properties
	}	
}


return


  • Guests
  • Last active:
  • Joined: --
ahk wont recognized %WINDIR% but:
A_WinDir


elerouxx
  • Members
  • 5 posts
  • Last active: Sep 10 2013 11:00 PM
  • Joined: 02 Nov 2009
Thanks! so I tried:

run,%A_WinDir%\notepad.exe

and it opens the notepad. Then i try:

run,%A_WinDir%\System32\Telephon.cpl

it opens the phone and modem control panel.
But then I try:

run,%A_WinDir%\System32\WacomTablet.cpl

and it still won't open the Wacom Tablet Properties control panel.

I guess there's another name for 'system32'. I don't know how Windows7 really works..

  • Guests
  • Last active:
  • Joined: --
Is it the 64-bit version of Windows 7 or 32-bit?

elerouxx
  • Members
  • 5 posts
  • Last active: Sep 10 2013 11:00 PM
  • Joined: 02 Nov 2009
It's Windows7 x64.

I just found a weird workaround ;)

I found out the control panels open with a program called 'Windows Control Panel', which is Control.exe in /system32,
so Run Control.exe WacomTablet.cpl opens the tablet control panel all right. Don't even need to set the directory because control.exe is accesible from anywhere.

Then I can't found a 'tab' control for the mapping 'tab' but I guess it's a custom control.
Anyway I added some fail-proof lines so the app now works in almost any conditions, with or without the wacom tablet open, and in any mode (mouse, pen, any tab). I don't know if clicking on a specific coordinate will restrain the macro from working in other systems, but it works for me so I share it here. Thanks!





;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <[email protected]>
;
; Script Function:
;	Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;Simple wacom switching with WIN+SPACE


#space::
IfWinNotExist Wacom Tablet Properties
{
	;If control panel is not open, open it and set to pen mapping mode, then minimize

	run,%A_WinDir%\System32\control.exe WacomTablet.cpl
	WinWait,Wacom Tablet Properties
	ControlClick,x140 y220,Wacom Tablet Properties ;mapping tab location
	WinMinimize,Wacom Tablet Properties
}

;Still check if window exists
ifWinExist Wacom Tablet Properties
{	
	
	;Check if Control Panel is in Mapping mode
	ControlGet,mapmode,FindString,Full,ComboBox2,Wacom Tablet Properties

	ifNotEqual,mapmode,1
	{
		;set cpl to pen mapping mode before switching	
		WinActivate,Wacom Tablet Properties
		WinWait,Wacom Tablet Properties
		ControlClick,Button3,Wacom Tablet Properties
		ControlClick,x140 y220,Wacom Tablet Properties ;mapping tab location
		WinMinimize,Wacom Tablet Properties

	}


	ControlGet, mon, choice,,ComboBox2,Wacom Tablet Properties
	

		
	if (InStr(mon,1))
	{
		Control, Choose,4,ComboBox2,Wacom Tablet Properties
		
	}
	Else
	{
		Control, Choose,3,ComboBox2,Wacom Tablet Properties
	}	
}
else
{
	MsgBox "There was some problem activating the Wacom Tablet Properties. Please open the control panel manually and set it on the Mapping tab" 


}


return


  • Guests
  • Last active:
  • Joined: --
This is how I do it. (A bit late maybe ;-))

;Wacom switch monitorz
#z::
DetectHiddenWindows, On
IfWinExist, Pen Mode Details
{
;Click arrow up to select next monitor (keeps looping 1,2,1,2 etc) so only arrow up is enough
ControlClick, msctls_updown321, Pen Mode Details,,,, NA X0 Y0
}
IfWinNotExist, Pen Mode Details
{
;Open Pen Tablet Properties
Run, control pentablet.cpl
WinWait Pen Tablet Properties
;Click Details... Button
SetControlDelay -1
ControlClick, Button11, Pen Tablet Properties,,,, NA
WinWait Pen Mode Details
;Click arrow up to select next monitor (keeps looping 1,2,1,2 etc) so only arrow up is enough
ControlClick, msctls_updown321, Pen Mode Details,,,, NA X0 Y0
;Hide window
WinHide Pen Mode Details
WinHide Pen Tablet Properties
}
DetectHiddenWindows, Off
OnExit, ExitSub
return

  • Guests
  • Last active:
  • Joined: --
the part about having to leave the properties window open isn't that just a wacom bug? IIRC some drivers doesn't have that problem.

ps. i love how I can post without registering, thank you AHK!

Lucefer
  • Guests
  • Last active:
  • Joined: --
see here: http://rutracker.org...c.php?t=3255955

Denton
  • Guests
  • Last active:
  • Joined: --
I'm able to get elerouxx's script to work (by updating the .cpl to "C:\Program Files\Tablet\Wacom\Professional_CPL.exe")

However Photoshop/Painter/openCanvas/FireFox and .. well basically anything other than Windows Explorer, loses the hotkey assignment.
It's as if all other applications override it?

Is there any way to fix that?

Denton
  • Guests
  • Last active:
  • Joined: --
I've had some more time to play with it and I've got it working.
Basically, having multiple application profiles in the Tablet preferences was causing the problem.
Even if the script changed the mapping to the other monitor, it only affected the profile named "All Other".
So if you're in Photoshop, mapping remains locked to whatever monitor was assigned in the Photoshop profile, hence ignoring the updated "All Other" profile.
The solution is to make the Desktop active thus invoking the "All Other" profile, which contains the correct alternate monitor mapping.

Selecting the Desktop obviously causes the current file/folder/application to lose focus, which means you can't drag things across monitors.
So I've included some basic "is mouse active" checks, which will allow dragging/switching first and THEN shifting focus to Desktop.

Been using this setup for a few weeks now, and it's been working great.
Note: I've bound the function to the tilde key, but you can change that.

Probably not the best/cleanest/efficient methods used in this script, but it works! Thanks to elerouxx for his original code 8)

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;Wacom Display Toggle - Invoked by tilde ` key

`::
IfWinNotExist Wacom Tablet Properties
{
   ;If control panel is not open, open it and set to pen mapping mode, then minimize
   run,"C:\Program Files\Tablet\Wacom\Professional_CPL.exe"
   WinWait,Wacom Tablet Properties
   ControlClick,x140 y220,Wacom Tablet Properties ;mapping tab location
   WinMinimize,Wacom Tablet Properties
}
;Still check if window exists
ifWinExist Wacom Tablet Properties
{     
   ;Check if Control Panel is in Mapping mode
   ControlGet,mapmode,FindString,Full,ComboBox2,Wacom Tablet Properties
   ifNotEqual,mapmode,1
   {
      ;set cpl to pen mapping mode before switching   
      WinActivate,Wacom Tablet Properties
      WinWait,Wacom Tablet Properties
      ControlClick,Button3,Wacom Tablet Properties
      ControlClick,x140 y220,Wacom Tablet Properties ;mapping tab location
      WinMinimize,Wacom Tablet Properties
   }
   ControlGet, mon, choice,,ComboBox2,Wacom Tablet Properties
   if (InStr(mon,1))
   {
      Control, Choose,4,ComboBox2,Wacom Tablet Properties
   }
   Else
   {
      Control, Choose,3,ComboBox2,Wacom Tablet Properties
   }
}
;Check for any active mouse buttons. If so, keep held and switch to other monitor.
GetKeyState, state, LButton, P
if state = U
{
  GetKeyState, state, RButton, P
  if state = U
  {
    GetKeyState, state,	MButton, P
    if state = U
    {
      WinActivate,Program Manager
      return
    }
  }
}
else
return