-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdt.pb
91 lines (80 loc) · 2.42 KB
/
dt.pb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#Myname = "Date-n-time-inserter-v0.7"
Enumeration
#Window
#SysTrayIcon
#Menu
#Exit
#change_hk
EndEnumeration
IncludeFile "hotkey-requester.pb"
Procedure myWinCallback(hWnd.i, uMsg.i, wParam.i, lParam.i)
If uMsg = #WM_HOTKEY
WM_HOTKEY_Event(wParam, lParam)
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Procedure pasteStuff()
Protected i.i, txt$
; continue if all keys are free
Repeat
For i = 0 To 1000
If GetKeyState_(i) <= -1
Break
ElseIf i = 1000
Debug "all keys are free"
Break 2
EndIf
Next
Delay(10)
ForEver
Define n.INPUT
n\type = #INPUT_KEYBOARD
txt$ = FormatDate("%yyyy.%mm.%dd %hh:%ii",Date())
SetClipboardText(txt$)
n\ki\wVk = #VK_CONTROL : n\ki\dwFlags = 0
SendInput_(1,@n,SizeOf(n))
n\ki\wVk = #VK_V
SendInput_(1,@n,SizeOf(n))
n\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1,@n,SizeOf(n))
n\ki\wVk = #VK_CONTROL
SendInput_(1,@n,SizeOf(n))
EndProcedure
Define ev.i, hkInsTimestamp.i, txt2.s = "Press the key combination you want To associate With this action",
icon, appname.s = GetFilePart(ProgramFilename())
OpenWindow(#Window, 0, 0, 500, 500, #Myname, #PB_Window_Invisible)
SetWindowCallback(@myWinCallback(), #Window)
icon = ExtractIcon_(WindowID(#Window),appname,0)
AddSysTrayIcon(#SysTrayIcon,WindowID(#Window),icon)
SendMessage_(WindowID(#Window),#WM_SETICON,#ICON_SMALL,icon)
SysTrayIconToolTip(#SysTrayIcon,#Myname)
CreatePopupMenu(#Menu)
MenuItem(1,#Myname)
DisableMenuItem(#Menu,1,1)
MenuBar()
MenuItem(#change_hk,"Change Hotkey")
MenuItem(#Exit,"Exit")
HotkeyRequester(#Window, #Myname, txt2, @pasteStuff())
Repeat
ev = WaitWindowEvent()
If ev = #PB_Event_SysTray And EventType() = #PB_EventType_RightClick
DisplayPopupMenu(#Menu,WindowID(#Window))
ElseIf ev = #PB_Event_Menu
Select EventMenu()
Case #change_hk
If isHotkey(hkInsTimestamp)
;If the hotkey was already set, delete it before showing requester again
RemoveHotkey(hkInsTimestamp)
EndIf
hkInsTimestamp = HotkeyRequester(#Window, #Myname, txt2, @pasteStuff())
If hkInsTimestamp
SetMenuItemText(#Menu,#change_hk, "Hotkey: "+HotkeyFriendlyName(hkInsTimestamp))
Else
SetMenuItemText(#Menu,#change_hk, "Hotkey: None")
EndIf
Case #Exit
Break
EndSelect
EndIf
Until ev = #PB_Event_CloseWindow
RemoveHotkey(#PB_All)