What is the (0), is that the Screen Number or something internal?
I'm trying to calculate the center of the screen by assigning CenterX = {ScreenWidth(0)}/2 but it does not work.
It returns almost as a text string 1920/2. I'm looking for the numeric value of 1920/2 which is 960
Using System Variable ScreenWidth(0)
Using System Variable ScreenWidth(0)
Windows 11 Pro, RoboTask v10.5
Re: Using System Variable ScreenWidth(0)
0 - is is the number of screen
0 - is aways the main screen.
For example I have 3 monitors
so 0 - main screen, 1 and 2 are additional screens
If you have only one monitor then you can use variable without parameter - {ScreenWidth}. In this case the engine will use main screen.
To find center use the expression {Divide({ScreenW},2)}. But this expression is valid only for main screen
for screen1 use {Divide({Add({ScreenLeft(1)},{ScreenRight(1)} )},2)}
for screen2 use {Divide({Add({ScreenLeft(2)},{ScreenRight(2)} )},2)}
Save the task text to a file and use the Task->Import menu to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.
0 - is aways the main screen.
For example I have 3 monitors
so 0 - main screen, 1 and 2 are additional screens
If you have only one monitor then you can use variable without parameter - {ScreenWidth}. In this case the engine will use main screen.
To find center use the expression {Divide({ScreenW},2)}. But this expression is valid only for main screen
for screen1 use {Divide({Add({ScreenLeft(1)},{ScreenRight(1)} )},2)}
for screen2 use {Divide({Add({ScreenLeft(2)},{ScreenRight(2)} )},2)}
If you want to use math operations use VB Evaluate or JS Evaluate actions. Example is below...by assigning CenterX = {ScreenWidth(0)}/2 but it does not work.
Save the task text to a file and use the Task->Import menu to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|307868550
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1615"
Hide=INTEGER|0
ID=INTEGER|-164659821
LogOnAsUser=INTEGER|1
Name=STRING|"find center"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
[Actions\Action1]
ActionID=STRING|"A_SCRIPT_VBEVALUATE"
Enabled=INTEGER|-1
Name=STRING|"VB Evaluate"
Params=FOLDER
[Actions\Action1\Params]
_rt_variables_produced=STRING|"CenterX"
expression=STRING|"{ScreenW}/2"
linecount=STRING|"0"
loadfromfile=STRING|"1"
variable=STRING|"CenterX"
[Actions\Action2]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{CenterX}"""
Params=FOLDER
[Actions\Action2\Params]
icon=STRING|"1"
msg0=STRING|"{CenterX}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
Re: Using System Variable ScreenWidth(0)
Thanks for the help. I guess I've never had the need to divide two values before, duh. Anyways I'm always learning something new is RoboTask
Windows 11 Pro, RoboTask v10.5