AutoHotkey Community

It is currently May 27th, 2012, 5:46 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: October 22nd, 2005, 10:55 pm 
Offline

Joined: February 4th, 2005, 7:24 pm
Posts: 24
Hi,

I love AutoHotkey and did a lot of workaround thanks to it.
I would like to go a step further and play with DLL and windows API.

Well... I'm a laptop user and at work, I attach a second monitor. At home, I don't have this second monitor. I'm getting tired of always performing the changes by hand and would like to use autohotkey for that purpose.

I think I should use ChangeDisplaySettingsEx as documented http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_3tfc.asp.

This function will require me to first call EnumDisplayDevices, I think but I'm getting lost with the structure it has for the out.

This is my first time playing with Windows API and I would be really happy if someone could give me a hand,

Thanks in advance,

Pierre.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2005, 10:56 am 
Quote:
SCRNMODE

This is a quick and dirty program for changing screen mode, (resolution, color depth, etc.), and then optionally running a specified program. It is useful for running apps/games that only run in a specific screen mode. For example, I run this program from a shortcut to start WinTV in 640x480 mode, since WinTV's "full-screen" option will only work at this resolution, (due to limitations of my video driver).

Run the program directly, (with no parameters), for a list of screen modes supported by your display. Specify a display mode as a parameter to change the display mode. You can also specify the name of a program to run after changing the display.

C:\>scrnmode 11 "C:\Program Files\WinTV\wintv.exe"

This sets the display mode to 11, then runs "wintv.exe". If the program to run also takes parameters, include them as a third parameter to scrnmode. (Enclose multiple parameters in quotes if necessary.) To reset the display mode to the original setting, run the program with "reset" as a parameter instead of a display number.

C:\>scrnmode reset

WARNING!: Changing display modes dynamically can hang certain Windows configurations. Avoid using this program any time you have important unsaved data in open applications. Please do not blame, (or flame), me if things get messed up.

[Home] - [Download] (Source included)
Hope that helps. 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2005, 5:07 pm 
Offline

Joined: February 4th, 2005, 7:24 pm
Posts: 24
Unfortunatelly, I already found other freeware applications to change the resolution but non can enable/disable a second monitor.

I don't ccare about the resolution indeed.

Nevertheless, thanks for replying...

Any other idea?

Pierre


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2005, 7:36 pm 
Offline

Joined: August 24th, 2005, 5:17 pm
Posts: 1237
Just recently I posted about Some SendDLL32 commands here:

http://www.autohotkey.com/forum/viewtopic.php?t=5871

There might be a command on there that you can use to bring up the desktop properties quite directly and then use "Control, Check" and "ControlSend" commands from there. Below is some code I was doing this for to enable auto-hiding tray icons (less complicated version posted elsewhere on the forum if you search for "autohide tray icons" in the help forum):



Code:
;Turn on auto-hide icons but set it off in registry for next reboot to prevent lost icons from auto-log on

