VBA resolves Windows empty Solitaire 617 Bureau _VBA

Source: Internet
Author: User

Windows has its own game-time Solitaire, in which the No. 617 inning is more difficult to solve, the number of times to try more, and often forget the solution and steps.

I had hoped to use a autoit or AutoHotkey, Aauto type of tool to write an automated script to quickly resolve this inning, but these tools need to be installed and easily treated as viruses. By using VBA in office to invoke the Windows API, you can quickly demonstrate the solution by sending key messages to the game window.

Declare Function FindWindow Lib "User32" Alias _
  "Findwindowa" (ByVal lpclassname as String, ByVal Lpwindowname as Str ing) as long
   
Declare Function sendmessage Lib "User32" Alias _
  "SendMessageA" (ByVal hwnd as Long, ByVal wmsg as L  Ong, ByVal WParam as Long, ByVal LParam as Long) as long
 
Const WM_CHAR = &h102
 
Sub f ()
s = "83 80 83 81 80  "& _" "A" & _ "" 14 "," & _ "M-I-M ("
  & _ ")
  10 004 10 & _
  "002" & _ "the same as"
  & _
  "All-by-and-a-June" ;
  "
 
FindWindow" ("Freewclass", "Gap Solitaire Game #617") for
i = 1 to Len (s)
  C = Mid (s), I, 1)
  m = 0.1
  If c >= "0" and C <= "9" Then
    a = SendMessage (h, WM_CHAR, ASC (c), 0)
  Else
    m = 0.3 End
  If
  m = m + timer:do while Timer < M:doevents:loop
Next end
Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.