Skip to content

Commit 30626fe

Browse files
authored
fix(execute): windows scaleFactor not work (#2)
1 parent a86ab6f commit 30626fe

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/main/agent/device.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
ScreenshotResult,
1111
} from '@ui-tars/desktop-shared/types';
1212

13+
import * as env from '@main/env';
1314
import { logger } from '@main/logger';
1415

1516
import { FACTOR } from './constant';
@@ -56,11 +57,15 @@ export class Desktop {
5657
screenWidth: number,
5758
screenHeight: number,
5859
) {
60+
const primaryDisplay = screen.getPrimaryDisplay();
61+
const { scaleFactor } = primaryDisplay;
62+
5963
await execute({
6064
prediction,
6165
screenWidth,
6266
screenHeight,
6367
logger,
68+
scaleFactor: !env.isMacOS ? scaleFactor : 1,
6469
});
6570
}
6671

src/main/agent/execute.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const moveStraightTo = async (startX: number | null, startY: number | null) => {
2626
};
2727

2828
export const execute = async (executeParams: {
29+
scaleFactor?: number;
2930
prediction: PredictionParsed;
3031
screenWidth: number;
3132
screenHeight: number;
@@ -36,11 +37,13 @@ export const execute = async (executeParams: {
3637
screenWidth,
3738
screenHeight,
3839
logger = console,
40+
scaleFactor = 1,
3941
} = executeParams;
4042

4143
logger.info(
4244
'[execute] executeParams',
4345
JSON.stringify({
46+
scaleFactor,
4447
prediction,
4548
screenWidth,
4649
screenHeight,
@@ -53,10 +56,14 @@ export const execute = async (executeParams: {
5356

5457
logger.info('[execute] action_type', action_type, 'startBoxStr', startBoxStr);
5558

56-
const { x: startX, y: startY } = startBoxStr
59+
const { x, y } = startBoxStr
5760
? parseBoxToScreenCoords(startBoxStr, screenWidth, screenHeight)
5861
: { x: null, y: null };
59-
logger.info('[execute] [Position]', startX, startY);
62+
63+
const startX = x ? x * scaleFactor : null;
64+
const startY = y ? y * scaleFactor : null;
65+
66+
logger.info(`[execute] [Position] (${x}, ${y}) => (${startX}, ${startY})`);
6067

6168
// execute configs
6269
mouse.config.mouseSpeed = 1500;

src/renderer/src/components/RunMessages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ const RunMessages: React.FC<RunMessagesProps> = (props) => {
180180
);
181181
}
182182
})}
183-
{thinking && <LoadingText>正在思考...</LoadingText>}
183+
{thinking && <LoadingText>Thinking...</LoadingText>}
184184
</Box>
185185
</Box>
186186
);

0 commit comments

Comments
 (0)