Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Quick Paste
#1
For Windows users only.

Requires the attached zip file to get the encrypted test file.

Most folks probably store their login credentials on their browsers. If you're not most folks, and would like a way to quickly copy/paste that info, try this.

Code: (Select All)
$Resize:On
_Title "Quick Paste"
ReDim Hold As POINTAPI
Type POINTAPI
    X_Pos As Long
    Y_Pos As Long
End Type
Declare Dynamic Library "User32"
    Function GetAsyncKeyState% (ByVal vkey As Long)
    Function GetCursorPos (lpPoint As POINTAPI)
    Sub SENDKEYS Alias keybd_event (ByVal bVk As Long, ByVal bScan As Long, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
End Declare
Const KEYEVENTF_KEYUP = &H2
Const VK_SHIFT = &H10
Const VK_CONTROL = &H11 ' Ctrl key
_ScreenHide
_ControlChr Off
On Error GoTo erh
mask$ = Chr$(7): pwmask$ = "*"
Open "my_encrypted_stuff.txt" For Input As #1
i = 0
Do
    Line Input #1, a$
    i = i + 1
    ReDim _Preserve a$(i): a$(i) = a$
Loop Until EOF(1)
Close #1
nop = i: renew = 1
ReDim renew(i), decode$(i), uncode$(i), col(i)
For i = 1 To nop
    a$ = a$(i)
    decode$ = ""
    For j = 1 To Len(a$)
        x = Asc(Mid$(a$, j, 1)) - 128
        decode$ = decode$ + Chr$(x)
    Next
    decode$(i) = decode$
    If renew And renew < 3 Then renew(i) = 1: renew = renew + 1 Else renew(i) = 0: renew = 0
    If LTrim$(decode$) = "" Then renew = 1
Next
Width 50, 15: _Font 16
_Delay .1
_ScreenMove 0, 0
lm = 1: rm = _Width
tm = 1: bm = _Height
_ScreenShow
_Resize On
GoSub dsp
Do
    _Limit 30
    mymouse mw, x, y, lb, rb
    Select Case mw
        Case Is < 0
            If scr > 0 Then
                scr = scr - 3: If scr < 0 Then scr = 0
                GoSub dsp
            End If
            mw = 0
        Case Is > 0
            If 1 + scr + (bm - tm) < nop Then
                scr = scr + 3: j = 1 + scr + (bm - tm)
                If j > nop Then scr = nop - (bm - tm) - 1
                GoSub dsp
            End If
            mw = 0
    End Select
    z& = GetCursorPos(Hold)
    hasFocus%% = _WindowHasFocus
    If hasFocus%% And Hold.Y_Pos >= _ScreenY And Hold.Y_Pos <= _ScreenY + _FontHeight * (_Height + 2) And Hold.X_Pos - _FontWidth >= _ScreenX And Hold.X_Pos <= _ScreenX + _FontWidth * (_Width + 1) Then
        If lb Or mb Then
            If UCase$(Mid$(decode$(scr + y + 1 - tm), 1, 5)) = "SITE:" Then
                url$ = _Trim$(Mid$(decode$(scr + y + 1 - tm), 6))
                _Title "Quick Paste - VISIT"
                Shell _DontWait _Hide "start " + url$
                _Delay .25
                _Title "Quick Paste"
            Else
                If clip = 0 Then
                    _Title "Quick Paste - COPIED"
                    _Clipboard$ = uncode$(scr + y + 1 - tm)
                    _Delay .5
                    _Title "Quick Paste"
                End If
            End If
        End If
    Else
        If GetAsyncKeyState(4) < 0 Or GetAsyncKeyState(VK_SHIFT) And GetAsyncKeyState(1) < 0 Then
            _Delay .5
            SENDKEYS VK_CONTROL, 0, 0, 0
            _Delay .1
            SENDKEYS &H56, 0, 0, 0 ' V
            _Delay .1
            SENDKEYS &H37, 0, KEYEVENTF_KEYUP, 0
            SENDKEYS VK_CONTROL, 0, KEYEVENTF_KEYUP, 0
            _Continue
        End If
    End If
    If rb Then
        If rby = 0 Then
            rby = y
            Locate rby, col(scr + rby + 1 - tm): Print uncode$(scr + rby + 1 - tm);
        End If
    End If
    If rby And rb = 0 Then
        Locate rby, col(scr + rby + 1 - tm)
        If renew(scr + rby + 1 - tm) = 0 Then
            If UCase$(Mid$(decode$(scr + rby + 1 - tm), 1, 3)) = "PW:" Then x$ = pwmask$: Color 14 Else x$ = mask$
            Print String$(Len(uncode$(scr + rby + 1 - tm)), x$);
            Color 7, 0
        End If
        rby = 0
    End If
    If _Resize Then
        aa& = _ResizeHeight
        If _ResizeHeight <> _Height * _FontHeight And InitialResize Then
            bm = _ResizeHeight \ _FontHeight
            GoSub dsp
        End If
        InitialResize = 1
    End If
Loop

dsp:
Cls
i1 = 1 + scr: i2 = 1 + scr + bm - tm
For i = i1 To i2
    j = InStr(decode$(i), ":"): col(i) = j + 1
    If renew(i) Then
        Print decode$(i);
    Else
        If UCase$(Mid$(decode$(i), 1, j - 1)) = "PW" Then x$ = pwmask$: Color 14 Else x$ = mask$
        Print Mid$(decode$(i), 1, j); String$(Len(decode$(i)) - j, x$);
    End If
    uncode$(i) = Mid$(decode$(i), j + 1)
    Color 7
    If i = nop Then Exit For
    If i < i2 Then Locate i - scr + 1, lm
Next
Return

erh:
_ScreenShow
Color 4: Print "Error"; Err; "at line"; _ErrorLine;
End

Sub mymouse (mw, x, y, lb, rb)
    While _MouseInput
        mw = mw + _MouseWheel
    Wend
    y = _MouseY
    x = _MouseX
    lb = _MouseButton(1)
    rb = _MouseButton(2)
    mb = _MouseButton(3)
End Sub

DOWNLOAD ZIP REQUIRED. CONTAINS THE ENCRYPTED FILE. 
.7z   Quick Paste With Simple File Encryption.7z (Size: 2.07 KB / Downloads: 39)

Here's how it works....

Mouse wheel to scroll up and down. The window was made to show 3 of the 4 entries.

Mouse drag to resize window.

Right click to show over hidden user name or password.

Left click on site name to visit site. (Opens your default browser).

Left click on UN or PW to copy user name or password clipboard.

Hold Shift and left click in form field to paste.

Left click upper right red x to close.

Note: The middle button works the same as the left, except you don't need to hold the shift key down to paste when using the middle button.

If you like it, I recommend making your own encryption function. This demo just adds128 to the existing characters. Even Clippy could hack it... in time! Big Grin Big Grin Big Grin

Oh, and it is Window only because it needs the Win32 API mouse to work outside of the QB64 screen.

Pete
Reply
#2
After running:
Red text on black background: "Error 5 at line 35", on Win 11.
Reply
#3
@BSpinosa

The forum didn't preserve the file format, that's the problem.

I edited the post. Included a tested zip file. That solved the problem.

Thanks,

Pete
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Comb Sort versus Quick Sort bplus 13 3,225 07-14-2023, 02:10 PM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: 1 Guest(s)