Example:
Type "ReadFile("
Taskbar shows:
ReadFile(#File,FileName$) - Open an existing file for read only operations
Hit hotkey
Current line shows: "ReadFile(#File,FileName$)"
Lazy, eh?

Code: Select all
CopyFile (SourceFileName$, DestinationFileName$); - Copy the source file to the destination.
Code: Select all
; pb_handle = FindWindow_(0, "PureBasic")
; Debug pb_handle
; SendMessage_(pb_handle, #WM_PASTE, 0, GetClipboardText())
lol .. i had nothing better to do that night. Here's the source if someonePB wrote:@Dare: What would you need to do that for? I'm just curious because it seems
to me that you'd need to delete each parameter of the copied text after it's
been copied to the IDE, which is counter-productive. If you're lazy as you say,
then why create that extra work?
Code: Select all
; opensource nonsense ;)
Define.s FName, FList, LineData, WhatToFind, tmp_data
Define.l pb_handle
Declare.s ReadRegKey(OpenKey.l, SubKey.s, ValueName.s)
Declare.s GetPBPath()
FList = GetPBPath() + "Compilers\pbfunctionlisting.txt"
#FunctionList = 1 ; file number
WhatToFind = ProgramParameter(0)
If OpenFile(#FunctionList, FList)
While Eof(#FunctionList) = 0
tmp_data = ReadString(#FunctionList)
If FindString(tmp_data, WhatToFind, 1) > 0
tmp_data = ReplaceString(tmp_data, ") -", "); -")
SetClipboardText(Trim(tmp_data))
Beep_(3000, 5)
; if I could paste to the IDE i would have..
; pb_handle = FindWindow_(0, "PureBasic")
; Debug pb_handle
; SendMessage_(pb_handle, #WM_PASTE, 0, GetClipboardText())
Debug tmp_data
Break
EndIf
Wend
CloseFile(#FunctionList)
Else
ClearClipboard()
MessageRequester("ERROR", "I could not open your PB Function List...")
EndIf
Procedure.s ReadRegKey(OpenKey.l, SubKey.s, ValueName.s)
hKey.l = 0
KeyValue.s = Space(255)
Datasize.l = 255
If RegOpenKeyEx_(OpenKey, SubKey, 0, #KEY_READ, @hKey)
KeyValue = "Error Opening Key"
Else
If RegQueryValueEx_(hKey, ValueName, 0, 0, @KeyValue, @Datasize)
KeyValue = "Error Reading Key"
Else
KeyValue = Left(KeyValue, Datasize - 1)
EndIf
RegCloseKey_(hKey)
EndIf
ProcedureReturn KeyValue
EndProcedure
Procedure.s GetPBPath()
RegistryString.s = ""
RegistryString = ReadRegKey(#HKEY_CLASSES_ROOT, "Applications\PureBasic.exe\shell\open\command", "")
RegistryString = ReplaceString(RegistryString, Chr(34), " ")
RegistryString = ReplaceString(RegistryString, "%1", " ")
RegistryString = LCase(RegistryString)
RegistryString = ReplaceString(RegistryString, "purebasic.exe", " ")
RegistryString = Trim(RegistryString)
ProcedureReturn RegistryString
EndProcedure
Code: Select all
; I mashed together Noaphense's Insert Help code and PBs send Keys
; code to make a tool that inserts the PB IDE Status Line Help direct into
; the IDE - it aint pretty, but it works.
;
; Ta - NAW
;
; SendKeys procedure by PB -- do whatever you want with it. :)
; Syntax: r=SendKeys(handle,window$,keys$) ; r = 0 for failure.
; Specify either a handle or window$ title to type to, but not both!
; You cannot type curly braces { } as part of the keystrokes, sorry!
;
Procedure SendKeys(handle,window$,keys$)
If window$<>"" : handle=FindWindow_(0,window$) : EndIf ; Use window$ instead of handle.
If IsWindow_(handle)=0 ; Does the target window actually exist?
ProcedureReturn 0 ; Nope, so report 0 for failure to type.
Else
; This block gives the target window the focus before typing.
thread1=GetWindowThreadProcessId_(GetForegroundWindow_(),0)
thread2=GetWindowThreadProcessId_(handle,0)
If thread1<>thread2 : AttachThreadInput_(thread1,thread2,#True) : EndIf
SetForegroundWindow_(handle) ; Target window now has the focus for typing.
Delay(10) ; 1/8 second pause before typing, to prevent fast CPU problems.
; Now the actual typing starts.
For r=1 To Len(keys$)
vk$=Mid(keys$,r,1)
If vk$="{" ; Special key found.
s=FindString(keys$,"}",r+1)-(r+1) ; Get length of special key.
s$=Mid(keys$,r+1,s) ; Get special key name.
Select s$ ; Get virtual key code of special key.
Case "ALTDOWN" : keybd_event_(#VK_MENU,0,0,0) ; Hold ALT down.
Case "ALTUP" : keybd_event_(#VK_MENU,0,#KEYEVENTF_KEYUP,0) ; Release ALT.
Case "BACKSPACE" : vk=#VK_BACK
Case "CONTROLDOWN" : keybd_event_(#VK_CONTROL,0,0,0) ; Hold CONTROL down.
Case "CONTROLUP" : keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0) ; Release CONTROL.
Case "DELETE" : vk=#VK_DELETE
Case "DOWN" : vk=#VK_DOWN
Case "END" : vk=#VK_END
Case "ENTER" : vk=#VK_RETURN
Case "F1" : vk=#VK_F1
Case "F2" : vk=#VK_F2
Case "F3" : vk=#VK_F3
Case "F4" : vk=#VK_F4
Case "F5" : vk=#VK_F5
Case "F6" : vk=#VK_F6
Case "F7" : vk=#VK_F7
Case "F8" : vk=#VK_F8
Case "F9" : vk=#VK_F9
Case "F10" : vk=#VK_F10
Case "F11" : vk=#VK_F11
Case "F12" : vk=#VK_F12
Case "ESCAPE" : vk=#VK_ESCAPE
Case "HOME" : vk=#VK_HOME
Case "INSERT" : vk=#VK_INSERT
Case "LEFT" : vk=#VK_LEFT
Case "PAGEDOWN" : vk=#VK_NEXT
Case "PAGEUP" : vk=#VK_PRIOR
Case "PRINTSCREEN" : vk=#VK_SNAPSHOT
Case "RETURN" : vk=#VK_RETURN
Case "RIGHT" : vk=#VK_RIGHT
Case "SHIFTDOWN" : shifted=1 : keybd_event_(#VK_SHIFT,0,0,0) ; Hold SHIFT down
Case "SHIFTUP" : shifted=0 : keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0) ; Release SHIFT.
Case "TAB" : vk=#VK_TAB
Case "UP" : vk=#VK_UP
EndSelect
If Left(s$,3)<>"ALT" And Left(s$,7)<>"CONTROL" And Left(s$,5)<>"SHIFT"
keybd_event_(vk,0,0,0) : keybd_event_(vk,0,#KEYEVENTF_KEYUP,0) ; Press the special key.
EndIf
r=r+s+1 ; Continue getting the keystrokes that follow the special key.
Else
vk=VkKeyScanEx_(Asc(vk$),GetKeyboardLayout_(0)) ; Normal key found.
If vk>304 And shifted=0 : keybd_event_(#VK_SHIFT,0,0,0) : EndIf ; Due to shifted character.
keybd_event_(vk,0,0,0) : keybd_event_(vk,0,#KEYEVENTF_KEYUP,0) ; Press the normal key.
If vk>304 And shifted=0 : keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0) : EndIf ; Due to shifted character.
EndIf
Next
If thread1<>thread2 : AttachThreadInput_(thread1,thread2,#False) : EndIf ; Finished typing to target window!
keybd_event_(#VK_MENU,0,#KEYEVENTF_KEYUP,0) ; Release ALT key if user forgot.
keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0) ; Release CONTROL key if user forgot.
keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0) ; Release SHIFT key if user forgot.
ProcedureReturn 1 ; Report successful typing! :)
EndIf
EndProcedure
Define.s FName, FList, LineData, WhatToFind, tmp_data
Define.l pb_handle
Declare.s ReadRegKey(OpenKey.l, SubKey.s, ValueName.s)
Declare.s GetPBPath()
FList = GetPBPath() + "Compilers\pbfunctionlisting.txt"
#FunctionList = 1 ; file number
WhatToFind = ProgramParameter(0)
If OpenFile(#FunctionList, FList)
While Eof(#FunctionList) = 0
tmp_data = ReadString(#FunctionList)
If FindString(tmp_data, WhatToFind, 1) > 0
tmp_data = ReplaceString(tmp_data, ") -", "); -")
SetClipboardText(Trim(tmp_data))
tmp_data=ReplaceString(Trim(StringField(tmp_data,1,";"))," [, Flags]",", Flags")
SetClipboardText(Mid(tmp_Data,Len(WhatToFind)+3,99))
SendKeys(0, "PureBasic - InsertIDE.pb", "{RIGHT}")
SendKeys(0, "PureBasic - InsertIDE.pb", "{CONTROLDOWN}{LEFT}")
SendKeys(0, "PureBasic - InsertIDE.pb", "{CONTROLDOWN}{LEFT}")
SendKeys(0, "PureBasic - InsertIDE.pb", "{SHIFTDOWN}{CONTROLDOWN}{RIGHT}")
SendKeys(0, "PureBasic - InsertIDE.pb", "{SHIFTDOWN}{CONTROLDOWN}{RIGHT}")
SendKeys(0,"PureBasic - InsertIDE.pb","{CONTROLDOWN}v{CONTROLUP}")
MessageRequester(Title$, Text$, Flags)
Beep_(1000, 50)
; if I could paste to the IDE i would have..
; pb_handle = FindWindow_(0, "PureBasic")
; Debug pb_handle
; SendMessage_(pb_handle, #WM_PASTE, 0, GetClipboardText())
Debug tmp_data
Break
EndIf
Wend
CloseFile(#FunctionList)
Else
ClearClipboard()
MessageRequester("ERROR", "I could not open your PB Function List...")
EndIf
Procedure.s ReadRegKey(OpenKey.l, SubKey.s, ValueName.s)
hKey.l = 0
KeyValue.s = Space(255)
Datasize.l = 255
If RegOpenKeyEx_(OpenKey, SubKey, 0, #KEY_READ, @hKey)
KeyValue = "Error Opening Key"
Else
If RegQueryValueEx_(hKey, ValueName, 0, 0, @KeyValue, @Datasize)
KeyValue = "Error Reading Key"
Else
KeyValue = Left(KeyValue, Datasize - 1)
EndIf
RegCloseKey_(hKey)
EndIf
ProcedureReturn KeyValue
EndProcedure
Procedure.s GetPBPath()
RegistryString.s = ""
RegistryString = ReadRegKey(#HKEY_CLASSES_ROOT, "Applications\PureBasic.exe\shell\open\command", "")
RegistryString = ReplaceString(RegistryString, Chr(34), " ")
RegistryString = ReplaceString(RegistryString, "%1", " ")
RegistryString = LCase(RegistryString)
RegistryString = ReplaceString(RegistryString, "purebasic.exe", " ")
RegistryString = Trim(RegistryString)
ProcedureReturn RegistryString
EndProcedure