Run, RunDLL32.EXE shell32.dll`,Options_RunDLL 1 ; display Taskbar and Start Menu Properties
WinWait, Taskbar and Start Menu Properties
Control_Check("Button7", "Taskbar and Start Menu Properties") ; Tick hide inactive icons
Control_Send("Button11", "Taskbar and Start Menu Properties") ; OK
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer, EnableAutoTray, 0
Return



Control_Send(Control_to_Click, Working_Window) ; defined my own function
  {
  Loop
    {
    Sleep, 50
    WinGet, Control_Check, ControlList, %Working_Window%
    IfInString, Control_Check, %Control_to_Click%
      {
      ControlGet, Control_Enabled, Enabled,, %Control_to_Click%, %Working_Window%
        If Control_Enabled = 1
        {
        ControlSend, %Control_to_Click%, {SPACE}, %Working_Window%
        Sleep, 50
        Break
        }
      }
    }
  }
Return



Control_Check(Control_to_Click, Working_Window) ; defined my own function

  {
  Loop
    {
    Sleep, 50
    WinGet, Control_Check, ControlList, %Working_Window%
    IfInString, Control_Check, %Control_to_Click%
      {
      ControlGet, Control_Enabled, Enabled,, %Control_to_Click%, %Working_Window%
        If Control_Enabled = 1
        {
        Control, Check,, %Control_to_Click%, %Working_Window%
        Sleep, 50
        Break
        }
      }
    }
  }
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2005, 4:26 pm 
Offline

Joined: February 4th, 2005, 7:24 pm
Posts: 24
I will have a look. Thanks.
I will come back with the result in this thread.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2005, 7:42 pm 
Quote:
I don't ccare about the resolution indeed
But ...
Quote:
Run the program directly, (with no parameters), for a list of screen modes supported by your display. Specify a display mode as a parameter to change the display mode. You can also specify the name of a program to run after changing the display.
... that's why I've proposed it. I guess the main thing to care about, if it comes to a swap of the screen is its Screen Refresh Rate and not its Resolution (which is 60Hz at your NoBo, isn't it ?) but that's MHO ... :roll:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2005, 9:13 pm 
Offline

Joined: February 4th, 2005, 7:24 pm
Posts: 24
Bobo

Maybe I was not enough factual.

I work with a laptop which has the possibility to attach a external monitor and define it as a second monitor (ie: I then have a desktop spanning over the 2 monitor, the laptop lcd screen and the external monitor).

I have to ways of working:

1) At home: I don't have the extra monitor. Therefore, my desktop is made of my laptop lcd screen only.

2) At work: I have a second monitor. I then configure it as monitor number 2 (right click on the grayed monitor and select "display" and tick the "extend my Windows desktop onto this monitor" in the display advanced properties.)

If I startup the laptop at home after one day in the office (I know I shouldn't do that...), then it is no problem because Windows will detect that the monitor is not longer there and the desktop will be made of only one monitor.

If I startup the laptop at work after having worked at home, I have to:
- right click the desktop and open the properties.
- go to the last tab (advanced properties)
- right click in the grayed monitor number 2.
- move it to the left of the monitor number one
- click ok.

I'm a lazy guy or at least I hate spending my time like this and think I should better spend time learning how to call windows API from autohotkey :wink:

The tool you reference will allow me change the resolution and refresh rate of the primary screen and it is not what I intend to do, unfortunatelly.

I found the different API I should call but I'm a bit lost...

I did not have time yet to lok at the post of evt though.

Thanks anyway for the time you spent so far...

Pierre


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 10th, 2005, 1:53 am 
Offline

Joined: April 16th, 2005, 1:05 am
Posts: 28
Would it be possable to change the screens resoultion using postmessage and WM_DISPLAYCHANGE?

i am horrable at using post/sendmessage and would really apprecate any help.

_________________
cstone


Report this post
Top
 Profile  
Reply with quote  
 Post subject: A possible workaround
PostPosted: January 25th, 2007, 8:22 pm 
Offline

Joined: January 25th, 2007, 8:21 pm
Posts: 1
Hey champ - I feel your problem, I'm in the same boat and had half heratedly looked into this cos it's a massive hassle.

Incidentally, I've got some half-cut VB Scripts and a wee app that can help if you need network settings updated/altered for each site you go to..

Anywho;
I've found that dirty ol' desk.cpl can handle key inputs just fine, so a VB Sendkeys script, or an AHK of the same thing outta be swell.

Try this:
Code:
ScreenToTurnOn = "2"  'this is the numerical 'id' of the screen,
                      'as it is displayed in the GUI applet, so,
                      'like XP, this script could scale to 9
                      '(or was it 10) monitors - if ya had a
                      'script for each monitor, or got the #
                      'from an input box variable
Set Shell = CreateObject("WScript.Shell")
Shell.Run "control.exe desk.cpl"
WScript.Sleep 500                         'just wait a half sec for windows to draw the applet
Shell.AppActivate "Display Properties"    'focus ....stay on target... ...stay on target
Shell.Sendkeys "^+{TAB}"                  'Control + shift + tab
WScript.Sleep 150
Shell.Sendkeys ScreenToTurnOn
WScript.Sleep 150
Shell.SendKeys "%e"
WScript.Sleep 150
Shell.SendKeys "%a"
WScript.Sleep 400
Shell.SendKeys "{enter}"


Oh, and this is a VBScript - not AHK key code, I've never bothered to do that in AH

"what could possibly go wrong?"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2008, 11:50 pm 
Offline

Joined: September 8th, 2008, 6:36 pm
Posts: 3
YES! air ben, this is exactly the nudge I was looking for! I've been trying to find a simple way to Extend my monitor onto the tv for video watching without having to use dllcalls or reg hacks.

I've adapted your VBS into AHK using SendInput:

Code:
Run control desk.cpl`,`, 3  ; Opens Control Panel > Display Properties > Settings
IfWinNotActive, Display Properties, , WinActivate, Display Properties,
WinWaitActive, Display Properties,
SendInput 2!e{ENTER} ; selects display 2, sends Alt-E to toggle Extend desktop to this monitor, then hits OK


I haven't figured out how to make the display # a variable and get sent through SendInput, but this works well enough for me!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2011, 10:06 pm 
Offline

Joined: April 23rd, 2011, 8:33 pm
Posts: 14
Location: Strasbourg, France
Thanks for sharing that!

It's a nice workarround for what I was trying to do!
Thanks


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Google Feedfetcher, mrhobbeys, rbrtryn and 59 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group