Date: 02-16-2022
Return to Index
created by gbSnippets
'Send Ctrl C to paste clipboard text
' Keybd_Event %VK_CONTROL, 0, 0, 0
' Keybd_Event 67, 0, 0, 0 'C = ASC 67
'Simulate Key Release
' Keybd_Event 67, 0, %KEYEVENTF_KEYUP, 0
' Keybd_Event %VK_CONTROL, 0, %KEYEVENTF_KEYUP, 0
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "win32api.inc"
%IDC_Button = 500
%gbCodeDropper = 501
Global hDlg,hFound As Dword, iResult As Long, R As Rect
Global szText, szClass, szParentClass As WStringZ * %Max_Path
Function PBMain() As Long
Dialog New Pixels, 0, "Find PB/Win Window",300,300,300,150,%WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button, "Find", 10,10,60,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local iResult&
Select Case Cb.Msg
Case %WM_InitDialog
iResult& = RegisterHotKey (Cb.Hndl, %gbCodeDropper, %HotKeyF_Control, %vk_d) 'Ctrl-H
If iResult& = 0 Then MsgBox "Cannot register Ctrl-D hot key!"
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Button
iResult = EnumWindows(CodePtr(EnumCallback), 0&)
If hFound Then
? szText + $CrLf + Str$(R.nLeft) + Str$(R.nTop)
Else
? "PB/Win not found!"
End If
End Select
Case %WM_HotKey
Select Case Cb.WParam
Case %gbCodeDropper
Dialog Show State hDlg, %SW_Restore
? "You called?"
End Select
Case %WM_Destroy
UnRegisterHotKey hDlg, %gbCodeDropper
End Select
End Function
Function EnumCallback (ByVal hWnd As Long, lParam As Long) As Long
iResult = GetWindowText(hWnd, szText, SizeOf(szText))
If Left$(szText,6) = "PB/Win" Then
iResult = GetWindowRect(hWnd,R) 'save bounding dimensions
hFound = hWnd
Function = 0
Else
Function = 1
End If
End Function
'gbs_01373
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm