Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
|
Lista Forumurilor Pe Tematici
|
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login
POZE MRRRR'S FORUM (VIEW ONLY)
Nu sunteti logat.
|
Nou pe simpatie: christyna1993
 | Femeie 25 ani Bucuresti cauta Barbat 30 - 44 ani |
|
TRaP
Moderator
Inregistrat: acum 7 ani
Postari: 827
|
|
On a different resolution screen, a HTA that fits perfectly on my laptop would not fit very well, text would be covered by margins.
This goes right after the <head></head> tags:
<script LANGUAGE="VBScript"> Sub Window_onLoad If Window.Screen.availWidth < 1800 Then window.resizeTo 720,640 End If If Window.Screen.availWidth > 1800 Then window.resizeTo 820,700 End If End Sub </script> |
|
|
pus acum 2 ani |
|
TRaP
Moderator
Inregistrat: acum 7 ani
Postari: 827
|
|
Adding the "Sub" around the resize options doesn't really work well sometimes.
Simpler code like below, added before the <HTA> tag is recommended
<script language="VBScript"> resizeTo 950,810 ' W, H moveTo 100,25 ' from left, from top </script> |
Source:
|
|
pus acum 2 luni |
|
TRaP
Moderator
Inregistrat: acum 7 ani
Postari: 827
|
|
Updated, since on this laptop I have a different resolution larger than 1080p and scaling larger than 100%, I need updated code.
The code below reads resolution of primary monitor and reads DPI from the registry the decides proper resolution. The "problem" seems to actually be the scaling and not the resolution.
<!-- RESIZE SHOULD ALWAYS BE BEFORE THE HTA:APPLICATION TAGS, BECAUSE THAT SETS THE DEFAULT SIZE --> <script language="VBScript">
Set shell = CreateObject("WScript.Shell") Set wmi = GetObject("winmgmts:\\.\root\cimv2") Set monitors = wmi.ExecQuery("Select * from Win32_DesktopMonitor Where Availability = 3")
' Get screen resolution from WMI For Each monitor In monitors width = monitor.ScreenWidth height = monitor.ScreenHeight Exit For ' Primary monitor only Next
' Try to read DPI setting from registry On Error Resume Next dpi = shell.RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI") If Err.Number <> 0 Then dpi = 96 ' default DPI Err.Clear End If On Error GoTo 0
' Convert DPI to scale percent Select Case dpi Case 96: scalePercent = "100%" Case 120: scalePercent = "125%" Case 144: scalePercent = "150%" Case 168: scalePercent = "175%" Case 192: scalePercent = "200%" Case Else: scalePercent = "Unknown (" & dpi & ")" End Select
'MsgBox "Resolution: " & width & "x" & height & vbCrLf & "Scaling: " & scalePercent
If width > 1920 and dpi = 120 Then resizeTo 1200,1000 ' W x H moveTo 100,25 ' from left, from top
Else resizeTo 1300,1200 ' W x H moveTo 100,25 ' from left, from top End If
</script> <!-- RESIZE SHOULD ALWAYS BE BEFORE THE HTA:APPLICATION TAGS, BECAUSE THAT SETS THE DEFAULT SIZE --> |
Source: ChatGPT
|
|
pus acum 1 luna |
|