Hello!
Is it possible to capture keystrokes outside the window?
There is a library (autoitx3), which seems to do this. But it works only on purebasic 4.00.
I am studying the library "MSAA" (Microsoft active accessibility), which seems to facilitate this feature in current versions of purebasic. But my original language is Brazilian Portuguese. The google translator helps, but very slow. And in fact, I don't even know how to use PureBasic correctly.
Does anyone know how to do this?
Thank you in advance.
Original em português.
Olá!
É possível capturar pressionamento de teclas fora da janela?
Há uma biblioteca (autoitx3), que parece fazer isso. Mas funciona apenas no purebasic 4.00.
Estou estudando a biblioteca "MSAA" (Microsoft active accessibility), que parece facilitar esse recurso nas versões atuais do purebasic. Mas meu idioma original é português brasileiro. O google tradutor ajuda, porém muito lento. E na verdade, nem sei como usar com o PureBasic corretamente.
Alguém sabe como fazer isso?
Grato desde já.
Shortcut keys in windows programs
-
- User
- Posts: 20
- Joined: Fri Jan 17, 2020 8:20 pm
Shortcut keys in windows programs
When our generation/OS updates, we either update ourselves, or we are removed.
But we are never fully uninstalled.
But we are never fully uninstalled.
-
- User
- Posts: 20
- Joined: Fri Jan 17, 2020 8:20 pm
Re: Shortcut keys in windows programs
I found something very simple.
Although I still don't understand how it works, but it serves what I need.
The source was at: http://forums.purebasic.com/english/vie ... 13&t=29773
Sorry if the code got ugly after I modified it, but I'm blind, and the structure makes no difference to my ears.
Although I still don't understand how it works, but it serves what I need.
The source was at: http://forums.purebasic.com/english/vie ... 13&t=29773
Code: Select all
; use: (Ctrl+a), (F7), and (escape to quit) in any window.
Procedure SetHotKey(*hWnd,Key,Modifiers)
Static ID
ID+1
If RegisterHotKey_(*hWnd,ID,Modifiers,Key)=0
ProcedureReturn -1
EndIf
ProcedureReturn ID
EndProcedure
Procedure HotKeyMsg()
msg.MSG
GetMessage_(@msg,0,0,0)
If msg\message=#WM_HOTKEY
ProcedureReturn msg\wParam
EndIf
EndProcedure
OpenWindow(0,0,0,0,0,"",#PB_Window_Invisible)
*hwnd=GetForegroundWindow_()
hk_ctrla=SetHotKey(WindowID(0),#VK_A,#MOD_CONTROL)
hk_f7=SetHotKey(WindowID(0),#VK_F7,0)
hk_esc=SetHotKey(WindowID(0),#VK_ESCAPE,0)
Repeat
HotKeyEvent=HotKeyMsg()
If HotKeyEvent
Select HotKeyEvent
Case hk_ctrla
;PrintN("Ctrl-A")
MessageBeep_(64)
Case hk_f7
MessageRequester("Hey!", "The F7 key was pressed!", 64)
Case hk_esc
Break
EndSelect
EndIf
Delay(20) ; Don't eat all the CPU time, we're on a multitask OS
ForEver
MessageRequester("Notify", "Bye!", 64)
;EndIf
When our generation/OS updates, we either update ourselves, or we are removed.
But we are never fully uninstalled.
But we are never fully uninstalled.