diff --git a/Config.ini b/Config.ini new file mode 100644 index 0000000..5ce78c6 --- /dev/null +++ b/Config.ini @@ -0,0 +1,7 @@ +https://api.openai.com/v1/chat/completions +Enter your API key on this line. +gpt-3.5-turbo +0.75 +- +JAHNVIS: Welcome! I'm your AI assistant. How may I assist you today? +Response with "JAHNVIS:" \ No newline at end of file diff --git a/HeyQuickKeyboard.exe b/HeyQuickKeyboard.exe index 76a9ee8..618907d 100644 Binary files a/HeyQuickKeyboard.exe and b/HeyQuickKeyboard.exe differ diff --git a/README.md b/README.md index f4818db..359564c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Hey Quick Keyboard v1.1 +# Hey Quick Keyboard v1.2 Hey Quick Keyboard is an AutoHotkey script that adds useful shortcuts and improves computer usability on Windows. With this script, you can use the numpad keys, tab keys, screenshot key, power keys, mouse keys, and more with different key combinations on your keyboard. For laptop users, it allows effortless navigation in 3D modeling software through keyboard shortcuts that simulate mouse middle-click and numpad functions. @@ -16,6 +16,7 @@ Hey Quick Keyboard is an AutoHotkey script that adds useful shortcuts and improv - For power operations, Win + F1 opens hibernate timer, Win + F2 opens restart timer, Win + F3 opens sleep timer, Win + F4 opens shutsdown timer and Win + F6 opens logout timer. - For mouse operations, you can use the Menu Key as a middle click and Left Alt + arrow keys as a scroll wheel for mouse operations. To move the mouse, use RCtrl + Arrows. To click, use RCtrl + Z for left click, RCtrl + Y for middle click, and RCtrl + C for right click. - You can turn off the screen witg Win + F12 and turn it on with Win + ESC. +- You can quickly ask questions to the AI ​​with Windows + C via [Hey Chat VBS](https://github.com/JahnStar/Hey-Chat-VBS) and play a role in MsgBox. ## Installation @@ -28,24 +29,10 @@ You can find all the shortcuts that this script provides in the [Shortcuts](#sho ## Hotkeys | Key Combination | Function | Action | -| --------------- | -------- | ------ | -| **Numpad** | Emulate the numpad keys | Type numbers or symbols | -| Win + CapsLock | Suspend | Toggle the script on or off | -| 0-9 (without Shift, Win or AltrGr) | Numpad 0-9 | Type numbers from 0 to 9 | -| Alt + . | Numpad . | Type a decimal point | -| Alt + / | Numpad / | Type a division sign | -| Alt + - | Numpad - | Type a subtraction sign | -| Alt + , | Numpad + | Type an addition sign | -| Ctrl + - | Ctrl + Numpad - | Zoom out | -| Ctrl + , | Ctrl + Numpad + | Zoom in | -| **Tab** | Switch between windows or tabs | Cycle through open applications or browser tabs | -| Pause | Ctrl + Shift + Tab | Switch and display windows | -| PgUp | Alt + Tab | Switch to the previous window | -| PgDn | Alt + Shift + Tab | Switch to the next window | -| **Screenshot** | Capture the screen or a part of it | Save or copy an image of the screen | -| PrtSc | Win + PrtSc | Take a screenshot and save it in the Pictures folder | -| Ctrl + PrtSc | PrtSc | Take a screenshot and copy it to the clipboard | -| **Windows** | Manage windows or tasks | Close, restart, or clear windows or processes | +| ---- | ---- | ---- | +| **-Windows-** | Manage windows or tasks | Close, restart, or clear windows or processes | +| Win + C | Ask AI with [Hey Chat VBS](https://github.com/JahnStar/Hey-Chat-VBS) | Quickly ask the selected text and speak to the AI | +| Win + S | Text to Speech | Speech selected text using Narrator | | Win + F | Quick Search | Search selected text on google | | Win + T | Quick Translate | Translate selected text with google translate | | Ctrl + Alt + F4 | Taskkill | Force quit the current window or application | @@ -53,19 +40,36 @@ You can find all the shortcuts that this script provides in the [Shortcuts](#sho | Win + F5 (As Admin) | Clear Temp Files (As Admin) | Delete temporary files with [Clear-TempFiles.ps1](https://github.com/Bromeego/Clean-Temp-Files/) | | Win + F12 | Turn off the display | Lock and turn screen off | | Win + ESC | Turn on the display | Unlock and turn screen on | -| **Power** | Set a timer for power options | Apply power actions after a specific time | +| **-Power-** | Set a timer for power options | Apply power actions after a specific time | | Win + F1 | Hibernate Timer | Set a timer to Hibernate after a specified time | | Win + F2 | Restart Timer | Set a timer to Restart after a specified time | | Win + F3 | Sleep Timer | Set a timer to Sleep after a specified time | | Win + F4 | Shutdown Timer | Set a timer to Shutdown after a specified time | | Win + F6 | Logout Timer | Set a timer to Logout after a specified time | -| **Mouse** | Emulate the mouse buttons or wheel | Click or scroll with the keyboard | +| **-Tab-** | Switch between windows or tabs | Cycle through open applications or browser tabs | +| Pause | Ctrl + Shift + Tab | Switch and display windows | +| PgUp | Alt + Tab | Switch to the previous window | +| PgDn | Alt + Shift + Tab | Switch to the next window | +| **-Screenshot-** | Capture the screen or a part of it | Save or copy an image of the screen | +| PrtSc | Win + PrtSc | Take a screenshot and save it in the Pictures folder | +| Ctrl + PrtSc | PrtSc | Take a screenshot and copy it to the clipboard | +| **-Numpad-** | Emulate the numpad keys | Type numbers or symbols | +| Win + CapsLock | Suspend | Toggle the script on or off | +| 0-9 (without Shift, Win or AltrGr) | Numpad 0-9 | Type numbers from 0 to 9 | +| Alt + . | Numpad . | Type a decimal point | +| Alt + / | Numpad / | Type a division sign | +| Alt + - | Numpad - | Type a subtraction sign | +| Alt + , | Numpad + | Type an addition sign | +| Ctrl + - | Ctrl + Numpad - | Zoom out | +| Ctrl + , | Ctrl + Numpad + | Zoom in | +| **-Mouse-** | Emulate the mouse buttons or wheel | Click or scroll with the keyboard | | RCtrl + Arrows | Mouse movement | Move the mouse cursor with the arrow keys | | RCtrl + M | Jump to the Middle | Move the mouse cursor in the middle | | RCtrl + Z | Left Click | Perform a mouse left click | | RCtrl + Y / Menu Key | Middle Click | Perform a mouse middle click | | RCtrl + C | Right Click | Perform a mouse right click | | Ctrl + Alt + Up/Down Arrow | Scroll Wheel | Scroll up or down | +| | | | ## Contact diff --git a/other/hey-chat-vbs/Hey-Chat-VBS.vbs b/other/hey-chat-vbs/Hey-Chat-VBS.vbs new file mode 100644 index 0000000..4300604 --- /dev/null +++ b/other/hey-chat-vbs/Hey-Chat-VBS.vbs @@ -0,0 +1,192 @@ +'*************************************************************************************************** +' Script: Hey-Chat-VBS v1 (29.12.2023) +' Author: Halil Emre Yildiz +' GitHub: @JahnStar +' Description: Hey Chat VBS is a simple chatbot that uses OpenAI API via Windows Script Host. +'*************************************************************************************************** + +Dim fso, file, endpoint, apiKey, model, randomness, voice, prompt +Set fso = CreateObject("Scripting.FileSystemObject") +Set file = fso.OpenTextFile("config.ini", 1) ' 1 means ForReading +endpoint = file.ReadLine +apiKey = file.ReadLine +model = file.ReadLine +randomness = file.ReadLine +voice = file.ReadLine +Do Until file.AtEndOfStream + prompt = prompt & file.ReadLine & vbCrLf +Loop +file.Close + +Dim WshShell +Set WshShell = CreateObject("WScript.Shell") +If apiKey = "" or apiKey = "Enter your API key on this line." Then + WshShell.Run "config.ini" + WshShell.Run "https://platform.openai.com/api-keys" + WScript.Quit +End if + +Dim requestBody, firstMessage, message +firstMessage = Split(prompt, vbCrLf)(0) +Speak firstMessage, voice + +message = FixedInputBox(firstMessage & vbCrLf & vbCrLf & "You:", "") +If IsEmpty(message) Or message = "" Then + WScript.Quit +End If + +Dim request, responseContent +Set request = CreateObject("Microsoft.XMLHTTP") + +Dim messages +messages = Array(Array("system", "[You are an AI assistant who can role-play, developed by Halil Emre Yildiz (AKA Jahn Star) and you are running in VBScript. [Github](https://github.com/JahnStar)]" & Replace(Replace(prompt, """", "'"), vbCrLf, "\n")), Array("user", message)) + +Do While True + + requestBody = "{""model"": """ & model & """, ""messages"": [" & WrapMessages(messages, true) & "], ""temperature"": " & randomness & "}" + + On Error Resume Next + + request.Open "POST", endpoint, False + request.setRequestHeader "Content-Type", "application/json" + request.setRequestHeader "Authorization", "Bearer " & apiKey + request.send requestBody + + If Err.Number <> 0 Then + MsgBox "An error occurred: " & Err.Description & vbCrLf & "Please report the issue by visiting:" & vbCrLf & _ + "https://github.com/JahnStar/Hey-Chat-VBS/issues", vbError, "Error" + End If + + On Error GoTo 0 + + If request.Status = 200 Then + ' get response + responseContent = ParseJSON(request.responseText, "content") + ' add to messages + ReDim Preserve messages(UBound(messages) + 1) + messages(UBound(messages)) = Array("assistant", Replace(responseContent, vbCrLf, "\n")) + ' tts + If Left(message, 1) = "-" And voice = "-" Then voice = 0 + Speak responseContent, voice + ' continue or quit + message = FixedInputBox(responseContent & vbCrLf & vbCrLf & "You:", "") + If IsEmpty(message) Or message = "" Then + ' copy log to clipboard + ShowConversationLogs(messages) + WScript.Quit + Else + ReDim Preserve messages(UBound(messages) + 1) + messages(UBound(messages)) = Array("user", message) + End If + Else + MsgBox "Error Log: " & vbCrLf & ParseJSON(request.responseText, "message") & vbCrLf & vbCrLf & "If you think it's a mistake, please report the issue by visiting:" & vbCrLf & _ + "https://github.com/JahnStar/Hey-Chat-VBS/issues", vbCritical, ParseJSON(request.responseText, "code") & " error: " & request.Status + ShowConversationLogs(messages) + WScript.Quit + End If +Loop + +Function Speak(text, voice) + If voice <> "-" Then WshShell.Run "tts.vbs """ & Split(text, ":")(1) & """ " & voice +End Function + +Function ShowConversationLogs(messages) + Dim logs + logs = Replace(WrapMessages(messages, False), "\n", vbCrLf) + InputBox "Conversation Ended: " & vbCrLf & vbCrLf & "```" & vbCrLf & logs & vbCrLf & "```" & vbCrLf & "Press CTRL+C to copy the conversation logs:", "Hey ChatVBS v1 ", logs +End Function + +Function WrapMessages(messages, toJson) + Dim json, i + For i = 0 To UBound(messages) + Dim role, content + role = messages(i)(0) + content = messages(i)(1) + + If (toJson = True) Then + json = json & "{""role"": """ & role & """, ""content"": """ & content & """}" + If i < UBound(messages) Then + json = json & ", " + End If + Else + If role <> "system" Then + If role <> "user" Then + role = "- (AI) " + Else + role = "- You: " + End If + json = json & role & content & vbCrLf + End If + End If + Next + WrapMessages = json +End Function + +Function ParseJSON(jsonString, key) + Dim startPos, endPos, keyPos, valueStartPos, valueEndPos + Dim keyValue, valueStr + + ' Replace escaped characters + jsonString = Replace(jsonString, "\""", "'") + jsonString = Replace(jsonString, "\\", "\") + jsonString = Replace(jsonString, "\n", vbCrLf) + + startPos = InStr(jsonString, """" & key & """") ' Start position of the switch + keyPos = InStr(startPos, jsonString, ":") ' Position of the ":" character of the key + + If keyPos > 0 Then + valueStartPos = InStr(keyPos, jsonString, """") + 1 ' Start position of the value + valueEndPos = InStr(valueStartPos, jsonString, """") ' End position of value + + valueStr = Mid(jsonString, valueStartPos, valueEndPos - valueStartPos) ' Value string + ParseJSON = valueStr ' Return value + Else + ParseJSON = "" ' Return empty string if key not found + End If +End Function + +Function FixedInputBox(message, default) + message = InputBox(message, "Hey ChatVBS v1 ", default) + message = Replace(message, """", "'") + message = Replace(message, "\""", "'") + message = Replace(message, "\\", "\") + FixedInputBox = Replace(message, "\n", vbCrLf) +End Function + +' Request example: +' { +' "model": "gpt-3.5-turbo", +' "messages": [ +' { +' "role": "system", +' "content": "You are a helpful assistant." +' }, +' { +' "role": "user", +' "content": "Hello!" +' }, +' "temperature": 0.7 +' ] +' } +' Response example: +' { +' "id": "chatcmpl-123", +' "object": "chat.completion", +' "created": 1677652288, +' "model": "gpt-3.5-turbo-0613", +' "system_fingerprint": "fp_44709d6fcb", +' "choices": [{ +' "index": 0, +' "message": { +' "role": "assistant", +' "content": "\n\nHello there, how may I assist you today?", +' }, +' "logprobs": null, +' "finish_reason": "stop" +' }], +' "usage": { +' "prompt_tokens": 9, +' "completion_tokens": 12, +' "total_tokens": 21 +' } +' } \ No newline at end of file diff --git a/other/hey-chat-vbs/LICENSE b/other/hey-chat-vbs/LICENSE new file mode 100644 index 0000000..9e67c5e --- /dev/null +++ b/other/hey-chat-vbs/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Halil Emre Yildiz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/other/hey-chat-vbs/README.md b/other/hey-chat-vbs/README.md new file mode 100644 index 0000000..22df824 --- /dev/null +++ b/other/hey-chat-vbs/README.md @@ -0,0 +1,48 @@ +# HeyChatVBScript + +HeyChatVBScript is an AI chat bot developed using VBScript. This bot responds to user inputs using OpenAI's GPT models. + +## Installation + +1. Clone or download this repository. +2. Open the `config.ini` file and enter your OpenAI API key, adjust the model and temperature values, and enter your prompt. +3. `config.ini` file guide: + 1. API endpoint URL + 2. API key + 3. API model name + 4. API temperature value + 5. TTS voice index (default: disabled "-") + 6. AI's welcome message + 7. Enter your prompt starting from this line and in the subsequent lines. + +## Usage + +1. Run the `HeyChatVBScript.vbs` file. +2. Enter a message to the chat bot. +3. Wait for the bot's response. +4. Continue the conversation by clicking the `OK` button. +5. To end the conversation and view the conversation log , click the `Cancel` button. + +## License + +MIT License + +Copyright (c) 2023 Halil Emre Yildiz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/script/HeyQuickKeyboard.ahk b/script/HeyQuickKeyboard.ahk index 8bb9cbd..cec312a 100644 --- a/script/HeyQuickKeyboard.ahk +++ b/script/HeyQuickKeyboard.ahk @@ -1,5 +1,8 @@ -; Developed by Halil Emre Yildiz (Github: @JahnStar) -; Hey Quick Keyboard +;*************************************************************************************************** +; Script: Hey Quick Keyboard v1.2 (29.12.2023) +; Author: Halil Emre Yildiz +; GitHub: @JahnStar +;*************************************************************************************************** ; Win + CapsLock to toggle it on or off ; Numpad @@ -55,7 +58,7 @@ Suspend, Off update_traytip() { - tray_text := "Hey Quick Keyboard v1.1`nAuthor: @JahnStar (Github)`n`nToggle with Win + CapsLock" + tray_text := "Hey Quick Keyboard v1.2`nAuthor: @JahnStar (Github)`n`nToggle with Win + CapsLock" if (A_IsSuspended) { @@ -76,7 +79,6 @@ update_traytip() Return } update_traytip() -get_mouse_position() Menu, Tray, Add, Run on Startup, TrayRunStartup Menu, Tray, Default, Run on Startup @@ -104,6 +106,8 @@ else Menu, Tray, Check, Run on Startup } } +;; Loops +get_mouse_position() Return ; - Ctrl + CapsLock --------------------------------- @@ -441,8 +445,36 @@ Return Clipboard := Return -;; Numpad with numerics -------------------------------------------------- +;; Ask AI -------------------------------------------------- +#C:: + AutoTrim, Off + Clipboard := "" ; clear the clipboard + Send, ^c + ClipWait, 0 + if (!ErrorLevel) ; if there is something in the clipboard + { + prompt = %clipboard% + Run, "%A_ScriptDir%\other\hey-chat-vbs\Hey-Chat-VBS.vbs" + Sleep, 500 + if (StrLen(prompt) > 100) + Send, ^v + else + Send, %prompt% + } + else Run, "%A_ScriptDir%\other\hey-chat-vbs\Hey-Chat-VBS.vbs" +Return +;; Text To Speech -------------------------------------------------- +#S:: + AutoTrim, Off + Send, ^c + ClipWait, 100 + Sleep, 400 + Run, wscript.exe "%A_ScriptDir%\tts.vbs" "%Clipboard%" +Return + +;; Numpad with numerics -------------------------------------------------- + RAlt & .::Send {NumpadDot} LAlt & .::Send {NumpadDot} LAlt & *::Send {NumpadMult} @@ -542,16 +574,19 @@ Return ; If mouse position is on bottom left, simulate LWin get_mouse_position(){ CoordMode, Mouse, Screen - MouseGetPos, x, y - if (x < 10) ; x >= A_ScreenWidth + loop { - if (y >= A_ScreenHeight) + MouseGetPos, x, y + if (x < 10) ; x >= A_ScreenWidth - 10 { - Send, {LWin} - sleep, 1000 + if (y >= A_ScreenHeight - 10) + { + Send, {LWin} + sleep, 1000 + } } + sleep, 50 } - sleep, 50 Return } ; If left button clicked and mouse position is on bottom right, simulate LWin+M. If else left button clicked and mouse position is on top left, simulate LWin+Tab. @@ -559,7 +594,7 @@ Return { CoordMode, Mouse, Screen MouseGetPos, x, y - if (x >= A_ScreenWidth && y >= A_ScreenHeight) + if (x >= A_ScreenWidth - 10 && y >= A_ScreenHeight - 10) { Send {LWin Down}m{LWin Up} } @@ -597,6 +632,8 @@ hotkeyInfo .= "Ctrl + PrtSc = PrtSc`n`n" hotkeyInfo .= "Windows`n" hotkeyInfo .= "Win + F = Quick Google Search`n" hotkeyInfo .= "Win + T = Quick Google Translate`n" +hotkeyInfo .= "Win + C = Quick AI Chatbot`n" +hotkeyInfo .= "Win + S = Text to Speech`n" hotkeyInfo .= "Ctrl + Alt + F4 Kill active window`n" hotkeyInfo .= "Win + F5 Restart Explorer`n" hotkeyInfo .= "Win + F12 Turn off the display`n" @@ -617,6 +654,6 @@ hotkeyInfo .= "Right Ctrl + Z = Left Click`n" hotkeyInfo .= "Right Ctrl + Y = Middle Click`n" hotkeyInfo .= "Right Ctrl + C = Right Click`n" hotkeyInfo .= "Ctrl + Left Alt + Up/Down Arrow = Scroll Wheel`n" -MsgBox, 64, Hey Quick Keyboard v1.1, %hotkeyInfo%`nDeveloped by Halil Emre Yildiz`nGithub: @JahnStar, 20 +MsgBox, 64, Hey Quick Keyboard v1.2, %hotkeyInfo%`nDeveloped by Halil Emre Yildiz`nGithub: @JahnStar, 20 Run, https://github.com/JahnStar/Hey-Quick-Keyboard/ return \ No newline at end of file diff --git a/tts.vbs b/tts.vbs new file mode 100644 index 0000000..ff2633f --- /dev/null +++ b/tts.vbs @@ -0,0 +1,13 @@ +Dim txtArgument, voice +txtArgument = WScript.Arguments.Item(0) +If WScript.Arguments.Count > 1 Then + voice = WScript.Arguments.Item(1) +Else + voice = 0 +End If + +' tts +Dim sapi +Set sapi = createObject("sapi.spvoice") +Set sapi.Voice = sapi.GetVoices.Item(voice) +sapi.Speak txtArgument \ No newline at end of file