TYPES:
BEGIN OF ty_clipdata,
data TYPE c LENGTH 500,
END OF ty_clipdata.
DATA: lt_clipdata TYPE STANDARD TABLE OF ty_clipdata.
DATA: ls_clipdata LIKE LINE OF lt_clipdata.
DATA: lv_clip_len TYPE i.
CONSTANTS: c_tab TYPE c VALUE cl_bcs_convert=>gc_tab.
DATA: lt_record TYPE STANDARD TABLE OF ty_clipdata.
DATA: ls_record LIKE LINE OF lt_record.
FIELD-SYMBOLS: <lfs_field> TYPE any.
TYPES: BEGIN OF lty_agr,
myfield1 TYPE myfield,
myfield2 TYPE urfield,
END OF lty_agr.
DATA: lt_data TYPE STANDARD TABLE OF lty_agr,
ls_data TYPE lty_agr,
lt_agr_db TYPE STANDARD TABLE OF lty_agr.
FIELD-SYMBOLS: <lfs_data> LIKE LINE OF lt_data.
*&---------------------------------------------------------------------*
*& Form GET_CLIP_DATA
*&---------------------------------------------------------------------*
* Get tab-separated tabular data from clipboard and parse it
*----------------------------------------------------------------------*
FORM get_clip_data .
* --- Get clipboard ---
cl_gui_frontend_services=>clipboard_import(
IMPORTING
data = lt_clipdata
length = lv_clip_len
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4 ).
IF sy-subrc NE 0.
MESSAGE 'Error while importing data from clipboard' TYPE 'E'.
ENDIF.
* --- Parse data ---
LOOP AT lt_clipdata INTO ls_clipdata.
SPLIT ls_clipdata AT c_tab INTO TABLE lt_record.
" SPE >>>
IF lt_record[ 1 ]-data(2) <> 'ZS'. " Your filter
CONTINUE.
ENDIF.
" <<< SPE
APPEND INITIAL LINE TO lt_data ASSIGNING <lfs_data>.
LOOP AT lt_record INTO ls_record.
ASSIGN COMPONENT sy-tabix OF STRUCTURE <lfs_data> TO <lfs_field>.
IF sy-subrc EQ 0.
<lfs_field> = ls_record-data.
ENDIF.
ENDLOOP.
ENDLOOP.
IF lt_data[] IS INITIAL.
MESSAGE 'No data parsed from clipboard' TYPE 'E'.
ENDIF.
ENDFORM. " GET_CLIP_DATA
abap clipboard
<iframe width="100%" height="1316" src="http://ginkobox.fr/vamp/index.php?embed=555b6d0abd678" type="text/html"></iframe>
Text only - Permalink - Snippet public post date 19/05/2015
#g:: ; Msc : Grep clipboard
Result =
InputBox, MatchVal, Grep Da Clipboard, Ur match!
Loop, Parse, clipboard, `r, `n
{
if ( RegExMatch( A_LoopField, MatchVal) > 0)
Result .= A_LoopField "`r`n"
}
Clipboard := Result
return
ahk clipboard
<iframe width="100%" height="362" src="http://ginkobox.fr/vamp/index.php?embed=5526919497998" type="text/html"></iframe>
Text only - Permalink - Snippet public post date 09/04/2015
#!/bin/python
# -*- coding: utf-8 -*-
"""Translate clipboard content on Windows unsing Google Translate"""
# Author : Ginko
# Date : 08/01/2015
# Version : 0.1.a
# License : zlib/libpng
# The zlib/libpng License
# Copyright (c) 2015 Ginko Aloe - ginkobox.fr
# This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
# Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
# 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
# goslate module from http://pythonhosted.org/goslate/
# Clip object inspired from https://stackoverflow.com/a/25678113
# Example usage (from cmd.exe): C:\pathTo\python.exe C:\path\to\translate.py en
import ctypes, sys
import goslate
class Clip(object):
def __init__(self):
self.wcscpy = ctypes.cdll.msvcrt.wcscpy
self.OpenClipboard = ctypes.windll.user32.OpenClipboard
self.EmptyClipboard = ctypes.windll.user32.EmptyClipboard
self.GetClipboardData = ctypes.windll.user32.GetClipboardData
self.SetClipboardData = ctypes.windll.user32.SetClipboardData
self.CloseClipboard = ctypes.windll.user32.CloseClipboard
self.CF_UNICODETEXT = 13
self.GlobalAlloc = ctypes.windll.kernel32.GlobalAlloc
self.GlobalLock = ctypes.windll.kernel32.GlobalLock
self.GlobalUnlock = ctypes.windll.kernel32.GlobalUnlock
self.GMEM_DDESHARE = 0x2000
def get(self):
self.OpenClipboard(None)
handle = self.GetClipboardData(self.CF_UNICODETEXT)
data = ctypes.c_wchar_p(handle).value
pcontents = self.GlobalLock(handle)
data = ctypes.c_wchar_p(pcontents).value if pcontents else u''
self.GlobalUnlock(handle)
self.CloseClipboard()
return data
def put(self, data):
# if not isinstance(data, unicode):
# data = data.decode('mbcs')
self.OpenClipboard(None)
self.EmptyClipboard()
hCd = self.GlobalAlloc(self.GMEM_DDESHARE, 2 * (len(data) + 1))
pchData = self.GlobalLock(hCd)
self.wcscpy(ctypes.c_wchar_p(pchData), data)
self.GlobalUnlock(hCd)
self.SetClipboardData(self.CF_UNICODETEXT, hCd)
self.CloseClipboard()
def main():
clip = Clip()
gs = goslate.Goslate()
lang = sys.argv[1] if len(sys.argv) > 1 else 'fr'
c = gs.translate(clip.get(), lang)
clip.put(c)
if __name__ == "__main__":
main()
clipboard python
<iframe width="100%" height="1550" src="http://ginkobox.fr/vamp/index.php?embed=54aec9f2a1d9d" type="text/html"></iframe>
Text only - Permalink - Snippet public post date 08/01/2015