Skip to content

EloiStree/2024_08_29_ScratchToWarcraft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 

Repository files navigation

2024_08_29_ScratchToWarcraft

Apprendre la programmation par warcraft via Scratch 😁


Dans le cadre d'un atelier

Example Scratch : https://scratch.mit.edu/projects/1061213031/

Language Supported ?

Guide d'installation

image
https://youtu.be/X0UA4ckn2ws

Installation

Opera GX:
image
https://www.opera.com/fr/gx

Tamper Monkey:
image
https://www.tampermonkey.net/

Installer Python:
image
https://www.python.org/

Installer les modules:
pip install pyperclip psutil pygetwindow websockets
image

Touches disponibles

Source: https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes

Key Decimal Hexadecimal Press Release
Rlease All 0 0x00 1000 2000
Clear Timed Command 256 0xFF 1256 2256
Backspace 8 0x08 1008 2008
Tab 9 0x09 1009 2009
Clear 12 0x0C 1012 2012
Enter 13 0x0D 1013 2013
Shift 16 0x10 1016 2016
Ctrl 17 0x11 1017 2017
Alt 18 0x12 1018 2018
Pause 19 0x13 1019 2019
CapsLock 20 0x14 1020 2020
Esc 27 0x1B 1027 2027
Escape 27 0x1B 1027 2027
Space 32 0x20 1032 2032
PageUp 33 0x21 1033 2033
PageDown 34 0x22 1034 2034
End 35 0x23 1035 2035
Home 36 0x24 1036 2036
LeftArrow 37 0x25 1037 2037
Left 37 0x25 1037 2037
UpArrow 38 0x26 1038 2038
Up 38 0x26 1038 2038
RightArrow 39 0x27 1039 2039
Right 39 0x27 1039 2039
DownArrow 40 0x28 1040 2040
Down 40 0x28 1040 2040
Select 41 0x29 1041 2041
Print 42 0x2A 1042 2042
Execute 43 0x2B 1043 2043
PrintScreen 44 0x2C 1044 2044
Insert 45 0x2D 1045 2045
Delete 46 0x2E 1046 2046
0 48 0x30 1048 2048
1 49 0x31 1049 2049
2 50 0x32 1050 2050
3 51 0x33 1051 2051
4 52 0x34 1052 2052
5 53 0x35 1053 2053
6 54 0x36 1054 2054
7 55 0x37 1055 2055
8 56 0x38 1056 2056
9 57 0x39 1057 2057
A 65 0x41 1065 2065
B 66 0x42 1066 2066
C 67 0x43 1067 2067
D 68 0x44 1068 2068
E 69 0x45 1069 2069
F 70 0x46 1070 2070
G 71 0x47 1071 2071
H 72 0x48 1072 2072
I 73 0x49 1073 2073
J 74 0x4A 1074 2074
K 75 0x4B 1075 2075
L 76 0x4C 1076 2076
M 77 0x4D 1077 2077
N 78 0x4E 1078 2078
O 79 0x4F 1079 2079
P 80 0x50 1080 2080
Q 81 0x51 1081 2081
R 82 0x52 1082 2082
S 83 0x53 1083 2083
T 84 0x54 1084 2084
U 85 0x55 1085 2085
V 86 0x56 1086 2086
W 87 0x57 1087 2087
X 88 0x58 1088 2088
Y 89 0x59 1089 2089
Z 90 0x5A 1090 2090
LeftWindows 91 0x5B 1091 2091
RightWindows 92 0x5C 1092 2092
Applications 93 0x5D 1093 2093
Sleep 95 0x5F 1095 2095
Numpad0 96 0x60 1096 2096
Numpad1 97 0x61 1097 2097
Numpad2 98 0x62 1098 2098
Numpad3 99 0x63 1099 2099
Numpad4 100 0x64 1100 2100
Numpad5 101 0x65 1101 2101
Numpad6 102 0x66 1102 2102
Numpad7 103 0x67 1103 2103
Numpad8 104 0x68 1104 2104
Numpad9 105 0x69 1105 2105
Multiply 106 0x6A 1106 2106
Add 107 0x6B 1107 2107
Separator 108 0x6C 1108 2108
Subtract 109 0x6D 1109 2109
Decimal 110 0x6E 1110 2110
Divide 111 0x6F 1111 2111
F1 112 0x70 1112 2112
F2 113 0x71 1113 2113
F3 114 0x72 1114 2114
F4 115 0x73 1115 2115
F5 116 0x74 1116 2116
F6 117 0x75 1117 2117
F7 118 0x76 1118 2118
F8 119 0x77 1119 2119
F9 120 0x78 1120 2120
F10 121 0x79 1121 2121
F11 122 0x7A 1122 2122
F12 123 0x7B 1123 2123
F13 124 0x7C 1124 2124
F14 125 0x7D 1125 2125
F15 126 0x7E 1126 2126
F16 127 0x7F 1127 2127
F17 128 0x80 1128 2128
F18 129 0x81 1129 2129
F19 130 0x82 1130 2130
F20 131 0x83 1131 2131
F21 132 0x84 1132 2132
F22 133 0x85 1133 2133
F23 134 0x86 1134 2134
F24 135 0x87 1135 2135
NumLock 144 0x90 1144 2144
ScrollLock 145 0x91 1145 2145
LeftShift 160 0xA0 1160 2160
RightShift 161 0xA1 1161 2161
LeftControl 162 0xA2 1162 2162
RightControl 163 0xA3 1163 2163
LeftAlt 164 0xA4 1164 2164
RightAlt 165 0xA5 1165 2165
LeftMenu 164 0xA4 1164 2164
RightMenu 165 0xA5 1165 2165
BrowserBack 166 0xA6 1166 2166
BrowserForward 167 0xA7 1167 2167
BrowserRefresh 168 0xA8 1168 2168
BrowserStop 169 0xA9 1169 2169
BrowserSearch 170 0xAA 1170 2170
BrowserFavorites 171 0xAB 1171 2171
BrowserHome 172 0xAC 1172 2172
VolumeMute 173 0xAD 1173 2173
VolumeDown 174 0xAE 1174 2174
VolumeUp 175 0xAF 1175 2175
MediaNextTrack 176 0xB0 1176 2176
MediaPreviousTrack 177 0xB1 1177 2177
MediaStop 178 0xB2 1178 2178
MediaPlay 179 0xB3 1179 2179
LaunchMail 180 0xB4 1180 2180
LaunchMediaSelect 181 0xB5 1181 2181
LaunchApp1 182 0xB6 1182 2182
LaunchApp2 183 0xB7 1183 2183
OEM1 186 0xBA 1186 2186
OEMPlus 187 0xBB 1187 2187
OEMComma 188 0xBC 1188 2188
OEMMinus 189 0xBD 1189 2189
OEMPeriod 190 0xBE 1190 2190
OEM2 191 0xBF 1191 2191
OEM3 192 0xC0 1192 2192
OEM4 219 0xDB 1219 2219
OEM5 220 0xDC 1220 2220
OEM6 221 0xDD 1221 2221
OEM7 222 0xDE 1222 2222
OEM8 223 0xDF 1223 2223
OEM102 226 0xE2 1226 2226
ProcessKey 229 0xE5 1229 2229
Packet 231 0xE7 1231 2231
Attn 246 0xF6 1246 2246
CrSel 247 0xF7 1247 2247
ExSel 248 0xF8 1248 2248
EraseEOF 249 0xF9 1249 2249
Play 250 0xFA 1250 2250
Zoom 251 0xFB 1251 2251
PA1 253 0xFD 1253 2253
0x08 8   1008 2008
0x09 9   1009 2009
0x0C 12   1012 2012
0x0D 13   1013 2013
0x10 16   1016 2016
0x11 17   1017 2017
0x12 18   1018 2018
0x13 19   1019 2019
0x14 20   1020 2020
0x1B 27   1027 2027
0x1B 27   1027 2027
0x20 32   1032 2032
0x21 33   1033 2033
0x22 34   1034 2034
0x23 35   1035 2035
0x24 36   1036 2036
0x25 37   1037 2037
0x25 37   1037 2037
0x26 38   1038 2038
0x26 38   1038 2038
0x27 39   1039 2039
0x27 39   1039 2039
0x28 40   1040 2040
0x28 40   1040 2040
0x29 41   1041 2041
0x2A 42   1042 2042
0x2B 43   1043 2043
0x2C 44   1044 2044
0x2D 45   1045 2045
0x2E 46   1046 2046
0x30 48   1048 2048
0x31 49   1049 2049
0x32 50   1050 2050
0x33 51   1051 2051
0x34 52   1052 2052
0x35 53   1053 2053
0x36 54   1054 2054
0x37 55   1055 2055
0x38 56   1056 2056
0x39 57   1057 2057
0x41 65   1065 2065
0x42 66   1066 2066
0x43 67   1067 2067
0x44 68   1068 2068
0x45 69   1069 2069
0x46 70   1070 2070
0x47 71   1071 2071
0x48 72   1072 2072
0x49 73   1073 2073
0x4A 74   1074 2074
0x4B 75   1075 2075
0x4C 76   1076 2076
0x4D 77   1077 2077
0x4E 78   1078 2078
0x4F 79   1079 2079
0x50 80   1080 2080
0x51 81   1081 2081
0x52 82   1082 2082
0x53 83   1083 2083
0x54 84   1084 2084
0x55 85   1085 2085
0x56 86   1086 2086
0x57 87   1087 2087
0x58 88   1088 2088
0x59 89   1089 2089
0x5A 90   1090 2090
0x5B 91   1091 2091
0x5C 92   1092 2092
0x5D 93   1093 2093
0x5F 95   1095 2095
0x60 96   1096 2096
0x61 97   1097 2097
0x62 98   1098 2098
0x63 99   1099 2099
0x64 100   1100 2100
0x65 101   1101 2101
0x66 102   1102 2102
0x67 103   1103 2103
0x68 104   1104 2104
0x69 105   1105 2105
0x6A 106   1106 2106
0x6B 107   1107 2107
0x6C 108   1108 2108
0x6D 109   1109 2109
0x6E 110   1110 2110
0x6F 111   1111 2111
0x70 112   1112 2112
0x71 113   1113 2113
0x72 114   1114 2114
0x73 115   1115 2115
0x74 116   1116 2116
0x75 117   1117 2117
0x76 118   1118 2118
0x77 119   1119 2119
0x78 120   1120 2120
0x79 121   1121 2121
0x7A 122   1122 2122
0x7B 123   1123 2123
0x7C 124   1124 2124
0x7D 125   1125 2125
0x7E 126   1126 2126
0x7F 127   1127 2127
0x80 128   1128 2128
0x81 129   1129 2129
0x82 130   1130 2130
0x83 131   1131 2131
0x84 132   1132 2132
0x85 133   1133 2133
0x86 134   1134 2134
0x87 135   1135 2135
0x90 144   1144 2144
0x91 145   1145 2145
0xA0 160   1160 2160
0xA1 161   1161 2161
0xA2 162   1162 2162
0xA3 163   1163 2163
0xA4 164   1164 2164
0xA5 165   1165 2165
0xA4 164   1164 2164
0xA5 165   1165 2165
0xA6 166   1166 2166
0xA7 167   1167 2167
0xA8 168   1168 2168
0xA9 169   1169 2169
0xAA 170   1170 2170
0xAB 171   1171 2171
0xAC 172   1172 2172
0xAD 173   1173 2173
0xAE 174   1174 2174
0xAF 175   1175 2175
0xB0 176   1176 2176
0xB1 177   1177 2177
0xB2 178   1178 2178
0xB3 179   1179 2179
0xB4 180   1180 2180
0xB5 181   1181 2181
0xB6 182   1182 2182
0xB7 183   1183 2183
0xBA 186   1186 2186
0xBB 187   1187 2187
0xBC 188   1188 2188
0xBD 189   1189 2189
0xBE 190   1190 2190
0xBF 191   1191 2191
0xC0 192   1192 2192
0xDB 219   1219 2219
0xDC 220   1220 2220
0xDD 221   1221 2221
0xDE 222   1222 2222
0xDF 223   1223 2223
0xE2 226   1226 2226
0xE5 229   1229 2229
0xE7 231   1231 2231
0xF6 246   1246 2246
0xF7 247   1247 2247
0xF8 248   1248 2248
0xF9 249   1249 2249
0xFA 250   1250 2250
0xFB 251   1251 2251
0xFD 253   1253 2253

