window tastendruck
window tastendruck
hi ich habe mal eine frage:
ich habe ein Programm geschrieben, und ich möchte, wenn es nicht anvisiert ist, der User allerdings f10 drückt, das dann Window 0 im Vordergrund ist.
ist das möglich?
also window 0 im vordergrund zu holen ist einfach aber der rest...
thx!
ich habe ein Programm geschrieben, und ich möchte, wenn es nicht anvisiert ist, der User allerdings f10 drückt, das dann Window 0 im Vordergrund ist.
ist das möglich?
also window 0 im vordergrund zu holen ist einfach aber der rest...
thx!
- ts-soft
- Beiträge: 22292
- Registriert: 08.09.2004 00:57
- Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel - Wohnort: Berlin
F10 ist nicht gut, hier ein Beispiel mit Alt-F10, wobei das nur funktioniert, wenn dieser Shortcut unbenutzt ist. Sollte also vom User einzustellen sein!
Code: Alles auswählen
; GlobalHotkeys library
; By Gansta93
#MOD_WINDOWS = $8
#PB_Event_Hotkey = 786
Procedure AddHotkey(Window, fsModifiers, Keys, HotkeyID) ; Create a new global hotkey HotkeyID in specified Window.
ProcedureReturn RegisterHotKey_(WindowID(Window), HotkeyID, fsModifiers, Keys)
EndProcedure
Procedure RemoveHotkey(Window, HotkeyID) ; Remove Specified HotkeyID in Window.
ProcedureReturn UnregisterHotKey_(WindowID(Window), HotkeyID)
EndProcedure
If OpenWindow(0, 0, 0, 200, 200, "Global hotkeys", #PB_Window_ScreenCentered | #PB_Window_TitleBar | #PB_Window_SystemMenu) And CreateStatusBar(0, WindowID(0))
StatusBarText(0, 0, "Type Alt+F10")
; We create the hotkeys, and display an error box if it is impossible to create one or the two.
If AddHotkey(0, #MOD_ALT, #PB_Shortcut_F10, 0) = 0
MessageRequester("Error", "Cannot create hotkey 0.")
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_Hotkey ; If an hotkey was called
Select EventwParam() ; For know what hotkey was called, no documentation on PureBasic for this function.
Case 0 ; Hotkey with ID 0 (Alt+A)
MessageRequester("Info", "Hotkey 0! (Alt + F10)")
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
; Now we remove the hotkeys.
RemoveHotkey(0, 0)
EndIf
End
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.

Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.

- ts-soft
- Beiträge: 22292
- Registriert: 08.09.2004 00:57
- Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel - Wohnort: Berlin
Fenster verstecken. Obigen Code einfach anpassen, also statt MessageRequester dort HideWindow(0, #False)
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.

Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.

Hier mal meine Variante:
Alt + F12 als Hotkey
Gruß Karl
Code: Alles auswählen
;Hotkey für Vordergrund
Procedure Steuerthread()
Repeat
If GetAsyncKeyState_(#VK_MENU) And GetAsyncKeyState_(#VK_F12)
SetActiveWindow(0)
SetWindowState(0, #PB_Window_Maximize) ;um zu zeigen, dass es würgt ;-)
EndIf
ForEver
EndProcedure
If OpenWindow(0, 0, 0, 640, 480, "Jannys Eis", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget)
th = CreateThread(@Steuerthread(), 0)
Repeat
event.l = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
If th : KillThread(th) : EndIf
CloseWindow(0)
EndIf
Gruß Karl
The Kopyright Liberation Front also known as the justified ancients of Mumu!
PB 5.X
PB 5.X
- ts-soft
- Beiträge: 22292
- Registriert: 08.09.2004 00:57
- Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel - Wohnort: Berlin
@Brügge
Nimm lieber meine Variante, dann kriegen die anderen Programme noch Luft
Der Code von Karl ist ein CPU-Killer, sorry
Nimm lieber meine Variante, dann kriegen die anderen Programme noch Luft

Der Code von Karl ist ein CPU-Killer, sorry
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.

Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
