Forum | | | | - Seite 1 - |
| Julian Schmidt | Hallo, ich bin auf der Suche nach einen Hotkey-Edit das so gut wie alle Scankeys untestützt.
Def CreateHotkeyEdit(5) Control("msctls_hotkey32","",$54010200,&(2),&(3),&(4),&(5),&(1),2000,%hinstance)
Def SetHotKey(3) SendMessage(&(1),1025,MakeWord(%(2),%(3)),0)
Def GetHotKey(1) SendMessage(&(1),1026,0,0)
Def GetKey(1) LoWord(Lobyte(SendMessage(&(1),1026,0,0)))
Def GetModifyer(1) LoWord(Hibyte(SendMessage(hk&,1026,0,0)))
Def MakeWord(2) (%(1) & $FF) | ((%(2) & $FF) << 8)
Def HiByte(1) %(1) >> 8
Def LoByte(1) %(1) & $FF
WindowTitle "Tastenkombinationionen"
Cls
Var hk& = CreateHotkeyEdit(%hwnd,300,10,250,24)
SetHotKey(hk&,65,4)
While 1
SetFocus(hk&)
WaitInput
Cls
Print "Du hast eingegeben: "
Print
Print "Taste ", GetKey(hk&)
Print "Modifyer ", GetModifyer(hk&)
EndWhile
In dem Beispiel kann das Eingabe-Feld z.B. nicht mit Druck umgehen.
Gruß |
| | | | |
| | « Dieser Beitrag wurde als Lösung gekennzeichnet. » | | - Seite 4 - |
| Julian Schmidt | Wow, mit dem Edit bekommt man wirklich alle Kombinationen hin. Danke iF. Klasse Sache.
Hier nochmal mit Erkennung aller Tasten und Readonly-Edit
{$iq}
declare Edit&,kbdlist&
windowstyle 16
cls
userMessages wm_user+1234
Edit& = @Create("Edit", %hWnd, "", 10, 10, 200, 24)
SendMessage(Edit&,$00CF,1,0)
kbdlist&=createKbdList()
initMyHook()
do{
waitInput
}
nProc initMyHook{
return SetWindowsHookEx(13,procAddr(myLowLevelKeyboardHookProc),getModuleHandle(0),0)/*WH_KEYBOARD_LL*/
}
nProc myLowLevelKeyboardHookProc(long code,wp,lp){
global edit&,kbdlist&
ifnot long(lp,8)==128 {
code=long(lp,0)
string mor
ifnot code>159 or code==16 or code==17 or code==18 {
case iskey(vk_shift) : mor=mor+"Shift + "
case iskey(vk_control) : mor=mor+"Strg + "
case iskey(vk_menu) : mor=mor+"Alt + "
}
setText(edit&,mor+substr(getString(kbdlist&,selectString(kbdlist&,0,str(code))),2," "))
}
CallNextHookEx(0, Code, wp, lp)
}
nProc selectString(long lb,srcFrom,string src){
return sendMessage(lb,lb_selectString,srcFrom,src)
}
createKbdList{
long kbdList=create("list",0)
addString(kbdList,"8 BackSpace")
addString(kbdList,"9 Tab")
addString(kbdList,"12 Entfernen")
addString(kbdList,"13 Return")
addString(kbdList,"16 Shift")
addString(kbdList,"17 Strg")
addString(kbdList,"18 Alt")
addString(kbdList,"19 Pause")
addString(kbdList,"20 Caps")
addString(kbdList,"27 Esc")
addString(kbdList,"32 Space")
addString(kbdList,"33 BildHoch")
addString(kbdList,"34 BildRunter")
addString(kbdList,"35 Ende")
addString(kbdList,"36 Pos1")
addString(kbdList,"37 Links")
addString(kbdList,"38 Hoch")
addString(kbdList,"39 Rechts")
addString(kbdList,"40 Runter")
addString(kbdList,"41 Select")
addString(kbdList,"42 Druck")
addString(kbdList,"43 Execute")
addString(kbdList,"44 Druck")
addString(kbdList,"45 Einfg")
addString(kbdList,"46 Entf")
addString(kbdList,"47 Hilfe")
addString(kbdList,"48 0")
addString(kbdList,"49 1")
addString(kbdList,"50 2")
addString(kbdList,"51 3")
addString(kbdList,"52 4")
addString(kbdList,"53 5")
addString(kbdList,"54 6")
addString(kbdList,"55 7")
addString(kbdList,"56 8")
addString(kbdList,"57 9")
addString(kbdList,"65 A")
addString(kbdList,"66 B")
addString(kbdList,"67 C")
addString(kbdList,"68 D")
addString(kbdList,"69 E")
addString(kbdList,"70 F")
addString(kbdList,"71 G")
addString(kbdList,"72 H")
addString(kbdList,"73 I")
addString(kbdList,"74 J")
addString(kbdList,"75 K")
addString(kbdList,"76 L")
addString(kbdList,"77 M")
addString(kbdList,"78 N")
addString(kbdList,"79 O")
addString(kbdList,"80 P")
addString(kbdList,"81 Q")
addString(kbdList,"82 R")
addString(kbdList,"83 S")
addString(kbdList,"84 T")
addString(kbdList,"85 U")
addString(kbdList,"86 V")
addString(kbdList,"87 W")
addString(kbdList,"88 X")
addString(kbdList,"89 Y")
addString(kbdList,"90 Z")
addString(kbdList,"96 0")
addString(kbdList,"97 1")
addString(kbdList,"98 2")
addString(kbdList,"99 3")
addString(kbdList,"100 4")
addString(kbdList,"101 5")
addString(kbdList,"102 6")
addString(kbdList,"103 7")
addString(kbdList,"104 8")
addString(kbdList,"105 9")
addString(kbdList,"106 *")
addString(kbdList,"107 +")
addString(kbdList,"109 -")
addString(kbdList,"110 ,")
addString(kbdList,"111 /")
addString(kbdList,"112 F1")
addString(kbdList,"113 F2")
addString(kbdList,"114 F3")
addString(kbdList,"115 F4")
addString(kbdList,"116 F5")
addString(kbdList,"117 F6")
addString(kbdList,"118 F7")
addString(kbdList,"119 F8")
addString(kbdList,"120 F9")
addString(kbdList,"121 F10")
addString(kbdList,"122 F11")
addString(kbdList,"123 F12")
addString(kbdList,"124 F13")
addString(kbdList,"125 F14")
addString(kbdList,"126 F15")
addString(kbdList,"127 F16")
addString(kbdList,"128 F17")
addString(kbdList,"129 F18")
addString(kbdList,"130 F19")
addString(kbdList,"131 F20")
addString(kbdList,"132 F21")
addString(kbdList,"133 F22")
addString(kbdList,"134 F23")
addString(kbdList,"135 F24")
addString(kbdList,"160 Shift")
addString(kbdList,"161 Shift")
addString(kbdList,"162 Strg")
addString(kbdList,"163 Strg")
addString(kbdList,"164 Alt")
addString(kbdList,"165 Alt")
return kbdList
}
|
| | | | | |
| | | | | - Seite 3 - |
| Julian Schmidt | Versteh nicht ganz wie ich das mit Quellcode umsetze....
'{$cleq}
{$iq}
Declare Edit&
Windowstyle 16
CLS
Edit& = @Create("Edit", %hWnd, "", 10, 10, 200, 24)
Edit& = setWindowLong(hWnd,gwl_wndProc,procaddr(myLowLevelKeyboardHookProc,4))
userMessages wm_user+1234
initMyHook()
do{
waitInput
select uMessage
caseof wm_user+1234
print &uwParam,&ulParam
endSelect
}
nProc initMyHook{
return SetWindowsHookEx(13,procAddr(myLowLevelKeyboardHookProc),getModuleHandle(0),0)/*WH_KEYBOARD_LL*/
}
nProc myLowLevelKeyboardHookProc(long code,wp,lp){
global owp&
Casenot long(lp,8) : casenot (long(lp,0)==162) : sendMessage(hWnd,wm_user+1234,long(lp,0),iskey(VK_SHIFT)+(2*iskey(VK_CONTROL))+(4*iskey(VK_MENU)))
messagebox(0,Str$(code)+"; "+Str$(wp)+"; "+Str$(lp),Str$(iskey(VK_MENU)),0)
CallNextHookEx(0, Code, wp, lp)
}
|
| | | | |
| | | Viel einfacher, schau mal:
{$cleq}
declare Edit&
windowstyle 16
cls
userMessages wm_user+1234
Edit& = @Create("Edit", %hWnd, "", 10, 10, 200, 24)
initMyHook()
do{
waitInput
}
nProc initMyHook{
return SetWindowsHookEx(13,procAddr(myLowLevelKeyboardHookProc),getModuleHandle(0),0)/*WH_KEYBOARD_LL*/
}
nProc myLowLevelKeyboardHookProc(long code,wp,lp){
global edit&
//Casenot long(lp,8) : casenot (long(lp,0)==162) : sendMessage(hWnd,wm_user+1234,long(lp,0),iskey(VK_SHIFT)+(2*iskey(VK_CONTROL))+(4*iskey(VK_MENU)))
setText(edit&,Str$(code)+"; "+Str$(wp)+"; "+Str$(lp)+"; "+Str$(iskey(VK_MENU)))
CallNextHookEx(0, Code, wp, lp)
}
|
| | | | |
| | Julian Schmidt | Ok, sieht so weit gut aus.
Wollte noch die Modifer auswerten. Leider kommt es durch XPSE zu Fehlern bei IF-Bedingungen im Stile If(N1,N2,N3).
Außerdem versteh ich nicht wie sich jetzt aus Code, wp, lp der Virtuelle Tastecode ergibt. Alla [...]
{$iq}
declare Edit&
windowstyle 16
cls
userMessages wm_user+1234
Edit& = @Create("Edit", %hWnd, "", 10, 10, 200, 24)
initMyHook()
do{
waitInput
}
nProc initMyHook{
return SetWindowsHookEx(13,procAddr(myLowLevelKeyboardHookProc),getModuleHandle(0),0)/*WH_KEYBOARD_LL*/
}
nProc myLowLevelKeyboardHookProc(long code,wp,lp){
global edit&
//Casenot long(lp,8) : casenot (long(lp,0)==162) : sendMessage(hWnd,wm_user+1234,long(lp,0),iskey(VK_SHIFT)+(2*iskey(VK_CONTROL))+(4*iskey(VK_MENU)))
Declare modifyer$
modifyer$=""'If(iskey(VK_CONTROL),"Strg + ")+If(iskey(VK_MENU),"Alt + ","")+If(iskey(VK_SHIFT),"Shift + ","")
setText edit&,modifyer$+Str$(code)+"; "+Str$(wp)+"; "+Str$(lp)+"; "+Str$(iskey(VK_MENU))
CallNextHookEx(0, Code, wp, lp)
}
|
| | | | |
| | | Schau mal: [...]
Wenn Du if als Funktion magst in nativen Funktionen dann iff wobei das letzte f für Funktion steht. Ist also kein xpse- sondern "Bedienerfehler". Achtung hierbei bei nativen Funktionen immer Typen beachten, iff als Funktion erwartet 3 longs.
Noch ein "Bedienerfehler":
Du schreibst in der nProc settext edit&, nativ nur Funktionen statt Befehle, also settext(edit&,... - einmal Vorwort überfliegen: [...] um Zeit und "Ärger" zu ersparen.
Schnellkurs:
Native Funktionen können in Profansyntax programmiert werden, oder auch in Assembler - es kann auch Assembler mit Profansyntax gemischt werden. Die Syntax in nativen Funktionen ist einfacher als die der Runtime. Beispielsweise müssen Funktionen immer wie Funktionen aufgerufen werden, nicht Sleep 50 sondern sleep(50) und einzig das Komma ist Parametertrennzeichen. Befehle und Systemvariablen können einzig vom Befehlssatz gestellt werden, NProc-Funktionen sind immer Funktionen. Float-Konstanten müssen immer mit Dezimalpunkt als Kommazahl ausgedrückt werden (z.B. 1.0 statt 1) und Stringkonstanten per Anführungszeichen (z.B. "Stringinhalt").
So läufts recht cool finde ich:
{$cleq}
declare Edit&,kbdlist&
windowstyle 16
cls
userMessages wm_user+1234
Edit& = @Create("Edit", %hWnd, "", 10, 10, 200, 24)
kbdlist&=createKbdList()
initMyHook()
do{
waitInput
}
nProc initMyHook{
return SetWindowsHookEx(13,procAddr(myLowLevelKeyboardHookProc),getModuleHandle(0),0)/*WH_KEYBOARD_LL*/
}
nProc myLowLevelKeyboardHookProc(long code,wp,lp){
global edit&,kbdlist&
ifnot long(lp,8) {
code=long(lp,0)
string mor
ifnot code>159 or code==16 or code==17 or code==18 {
case iskey(vk_shift) : mor=mor+"Shift+"
case iskey(vk_control) : mor=mor+"Strg+"
case iskey(vk_menu) : mor=mor+"Alt+"
}
setText(edit&,mor+substr(getString(kbdlist&,selectString(kbdlist&,0,str(code)+" ")),2," "))
}
CallNextHookEx(0, Code, wp, lp)
}
nProc selectString(long lb,srcFrom,string src){
return sendMessage(lb,lb_selectString,srcFrom,src)
}
createKbdList{
long kbdList=create("list",0)
addString(kbdList,"8 BackSpace")
addString(kbdList,"9 Tab")
addString(kbdList,"12 Entfernen")
addString(kbdList,"13 Return")
addString(kbdList,"16 Shift")
addString(kbdList,"17 Strg")
addString(kbdList,"18 Alt")
addString(kbdList,"19 Pause")
addString(kbdList,"20 Caps")
addString(kbdList,"27 Esc")
addString(kbdList,"32 Space")
addString(kbdList,"33 BildHoch")
addString(kbdList,"34 BildRunter")
addString(kbdList,"35 Ende")
addString(kbdList,"36 Pos1")
addString(kbdList,"37 Links")
addString(kbdList,"38 Hoch")
addString(kbdList,"39 Rechts")
addString(kbdList,"40 Runter")
addString(kbdList,"41 Select")
addString(kbdList,"42 Druck")
addString(kbdList,"43 Execute")
addString(kbdList,"44 Druck")
addString(kbdList,"45 Einfg")
addString(kbdList,"46 Entf")
addString(kbdList,"47 Hilfe")
addString(kbdList,"48 0")
addString(kbdList,"49 1")
addString(kbdList,"50 2")
addString(kbdList,"51 3")
addString(kbdList,"52 4")
addString(kbdList,"53 5")
addString(kbdList,"54 6")
addString(kbdList,"55 7")
addString(kbdList,"56 8")
addString(kbdList,"57 9")
addString(kbdList,"65 A")
addString(kbdList,"66 B")
addString(kbdList,"67 C")
addString(kbdList,"68 D")
addString(kbdList,"69 E")
addString(kbdList,"70 F")
addString(kbdList,"71 G")
addString(kbdList,"72 H")
addString(kbdList,"73 I")
addString(kbdList,"74 J")
addString(kbdList,"75 K")
addString(kbdList,"76 L")
addString(kbdList,"77 M")
addString(kbdList,"78 N")
addString(kbdList,"79 O")
addString(kbdList,"80 P")
addString(kbdList,"81 Q")
addString(kbdList,"82 R")
addString(kbdList,"83 S")
addString(kbdList,"84 T")
addString(kbdList,"85 U")
addString(kbdList,"86 V")
addString(kbdList,"87 W")
addString(kbdList,"88 X")
addString(kbdList,"89 Y")
addString(kbdList,"90 Z")
addString(kbdList,"96 0")
addString(kbdList,"97 1")
addString(kbdList,"98 2")
addString(kbdList,"99 3")
addString(kbdList,"100 4")
addString(kbdList,"101 5")
addString(kbdList,"102 6")
addString(kbdList,"103 7")
addString(kbdList,"104 8")
addString(kbdList,"105 9")
addString(kbdList,"106 *")
addString(kbdList,"107 +")
addString(kbdList,"109 -")
addString(kbdList,"110 ,")
addString(kbdList,"111 /")
addString(kbdList,"112 F1")
addString(kbdList,"113 F2")
addString(kbdList,"114 F3")
addString(kbdList,"115 F4")
addString(kbdList,"116 F5")
addString(kbdList,"117 F6")
addString(kbdList,"118 F7")
addString(kbdList,"119 F8")
addString(kbdList,"120 F9")
addString(kbdList,"121 F10")
addString(kbdList,"122 F11")
addString(kbdList,"123 F12")
addString(kbdList,"124 F13")
addString(kbdList,"125 F14")
addString(kbdList,"126 F15")
addString(kbdList,"127 F16")
addString(kbdList,"128 F17")
addString(kbdList,"129 F18")
addString(kbdList,"130 F19")
addString(kbdList,"131 F20")
addString(kbdList,"132 F21")
addString(kbdList,"133 F22")
addString(kbdList,"134 F23")
addString(kbdList,"135 F24")
addString(kbdList,"160 Shift")
addString(kbdList,"161 Shift")
addString(kbdList,"162 Strg")
addString(kbdList,"163 Strg")
addString(kbdList,"164 Alt")
addString(kbdList,"165 Alt")
return kbdList
}
Nachtrag: Code nochmal geändert, hat noch was gefehlt.
|
| | | | |
| | | | - Seite 4 - |
| | Julian Schmidt | Ja, funktioniert schon ganz ordentlich.
Bei Fokus auf dem Edit wird nur der geschriebene Text plus der ausgelesene Text eingesetzt. Lässt sich natürlich per Disable oder Readonly verhindern.
Außerdem werden Tasten wie Pfeiltasten, Druck, Bildlauf und ein paar Mehr immernoch nicht erkannt. |
| | | | |
| | | Damit diese Tasten auch funktionieren einfach statt:
Diese Zeile nutzen:
Hättest aber auch selbst herausbekommen können einfach per:
Readonly halte ich für eine gute Idee oder Drawtext nutzen. |
| | | | |
| | Julian Schmidt | Wow, mit dem Edit bekommt man wirklich alle Kombinationen hin. Danke iF. Klasse Sache.
Hier nochmal mit Erkennung aller Tasten und Readonly-Edit
{$iq}
declare Edit&,kbdlist&
windowstyle 16
cls
userMessages wm_user+1234
Edit& = @Create("Edit", %hWnd, "", 10, 10, 200, 24)
SendMessage(Edit&,$00CF,1,0)
kbdlist&=createKbdList()
initMyHook()
do{
waitInput
}
nProc initMyHook{
return SetWindowsHookEx(13,procAddr(myLowLevelKeyboardHookProc),getModuleHandle(0),0)/*WH_KEYBOARD_LL*/
}
nProc myLowLevelKeyboardHookProc(long code,wp,lp){
global edit&,kbdlist&
ifnot long(lp,8)==128 {
code=long(lp,0)
string mor
ifnot code>159 or code==16 or code==17 or code==18 {
case iskey(vk_shift) : mor=mor+"Shift + "
case iskey(vk_control) : mor=mor+"Strg + "
case iskey(vk_menu) : mor=mor+"Alt + "
}
setText(edit&,mor+substr(getString(kbdlist&,selectString(kbdlist&,0,str(code))),2," "))
}
CallNextHookEx(0, Code, wp, lp)
}
nProc selectString(long lb,srcFrom,string src){
return sendMessage(lb,lb_selectString,srcFrom,src)
}
createKbdList{
long kbdList=create("list",0)
addString(kbdList,"8 BackSpace")
addString(kbdList,"9 Tab")
addString(kbdList,"12 Entfernen")
addString(kbdList,"13 Return")
addString(kbdList,"16 Shift")
addString(kbdList,"17 Strg")
addString(kbdList,"18 Alt")
addString(kbdList,"19 Pause")
addString(kbdList,"20 Caps")
addString(kbdList,"27 Esc")
addString(kbdList,"32 Space")
addString(kbdList,"33 BildHoch")
addString(kbdList,"34 BildRunter")
addString(kbdList,"35 Ende")
addString(kbdList,"36 Pos1")
addString(kbdList,"37 Links")
addString(kbdList,"38 Hoch")
addString(kbdList,"39 Rechts")
addString(kbdList,"40 Runter")
addString(kbdList,"41 Select")
addString(kbdList,"42 Druck")
addString(kbdList,"43 Execute")
addString(kbdList,"44 Druck")
addString(kbdList,"45 Einfg")
addString(kbdList,"46 Entf")
addString(kbdList,"47 Hilfe")
addString(kbdList,"48 0")
addString(kbdList,"49 1")
addString(kbdList,"50 2")
addString(kbdList,"51 3")
addString(kbdList,"52 4")
addString(kbdList,"53 5")
addString(kbdList,"54 6")
addString(kbdList,"55 7")
addString(kbdList,"56 8")
addString(kbdList,"57 9")
addString(kbdList,"65 A")
addString(kbdList,"66 B")
addString(kbdList,"67 C")
addString(kbdList,"68 D")
addString(kbdList,"69 E")
addString(kbdList,"70 F")
addString(kbdList,"71 G")
addString(kbdList,"72 H")
addString(kbdList,"73 I")
addString(kbdList,"74 J")
addString(kbdList,"75 K")
addString(kbdList,"76 L")
addString(kbdList,"77 M")
addString(kbdList,"78 N")
addString(kbdList,"79 O")
addString(kbdList,"80 P")
addString(kbdList,"81 Q")
addString(kbdList,"82 R")
addString(kbdList,"83 S")
addString(kbdList,"84 T")
addString(kbdList,"85 U")
addString(kbdList,"86 V")
addString(kbdList,"87 W")
addString(kbdList,"88 X")
addString(kbdList,"89 Y")
addString(kbdList,"90 Z")
addString(kbdList,"96 0")
addString(kbdList,"97 1")
addString(kbdList,"98 2")
addString(kbdList,"99 3")
addString(kbdList,"100 4")
addString(kbdList,"101 5")
addString(kbdList,"102 6")
addString(kbdList,"103 7")
addString(kbdList,"104 8")
addString(kbdList,"105 9")
addString(kbdList,"106 *")
addString(kbdList,"107 +")
addString(kbdList,"109 -")
addString(kbdList,"110 ,")
addString(kbdList,"111 /")
addString(kbdList,"112 F1")
addString(kbdList,"113 F2")
addString(kbdList,"114 F3")
addString(kbdList,"115 F4")
addString(kbdList,"116 F5")
addString(kbdList,"117 F6")
addString(kbdList,"118 F7")
addString(kbdList,"119 F8")
addString(kbdList,"120 F9")
addString(kbdList,"121 F10")
addString(kbdList,"122 F11")
addString(kbdList,"123 F12")
addString(kbdList,"124 F13")
addString(kbdList,"125 F14")
addString(kbdList,"126 F15")
addString(kbdList,"127 F16")
addString(kbdList,"128 F17")
addString(kbdList,"129 F18")
addString(kbdList,"130 F19")
addString(kbdList,"131 F20")
addString(kbdList,"132 F21")
addString(kbdList,"133 F22")
addString(kbdList,"134 F23")
addString(kbdList,"135 F24")
addString(kbdList,"160 Shift")
addString(kbdList,"161 Shift")
addString(kbdList,"162 Strg")
addString(kbdList,"163 Strg")
addString(kbdList,"164 Alt")
addString(kbdList,"165 Alt")
return kbdList
}
|
| | | | |
| | | Ah, super -
vlt. kannst das noch eben nach Quelltexte abstellen. |
| | | | |
| | Julian Schmidt | | | | | |
| | | Saubere Arbeit -
fehlt noch sowas wie Shift + Mausrand-Hinab und Strg + Rechtsklick ...
bzw. Shift + Strg + Alt + F12 + Links&Rechtsklick + Mausrad-Hinauf.
Wers hinbekommt! ^^ |
| | | | |
| | Julian Schmidt | Uff, Ächz
Wenn das einer schafft, dann DU! |
| | | | |
| | | Mit einem kleinen Trick tatsächlich da Strg+Alt über AltGr ereichbar ist, Du also mit der einen Hand nur AltGr+Shift+F12 halten musst und mit der anderen kannst Du ja beide Maustasten halten und mit dem Mittel- Finger das Mausrad bedienen. Geht also! ^^ |
| | | | |
|
AntwortenThemenoptionen | 44.991 Betrachtungen |
ThemeninformationenDieses Thema hat 3 Teilnehmer: |
|