tpt Posted January 27, 2009 Share Posted January 27, 2009 Hello, i am new in these forums & autoit scripting. I need your help building similar hotkey system than in ventrilo (Image below).Short explanation: If my cursor is in the box and i press some key my hotkey will be changed to that key.Can anyone explain how i do this or maybe give some snippets?Thanks in advance! Link to comment Share on other sites More sharing options...
jvanegmond Posted January 28, 2009 Share Posted January 28, 2009 This has been made a while ago, it should still work (with slight modifications?).http://www.autoitscript.com/forum/index.php?showtopic=56374 github.com/jvanegmond Link to comment Share on other sites More sharing options...
tpt Posted January 28, 2009 Author Share Posted January 28, 2009 (edited) Thank you very much. Edited January 28, 2009 by tpt Link to comment Share on other sites More sharing options...
tpt Posted January 28, 2009 Author Share Posted January 28, 2009 I have one new question: Once i have selected the hotkey, how can i make function for it? Link to comment Share on other sites More sharing options...
tpt Posted January 28, 2009 Author Share Posted January 28, 2009 (edited) I have one new question:Once i have selected the hotkey, how can i make function for it?I mean with the script that Mandanian gave me.EDIT: Couldn't edit my last message so i had to make new reply. >.< Edited January 28, 2009 by tpt Link to comment Share on other sites More sharing options...
jvanegmond Posted January 28, 2009 Share Posted January 28, 2009 Set a hotkey then press the button. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> HotKeySet('{CAPSLOCK}', '_ExcludeHotkey') HotKeySet('{NUMLOCK}', '_ExcludeHotkey') Global Const $HKM_SETHOTKEY = $WM_USER + 1 Global Const $HKM_GETHOTKEY = $WM_USER + 2 Global Const $HKM_SETRULES = $WM_USER + 3 Global Const $HOTKEYF_ALT = 0x04 Global Const $HOTKEYF_CONTROL = 0x02 Global Const $HOTKEYF_EXT = 0x80; Extended key Global Const $HOTKEYF_SHIFT = 0x01 ; invalid key combinations Global Const $HKCOMB_A = 0x8; ALT Global Const $HKCOMB_C = 0x4; CTRL Global Const $HKCOMB_CA = 0x40; CTRL+ALT Global Const $HKCOMB_NONE = 0x1; Unmodified keys Global Const $HKCOMB_S = 0x2; SHIFT Global Const $HKCOMB_SA = 0x20; SHIFT+ALT Global Const $HKCOMB_SC = 0x10; SHIFT+CTRL Global Const $HKCOMB_SCA = 0x80; SHIFT+CTRL+ALT $gui_Main = GUICreate('Get Hotkey', 220, 90) $bt = GUICtrlCreateButton('Set as hotkey', 10, 50, 200, 30); GUICtrlSetState(-1, $GUI_DEFBUTTON) $hWnd = _WinAPI_CreateWindowEx (0, 'msctls_hotkey32', '', BitOR($WS_CHILD, $WS_VISIBLE), 10, 10, 200, 25, $gui_Main) _SendMessage($hWnd, $HKM_SETRULES, _ BitOR($HKCOMB_NONE, $HKCOMB_S), _ ; invalid key combinations BitOR(BitShift($HOTKEYF_ALT, -16), BitAND(0, 0xFFFF))); add ALT to invalid entries GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $bt $i_HotKey = _SendMessage($hWnd, $HKM_GETHOTKEY) $n_Flag = BitShift($i_HotKey, 8); high byte $i_HotKey = BitAND($i_HotKey, 0xFF); low byte $sz_Flag = "" If BitAND($n_Flag, $HOTKEYF_SHIFT) Then $sz_Flag = "SHIFT + " If BitAND($n_Flag, $HOTKEYF_CONTROL) Then $sz_Flag = $sz_Flag & " CTRL + " If BitAND($n_Flag, $HOTKEYF_ALT) Then $sz_Flag = $sz_Flag & " ALT + " ;Msgbox(0, $sz_Flag & Chr($i_Hotkey), 'Chr(' & $i_Hotkey & ') = ' & Chr($i_Hotkey) & @CRLF & @CRLF & ) HotKeySet(_GetCode($sz_Flag & Chr($i_Hotkey)), "_Hotkey") If $i_Hotkey = 20 or $i_Hotkey = 144 then _SendMessage($hWnd, $HKM_SETHOTKEY) EndIf GUICtrlSetState($bt, $GUI_DISABLE + $GUI_FOCUS) GUICtrlSetData($bt,"Try the hotkey out :)") _WinAPI_DestroyWindow ($hWnd) EndSwitch WEnd _WinAPI_DestroyWindow ($hWnd) Exit Func _Hotkey() MsgBox(0,"","Hotkey has been pressed.") EndFunc Func _GetCode($string) $temp = StringSplit($string, '+') $lastTerm = StringLower(StringStripWS($temp[Ubound($temp) - 1], 8)) If StringLen($lastTerm) > 1 then If StringLeft($lastTerm, 1) = 'F' then $append = '{' & StringUpper($lastTerm) & '}' EndIf Else $temp = StringLower(StringRight($string, 1)) If $temp = '!' then $append = '{PGUP}' ElseIf $temp = '"' then $append = '{PGDN}' ElseIf $temp = '$' then $append = '{HOME}' ElseIf $temp = '#' then $append = '{END}' ElseIf $temp = '-' then $append = '{INS}' Else $append = StringLower(StringRight($string, 1)) EndIf EndIf $hotkeyAssignment = '' If StringInStr($string, 'CTRL') > 0 then $hotkeyAssignment &= '^' EndIf If StringInStr($string, 'SHIFT') > 0 then $hotkeyAssignment &= '+' EndIf If StringInStr($string, 'ALT') > 0 then $hotkeyAssignment &= '!' EndIf $hotkeyAssignment &= $append Return $hotkeyAssignment EndFunc Func _ExcludeHotkey() _SendMessage(_WinAPI_GetFocus(), $HKM_SETHOTKEY) EndFunc github.com/jvanegmond Link to comment Share on other sites More sharing options...
tpt Posted January 28, 2009 Author Share Posted January 28, 2009 (edited) Set a hotkey then press the button. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> HotKeySet('{CAPSLOCK}', '_ExcludeHotkey') HotKeySet('{NUMLOCK}', '_ExcludeHotkey') Global Const $HKM_SETHOTKEY = $WM_USER + 1 Global Const $HKM_GETHOTKEY = $WM_USER + 2 Global Const $HKM_SETRULES = $WM_USER + 3 Global Const $HOTKEYF_ALT = 0x04 Global Const $HOTKEYF_CONTROL = 0x02 Global Const $HOTKEYF_EXT = 0x80; Extended key Global Const $HOTKEYF_SHIFT = 0x01 ; invalid key combinations Global Const $HKCOMB_A = 0x8; ALT Global Const $HKCOMB_C = 0x4; CTRL Global Const $HKCOMB_CA = 0x40; CTRL+ALT Global Const $HKCOMB_NONE = 0x1; Unmodified keys Global Const $HKCOMB_S = 0x2; SHIFT Global Const $HKCOMB_SA = 0x20; SHIFT+ALT Global Const $HKCOMB_SC = 0x10; SHIFT+CTRL Global Const $HKCOMB_SCA = 0x80; SHIFT+CTRL+ALT $gui_Main = GUICreate('Get Hotkey', 220, 90) $bt = GUICtrlCreateButton('Set as hotkey', 10, 50, 200, 30); GUICtrlSetState(-1, $GUI_DEFBUTTON) $hWnd = _WinAPI_CreateWindowEx (0, 'msctls_hotkey32', '', BitOR($WS_CHILD, $WS_VISIBLE), 10, 10, 200, 25, $gui_Main) _SendMessage($hWnd, $HKM_SETRULES, _ BitOR($HKCOMB_NONE, $HKCOMB_S), _ ; invalid key combinations BitOR(BitShift($HOTKEYF_ALT, -16), BitAND(0, 0xFFFF))); add ALT to invalid entries GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $bt $i_HotKey = _SendMessage($hWnd, $HKM_GETHOTKEY) $n_Flag = BitShift($i_HotKey, 8); high byte $i_HotKey = BitAND($i_HotKey, 0xFF); low byte $sz_Flag = "" If BitAND($n_Flag, $HOTKEYF_SHIFT) Then $sz_Flag = "SHIFT + " If BitAND($n_Flag, $HOTKEYF_CONTROL) Then $sz_Flag = $sz_Flag & " CTRL + " If BitAND($n_Flag, $HOTKEYF_ALT) Then $sz_Flag = $sz_Flag & " ALT + " ;Msgbox(0, $sz_Flag & Chr($i_Hotkey), 'Chr(' & $i_Hotkey & ') = ' & Chr($i_Hotkey) & @CRLF & @CRLF & ) HotKeySet(_GetCode($sz_Flag & Chr($i_Hotkey)), "_Hotkey") If $i_Hotkey = 20 or $i_Hotkey = 144 then _SendMessage($hWnd, $HKM_SETHOTKEY) EndIf GUICtrlSetState($bt, $GUI_DISABLE + $GUI_FOCUS) GUICtrlSetData($bt,"Try the hotkey out :)") _WinAPI_DestroyWindow ($hWnd) EndSwitch WEnd _WinAPI_DestroyWindow ($hWnd) Exit Func _Hotkey() MsgBox(0,"","Hotkey has been pressed.") EndFunc Func _GetCode($string) $temp = StringSplit($string, '+') $lastTerm = StringLower(StringStripWS($temp[Ubound($temp) - 1], 8)) If StringLen($lastTerm) > 1 then If StringLeft($lastTerm, 1) = 'F' then $append = '{' & StringUpper($lastTerm) & '}' EndIf Else $temp = StringLower(StringRight($string, 1)) If $temp = '!' then $append = '{PGUP}' ElseIf $temp = '"' then $append = '{PGDN}' ElseIf $temp = '$' then $append = '{HOME}' ElseIf $temp = '#' then $append = '{END}' ElseIf $temp = '-' then $append = '{INS}' Else $append = StringLower(StringRight($string, 1)) EndIf EndIf $hotkeyAssignment = '' If StringInStr($string, 'CTRL') > 0 then $hotkeyAssignment &= '^' EndIf If StringInStr($string, 'SHIFT') > 0 then $hotkeyAssignment &= '+' EndIf If StringInStr($string, 'ALT') > 0 then $hotkeyAssignment &= '!' EndIf $hotkeyAssignment &= $append Return $hotkeyAssignment EndFunc Func _ExcludeHotkey() _SendMessage(_WinAPI_GetFocus(), $HKM_SETHOTKEY) EndFunc Thank you very much again... But i found out that some of the hotkeys i enter does not work ie. f1 Any idea why it doesn't work/How to fix? EDIT: It works flawlessy with pgdn but not with f1. Edited January 28, 2009 by tpt Link to comment Share on other sites More sharing options...
jvanegmond Posted January 29, 2009 Share Posted January 29, 2009 The function is documented here: http://msdn.microsoft.com/en-us/library/bb775235(VS.85).aspxIt seems that extended keys are unhandled, or handled in a incorrect way. I can't write the entire bit that handles the extended keys, you'll have to do that yourself making educated guesses on how it should be.I've done a little part of it, to at least fix your {F1} through {F12} problems.expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> HotKeySet('{CAPSLOCK}', '_ExcludeHotkey') HotKeySet('{NUMLOCK}', '_ExcludeHotkey') Global Const $HKM_SETHOTKEY = $WM_USER + 1 Global Const $HKM_GETHOTKEY = $WM_USER + 2 Global Const $HKM_SETRULES = $WM_USER + 3 Global Const $HOTKEYF_ALT = 0x04 Global Const $HOTKEYF_CONTROL = 0x02 Global Const $HOTKEYF_EXT = 0x80; Extended key Global Const $HOTKEYF_SHIFT = 0x01 ; invalid key combinations Global Const $HKCOMB_A = 0x8; ALT Global Const $HKCOMB_C = 0x4; CTRL Global Const $HKCOMB_CA = 0x40; CTRL+ALT Global Const $HKCOMB_NONE = 0x1; Unmodified keys Global Const $HKCOMB_S = 0x2; SHIFT Global Const $HKCOMB_SA = 0x20; SHIFT+ALT Global Const $HKCOMB_SC = 0x10; SHIFT+CTRL Global Const $HKCOMB_SCA = 0x80; SHIFT+CTRL+ALT $gui_Main = GUICreate('Get Hotkey', 220, 90) $bt = GUICtrlCreateButton('Set as hotkey', 10, 50, 200, 30); GUICtrlSetState(-1, $GUI_DEFBUTTON) $hWnd = _WinAPI_CreateWindowEx (0, 'msctls_hotkey32', '', BitOR($WS_CHILD, $WS_VISIBLE), 10, 10, 200, 25, $gui_Main) _SendMessage($hWnd, $HKM_SETRULES, _ BitOR($HKCOMB_NONE, $HKCOMB_S), _ ; invalid key combinations BitOR(BitShift($HOTKEYF_ALT, -16), BitAND(0, 0xFFFF))); add ALT to invalid entries GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $bt $i_HotKey = _SendMessage($hWnd, $HKM_GETHOTKEY) $n_Flag = BitShift($i_HotKey, 8); high byte $i_HotKey = BitAND($i_HotKey, 0xFF); low byte $sHotkey = "" If ( BitAND($i_Hotkey, 32) ) Then Switch $i_Hotkey Case 112 To 124 $n = $i_Hotkey - 111 $sHotkey = "{F" & $n & "}" EndSwitch Else $sz_Flag = "" If BitAND($n_Flag, $HOTKEYF_SHIFT) Then $sz_Flag = "SHIFT + " If BitAND($n_Flag, $HOTKEYF_CONTROL) Then $sz_Flag = $sz_Flag & " CTRL + " If BitAND($n_Flag, $HOTKEYF_ALT) Then $sz_Flag = $sz_Flag & " ALT + " $sHotkey = _GetCode($sz_Flag & Chr($i_Hotkey)) If $i_Hotkey = 20 or $i_Hotkey = 144 then _SendMessage($hWnd, $HKM_SETHOTKEY) EndIf EndIf MsgBox(0,"","HotKey set to: " & $sHotkey ) HotKeySet($sHotkey, "_Hotkey") GUICtrlSetState($bt, $GUI_DISABLE + $GUI_FOCUS) GUICtrlSetData($bt,"Try the hotkey out ") _WinAPI_DestroyWindow ($hWnd) EndSwitch WEnd _WinAPI_DestroyWindow ($hWnd) Exit Func _Hotkey() MsgBox(0,"","Hotkey has been pressed.") EndFunc Func _GetCode($string) $temp = StringSplit($string, '+') $lastTerm = StringLower(StringStripWS($temp[Ubound($temp) - 1], 8)) If StringLen($lastTerm) > 1 then If StringLeft($lastTerm, 1) = 'F' then $append = '{' & StringUpper($lastTerm) & '}' EndIf Else $temp = StringLower(StringRight($string, 1)) If $temp = '!' then $append = '{PGUP}' ElseIf $temp = '"' then $append = '{PGDN}' ElseIf $temp = '$' then $append = '{HOME}' ElseIf $temp = '#' then $append = '{END}' ElseIf $temp = '-' then $append = '{INS}' Else $append = StringLower(StringRight($string, 1)) EndIf EndIf $hotkeyAssignment = '' If StringInStr($string, 'CTRL') > 0 then $hotkeyAssignment &= '^' EndIf If StringInStr($string, 'SHIFT') > 0 then $hotkeyAssignment &= '+' EndIf If StringInStr($string, 'ALT') > 0 then $hotkeyAssignment &= '!' EndIf $hotkeyAssignment &= $append Return $hotkeyAssignment EndFunc Func _ExcludeHotkey() _SendMessage(_WinAPI_GetFocus(), $HKM_SETHOTKEY) EndFunc github.com/jvanegmond Link to comment Share on other sites More sharing options...
tpt Posted January 29, 2009 Author Share Posted January 29, 2009 The function is documented here: http://msdn.microsoft.com/en-us/library/bb775235(VS.85).aspx It seems that extended keys are unhandled, or handled in a incorrect way. I can't write the entire bit that handles the extended keys, you'll have to do that yourself making educated guesses on how it should be. I've done a little part of it, to at least fix your {F1} through {F12} problems. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> HotKeySet('{CAPSLOCK}', '_ExcludeHotkey') HotKeySet('{NUMLOCK}', '_ExcludeHotkey') Global Const $HKM_SETHOTKEY = $WM_USER + 1 Global Const $HKM_GETHOTKEY = $WM_USER + 2 Global Const $HKM_SETRULES = $WM_USER + 3 Global Const $HOTKEYF_ALT = 0x04 Global Const $HOTKEYF_CONTROL = 0x02 Global Const $HOTKEYF_EXT = 0x80; Extended key Global Const $HOTKEYF_SHIFT = 0x01 ; invalid key combinations Global Const $HKCOMB_A = 0x8; ALT Global Const $HKCOMB_C = 0x4; CTRL Global Const $HKCOMB_CA = 0x40; CTRL+ALT Global Const $HKCOMB_NONE = 0x1; Unmodified keys Global Const $HKCOMB_S = 0x2; SHIFT Global Const $HKCOMB_SA = 0x20; SHIFT+ALT Global Const $HKCOMB_SC = 0x10; SHIFT+CTRL Global Const $HKCOMB_SCA = 0x80; SHIFT+CTRL+ALT $gui_Main = GUICreate('Get Hotkey', 220, 90) $bt = GUICtrlCreateButton('Set as hotkey', 10, 50, 200, 30); GUICtrlSetState(-1, $GUI_DEFBUTTON) $hWnd = _WinAPI_CreateWindowEx (0, 'msctls_hotkey32', '', BitOR($WS_CHILD, $WS_VISIBLE), 10, 10, 200, 25, $gui_Main) _SendMessage($hWnd, $HKM_SETRULES, _ BitOR($HKCOMB_NONE, $HKCOMB_S), _ ; invalid key combinations BitOR(BitShift($HOTKEYF_ALT, -16), BitAND(0, 0xFFFF))); add ALT to invalid entries GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $bt $i_HotKey = _SendMessage($hWnd, $HKM_GETHOTKEY) $n_Flag = BitShift($i_HotKey, 8); high byte $i_HotKey = BitAND($i_HotKey, 0xFF); low byte $sHotkey = "" If ( BitAND($i_Hotkey, 32) ) Then Switch $i_Hotkey Case 112 To 124 $n = $i_Hotkey - 111 $sHotkey = "{F" & $n & "}" EndSwitch Else $sz_Flag = "" If BitAND($n_Flag, $HOTKEYF_SHIFT) Then $sz_Flag = "SHIFT + " If BitAND($n_Flag, $HOTKEYF_CONTROL) Then $sz_Flag = $sz_Flag & " CTRL + " If BitAND($n_Flag, $HOTKEYF_ALT) Then $sz_Flag = $sz_Flag & " ALT + " $sHotkey = _GetCode($sz_Flag & Chr($i_Hotkey)) If $i_Hotkey = 20 or $i_Hotkey = 144 then _SendMessage($hWnd, $HKM_SETHOTKEY) EndIf EndIf MsgBox(0,"","HotKey set to: " & $sHotkey ) HotKeySet($sHotkey, "_Hotkey") GUICtrlSetState($bt, $GUI_DISABLE + $GUI_FOCUS) GUICtrlSetData($bt,"Try the hotkey out ") _WinAPI_DestroyWindow ($hWnd) EndSwitch WEnd _WinAPI_DestroyWindow ($hWnd) Exit Func _Hotkey() MsgBox(0,"","Hotkey has been pressed.") EndFunc Func _GetCode($string) $temp = StringSplit($string, '+') $lastTerm = StringLower(StringStripWS($temp[Ubound($temp) - 1], 8)) If StringLen($lastTerm) > 1 then If StringLeft($lastTerm, 1) = 'F' then $append = '{' & StringUpper($lastTerm) & '}' EndIf Else $temp = StringLower(StringRight($string, 1)) If $temp = '!' then $append = '{PGUP}' ElseIf $temp = '"' then $append = '{PGDN}' ElseIf $temp = '$' then $append = '{HOME}' ElseIf $temp = '#' then $append = '{END}' ElseIf $temp = '-' then $append = '{INS}' Else $append = StringLower(StringRight($string, 1)) EndIf EndIf $hotkeyAssignment = '' If StringInStr($string, 'CTRL') > 0 then $hotkeyAssignment &= '^' EndIf If StringInStr($string, 'SHIFT') > 0 then $hotkeyAssignment &= '+' EndIf If StringInStr($string, 'ALT') > 0 then $hotkeyAssignment &= '!' EndIf $hotkeyAssignment &= $append Return $hotkeyAssignment EndFunc Func _ExcludeHotkey() _SendMessage(_WinAPI_GetFocus(), $HKM_SETHOTKEY) EndFunc Thanks for the link/help once again. ^^ Link to comment Share on other sites More sharing options...
tpt Posted February 7, 2009 Author Share Posted February 7, 2009 One last question.. How can i detect all mouse buttons? mouse1, mouse2, mouse3, mwheeldown, mwheelup, mouse4 and mouse5. Thanks in advance! Link to comment Share on other sites More sharing options...
UFWU Posted February 8, 2009 Share Posted February 8, 2009 One last question.. How can i detect all mouse buttons? mouse1, mouse2, mouse3, mwheeldown, mwheelup, mouse4 and mouse5. Thanks in advance! just viewed this topic and i cant figure that script out u set a hotkey to show msg box thats it???? this is the closest thing to hotkey i have but i would like it so it ask for an input instead of having to press h to find the keys you might need to modify it coz i have it setup for Tales Of Pirates _ispressed Keys are below it expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> HotKeySet('{CAPSLOCK}', '_ExcludeHotkey') HotKeySet('{NUMLOCK}', '_ExcludeHotkey') Global Const $HKM_SETHOTKEY = $WM_USER + 1 Global Const $HKM_GETHOTKEY = $WM_USER + 2 Global Const $HKM_SETRULES = $WM_USER + 3 Global Const $HOTKEYF_ALT = 0x04 Global Const $HOTKEYF_CONTROL = 0x02 Global Const $HOTKEYF_EXT = 0x80; Extended key Global Const $HOTKEYF_SHIFT = 0x01 ; invalid key combinations Global Const $HKCOMB_A = 0x8; ALT Global Const $HKCOMB_C = 0x4; CTRL Global Const $HKCOMB_CA = 0x40; CTRL+ALT Global Const $HKCOMB_NONE = 0x1; Unmodified keys Global Const $HKCOMB_S = 0x2; SHIFT Global Const $HKCOMB_SA = 0x20; SHIFT+ALT Global Const $HKCOMB_SC = 0x10; SHIFT+CTRL Global Const $HKCOMB_SCA = 0x80; SHIFT+CTRL+ALT $gui_Main = GUICreate('Get Hotkey', 220, 90) $bt = GUICtrlCreateButton('Set as hotkey', 10, 50, 200, 30); GUICtrlSetState(-1, $GUI_DEFBUTTON) $hWnd = _WinAPI_CreateWindowEx (0, 'msctls_hotkey32', '', BitOR($WS_CHILD, $WS_VISIBLE), 10, 10, 200, 25, $gui_Main) _SendMessage($hWnd, $HKM_SETRULES, _ BitOR($HKCOMB_NONE, $HKCOMB_S), _ ; invalid key combinations BitOR(BitShift($HOTKEYF_ALT, -16), BitAND(0, 0xFFFF))); add ALT to invalid entries GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $bt $i_HotKey = _SendMessage($hWnd, $HKM_GETHOTKEY) $n_Flag = BitShift($i_HotKey, 8); high byte $i_HotKey = BitAND($i_HotKey, 0xFF); low byte $sHotkey = "" If ( BitAND($i_Hotkey, 32) ) Then Switch $i_Hotkey Case 112 To 124 $n = $i_Hotkey - 111 $sHotkey = "{F" & $n & "}" EndSwitch Else $sz_Flag = "" If BitAND($n_Flag, $HOTKEYF_SHIFT) Then $sz_Flag = "SHIFT + " If BitAND($n_Flag, $HOTKEYF_CONTROL) Then $sz_Flag = $sz_Flag & " CTRL + " If BitAND($n_Flag, $HOTKEYF_ALT) Then $sz_Flag = $sz_Flag & " ALT + " $sHotkey = _GetCode($sz_Flag & Chr($i_Hotkey)) If $i_Hotkey = 20 or $i_Hotkey = 144 then _SendMessage($hWnd, $HKM_SETHOTKEY) EndIf EndIf MsgBox(0,"","HotKey set to: " & $sHotkey ) HotKeySet($sHotkey, "_Hotkey") GUICtrlSetState($bt, $GUI_DISABLE + $GUI_FOCUS) GUICtrlSetData($bt,"Try the hotkey out ") _WinAPI_DestroyWindow ($hWnd) EndSwitch WEnd _WinAPI_DestroyWindow ($hWnd) Exit Func _Hotkey() MsgBox(0,"","Hotkey has been pressed.") EndFunc Func _GetCode($string) $temp = StringSplit($string, '+') $lastTerm = StringLower(StringStripWS($temp[Ubound($temp) - 1], 8)) If StringLen($lastTerm) > 1 then If StringLeft($lastTerm, 1) = 'F' then $append = '{' & StringUpper($lastTerm) & '}' EndIf Else $temp = StringLower(StringRight($string, 1)) If $temp = '!' then $append = '{PGUP}' ElseIf $temp = '"' then $append = '{PGDN}' ElseIf $temp = '$' then $append = '{HOME}' ElseIf $temp = '#' then $append = '{END}' ElseIf $temp = '-' then $append = '{INS}' Else $append = StringLower(StringRight($string, 1)) EndIf EndIf $hotkeyAssignment = '' If StringInStr($string, 'CTRL') > 0 then $hotkeyAssignment &= '^' EndIf If StringInStr($string, 'SHIFT') > 0 then $hotkeyAssignment &= '+' EndIf If StringInStr($string, 'ALT') > 0 then $hotkeyAssignment &= '!' EndIf $hotkeyAssignment &= $append Return $hotkeyAssignment EndFunc Func _ExcludeHotkey() _SendMessage(_WinAPI_GetFocus(), $HKM_SETHOTKEY) EndFunc Link to comment Share on other sites More sharing options...
jvanegmond Posted February 8, 2009 Share Posted February 8, 2009 One last question.. How can i detect all mouse buttons? mouse1, mouse2, mouse3, mwheeldown, mwheelup, mouse4 and mouse5.Thanks in advance!_Kurt made this: http://www.autoitscript.com/forum/index.php?showtopic=81761Very cool to watch as well. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now