I was playing around with some code to turn Windows Magnifier on/off and am seeing something I don't understand.
The code below works fine on my PC. "Start" turns on the magnifier and "End" turns it off. I can also use WinKey+Add to start the magnifier and WinKey+ESC to close the magnifier. (Add is the plus key on the keyboard numeric keypad)

But if I run the code on my 2nd PC, the Start/End buttons do not work. Also, if the app is running, the WinKey+Add and WinKey+ESC keys have no effect either. If I close the app, they work!
I tried it on a 3rd PC as well and I get the same results as on the 2nd PC - but the 2nd and 3rd PCs are not the same and do not have the same keyboards.
I'm not sure how to explain the results.
The code below works fine on my PC. "Start" turns on the magnifier and "End" turns it off. I can also use WinKey+Add to start the magnifier and WinKey+ESC to close the magnifier. (Add is the plus key on the keyboard numeric keypad)
But if I run the code on my 2nd PC, the Start/End buttons do not work. Also, if the app is running, the WinKey+Add and WinKey+ESC keys have no effect either. If I close the app, they work!
I tried it on a 3rd PC as well and I get the same results as on the 2nd PC - but the 2nd and 3rd PCs are not the same and do not have the same keyboards.
I'm not sure how to explain the results.
Code:
'Compilable Example: #Compile Exe #Dim All %Unicode = 1 #Include "Win32API.inc" Enum Equates Singular IDC_Start = 500 IDC_End IDC_Graphic End Enum Global hDlg As Dword Function PBMain() As Long Dialog New Pixels, 0, "Test",300,300,200,200, %WS_OverlappedWindow To hDlg Control Add Button, hDlg, %IDC_Start,"Start", 10,10,60,20 Control Add Button, hDlg, %IDC_End,"End", 75,10,60,20 Control Add Graphic, hDlg, %IDC_Graphic, "", 5, 35, 190, 160, %SS_Notify Or %WS_Border Graphic Attach hDlg, %IDC_Graphic Graphic Color %Black, %rgb_LightYellow Graphic Clear Dialog Show Modal hDlg Call DlgProc End Function CallBack Function DlgProc() As Long Select Case Cb.Msg Case %WM_Command Select Case Cb.Ctl Case %IDC_Start : StartMagnifier Case %IDC_End : EndMagnifier Case %IDC_Graphic : Beep End Select Case %WM_ContextMenu Dialog End hDlg End Select End Function Sub StartMagnifier keybd_event(%VK_LWIN, &H45, 0, 0) keybd_event(%VK_Add, &H45, 0, 0) keybd_event(%VK_Add, &H45, %KEYEVENTF_KEYUP, 0) keybd_event(%VK_LWIN, &H45, %KEYEVENTF_KEYUP, 0) End Sub Sub EndMagnifier keybd_event(%VK_LWIN, &H45, 0, 0) keybd_event(%VK_Escape, &H45, 0, 0) keybd_event(%VK_Escape, &H45, %KEYEVENTF_KEYUP, 0) keybd_event(%VK_LWIN, &H45, %KEYEVENTF_KEYUP, 0) End Sub
Comment