Send windows key in vbs?

前端 未结 5 834
生来不讨喜
生来不讨喜 2021-01-12 18:12

I\'ve looked everywhere for this, is it actually possible to do? If you press WIN + LEFT ARROW it will mount your selected window to the left of your screen, and that\'s exa

相关标签:
5条回答
  • 2021-01-12 18:49

    Yes, You can send the windows key in VBS.

    Set vb = CreateObject("WScript.Shell")
    vb.Sendkeys "^{ESC}"
    

    It's actually alt + Esc work as windows key.

    0 讨论(0)
  • 2021-01-12 18:50

    a very late response, but here is my working effort

    Dim shellObject : Set shellObject = CreateObject("WScript.Shell")
    Extern.Declare micVoid, "keybd_event", "user32.dll", "keybd_event", micByte, micByte, micLong, micLong
    Const KEYEVENTF_KEYUP = &H2
    Const VK_LWIN = &H5B
    
    Wait 5
    Call Extern.keybd_event(VK_LWIN,0,0,0) 'press win key
    Wait 5
    shellObject.SendKeys  "({UP})" 'right aline the window. TODO Error handlng
    Wait 5
    Call Extern.keybd_event(VK_LWIN,0,KEYEVENTF_KEYUP,0) 'up win key
    Set shellObject = Nothing
    
    0 讨论(0)
  • 2021-01-12 18:55

    VBScript's SendKeys doesn't support the Windows key.


    You can use AutoIt instead:

    Send("{#Left}")
    
    0 讨论(0)
  • 2021-01-12 19:05

    Oh, so you want to mount the window to the left, I currently don't think there's a way to do that, but there's another shortcut for start menu, as well as windows key, it's Ctrl+Esc, ^{ESC}, you could possibly run the onscreen keyboard, then somehow tab over to the key, but it would be hard, also how about trying Alt+Space, %{SPACE}, to click the window icon then, M for move, then set the cursors position to the left of the screen, somehow? I don't currently need help moving the cursor in V.B.S., but you could Google it. Hash symbol is actually typing the symbol #, hash, tested with this. I also got help on the send-keys function, here. I have way to much researching, but I still can't find a answer. Some-one also said using "Auto hotkey", a third party program, but I don't really trust programs that can take control over your whole PC.


    So I guess your options are:

    • Alt+Space to click window icon, then M for move, then move cursor to left side of the screen
    • Auto HotKey, although I don't recommend it.
    • Other commands, but SendKeys, in VBS,
    • Running a file, built in a different language to do so.
    • Or well, waiting-for / asking Microsoft to add it in, in the next version of Windows?!
    0 讨论(0)
  • 2021-01-12 19:09
    Set Keys = CreateObject("WScript.Shell")
    
    Keys.SendKeys("^{Esc}")
    

    This should work, it Simulates the push of the Windows key by pushing the CTRL ^ and the ESC {Esc}keys, i don't know how to make the window mount to the left of the screen

    0 讨论(0)
提交回复
热议问题