Skip to content

Commit

Permalink
New AI feature
Browse files Browse the repository at this point in the history
Added Hey Chat VBS
  • Loading branch information
JahnStar committed Dec 29, 2023
1 parent 722cdd8 commit fc27933
Show file tree
Hide file tree
Showing 8 changed files with 356 additions and 34 deletions.
7 changes: 7 additions & 0 deletions Config.ini
Original file line number Diff line number Diff line change
@@ -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:"
Binary file modified HeyQuickKeyboard.exe
Binary file not shown.
46 changes: 25 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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

Expand All @@ -28,44 +29,47 @@ 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 |
| Win + F5 | Restart Explorer | Restart the Explorer to refresh the desktop and taskbar |
| 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

Expand Down
192 changes: 192 additions & 0 deletions other/hey-chat-vbs/Hey-Chat-VBS.vbs
Original file line number Diff line number Diff line change
@@ -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 <Github/JahnStar>", 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 <Github/JahnStar>", 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
' }
' }
21 changes: 21 additions & 0 deletions other/hey-chat-vbs/LICENSE
Original file line number Diff line number Diff line change
@@ -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.
48 changes: 48 additions & 0 deletions other/hey-chat-vbs/README.md
Original file line number Diff line number Diff line change
@@ -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.
Loading

0 comments on commit fc27933

Please sign in to comment.