2626int prompt_input ()
2727{
2828 printf ("Press key execute:\n" );
29- printf (" 1. 'x ' 1. exit \n" );
29+ printf (" 1. 'q ' 1. quit \n" );
3030 printf (" 2. 'c' 2. create device\n" );
3131 printf (" 3. 'd' 3. destroy device\n" );
3232 printf (" 4. 'i' 4. install or update driver\n" );
3333 printf (" 5. 'u' 5. uninstall driver\n" );
34- printf (" 6. '1','2','3' 6. plug in monitor 0,1,2 \n" );
35- printf (" 7. '4','5','6' 7. plug out monitor 0,1,2 \n" );
34+ printf (" 6. 'a' 6. plug in monitor\n" );
35+ printf (" 7. 'b' 7. plug out monitor\n" );
3636 return _getch ();
3737}
3838
@@ -45,6 +45,8 @@ int __cdecl main(int argc, char* argv[])
4545 DWORD height = 1080 ;
4646 DWORD sync = 60 ;
4747
48+ UINT index = 0 ;
49+
4850 TCHAR exePath [1024 ] = { 0 , };
4951 (void )GetModuleFileName (NULL , exePath , sizeof (exePath )/sizeof (exePath [0 ]) - 1 );
5052 * _tcsrchr (exePath , _T ('\\' )) = _T ('\0' );
@@ -105,11 +107,9 @@ int __cdecl main(int argc, char* argv[])
105107 hSwDevice = NULL ;
106108 printf ("Close device done\n" );
107109 break ;
108- case '1' :
109- case '2' :
110- case '3' :
111- printf ("Plug in monitor begin\n" );
112- if (FALSE == MonitorPlugIn (key - '1' , 0 , 25 ))
110+ case 'a' :
111+ printf ("Plug in monitor begin, current index %u\n" , index );
112+ if (FALSE == MonitorPlugIn (index , 0 , 25 ))
113113 {
114114 printf (GetLastMsg ());
115115 }
@@ -118,26 +118,32 @@ int __cdecl main(int argc, char* argv[])
118118 printf ("Plug in monitor done\n" );
119119
120120 MonitorMode modes [2 ] = { { 1920 , 1080 , 60 }, { 1024 , 768 , 60 }, };
121- if (FALSE == MonitorModesUpdate (key - '1' , sizeof (modes )/sizeof (modes [0 ]), modes ))
121+ if (FALSE == MonitorModesUpdate (index , sizeof (modes )/sizeof (modes [0 ]), modes ))
122122 {
123123 printf (GetLastMsg ());
124124 }
125+
126+ index += 1 ;
125127 }
126128 break ;
127- case '4' :
128- case '5' :
129- case '6' :
130- printf ("Plug out monitor begin\n" );
131- if (FALSE == MonitorPlugOut (key - '4' ))
129+ case 'b' :
130+ if (index == 0 ) {
131+ printf ("No virtual monitors\n" );
132+ break ;
133+ }
134+
135+ printf ("Plug out monitor begin, current index %u\n" , index - 1 );
136+ if (FALSE == MonitorPlugOut (index - 1 ))
132137 {
133138 printf (GetLastMsg ());
134139 }
135140 else
136141 {
142+ index -= 1 ;
137143 printf ("Plug out monitor done\n" );
138144 }
139145 break ;
140- case 'x ' :
146+ case 'q ' :
141147 bExit = TRUE;
142148 break ;
143149 default :
0 commit comments