If mouse ensable and only one account on screen

1599998888

  • 15 Mouse Move type
  • 9999: percent width screen 0-9999
  • 8888: percent height screen 0-9999

Label | Press | Release

  • | - | - Mouse Left | 1260 | 2260 Mouse Middle | 1261 | 2261 Mouse Right | 1262 | 2262 Mouse Button 4 | 1263 | 2263 Mouse Button 5 | 1264 | 2264 Mouse Double Click Left | 1265 | 2265 Mouse Triple Click Left | 1266 | 2266 Mouse Double Click Right | 1267 | 2267 Mouse Triple Click Right | 1268 | 2268

Convert int with Micro Python and Arduino

Arduino Version

// ##########  RECEIVED INTEGER AS BYTES
/// CONVERT FOUR BYTE IN LITTLE ENDIAN FORMAT TO SIGNED INTEGER 32 BITS
// USE: byte bytes[4] = {0xC0, 0x1D, 0xFE, 0xFF};  // Little-endian encoding of -123456
// USE: int32_t result = parseLittleEndian(bytes[0], bytes[1], bytes[2], bytes[3]);
int32_t parseLittleEndian(byte b0, byte b1, byte b2, byte b3) {
  // Combine bytes in little-endian order
  return ((int32_t)b0) | ((int32_t)b1 << 8) | ((int32_t)b2 << 16) | ((int32_t)b3 << 24);
}

