is there a way for put in clipboard the value of a variable highlighted in the IDE of PB ?
Thanks to this code of MESA that i have simplified, i take the name of the variable highlighted
viewtopic.php?p=595584#p595584
Code: Select all
Global PbIdeHandle, ScintillaHandle
Global classText.s = Space(256), SelectedWord.s
Procedure.s GetScintillaText()
Protected ReturnValue.s
Protected length
Protected buffer
Protected processId
Protected hProcess
Protected result
length = SendMessage_(ScintillaHandle, #SCI_GETLENGTH, 0, 0)
If length
length + 2
buffer = AllocateMemory(length)
If buffer
SendMessageTimeout_(ScintillaHandle, #SCI_GETCHARACTERPOINTER, 0, 0, #SMTO_ABORTIFHUNG, 2000, @result)
If result
GetWindowThreadProcessId_(ScintillaHandle, @processId)
hProcess = OpenProcess_(#PROCESS_ALL_ACCESS, #False, processId)
If hProcess
ReadProcessMemory_(hProcess, result, buffer, length, 0)
ReturnValue = PeekS(buffer, -1, #PB_UTF8)
CloseHandle_(hProcess) ; <-- Axolotl, added acc. to MSDN
EndIf
EndIf
EndIf
FreeMemory(buffer)
EndIf
ProcedureReturn ReturnValue
EndProcedure
; Finding the Scintilla
Procedure.l enumChildren0(hwnd.l)
If hwnd
GetClassName_(hwnd, @classText, 256)
If classText = "WindowClass_2"
GetWindowText_(hwnd, @classText, 256)
If Left(classText, 9) = "PureBasic"
PbIdeHandle = hwnd
ProcedureReturn 0
EndIf
EndIf
ProcedureReturn 1
EndIf
ProcedureReturn 0
EndProcedure
Procedure.l enumChildren1(hwnd.l)
If hwnd
GetClassName_(hwnd, @classText, 256)
If classText = "Scintilla"
ScintillaHandle = hwnd
ProcedureReturn 0
EndIf
ProcedureReturn 1
EndIf
ProcedureReturn 0
EndProcedure
Procedure Initialization()
PbIdeHandle = Val(GetEnvironmentVariable("PB_TOOL_MainWindow"))
ScintillaHandle = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
SelectedWord.s = GetEnvironmentVariable("PB_TOOL_Word")
ScintillaText.s = GetScintillaText()
CursorLine = Int(Val(StringField(GetEnvironmentVariable("PB_TOOL_Cursor"), 1, "x")))
ProcedureReturn 0 ; default (ZERO is returned by default, even if there is no ProcedureReturn)
EndProcedure
Initialization()
ScintillaText.s = GetScintillaText()
MessageRequester(Trim(Str(@SelectedWord)), SelectedWord)
Have a good day

