Hallo.
Ich versuche ein Script zu erstellen welches das selbe macht wie phraseXpress, nur nicht so vielseitig. Also einfach ein Tool in dem man Tastenkombinationen hinterlegen kann und beim Drücken dieser wird der hinterlegte Text geschrieben. Jetzt habe ich soweit zwei verschiedene Scripte gefunden, die in die Richtung gehen. Aber wirklich hinbekommen tu ich es nicht.
So sollte es aussehen [Blockierte Grafik: http://img3.fotos-hochladen.net/uploads/pejwuh2r618v.gif]
Habe auch mal die beiden Scripte die in die Richtung gehen (Hier aus dem Forum) angehangen
Spoiler anzeigen
;~ Func _hotkeyset()
; ==================================================================================================
; <_HotKeyControl.au3>
;
; Functions:
; _ToggleAsHotkeyControl()
; _GetAutoItHotkey()
;
; _HotkeyWindowProc()
; _GetAutoItCode()
; _ShowHotKey()
; _GetHandleIndex()
;
; Author: WideBoyDixon
; ==================================================================================================
#include-once
[/autoit] [autoit][/autoit] [autoit]#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIEdit.au3>
#Region VIRTUAL_KEYS
Global Const $VKEY_LBUTTON = 0x01, $VKEY_RBUTTON = 0x02, $VKEY_CANCEL = 0x03, $VKEY_MBUTTON = 0x04
Global Const $VKEY_XBUTTON1 = 0x05, $VKEY_XBUTTON2 = 0x06, $VKEY_BACK = 0x08, $VKEY_TAB = 0x09
Global Const $VKEY_CLEAR = 0x0C, $VKEY_RETURN = 0x0D, $VKEY_SHIFT = 0x10, $VKEY_CONTROL = 0x11
Global Const $VKEY_MENU = 0x12, $VKEY_PAUSE = 0x13, $VKEY_CAPITAL = 0x14, $VKEY_KANA = 0x15
Global Const $VKEY_HANGEUL = 0x15, $VKEY_HANGUL = 0x15, $VKEY_JUNJA = 0x17, $VKEY_FINAL = 0x18
Global Const $VKEY_HANJA = 0x19, $VKEY_KANJI = 0x19, $VKEY_ESCAPE = 0x1B, $VKEY_CONVERT = 0x1C
Global Const $VKEY_NONCONVERT = 0x1D, $VKEY_ACCEPT = 0x1E, $VKEY_MODECHANGE = 0x1F, $VKEY_SPACE = 0x20
Global Const $VKEY_PRIOR = 0x21, $VKEY_NEXT = 0x22, $VKEY_END = 0x23, $VKEY_HOME = 0x24
Global Const $VKEY_LEFT = 0x25, $VKEY_UP = 0x26, $VKEY_RIGHT = 0x27, $VKEY_DOWN = 0x28
Global Const $VKEY_SELECT = 0x29, $VKEY_PRINT = 0x2A, $VKEY_EXECUTE = 0x2B, $VKEY_SNAPSHOT = 0x2C
Global Const $VKEY_INSERT = 0x2D, $VKEY_DELETE = 0x2E, $VKEY_HELP = 0x2F, $VKEY_LWIN = 0x5B
Global Const $VKEY_RWIN = 0x5C, $VKEY_APPS = 0x5D, $VKEY_SLEEP = 0x5F, $VKEY_NUMPAD0 = 0x60
Global Const $VKEY_NUMPAD1 = 0x61, $VKEY_NUMPAD2 = 0x62, $VKEY_NUMPAD3 = 0x63, $VKEY_NUMPAD4 = 0x64
Global Const $VKEY_NUMPAD5 = 0x65, $VKEY_NUMPAD6 = 0x66, $VKEY_NUMPAD7 = 0x67, $VKEY_NUMPAD8 = 0x68
Global Const $VKEY_NUMPAD9 = 0x69, $VKEY_MULTIPLY = 0x6A, $VKEY_ADD = 0x6B, $VKEY_SEPARATOR = 0x6C
Global Const $VKEY_SUBTRACT = 0x6D, $VKEY_DECIMAL = 0x6E, $VKEY_DIVIDE = 0x6F, $VKEY_F1 = 0x70
Global Const $VKEY_F2 = 0x71, $VKEY_F3 = 0x72, $VKEY_F4 = 0x73, $VKEY_F5 = 0x74
Global Const $VKEY_F6 = 0x75, $VKEY_F7 = 0x76, $VKEY_F8 = 0x77, $VKEY_F9 = 0x78
Global Const $VKEY_F10 = 0x79, $VKEY_F11 = 0x7A, $VKEY_F12 = 0x7B, $VKEY_F13 = 0x7C
Global Const $VKEY_F14 = 0x7D, $VKEY_F15 = 0x7E, $VKEY_F16 = 0x7F, $VKEY_F17 = 0x80
Global Const $VKEY_F18 = 0x81, $VKEY_F19 = 0x82, $VKEY_F20 = 0x83, $VKEY_F21 = 0x84
Global Const $VKEY_F22 = 0x85, $VKEY_F23 = 0x86, $VKEY_F24 = 0x87, $VKEY_NUMLOCK = 0x90
Global Const $VKEY_SCROLL = 0x91, $VKEY_OEM_NEC_EQUAL = 0x92, $VKEY_OEM_FJ_JISHO = 0x92, $VKEY_OEM_FJ_MASSHOU = 0x93
Global Const $VKEY_OEM_FJ_TOUROKU = 0x94, $VKEY_OEM_FJ_LOYA = 0x95, $VKEY_OEM_FJ_ROYA = 0x96
Global Const $VKEY_LSHIFT = 0xA0, $VKEY_RSHIFT = 0xA1, $VKEY_LCONTROL = 0xA2, $VKEY_RCONTROL = 0xA3
Global Const $VKEY_LMENU = 0xA4, $VKEY_RMENU = 0xA5, $VKEY_BROWSER_BACK = 0xA6, $VKEY_BROWSER_FORWARD = 0xA7
Global Const $VKEY_BROWSER_REFRESH = 0xA8, $VKEY_BROWSER_STOP = 0xA9, $VKEY_BROWSER_SEARCH = 0xAA, $VKEY_BROWSER_FAVORITES = 0xAB
Global Const $VKEY_BROWSER_HOME = 0xAC, $VKEY_VOLUME_MUTE = 0xAD, $VKEY_VOLUME_DOWN = 0xAE, $VKEY_VOLUME_UP = 0xAF
Global Const $VKEY_MEDIA_NEXT_TRACK = 0xB0, $VKEY_MEDIA_PREV_TRACK = 0xB1, $VKEY_MEDIA_STOP = 0xB2, $VKEY_MEDIA_PLAY_PAUSE = 0xB3
Global Const $VKEY_LAUNCH_MAIL = 0xB4, $VKEY_LAUNCH_MEDIA_SELECT = 0xB5, $VKEY_LAUNCH_APP1 = 0xB6, $VKEY_LAUNCH_APP2 = 0xB7
Global Const $VKEY_OEM_1 = 0xBA, $VKEY_OEM_PLUS = 0xBB, $VKEY_OEM_COMMA = 0xBC, $VKEY_OEM_MINUS = 0xBD
Global Const $VKEY_OEM_PERIOD = 0xBE, $VKEY_OEM_2 = 0xBF, $VKEY_OEM_3 = 0xC0, $VKEY_OEM_4 = 0xDB
Global Const $VKEY_OEM_5 = 0xDC, $VKEY_OEM_6 = 0xDD, $VKEY_OEM_7 = 0xDE, $VKEY_OEM_8 = 0xDF
Global Const $VKEY_OEM_AX = 0xE1, $VKEY_OEM_102 = 0xE2, $VKEY_ICO_HELP = 0xE3, $VKEY_ICO_00 = 0xE4
Global Const $VKEY_PROCESSKEY = 0xE5, $VKEY_ICO_CLEAR = 0xE6, $VKEY_PACKET = 0xE7, $VKEY_OEM_RESET = 0xE9
Global Const $VKEY_OEM_JUMP = 0xEA, $VKEY_OEM_PA1 = 0xEB, $VKEY_OEM_PA2 = 0xEC, $VKEY_OEM_PA3 = 0xED
Global Const $VKEY_OEM_WSCTRL = 0xEE, $VKEY_OEM_CUSEL = 0xEF, $VKEY_OEM_ATTN = 0xF0, $VKEY_OEM_FINISH = 0xF1
Global Const $VKEY_OEM_COPY = 0xF2, $VKEY_OEM_AUTO = 0xF3, $VKEY_OEM_ENLW = 0xF4, $VKEY_OEM_BACKTAB = 0xF5
Global Const $VKEY_ATTN = 0xF6, $VKEY_CRSEL = 0xF7, $VKEY_EXSEL = 0xF8, $VKEY_EREOF = 0xF9
Global Const $VKEY_PLAY = 0xFA, $VKEY_ZOOM = 0xFB, $VKEY_NONAME = 0xFC, $VKEY_PA1 = 0xFD, $VKEY_OEM_CLEAR = 0xFE
#EndRegion VIRTUAL_KEYS
#Region GLOBAL_VARIABLES
; This maps virtual keycodes to AutoIt equivalents
Global $gaVirtkeyMap[75][2] = [[$VKEY_SPACE, "{SPACE}"],[$VKEY_RETURN, "{ENTER}"],[$VKEY_MENU, "{ALT}"],[$VKEY_BACK, "{BS}"], _ ; 4
[$VKEY_DELETE, "{DEL}"],[$VKEY_UP, "{UP}"],[$VKEY_DOWN, "{DOWN}"],[$VKEY_LEFT, "{LEFT}"], _ ; 8
[$VKEY_RIGHT, "{RIGHT}"],[$VKEY_HOME, "{HOME}"],[$VKEY_END, "{END}"],[$VKEY_ESCAPE, "{ESC}"], _ ; 12
[$VKEY_INSERT, "{INS}"],[$VKEY_PRIOR, "{PGUP}"],[$VKEY_NEXT, "{PGDN}"],[$VKEY_F1, "{F1}"], _ ; 16
[$VKEY_F2, "{F2}"],[$VKEY_F3, "{F3}"],[$VKEY_F4, "{F4}"],[$VKEY_F5, "{F5}"], _ ; 20
[$VKEY_F6, "{F6}"],[$VKEY_F7, "{F7}"],[$VKEY_F8, "{F8}"],[$VKEY_F9, "{F9}"], _ ; 24
[$VKEY_F10, "{F10}"],[$VKEY_F11, "{F11}"],[$VKEY_F12, "{F12}"],[$VKEY_TAB, "{TAB}"], _ ; 28
[$VKEY_PRINT, "{PRINTSCREEN}"],[$VKEY_LWIN, "{LWIN}"],[$VKEY_RWIN, "{RWIN}"], _ ; 31
[$VKEY_NUMLOCK, "{NUMLOCK}"],[$VKEY_CAPITAL, "{CAPSLOCK}"],[$VKEY_SCROLL, "{SCROLLLOCK}"], _ ; 34
[$VKEY_PAUSE, "{PAUSE}"],[$VKEY_NUMPAD0, "{NUMPAD0}"],[$VKEY_NUMPAD1, "{NUMPAD1}"], _ ; 37
[$VKEY_NUMPAD2, "{NUMPAD2}"],[$VKEY_NUMPAD3, "{NUMPAD3}"],[$VKEY_NUMPAD4, "{NUMPAD4}"], _ ; 40
[$VKEY_NUMPAD5, "{NUMPAD5}"],[$VKEY_NUMPAD6, "{NUMPAD6}"],[$VKEY_NUMPAD7, "{NUMPAD7}"], _ ; 43
[$VKEY_NUMPAD8, "{NUMPAD8}"],[$VKEY_NUMPAD9, "{NUMPAD0}"],[$VKEY_ADD, "{NUMPADADD}"], _ ; 46
[$VKEY_SUBTRACT, "{NUMPADSUB}"],[$VKEY_DIVIDE, "{NUMPADDIV}"],[$VKEY_DECIMAL, "{NUMPADDOT}"], _ ; 49
[$VKEY_APPS, "{APPSKEY}"],[$VKEY_LMENU, "{LALT}"],[$VKEY_RMENU, "{RALT}"], _ ; 52
[$VKEY_LCONTROL, "{LCTRL}"],[$VKEY_RCONTROL, "{RCTRL}"],[$VKEY_LSHIFT, "{LSHIFT}"], _ ; 55
[$VKEY_RSHIFT, "{RSHIFT}"],[$VKEY_SLEEP, "{SLEEP}"],[$VKEY_BROWSER_BACK, "{BROWSER_BACK}"], _ ; 58
[$VKEY_BROWSER_FORWARD, "{BROWSER_FORWARD}"],[$VKEY_BROWSER_REFRESH, "{BROWSER_REFRESH}"], _ ; 60
[$VKEY_BROWSER_STOP, "{BROWSER_STOP}"],[$VKEY_BROWSER_SEARCH, "{BROWSER_SEARCH}"], _ ; 62
[$VKEY_BROWSER_FAVORITES, "{BROWSER_FAVORITES}"],[$VKEY_BROWSER_HOME, "{BROWSER_HOME}"], _ ; 64
[$VKEY_VOLUME_MUTE, "{VOLUME_MUTE}"],[$VKEY_VOLUME_DOWN, "{VOLUME_DOWN}"],[$VKEY_VOLUME_UP, "{VOLUME_UP}"], _ ; 67
[$VKEY_MEDIA_NEXT_TRACK, "{MEDIA_NEXT}"],[$VKEY_MEDIA_PREV_TRACK, "{MEDIA_PREV}"], _ ; 69
[$VKEY_MEDIA_STOP, "{MEDIA_STOP}"],[$VKEY_MEDIA_PLAY_PAUSE, "{MEDIA_PLAY_PAUSE}"], _ ; 71
[$VKEY_LAUNCH_MAIL, "{LAUNCH_MAIL}"],[$VKEY_LAUNCH_MEDIA_SELECT, "{LAUNCH_MEDIA}"], _ ; 73
[$VKEY_LAUNCH_APP1, "{LAUNCH_APP1}"],[$VKEY_LAUNCH_APP2, "{LAUNCH_APP2}"]] ; 75
; Up to 20 hotkeys. Use this array to store:
; - Window handle of the edit control
; - AutoIt key combination
; - Wndproc_new
; - Wndproc_old
; - Modifier key flags
; - Locked flag
; - Key
Global $gaHotkeyList[20][7]
#EndRegion GLOBAL_VARIABLES
; ==================================================================================================
; Func _ToggleAsHotkeyControl($hWnd)
;
; Function to toggle whether the input control is a hotkey
;
; $hWnd = Handle to the input control
;
; Returns:
; Success: True
; Failure: False, with @error set:
;
; Author: WideBoyDixon
; ==================================================================================================
;### Tidy Error -> func Not closed before "Func" statement.
;### Tidy Error -> "func" cannot be inside any IF/Do/While/For/Case/Func statement.
Func _ToggleAsHotkeyControl($hWnd)
Dim $nI, $nJ = -1, $bFound = False
; Check the current array to see if we've already got this one
For $nI = 0 To UBound($gaHotkeyList) - 1
If $gaHotkeyList[$nI][0] = $hWnd Then
; Found it
$bFound = True
$nJ = $nI
ExitLoop
ElseIf (Not IsHWnd($gaHotkeyList[$nI][0])) And ($nJ = -1) Then
; Remember the first empty location
$nJ = $nI
EndIf
Next
; If we already had it then remove this one
If $bFound Then
$gaHotkeyList[$nJ][0] = ""
_WinAPI_SetWindowLong($hWnd, 0xFFFFFFFC, $gaHotkeyList[$nJ][3])
Return SetError(0, 0, True)
EndIf
; If we don't have any spare slots then this is an error
If ($nJ = -1) Then Return SetError(1, 0, False)
; Store the details and subclass the window
$gaHotkeyList[$nJ][0] = $hWnd
$gaHotkeyList[$nJ][1] = ""
$gaHotkeyList[$nJ][2] = DllCallbackRegister("_HotkeyWindowProc", "ptr", "hwnd;uint;long;ptr")
$gaHotkeyList[$nJ][3] = _WinAPI_SetWindowLong($hWnd, 0xFFFFFFFC, DllCallbackGetPtr($gaHotkeyList[$nJ][2]))
$gaHotkeyList[$nJ][4] = 0
$gaHotkeyList[$nJ][5] = False
$gaHotkeyList[$nJ][6] = ""
; Success
Return SetError(0, 0, True)
EndFunc ;==>_ToggleAsHotkeyControl
; ==================================================================================================
; Func _HotkeyWindowProc($hWnd, $uiMsg, $wParam, $lParam)
;
; Windows procedure for subclassing an input control
;
; $hWnd = Handle to the input control
; $uiMsg = The windows message
; $wParam = WPARAM
; $lParam = LPARAM
;
; Returns:
; 1 = Don't process this message as it's already been handled
; Other = Use the default processing for this message
;
; Author: WideBoyDixon
; ==================================================================================================
;### Tidy Error -> func Not closed before "Func" statement.
;### Tidy Error -> "func" cannot be inside any IF/Do/While/For/Case/Func statement.
Func _HotkeyWindowProc($hWnd, $uiMsg, $wParam, $lParam)
Local $scanCode, $sAutoitKey
Local $nIndex = _GetHandleIndex($hWnd) ; Get the index of this window in the array
If $nIndex >= 0 Then
If $uiMsg = $WM_GETDLGCODE Then
If $wParam = $VKEY_RETURN Then
$uiMsg = $WM_KEYDOWN ; A bit of a hack to get {ENTER} recognised ...
EndIf
EndIf
Switch $uiMsg
Case $WM_SETFOCUS
; Re-start when we get the focus
$gaHotkeyList[$nIndex][4] = 0
$gaHotkeyList[$nIndex][5] = False
$gaHotkeyList[$nIndex][6] = ""
Case $WM_SYSKEYDOWN, $WM_KEYDOWN
; A key is down
$scanCode = DllCall("user32.dll", "uint", "MapVirtualKey", "uint", $wParam, "uint", 2) ; Map the virtual key to a scan code
Switch $wParam
Case $VKEY_SHIFT, $VKEY_LSHIFT, $VKEY_RSHIFT
; Shift has been pressed
$gaHotkeyList[$nIndex][4] = BitOR($gaHotkeyList[$nIndex][4], 1)
Case $VKEY_CONTROL, $VKEY_LCONTROL, $VKEY_RCONTROL
; Control has been pressed
$gaHotkeyList[$nIndex][4] = BitOR($gaHotkeyList[$nIndex][4], 2)
Case $VKEY_LWIN, $VKEY_RWIN
; Windows key has been pressed
$gaHotkeyList[$nIndex][4] = BitOR($gaHotkeyList[$nIndex][4], 4)
Case $VKEY_MENU, $VKEY_LMENU, $VKEY_RMENU
; Alt key has been pressed
$gaHotkeyList[$nIndex][4] = BitOR($gaHotkeyList[$nIndex][4],
;~ Case Else
$sAutoitKey = _GetAutoItCode($wParam) ; Is there an AutoIt equivalent?
;~ If $sAutoitKey = "" Then
;~ ; No AutoIt code ... can we use the scan code?
;~ If $scanCode[0] <> 0 Then $sAutoitKey = Chr($scanCode[0])
;~ EndIf
Case Else
$sAutoitKey = _GetAutoItCode($wParam)
If $sAutoitKey = "" Then
Select; No AutoIt code ... can we use the scan code?
Case $scanCode[0] = 65
$sAutoitKey = Chr(97)
Case $scanCode[0] = 66
$sAutoitKey = Chr(98)
Case $scanCode[0] = 67
$sAutoitKey = Chr(99)
Case $scanCode[0] = 68
$sAutoitKey = Chr(100)
Case $scanCode[0] = 69
$sAutoitKey = Chr(101)
Case $scanCode[0] = 70
$sAutoitKey = Chr(102)
Case $scanCode[0] = 71
$sAutoitKey = Chr(103)
Case $scanCode[0] = 72
$sAutoitKey = Chr(104)
Case $scanCode[0] = 73
$sAutoitKey = Chr(105)
Case $scanCode[0] = 74
$sAutoitKey = Chr(106)
Case $scanCode[0] = 75
$sAutoitKey = Chr(107)
Case $scanCode[0] = 76
$sAutoitKey = Chr(108)
Case $scanCode[0] = 77
$sAutoitKey = Chr(109)
Case $scanCode[0] = 78
$sAutoitKey = Chr(110)
Case $scanCode[0] = 79
$sAutoitKey = Chr(111)
Case $scanCode[0] = 80
$sAutoitKey = Chr(112)
Case $scanCode[0] = 81
$sAutoitKey = Chr(113)
Case $scanCode[0] = 82
$sAutoitKey = Chr(114)
Case $scanCode[0] = 83
$sAutoitKey = Chr(115)
Case $scanCode[0] = 84
$sAutoitKey = Chr(116)
Case $scanCode[0] = 85
$sAutoitKey = Chr(117)
Case $scanCode[0] = 86
$sAutoitKey = Chr(118)
Case $scanCode[0] = 87
$sAutoitKey = Chr(119)
Case $scanCode[0] = 88
$sAutoitKey = Chr(120)
Case $scanCode[0] = 89
$sAutoitKey = Chr(121)
Case $scanCode[0] = 90
$sAutoitKey = Chr(122)
Case $sAutoitKey = ""
If $scanCode[0] <> 0 Then $sAutoitKey = Chr($scanCode[0])
;~ MsgBox(0, "", $scanCode[0])
EndSelect
EndIf
; If we have a key then store it
If $sAutoitKey <> "" Then
$gaHotkeyList[$nIndex][6] = $sAutoitKey
_ShowHotKey($nIndex)
$gaHotkeyList[$nIndex][5] = True
EndIf
EndSwitch
If Not $gaHotkeyList[$nIndex][5] Then _ShowHotKey($nIndex) ; Show the current status
Return 1 ; Don't process this message any more
Case $WM_SYSKEYUP, $WM_KEYUP
; A key is up
Switch $wParam
Case $VKEY_SHIFT, $VKEY_LSHIFT, $VKEY_RSHIFT
; Shift is up
$gaHotkeyList[$nIndex][4] = BitAND($gaHotkeyList[$nIndex][4], 14)
Case $VKEY_CONTROL, $VKEY_LCONTROL, $VKEY_RCONTROL
; Control is up
$gaHotkeyList[$nIndex][4] = BitAND($gaHotkeyList[$nIndex][4], 13)
Case $VKEY_LWIN, $VKEY_RWIN
; Windows key is up
$gaHotkeyList[$nIndex][4] = BitAND($gaHotkeyList[$nIndex][4], 11)
Case $VKEY_MENU, $VKEY_LMENU, $VKEY_RMENU
; Alt is up
$gaHotkeyList[$nIndex][4] = BitAND($gaHotkeyList[$nIndex][4], 7)
EndSwitch
If Not $gaHotkeyList[$nIndex][5] Then _ShowHotKey($nIndex) ; Show the current status if necessary
If $gaHotkeyList[$nIndex][5] Then
; Have all modifier keys been released? If so then reset the hotkey
$gaHotkeyList[$nIndex][5] = ($gaHotkeyList[$nIndex][5] <> 0)
If Not $gaHotkeyList[$nIndex][5] Then $gaHotkeyList[$nIndex][6] = ""
EndIf
Return 1 ; Don't process this message any more
Case $WM_CHAR, $WM_PASTE, $WM_CUT
Return 1 ; Don't process this message any more
EndSwitch
; Use default processing for all other messages
Return _WinAPI_CallWindowProc($gaHotkeyList[$nIndex][3], $hWnd, $uiMsg, $wParam, $lParam)
Else
Return _WinAPI_DefWindowProc($hWnd, $uiMsg, $wParam, $lParam)
EndIf
EndFunc ;==>_HotkeyWindowProc
; ==================================================================================================
; Func _GetAutoItCode($vkCode)
;
; Get an AutoIt equivalent for a virtual key
;
; $vkCode = The virtual key code
;
; Returns:
; The AutoIt equivalent or an empty string if there isn't one
;
; Author: WideBoyDixon
; ==================================================================================================
;### Tidy Error -> func Not closed before "Func" statement.
;### Tidy Error -> "func" cannot be inside any IF/Do/While/For/Case/Func statement.
Func _GetAutoItCode($vkCode)
Local $nI, $sRet = ""
; Look through the map array to find this value
For $nI = 0 To UBound($gaVirtkeyMap) - 1
If $gaVirtkeyMap[$nI][0] = $vkCode Then
; Found it ... return it
$sRet = $gaVirtkeyMap[$nI][1]
ExitLoop
EndIf
Next
Return SetError(0, 0, $sRet)
EndFunc ;==>_GetAutoItCode
; ==================================================================================================
; Func _ShowHotKey($nIndex)
;
; Display the hotkey for an input control
;
; $nIndex = The array index for the control
;
; Returns:
; None - the text of the control is set
;
; Author: WideBoyDixon
; ==================================================================================================
;### Tidy Error -> func Not closed before "Func" statement.
;### Tidy Error -> "func" cannot be inside any IF/Do/While/For/Case/Func statement.
Func _ShowHotKey($nIndex)
Local $sText = ""
$gaHotkeyList[$nIndex][1] = ""
; Build up the hotkey - display and AutoIt specific
If BitAND($gaHotkeyList[$nIndex][4], 1) Then
$gaHotkeyList[$nIndex][1] &= "+"
$sText &= "SHIFT + "
EndIf
If BitAND($gaHotkeyList[$nIndex][4], 2) Then
$gaHotkeyList[$nIndex][1] &= "^"
$sText &= "CTRL + "
EndIf
If BitAND($gaHotkeyList[$nIndex][4], 4) Then
$gaHotkeyList[$nIndex][1] &= "#"
$sText &= "WIN + "
EndIf
If BitAND($gaHotkeyList[$nIndex][4], Then
$gaHotkeyList[$nIndex][1] &= "!"
$sText &= "ALT + "
EndIf
$gaHotkeyList[$nIndex][1] &= $gaHotkeyList[$nIndex][6]
$sText &= $gaHotkeyList[$nIndex][6]
; Set the window text and set the selection to be the end of the string
_WinAPI_SetWindowText($gaHotkeyList[$nIndex][0], $sText)
_GUICtrlEdit_SetSel($gaHotkeyList[$nIndex][0], StringLen($sText), StringLen($sText))
EndFunc ;==>_ShowHotKey
; ==================================================================================================
; Func _GetHandleIndex($hWnd)
;
; Get the index in the array for a window handle
;
; $hWnd = The window handle of the input control
;
; Returns:
; The array index for the handle or -1 if it's not found
;
; Author: WideBoyDixon
; ==================================================================================================
;### Tidy Error -> func Not closed before "Func" statement.
;### Tidy Error -> "func" cannot be inside any IF/Do/While/For/Case/Func statement.
Func _GetHandleIndex($hWnd)
Local $nI, $nJ = -1
For $nI = 0 To UBound($gaHotkeyList) - 1
If $gaHotkeyList[$nI][0] = $hWnd Then
$nJ = $nI
ExitLoop
EndIf
Next
Return $nJ
EndFunc ;==>_GetHandleIndex
; ==================================================================================================
; Func _GetAutoItHotkey($hWnd)
;
; Get the AutoIt hotkey combination for a window handle
;
; $hWnd = The window handle of the input control
;
; Returns:
; Success: The AutoIt version of the hotkey which can be used in HotKeySet
; Failure: An empty string ("") with @error set to 1
;
; Author: WideBoyDixon
; ==================================================================================================
;### Tidy Error -> func Not closed before "Func" statement.
;### Tidy Error -> "func" cannot be inside any IF/Do/While/For/Case/Func statement.
Func _GetAutoItHotkey($hWnd)
Local $nIndex = _GetHandleIndex($hWnd)
If $nIndex = -1 Then Return SetError(1, 0, "")
Return SetError(0, 0, $gaHotkeyList[$nIndex][1])
EndFunc ;==>_GetAutoItHotkey
; ==================================================================================================
; Func _SetAutoItHotkey($hWnd, $sAutoitKey)
;
; Set the AutoIt hotkey combination for a window handle
;
; $hWnd = The window handle of the input control
; $sAutoitKey = The Autoit hotkey string
;
; Returns:
; Success: The AutoIt version of the hotkey which can be used in HotKeySet
; Failure: An empty string ("") with @error set to 1
;
; Author: WideBoyDixon
; ==================================================================================================
;### Tidy Error -> func Not closed before "Func" statement.
;### Tidy Error -> "func" cannot be inside any IF/Do/While/For/Case/Func statement.
Func _SetAutoItHotkey($hWnd, $sAutoitKey)
Local $nIndex = _GetHandleIndex($hWnd), $sKey = $sAutoitKey
If $nIndex = -1 Then Return SetError(1, 0, False)
$gaHotkeyList[$nIndex][4] = 0
$gaHotkeyList[$nIndex][5] = False
$gaHotkeyList[$nIndex][6] = ""
While StringInStr("+^#!", StringLeft($sKey, 1)) > 0
Switch StringLeft($sKey, 1)
Case "+"
$gaHotkeyList[$nIndex][4] += 1
Case "^"
$gaHotkeyList[$nIndex][4] += 2
Case "#"
$gaHotkeyList[$nIndex][4] += 4
Case "!"
$gaHotkeyList[$nIndex][4] += 8
EndSwitch
$sKey = StringMid($sKey, 2)
WEnd
$gaHotkeyList[$nIndex][6] = $sKey
_ShowHotKey($nIndex)
EndFunc ;==>_SetAutoItHotkey
$hotkeyfenster = GUICreate("Tastenbelegung ändern", 300, 230)
GUICtrlCreateLabel("Start :", 8, 10)
GUICtrlCreateLabel("Stopp", 8, 45)
GUICtrlCreateLabel("Lauter :", 8, 80)
GUICtrlCreateLabel("Leiser :", 8, 115)
$okbutton = GUICtrlCreateButton("&Speichern", 110, 180, 80, 23)
Dim $cEdit1 = GUICtrlCreateInput("-", 110, 10, 130, 24)
Dim $hwndEdit1 = GUICtrlGetHandle($cEdit1)
Dim $cEdit2 = GUICtrlCreateInput("-", 110, 45, 130, 24)
Dim $hwndEdit2 = GUICtrlGetHandle($cEdit2)
Dim $cEdit3 = GUICtrlCreateInput("-", 110, 80, 130, 24)
Dim $hwndEdit3 = GUICtrlGetHandle($cEdit3)
Dim $cEdit4 = GUICtrlCreateInput("-", 110, 115, 130, 24)
Dim $hwndEdit4 = GUICtrlGetHandle($cEdit4)
GUISetState(@SW_SHOW)
_ToggleAsHotkeyControl($hwndEdit1)
_ToggleAsHotkeyControl($hwndEdit2)
_ToggleAsHotkeyControl($hwndEdit3)
_ToggleAsHotkeyControl($hwndEdit4)
While 1
Sleep(50)
$guimsg = GUIGetMsg()
Switch $guimsg
Case $GUI_EVENT_CLOSE
GUIDelete($hotkeyfenster)
Exit
Case $okbutton
IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeystart", _GetAutoItHotkey($hwndEdit1))
IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeystopp", _GetAutoItHotkey($hwndEdit2))
IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeylauter", _GetAutoItHotkey($hwndEdit3))
IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeyleiser", _GetAutoItHotkey($hwndEdit4))
GUIDelete($hotkeyfenster)
Exit
EndSwitch
WEnd
;~ EndFunc ;==>_SetAutoItHotkey
und
Spoiler anzeigen
#include<WindowsConstants.au3>
#include<ListViewConstants.au3>
#include<ButtonConstants.au3>
#include<GUIConstantsEx.au3>
#include<Guilistview.au3>
Global $sHeader = "Artikelnummer|Art|Nummer|Baureihe|Name" ; Die Überschriften für das Listview und für das "Neuer Eintrag"-Fenster
Global $sDBFile = @ScriptDir & "\datenbank.txt" ; Pfad und Name der Datenbank-Datei
Global $iEdit = -1 ; Wert auf -1 setzen, weil _GUICtrlListView_GetSelectionMark() einen Nullbasierten Wert liefert
#Region Hauptfenster
Global $hGui = GUICreate("Listview-Datenbank-Beispiel", 600, 480) ; Hauptfenster erstellen
Global $hListView = GUICtrlCreateListView($sHeader, 0, 0, 600, 420, $LVS_SHOWSELALWAYS) ; Listview erstellen
Global $hLVHandle = GUICtrlGetHandle($hListView) ; das Handle vom Listview wird für die UDF-Listview-Funktionen benötigt
_GUICtrlListView_SetColumn($hLVHandle, 0, "Artikelnummer", 120, 1) ; 1. Spalte = 120 Px breit, rechts ausgerichtet
_GUICtrlListView_SetColumn($hLVHandle, 1, "Art", 60, 0) ; 2. Spalte = 60 Px breit, links ausgerichtet
_GUICtrlListView_SetColumn($hLVHandle, 2, "Nummer", 90, 0) ; 3. Spalte = 90 Px breit, links ausgerichtet
_GUICtrlListView_SetColumn($hLVHandle, 3, "Baureihe", 100, 0) ; 4. Spalte = 100 Px breit, links ausgerichtet
_GUICtrlListView_SetColumn($hLVHandle, 4, "Name", 120, 0) ; 5. Spalte = 120 Px breit, links ausgerichtet
Global $hNew = GUICtrlCreateButton("Neuer Eintrag", 5, 430, 80, 35, $BS_DEFPUSHBUTTON) ; Dieser Button ist der Default-Push-Button (wenn der User [Enter] drückt)
Global $hEdit = GUICtrlCreateButton("Markierten Eintrag bearbeiten", 95, 430, 110, 35, $BS_MULTILINE) ; $BS_Multiline für mehrzeiligen Button
Global $hLoad = GUICtrlCreateButton("Laden", 230, 430, 70, 35)
Global $hSave = GUICtrlCreateButton("Speichern", 310, 430, 70, 35)
Global $hDel = GUICtrlCreateButton("Markierte Einträge löschen", 400, 430, 90, 35, $BS_MULTILINE)
Global $hDelAll = GUICtrlCreateButton("Alle Einträge löschen", 500, 430, 90, 35, $BS_MULTILINE)
Global $hCM = GUICtrlCreateContextMenu($hListView) ; ein Kontextmenü für das Listview erstellen
Global $hCMNew = GUICtrlCreateMenuItem("Neuer Eintrag", $hCM) ; der 1. Kontextmenüeintrag
Global $hCMEdit = GUICtrlCreateMenuItem("Eintrag bearbeiten", $hCM) ; der 2. Kontextmenüeintrag
Global $hCMDel = GUICtrlCreateMenuItem("Markierte Einträge löschen", $hCM) ; der 3. Kontextmenüeintrag
#EndRegion Hauptfenster
#Region Fenster für neuen Eintrag
Global $hGuiNew = GUICreate("Neuer Eintrag", 632, 140, -1, -1, $WS_SYSMENU) ; das Fenster "Neuer Eintrag" erstellen
Global $aHeader = StringSplit($sHeader, '|') ; Überschriften-Array
Global $aNew[$aHeader[0]] ; Array für die Input-IDs
For $i = 1 To $aHeader[0]
GUICtrlCreateLabel($aHeader[$i], 4 + ($i - 1) * 125, 15, 110, 20) ; Überschriften-Label erstellen
GUICtrlSetFont(-1, 8, 400, 0, 'Verdana') ; Schriftgröße und -art der Überschriften festlegen
$aNew[$i - 1] = GUICtrlCreateInput("", 2 + ($i - 1) * 125, 30, 120, 20, Default, $WS_EX_STATICEDGE) ; Eingabefelder erstellen
GUICtrlSetFont(-1, 10, 600, 0, 'Verdana') ; Schriftgröße und -art der Eingabefelder festlegen
Next
Global $hCreate = GUICtrlCreateButton("Eintrag speichern", 254, 65, 120, 25, $BS_DEFPUSHBUTTON) ; Button zum speichern
#EndRegion Fenster für neuen Eintrag
_GUICtrlListView_RegisterSortCallBack($hLVHandle) ; damit man das Listview (mit Klick auf die Spaltenüberschrift) sortieren kann
[/autoit] [autoit][/autoit] [autoit]GUISetState(@SW_SHOW, $hGui) ; Hauptfenster sichtbar machen
[/autoit] [autoit][/autoit] [autoit]If FileExists($sDBFile) Then Load() ; wenn Datenbank-Datei existiert, dann Datenbank laden
[/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg(1) ; Message-Event holen (1) = erweiterter Modus
Switch $nMsg[0] ; anhand der Control-ID das entsprechende Case aufrufen
Case $hListView ; User hat auf eine Spaltenüberschrift geklickt
_GUICtrlListView_SortItems($hLVHandle, GUICtrlGetState($hListView)) ; Einträge entsprechend sortieren
Case $hNew, $hCMNew ; User hat auf "Neuer Eintrag" geklickt
WinSetTitle($hGuiNew, "", "Neuer Eintrag") ; den Titel des Fenster anpassen
GUISetState(@SW_SHOW, $hGuiNew) ; das Fenster "Neuer Eintrag" anzeigen
GUISetState(@SW_DISABLE, $hGui) ; das Hauptfenster deaktivieren
Case $hEdit, $hCMEdit ; User hat auf "Eintrag bearbeiten" geklickt
WinSetTitle($hGuiNew, "", "Eintrag bearbeiten") ; den Titel des Fenster anpassen
GUISetState(@SW_SHOW, $hGuiNew) ; das Fenster "Neuer Eintrag" anzeigen
GUISetState(@SW_DISABLE, $hGui) ; das Hauptfenster deaktivieren
Edit()
Case $hLoad ; User hat auf "Laden" geklickt
Load()
Case $hSave ; User hat auf "Laden" geklickt
Save()
Case $hDel, $hCMDel ; User hat auf "Markierte Einträge löschen" geklickt
If MsgBox(256 + 32 + 4, "Einträge löschen", "Wollen sie die markierten Einträge wirklich löschen?") = 6 Then _GUICtrlListView_DeleteItemsSelected($hLVHandle)
Case $hDelAll ; User hat auf "Alle Einträge löschen" geklickt
If MsgBox(256 + 32 + 4, "Einträge löschen", "Wollen sie wirklich alle Einträge löschen?") = 6 Then _GUICtrlListView_DeleteAllItems($hLVHandle)
Case $hCreate ; User hat auf "Eintrag speichern" im Fenster "Neuer Eintrag" geklickt
NewItem()
Case $GUI_EVENT_CLOSE ; User hat auf das Schließen-Symbol geklickt (bzw. die ESC-Taste gedrückt)
Switch $nMsg[1] ; erweiterte Abfrage für welches Fenster
Case $hGui ; User will das Hauptfenster schließen
If MsgBox(32 + 4, "Beenden", "Wollen sie das Programm wirklich beenden?") = 6 Then End() ; wenn ja, dann End-Funktion aufrufen
Case $hGuiNew ; User will das "Neuer Eintrag"-Fenster schließen
$iEdit = -1
For $i = 0 To UBound($aNew) - 1
GUICtrlSetData($aNew[$i], "") ; Alle Eingabefelder leeren
Next
GUISetState(@SW_HIDE, $hGuiNew) ; "Neuer Eintrag"-Fenster verstecken
GUISetState(@SW_ENABLE, $hGui) ; Hauptfenster wieder aktivieren
WinActivate($hGui) ; und in den Vordergrund holen
EndSwitch
EndSwitch
WEnd
Func End()
;~ Save() ; wenn der vordere Kommentar entfernt wird, dann werden vor dem beenden noch die Daten gespeichert
_GUICtrlListView_UnRegisterSortCallBack($hLVHandle) ; Sortierroutine wieder de-registrieren
Exit ; Programm beenden
EndFunc
Func NewItem() ; Funktion zum auslesen der Eingabefelder (Neuer Eintrag bzw. Eintrag bearbeiten)
Local $sItem = ""
For $i = 0 To UBound($aNew) - 1 ; Schleife, um alle Eingabefelder durchzugehen
If $iEdit > -1 Then ; wenn $iEdit > -1 (Eintrag bearbeiten), dann...
_GUICtrlListView_SetItemText($hLVHandle, $iEdit, GUICtrlRead($aNew[$i]), $i) ; den Eintrag aus dem Eingabefeld ins Listview schreiben
Else ; sonst $iEdit = -1 (neuer Eintrag)
$sItem &= GUICtrlRead($aNew[$i]) & "|" ; den Eintrag aus dem Eingabefeld erstmal in einer Variablen ($sItem) speichern
EndIf
GUICtrlSetData($aNew[$i], "") ; das entsprechende Eingabefeld leeren
Next
If $iEdit > -1 Then ; wenn $iEdit > -1 (Eintrag bearbeiten), dann...
$iEdit = -1
GUISetState(@SW_HIDE, $hGuiNew) ; "Neuer Eintrag"-Fenster verstecken
GUISetState(@SW_ENABLE, $hGui) ; Hauptfenster wieder aktivieren
Sleep(300)
WinActivate($hGui) ; und in den Vordergrund holen
Else ; sonst $iEdit = -1 (neuer Eintrag)
GUICtrlSetState($aNew[0], $GUI_FOCUS) ; den Focus wieder auf das erste Eingabefeld setzen, für weitere Eingaben
GUICtrlCreateListViewItem(StringTrimRight($sItem, 1), $hListView) ; mit den Werten aus $sItem einen neuen Listview-Eintrag hinzufügen
EndIf
EndFunc ;==>NewItem
Func Edit() ; Funktion zum bearbeiten eines Listview-Eintrags im "Eintrag bearbeiten"-Fenster
$iEdit = _GUICtrlListView_GetSelectionMark($hLVHandle) ; auslesen, welcher Listview-Eintrag markiert (bei mehreren, den obersten) ist
If $iEdit > -1 Then
Local $aItem = _GUICtrlListView_GetItemTextArray($hLVHandle, $iEdit) ; die Einträge aus dem Listview in ein Array holen
For $i = 1 To $aItem[0]
GUICtrlSetData($aNew[$i - 1], $aItem[$i]) ; und in die entsprechenden Eingabefelder schreiben
Next
EndIf
EndFunc ;==>Edit
Func Load() ; Datenbank-Datei laden
Local $sItem
Local $hFile = FileOpen($sDBFile, 0) ; Datei zum lesen öffnen
If $hFile <> -1 Then ; wenn das öffnen erfolgreich war, dann...
_GUICtrlListView_BeginUpdate($hLVHandle) ; Listview sperren
While True ; Endlosschleife
$sItem = FileReadLine($hFile) ; Zeile aus der Datei lesen
If @error Then ExitLoop ; wenn das Ende der Datei erreicht ist, dann Endlosschleife verlassen
GUICtrlCreateListViewItem($sItem, $hListView) ; mit den eingelesenen Daten einen neuen Listview-Eintrag erstellen
WEnd
_GUICtrlListView_EndUpdate($hLVHandle) ; Listview wieder freigeben
FileClose($hFile) ; Datei schließen
EndIf
EndFunc ;==>Load
Func Save() ; Datenbank-Datei speichern
Local $sItem
Local $iCount = _GUICtrlListView_GetItemCount($hLVHandle) - 1 ; Anzahl der Listview-Einträge holen
Local $hFile = FileOpen($sDBFile, 2) ; Datei zum speichern (überschreiben) öffnen
If $hFile <> -1 Then ; wenn das öffnen erfolgreich war, dann...
For $i = 0 To $iCount ; Schleife, um alle Listview-Einträge durchzugehen
$sItem = _GUICtrlListView_GetItemTextString($hLVHandle, $i) ; die Werte aus dem Listview-Eintrag holen
FileWriteLine($hFile, $sItem) ; und in die Datei schreiben
Next
FileClose($hFile) ; Datei schließen
EndIf
EndFunc ;==>Save
Kann mir jemand zu Hand gehen? Danke vielmals