// ##########  SEND INTEGER TO BYTES
// CONVERT SIGNE INTEGER INTO FOUR BYTES IN LITTLE ENDIAN
// USE: int32_t value = -123456;
// USE: byte bytes[4];
// USE: intToBytes(value, bytes);
void intToBytes(int32_t value, uint8_t bytes[4]) {
  bytes[0] = value & 0xFF;         // Extract the lowest 8 bits
  bytes[1] = (value >> 8) & 0xFF;  // Shift right by 8 bits and extract the next 8 bits
  bytes[2] = (value >> 16) & 0xFF; // Shift right by 16 bits and extract the next 8 bits
  bytes[3] = (value >> 24) & 0xFF; // Shift right by 24 bits and extract the highest 8 bits
}

Python version

import struct

# Pack means to turn into 1 and 0 from value with type
# Unpack means to turn 1 and 0 in value with type
# i  means signed integer
# Q means long unsigned value (double of an integer)
# < in little endian order


byte_integer_value = struct.pack("<i", integer)
unpacked_integer = struct.unpack("<i", byte_integer_value)[0]

byte_index_integer_value = struct.pack("<ii", integer1, integer2)
unpacked_integers = struct.unpack("<ii", byte_index_integer_value)

byte_index_integer_date_value = struct.pack("<iiQ", integer1, integer2, date_value)
unpacked_values = struct.unpack("<iiQ", byte_index_integer_date_value)

