PureBasic Forum
http://forums.purebasic.com/english/

Shortcut to #PB_Any?
http://forums.purebasic.com/english/viewtopic.php?f=18&t=75485
Page 1 of 1

Author:  AMpos [ Tue Jun 09, 2020 12:17 am ]
Post subject:  Shortcut to #PB_Any?

Is there a shortcut, or a way to define one, so when I type in the IDE something like "##", it changes to "#PB_Any"? (I'm getting tired of writing the full "#PB_Any")

Thanks in advance.

Author:  BarryG [ Tue Jun 09, 2020 1:03 am ]
Post subject:  Re: Shortcut to #PB_Any?

Not that I know of. I suggest you post it as a wish in the Requests area.

Author:  STARGÅTE [ Tue Jun 09, 2020 1:28 am ]
Post subject:  Re: Shortcut to #PB_Any?

Just compile this code and add it as a IDE tool with your specified shortcut (for example Ctrl+Shift+A)
Code:
Procedure GetProcessFromWindow(WindowID.i)
   Protected ProcessID.i
   If GetWindowThreadProcessId_(WindowID, @ProcessID)
      ProcedureReturn OpenProcess_(#PROCESS_ALL_ACCESS, #False, ProcessID)
   EndIf
EndProcedure

Procedure SendText(Text.s)
   Protected ScintillaID.i = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
   Protected ProcessID.i = GetProcessFromWindow(ScintillaID)
   Protected Length.i
   Protected *MemoryID, *Buffer, Format.i
   If ProcessID
      Select SendMessage_(ScintillaID, #SCI_GETCODEPAGE, #Null, #Null)
         Case 0     : Format = #PB_Ascii
         Case 65001 : Format = #PB_UTF8
      EndSelect
      Length.i = StringByteLength(Text, Format)
      *Buffer = AllocateMemory(Length+SizeOf(Character))
      If *Buffer
         PokeS(*Buffer, Text, #PB_Default, Format)
         *MemoryID = VirtualAllocEx_(ProcessID, #Null, Length, #MEM_RESERVE|#MEM_COMMIT, #PAGE_EXECUTE_READWRITE)
         If *MemoryID
            WriteProcessMemory_(ProcessID, *MemoryID, *Buffer, Length, #Null)
            SendMessage_(ScintillaID, #SCI_ADDTEXT, Length, *MemoryID)
            VirtualFreeEx_(ProcessID, *MemoryID, Length, #MEM_RELEASE)
         EndIf
         FreeMemory(*Buffer)
      EndIf
      CloseHandle_(ProcessID)
   EndIf
EndProcedure

SendText("#PB_Any")

Author:  BarryG [ Tue Jun 09, 2020 1:49 am ]
Post subject:  Re: Shortcut to #PB_Any?

Thanks, but that's a hotkey. We're talking about auto-complete.

Author:  dige [ Tue Jun 09, 2020 8:30 am ]
Post subject:  Re: Shortcut to #PB_Any?

@STARGÅTE: nice tool, thank you!

Author:  HeX0R [ Tue Jun 09, 2020 2:00 pm ]
Post subject:  Re: Shortcut to #PB_Any?

AMpos wrote:
Is there a shortcut, or a way to define one, so when I type in the IDE something like "##", it changes to "#PB_Any"? (I'm getting tired of writing the full "#PB_Any")

Thanks in advance.

Use -1 instead ;)

Author:  oreopa [ Wed Jul 08, 2020 2:56 am ]
Post subject:  Re: Shortcut to #PB_Any?

Code:
#z = #PB_Any

Author:  Caronte3D [ Wed Jul 08, 2020 7:04 am ]
Post subject:  Re: Shortcut to #PB_Any?

HeX0R wrote:
Use -1 instead ;)

Nice! :wink:

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/