Ruby is very powerful. You can use the WIN32API module of the additional database DL/Win32 to directly call WIN32API
WIN32API. New
Parameter 1 string Call DLL name
Parameter 2 Name of the dllexport IN THE STRING DLL
Parameter 3 String Array represents the type of each parameter l represents long p represents point I represents int V represents void (in actual use, hresult and various handle are both long and the string is P)
Parameter 4 string indicates the same type as the return value.
Require " DL/Win32 "
Findwindow = WIN32API. New ' User32.dll ' , ' Findwindow ' , % W (L p ), ' L '
Setwindowtext = WIN32API. New ' User32.dll ' , ' Setwindowtext ' , % W (L p ), ' I '
If Argv. Length = 0 then
Puts " Instructions for use: "
Puts " A parameter is used to view the Form ID based on the Form title. "
Puts " When there are two parameters, the form is searched based on the title of parameter 1, and then changed to the title of parameter 2 "
Elsif argv. Length > 0 then
Win = Findwindow. Call (0, argv. Shift)
Puts win
If Win ! = 0 then
Bset = Setwindowtext. Call (Win, argv. Shift)
If Bset = 1 Then
Puts " Success! "
Else
Puts " Fail! "
End
End
End