Two problems

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

koleviko
Junior Coder
Posts: 45
Joined: Thu Nov 20, 2008 2:59 pm

Two problems

Post by koleviko » Wed Jan 27, 2010 6:17 pm

First.

How do I know? Is the operating system is Windows XP or Windows Vista or Windows 7?

Code: Select all


let> a = os_ver
MessageModal> a
[/quote]

This tool is not showing me XP or Win 7 is?



Second.

Why have mistake.
I want to charge 3 - 4 "Dialogs" in the script but it did not is receives.

Code: Select all

 
label>start

Dialog>Dialog3
   Caption=Warning
   Width=277
   Height=209
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Image=C:\1.bmp,0,-8,273,193,msImage6,1
EndDialog>Dialog3
//ResetDialogAction>Dialog3 ???
show>Dialog3,


Dialog>Dialog4
   Caption=Warning2
   Width=277
   Height=209
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Image=C:\2.bmp,0,-8,273,193,msImage6,1
EndDialog>Dialog4
show>Dialog4,
//ResetDialogAction>Dialog4
goto>start

[/quote]

:idea:

sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Wed Jan 27, 2010 9:27 pm

For your first issue

Code: Select all

RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows NT\CurrentVersion,ProductName,osname
messagemodal>osname
should hopefully pull what you are looking for. Your initial command works ok its just that the variable you are pulling doesn't give the product name

The second issue is you are trying to load the dialogs over and over. your label should be below the two dialogs like so


Code: Select all


Dialog>Dialog3
   Caption=Warning
   Width=277
   Height=209
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Image=C:\1.bmp,0,-8,273,193,msImage6,1
EndDialog>Dialog3
//ResetDialogAction>Dialog3 ???
show>Dialog3,


Dialog>Dialog4
   Caption=Warning2
   Width=277
   Height=209
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Image=C:\2.bmp,0,-8,273,193,msImage6,1
EndDialog>Dialog4
show>Dialog4,
//ResetDialogAction>Dialog4

label>start

goto>start

That will prevent your errors, are you trying to pull up the dialogs repeatedly or just once per dialog on your initial run?
Hope this helps
-J
Last edited by sarver311 on Thu Jan 28, 2010 12:05 am, edited 1 time in total.

koleviko
Junior Coder
Posts: 45
Joined: Thu Nov 20, 2008 2:59 pm

Post by koleviko » Wed Jan 27, 2010 10:26 pm

First problem î.ê. 8)


Second NOT :x


Only one "Dialog" you can have in a script????
I made "5 - Dialog - Pictures" I want to show my paintings in a task.
Script displays them once, then gives an error. ???


Code: Select all


Dialog>Dialog3
   Caption=Warning
   Width=277
   Height=209
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Button=User Name,8,88,73,33,6
   CheckBox=Box1,Save,160,24,17,False
   Image=C:\1.bmp,0,-8,273,193,msImage6,1
EndDialog>Dialog3

show>Dialog3


label>start
GetDialogAction>Dialog3,r

if>r=6,program

goto>start

srt>program
if>Dialog3.Box1=True,,fin1


Dialog>Dialog4
   Caption=Warning2
   Width=277
   Height=209
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Image=C:\2.bmp,0,-8,273,193,msImage6,1
EndDialog>Dialog4
show>Dialog4

label>fin1
ResetDialogAction>Dialog3
end>program



goto>start


Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Jan 27, 2010 11:17 pm

koleviko: The problem with your OS code is the spaces. This does work:

Code: Select all

let>a=os_ver
MessageModal>a

koleviko
Junior Coder
Posts: 45
Joined: Thu Nov 20, 2008 2:59 pm

Post by koleviko » Thu Jan 28, 2010 12:05 am

This works !

Code: Select all


RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows NT\CurrentVersion,ProductName,osname
Messagemodal> %osname% %CRLF%  %os_ver%

[/quote]


I'm interested in the second problem with more than one "Dialogs" in the script???
:shock: :shock: :( :shock: :shock:

sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Thu Jan 28, 2010 12:55 am

Im glad that works for you.

In regards to your second issue can you elaborate more on what you are trying to do? Are you trying to load both dialogs at once? Load them after a certain button is clicked? In a certain sequence when the script first starts?

Thanks
-Josh

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jan 28, 2010 9:43 am

Macro Scheduler already has a system variable called OS_VER.

So:

MessageModal>OS_VER

You can see it in the watch list when you use the debugger.

You can have as many dialogs as you like but do NOT put Dialog blocks inside loops. Dialog blocks *CREATE* dialogs. You only need to create a dialog once. You can SHOW it as many times as you like once it is created but if you try to create a dialog which has already been created (i.e. has the same name as one you've already created) you will get an error.

So don't put dialog blocks inside loops.

If you need to change values you can use Get/ResetDialogAction inside your loop and you can Show and Close dialogs as many times as you like inside your loops.

Just don't try and create the same dialog more than once.

What I do is I always put my Dialog blocks at the VERY TOP of the script outside of any loops.

Then further down I will have my action loops which act on those dialogs.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

koleviko
Junior Coder
Posts: 45
Joined: Thu Nov 20, 2008 2:59 pm

Post by koleviko » Thu Jan 28, 2010 1:15 pm

Great !!! :P


So "Dialogs" already working! :) :) :)

