Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Struggle with forum software

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Struggle with forum software

    Problems with copying text of programs for users of IE are well-known.
    Today I wrote a small utility (see warning inside the text).
    You press Ctrl-C and start this program (I put an icon on Task Bar).
    Code:
    #Compile Exe
    #Register None
    #Dim All
    #Include "Win32Api.Inc"
    '--------------- CHANGE PATHES, IF NECESSARY ---------------
    $DirSamples = "C:\PBDLL60\Samples\"
    $DirWordPad = "G:\Program Files\Windows NT\Accessories\"
    '-----------------------------------------------------------
    Sub SendKbd (hwnd As Long, key1 As Long, key2 As Long)
       KeyBd_Event key1, MapVirtualKey(key1, 0), 0, 0: Sleep 0
       KeyBd_Event key2, MapVirtualKey(key2, 0), 0, 0: Sleep 0
       KeyBd_Event key2, MapVirtualKey(key2, 0), %KEYEVENTF_KEYUP, 0: Sleep 0
       KeyBd_Event key1, MapVirtualKey(key1, 0), %KEYEVENTF_KEYUP, 0: Sleep 0
    End Sub
    
    Function PbMain()
       Dim TmpName As String, hDlg As Long, nTest As Long, lResult As Long
       TmpName$ = $DirSamples + "~Tmp.Bas"
       Open TmpName$ For Output As #1: Close #1
       lResult = Shell ($DirWordPad + "Wordpad.exe " + TmpName$)
       For nTest = 1 To 100
          hDlg = FindWindow(ByVal 0, "~Tmp - WordPad")
    '-- In some OSes it's necessary to change to ---------------
    '     hDlg = FindWindow(ByVal 0, "~Tmp.Bas - WordPad")
    '-----------------------------------------------------------
          If hDlg <> 0 Then Exit For
          Sleep 100
       Next
       If hDlg = 0 Then MsgBox "Not found": Exit Function
       SetForegroundWindow hDlg
       SendKbd hDlg&, %VK_CONTROL, 86 ' Ctrl-V
       SendKbd hDlg&, %VK_CONTROL, 83 ' Ctrl-S
    '--- Depends of PC -----------------------------------------
       Sleep 1000
    '-- in non-English releases could be Alt-J and so on -------
       SendKbd hDlg&, %VK_MENU, 89 ' Alt-Y
    '-----------------------------------------------------------
       SendKbd hDlg&, %VK_MENU, %VK_F4 ' Alt-F4
       lResult& = Shell("PbEdit.Exe " + TmpName$)
    End Function
    [This message has been edited by Semen Matusovski (edited March 08, 2000).]

    #2
    Cool!

    You have to change:

    hDlg = FindWindow(ByVal 0, "~Tmp - WordPad")

    to:

    hDlg = FindWindow(ByVal 0, "~Tmp.Bas - WordPad")

    On my NT, you have to change

    SendKbd hDlg&, %VK_MENU, 89 ' Alt-Y

    to:

    SendKbd hDlg&, %VK_MENU, 84 ' Alt-T

    Regards
    Peter


    ------------------
    [email protected]
    www.dreammodel.dk

    Comment


      #3
      Peter --
      It seems to me that caption of WordPad's window depends of Windows release.
      Alt-Y means Yes and in non-English releases could be another letter. I added warnings.
      Thanks.

      [This message has been edited by Semen Matusovski (edited March 08, 2000).]

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