Xbox Xinput version

XInput is finite and won't change over time. Therefore, the following code should work for most of my future tools.
Why include XInput code in a Scratch to Warcraft project?
Because:

  • This project serves as the landing page for this workshop. 😋
  • I plan to support a Warcraft version with split-screen gameplay using four XInput gamepads.

Preferred versions for your code:

  • 1899887766: To manage the left and right joysticks of the gamepad using 4 bytes.
  • 1700000000: To manage all the buttons using 4 bytes.

If those aren't feasible, try the following alternative:
🤖 Code generated by GPT without thorough re-testing at this stage.
You can find the original code here: GitHub Repository

Short Description Integer to Press Integer to Release
Random input for all gamepads, no menu 1399 2399
Enable hardware joystick ON/OFF 1390 2390
Press A button 1300 2300
Press X button 1301 2301
Press B button 1302 2302
Press Y button 1303 2303
Press left side button 1304 2304
Press right side button 1305 2305
Press left stick 1306 2306
Press right stick 1307 2307
Press menu right 1308 2308
Press menu left 1309 2309
Release D-pad 1310 2310
Press arrow north 1311 2311
Press arrow northeast 1312 2312
Press arrow east 1313 2313
Press arrow southeast 1314 2314
Press arrow south 1315 2315
Press arrow southwest 1316 2316
Press arrow west 1317 2317
Press arrow northwest 1318 2318
Press Xbox home button 1319 2319
Random axis 1320 2320
Start recording 1321 2321
Set left stick to neutral (clockwise) 1330 2330
Move left stick up 1331 2331
Move left stick up-right 1332 2332
Move left stick right 1333 2333
Move left stick down-right 1334 2334
Move left stick down 1335 2335
Move left stick down-left 1336 2336
Move left stick left 1337 2337
Move left stick up-left 1338 2338
Set right stick to neutral (clockwise) 1340 2340
Move right stick up 1341 2341
Move right stick up-right 1342 2342
Move right stick right 1343 2343
Move right stick down-right 1344 2344
Move right stick down 1345 2345
Move right stick down-left 1346 2346
Move right stick left 1347 2347
Move right stick up-left 1348 2348
Set left stick horizontal to 1.0 1350 2350
Set left stick horizontal to -1.0 1351 2351
Set left stick vertical to 1.0 1352 2352
Set left stick vertical to -1.0 1353 2353
Set right stick horizontal to 1.0 1354 2354
Set right stick horizontal to -1.0 1355 2355
Set right stick vertical to 1.0 1356 2356
Set right stick vertical to -1.0 1357 2357
Set left trigger to 100% 1358 2358
Set right trigger to 100% 1359 2359
Set left stick horizontal to 0.75 1360 2360
Set left stick horizontal to -0.75 1361 2361
Set left stick vertical to 0.75 1362 2362
Set left stick vertical to -0.75 1363 2363
Set right stick horizontal to 0.75 1364 2364
Set right stick horizontal to -0.75 1365 2365
Set right stick vertical to 0.75 1366 2366
Set right stick vertical to -0.75 1367 2367
Set left trigger to 75% 1368 2368
Set right trigger to 75% 1369 2369
Set left stick horizontal to 0.5 1370 2370
Set left stick horizontal to -0.5 1371 2371
Set left stick vertical to 0.5 1372 2372
Set left stick vertical to -0.5 1373 2373
Set right stick horizontal to 0.5 1374 2374
Set right stick horizontal to -0.5 1375 2375
Set right stick vertical to 0.5 1376 2376
Set right stick vertical to -0.5 1377 2377
Set left trigger to 50% 1378 2378
Set right trigger to 50% 1379 2379
Set left stick horizontal to 0.25 1380 2380
Set left stick horizontal to -0.25 1381 2381
Set left stick vertical to 0.25 1382 2382
Set left stick vertical to -0.25 1383 2383
Set right stick horizontal to 0.25 1384 2384
Set right stick horizontal to -0.25 1385 2385
Set right stick vertical to 0.25 1386 2386
Set right stick vertical to -0.25 1387 2387
Set left trigger to 25% 1388 2388
Set right trigger to 25% 1389 2389
Release ALL Touch 1390 2390
Release ALL Touch but menu 1391 2391
Clear Timed Command 1398 2398

Steam Deck Button / Function Button

On traditional keyboards, you have F1 to F12 keys, and in the past, there were F1 to F24 keys. These function keys were designed to be associated with specific callable functions.

This is essentially what devices like the Steam Deck and drum pads achieve today. They assign specific functions to buttons, enabling easy access to various features.

In my proposed standard, I suggest reserving the range 1800-1999 for callable functions, effectively creating an extended set of function keys: F1 to F199.

Example Mapping:

1800 -> 1999
2800 -> 2899

What will be stored there?

It depends entirely on the context. These could be any functions or actions required by the application or system in use. In the context of Scratch to Wow, we could list action that need to be triggerable but don't need to be store on a keystroke but write in the console from /run script

image 1
image 2

About

Apprendre la programmation par warcraft via Scratch 😁

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published