Code: Select all


Dialog>Dialog3
   Caption=Warning
   Width=277
   Height=209
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Button=User Name,8,88,73,33,6
   CheckBox=Box1,Save,160,24,17,False
   Image=C:\1.bmp,0,-8,273,193,msImage6,1
EndDialog>Dialog3


Dialog>Dialog4
   Caption=Warning2
   Width=277
   Height=209
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Image=C:\2.bmp,0,-8,273,193,msImage6,1
EndDialog>Dialog4

show>Dialog3


label>start
GetDialogAction>Dialog3,r

if>r=6,program

goto>start

srt>program
if>Dialog3.Box1=True,,fin1



show>Dialog4

label>fin1
ResetDialogAction>Dialog3
end>program



goto>start

[/quote]


8)

sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Tue Feb 02, 2010 7:00 pm

Glad to hear it Koleviko! :D

koleviko
Junior Coder
Posts: 45
Joined: Thu Nov 20, 2008 2:59 pm

Re: Two problems

Post by koleviko » Tue Feb 16, 2010 6:52 pm

Àgain First.

If operating system is Windows Vista (TM) Ultimate or Windows Vista Home Premium or Windows 7 - do something.


If the system is Windows XP - do something else.



Code: Select all

 
//My system is :  Windows 7 Ultimate

RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows NT\CurrentVersion,ProductName,osname
let>a=Windows 7 Home Premium
let>b=Windows Vista (TM) Ultimate
let>c=Windows 7 Ultimate
let>d=Windows Vista Home Premium
let>r=%a% %b% %c% %d%

If>osname=r,,finish
MessageModal>yes system Found

label>finish
MessageModal> You do not use the systems listed

[/quote]

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Tue Feb 16, 2010 7:56 pm

There are many ways you can do this. Here's one of them:

Code: Select all

RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows NT\CurrentVersion,ProductName,osname
let>a=Windows 7 Home Premium
let>b=Windows Vista (TM) Ultimate
let>c=Windows 7 Ultimate
let>d=Windows Vista Home Premium
let>list=%a% %b% %c% %d%

Pos>%osname%,%list%,1,isinlist,
IF>%isinlist%>0
  MessageModal>System Found %osname%
ELSE>
  MessageModal>%osname% is not a listed system
ENDIF
Position will search for osname in the variable list
If it does not find osname in list it will return a ZERO to isinlist
If it finds osname in list it will return an integer value that is the index of the first character of osname within isinlist (in other words a number greater than 0)
Phil Pendlebury - Linktree

koleviko
Junior Coder
Posts: 45
Joined: Thu Nov 20, 2008 2:59 pm

Post by koleviko » Tue Feb 16, 2010 8:21 pm

Thanks :D .


I never used the 'POS' and not even know that there . :shock:

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Tue Feb 16, 2010 9:02 pm

koleviko wrote:Thanks :D .
I never used the 'POS' and not even know that there . :shock:
You're welcome.

Neither have I, I just looked for string commands and figured that as I am just a beginner at regex I would stick to something simple.

The manual is often your friend.
Phil Pendlebury - Linktree

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Feb 16, 2010 11:32 pm

If operating system is Windows Vista (TM) Ultimate or Windows Vista Home Premium or Windows 7 - do something.

If the system is Windows XP - do something else.
I have no OSs greater than XP to test this on but from the information an THIS MICROSOFT SITE and from the looks of the output of the Macro Scheduler system variable "OS_VER", it would seem that this might work. Perhaps someone with Vista and Win7 could test it and report back.

Code: Select all

Separate>os_ver,.,val

If>val_2>5
  ///Do non XP things
  MDL>Version is greater than XP
Else
  ///Do XP things
  MDL>Version is Win 2000, XP or Server 2003
EndIf

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Feb 17, 2010 1:38 am

That works, the Vista I tried returns:

NT.6.0.6002

and my 7's return

NT.6.1.7600

The last 4 are the build number, more info in this wiki page.

Unfortunately you'll see from that wiki page that the data from OS_VER is not as useful as that from the reg since there can be a number of what you or I would think are different OS's with the same OS_VER, e.g. Vista Home Basic and Itanium Windows Server 2008.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts