Comments (6)
localized ):::
is there any way to get the localized version of Desktop ?
from vd.ahk.
#SingleInstance force
ListLines 0
KeyHistory 0
SendMode "Input" ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir A_ScriptDir ; Ensures a consistent starting directory.
FindStringResourceEx(hModule, uId, langId) { ;https://stackoverflow.com/questions/2502375/find-localized-windows-strings#2588937
debugThis := uId // 16 + 1
hrsrc := DllCall("FindResourceExW", "Ptr",hModule, "Ptr",6, "Ptr",debugThis, "UShort",langId, "UPtr") ;RT_STRING=6
pwsz:=0
if (hrsrc) {
hglob := DllCall("LoadResource", "Ptr",hModule, "Ptr",hrsrc, "Ptr")
if (hglob) {
pwsz := DllCall("LockResource", "Ptr",hglob, "Ptr")
if (pwsz) {
lolWhat := uId & 15
j:=0
while (j < lolWhat) {
pwsz += 2 + 2*NumGet(pwsz, 0, "UShort")
++j
}
length:=NumGet(pwsz, 0, "UShort")
pwsz+=2
}
}
}
return pwsz && StrGet(pwsz, length, "UTF-16")
}
hModule := DllCall("GetModuleHandle", "Str", "twinui.pcshell.dll", "Ptr") || DllCall("LoadLibrary", "Str", "twinui.pcshell.dll", "Ptr")
localizedString := FindStringResourceEx(hModule, 13502, DllCall("GetUserDefaultUILanguage", "UShort")) ;"Desktop"=13502
MsgBox A_Clipboard:=localizedString
ExitApp
f3::ExitApp
from vd.ahk.
Sorry for late reply.
I tried a few methods I found to attempt to get "Desktop" in the local language, without luck. Even gave the ChatGPT a few tries without luck before creating the ticket.
Seems like the code you provided return 0 for me, unfortunately.
But, this code worked for me. It is possible that the line number is different on different OS systems. I have the same OS version on both my desktop and my surface so unable to check:
DLL_File := A_WinDir "\System32\shell32.dll"
LocaleString_Desktop := DLL_ReadStringNum(DLL_File,21769)
MsgBox, % LocaleString_Desktop
DLL_ReadStringNum(DllFile, StringNum) {
hModule := DllCall("LoadLibrary", "str", DllFile, "Ptr")
VarSetCapacity(string, 1024)
DllCall("LoadString", "uint", hModule, "uint", StringNum, "uint", &string, "int", 1024)
DllCall("FreeLibrary", "Ptr", hModule)
Return string
}
from vd.ahk.
This one also works for me (no changes to the DLL_ReadStringNum function needed, only the file path and line number):
DLL_File := A_WinDir "\System32\twinui.pcshell.dll"
LocaleString_Desktop := DLL_ReadStringNum(DLL_File,13502)
from vd.ahk.
@marium0505
wow, this is so short, where did you find about LoadString
?
I want to post this as an answer to https://stackoverflow.com/questions/2502375/find-localized-windows-strings, mention that it only gets UserDefaultUILanguage
you're sending v1 code, maybe you ran my v2 code using v1 ahk, sorry(I didn't mention it), I always use v2 when testing winapi stuff
shell32.dll
(8MB) is smaller to load than twinui.pcshell.dll
(9MB) so I will use shell32.dll
here is my v2 version:
#SingleInstance force
ListLines 0
KeyHistory 0
SendMode "Input" ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir A_ScriptDir ; Ensures a consistent starting directory.
getLocalizedWord_Desktop() {
hModule := DllCall("GetModuleHandle", "Str", "shell32.dll", "Ptr") || DllCall("LoadLibrary", "Str", "shell32.dll", "Ptr")
length:=DllCall("LoadString", "Uint", hModule, "Uint", 21769, "Ptr*", &lpBuffer:=0, "Int", 0)
localizedStr := StrGet(lpBuffer, length, "UTF-16")
Return localizedStr
}
MsgBox getLocalizedWord_Desktop()
Exitapp
f3::Exitapp
from vd.ahk.
seems like 4162 also gets "Desktop", I wanted to share this script:
#SingleInstance force
ListLines 0
KeyHistory 0
SendMode "Input" ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir A_ScriptDir ; Ensures a consistent starting directory.
getNumbers(hModule, stringToSearch) {
arr:=[]
i:=0
while (i < 65536) {
localizedStr:=""
length:=DllCall("LoadString", "Uint", hModule, "Uint", i, "Ptr*", &lpBuffer:=0, "Int", 0)
localizedStr := StrGet(lpBuffer, length, "UTF-16")
if (localizedStr == stringToSearch) {
arr.Push(i)
}
++i
}
return arr
}
hModule := DllCall("LoadLibrary", "Str", "shell32.dll", "Ptr")
arr:=getNumbers(hModule, "Desktop")
finalStr:=""
for v in arr {
finalStr.=v "`n"
}
MsgBox A_Clipboard:=finalStr
Exitapp
f3::Exitapp
from vd.ahk.
Related Issues (20)
- After pinning with AH2 version, I get an error when switching desktops by number.
- Script sending "Q" to discord | Desktop switch failure. HOT 2
- getDesktopNumOfWindow sometimes returns -1 rather than the correct num HOT 4
- Error HOT 10
- open Application directly on one virtual desktop in background HOT 2
- "Error: (0x80004002) No such interface supported" after updating Windows 11 (Beta insider channel) HOT 13
- sending keypress to specified virtual desktop only.
- Ah2: Desktop Looping & Switching + Other Feature Regression from Commit ee2f54f626914273f00853306c1daaf803f756cb HOT 2
- It doesn't work on Windows 11 Build 22621.2215 (22H2) HOT 2
- A problem with the new Windows update 11 HOT 18
- Virtual desktop Tasksbar icons HOT 4
- renaming desktops HOT 1
- Switching to Relative Desktop fails initially HOT 2
- Current desktop count is always zero
- New Windows Build 23606: VD.getCurrentDesktopNum() always returns 0 HOT 4
- Windows Server 2022 version HOT 3
- It doesn't work on Windows 11 Build 22631.3085 (23H2) HOT 13
- v2_port分支没有 TogglePinApp,PinApp,UnPinApp HOT 2
- WinExist in another virtual desktop HOT 7
- Previous Desktop HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vd.ahk.