AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting Display setting from computer with AHK???
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
newpie



Joined: 16 Nov 2007
Posts: 101

PostPosted: Sat Nov 17, 2007 3:43 am    Post subject: Getting Display setting from computer with AHK??? Reply with quote

Hello, I have an interesting problem. I have 2 very long scripts. One for one setting on a display Lets say 1280 X 720 and another for 1280 x800.

These scripts will be run on multiple computers where I don't know what setting they have.

How could I combine my two scripts and make it choose the correct one?

Is there a way that I can access the display settings to let me know which one to pick somehow?

Perhaps a third script to find out what they are running and then it can run the appropriate script and shut itself down when it's done?

If it was one script perhaps I could use some commands like GoSub to a label, one label for each script.

Any help would be appreciated. Thanks
Back to top
View user's profile Send private message
aCkRiTe



Joined: 21 Jul 2006
Posts: 502

PostPosted: Sat Nov 17, 2007 4:05 am    Post subject: Reply with quote

take a look at A_ScreenWidth and A_ScreenHeight variables. Also SysGet
_________________

HTH...



Last edited by aCkRiTe on Sat Nov 17, 2007 4:08 am; edited 1 time in total
Back to top
View user's profile Send private message
Murp|e



Joined: 12 Jan 2007
Posts: 240
Location: Norway

PostPosted: Sat Nov 17, 2007 4:07 am    Post subject: Reply with quote

Use the default variables %A_ScreenWidth% and %A_ScreenHeight%. So something like this:
Code:

if A_ScreenWidth = 1280 AND A_ScreenHeight = 720
 Gosub, Script720
elseif A_ScreenWidth = 1280 AND A_ScreenHeight = 800
Gosub, Script800
else
msgbox, Incompatible screen resolution.


The above won't work "out of the box", but it should get you started.
Back to top
View user's profile Send private message Visit poster's website
newpie



Joined: 16 Nov 2007
Posts: 101

PostPosted: Sat Nov 17, 2007 5:52 am    Post subject: Reply with quote

Thanks, for the tips.

Murple, I assume the script you wrote is basically the idea that I would be writing a third script and just have it run which script which is appropriate OR is it possible to put your script
Code:


if A_ScreenWidth = 1280 AND A_ScreenHeight = 720
 Gosub, Script720
elseif A_ScreenWidth = 1280 AND A_ScreenHeight = 800
Gosub, Script800
else
msgbox, Incompatible screen resolution.


in one very long script and have it go to the labels specified.

I of course would rather have a very long script, but it most likely doesn't matter. If it is a long script I guess I would run into the problem of duplicate hotkey errors, is this correct , or is there a way around that.

Thanks again.
Back to top
View user's profile Send private message
Murp|e



Joined: 12 Jan 2007
Posts: 240
Location: Norway

PostPosted: Sat Nov 17, 2007 2:12 pm    Post subject: Reply with quote

You can paste everything into one long script. Don't know what you mean with duplicate errors, but you don't want to have any errors in your code -duplicate or not.

Happy coding.
Back to top
View user's profile Send private message Visit poster's website
newpie



Joined: 16 Nov 2007
Posts: 101

PostPosted: Sun Nov 18, 2007 3:26 am    Post subject: Reply with quote

Thanks Murple, what I meant with duplicate errors is when you have two hotkeys that are exactly the same: like

Code:

F1:: send, works
F1:: send, doesn't work


It will return a dupicate hotkey error. I will try and work on my long script to try and get it working. I will write if I have any problems.
Thanks again.
Back to top
View user's profile Send private message
newpie



Joined: 16 Nov 2007
Posts: 101

PostPosted: Sun Nov 18, 2007 9:15 pm    Post subject: Reply with quote

Hello, I was wondeirng how I get around the duplicate hotkey error when I run both of the scripts together using the previous code.

For example:
One script has F1:: does a fucntion
Second script has F1:: does a function

I though maybe the
{
} would help, but it doesn't.

Any help is appreciated. Thanks
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1213
Location: USA

PostPosted: Sun Nov 18, 2007 9:28 pm    Post subject: Reply with quote

remove one of them.
_________________
Back to top
View user's profile Send private message
newpie



Joined: 16 Nov 2007
Posts: 101

PostPosted: Sun Nov 18, 2007 9:40 pm    Post subject: Reply with quote

So I am assumming if I am not able to remove one of them, then essentialy I can't have one long script, I will have to have a third script to determine which of the other two scripts need to be used for the correct display setting. Is this correct?
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1213
Location: USA

PostPosted: Mon Nov 19, 2007 12:04 am    Post subject: Reply with quote

post your scripts we can help.
_________________
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Mon Nov 19, 2007 12:46 am    Post subject: Reply with quote

Since you are deciding which (sub)script to run, I assume you don't want both of the hotkeys to work at the same time. Use something like this:
Code:
; auto-execute section:
; if script 1 is to be used
Hotkey, F1, script1_F1, On
; else
Hotkey, F1, script2_F1, On

;...
script1_F1:
  ; function
return

script2_F1:
  ; function
return
Back to top
View user's profile Send private message
newpie



Joined: 16 Nov 2007
Posts: 101

PostPosted: Mon Nov 19, 2007 2:10 am    Post subject: Reply with quote

Thank you, I will try and use this script lexikos. The reason why I need to run two different scripts with the same hotkey is because I am using ImageSearch and of course this depends on the display setting.
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Mon Nov 19, 2007 2:11 am    Post subject: Reply with quote

why not make the imagesearch line smart enough to detect resolution?
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
newpie



Joined: 16 Nov 2007
Posts: 101

PostPosted: Mon Nov 19, 2007 2:54 am    Post subject: Reply with quote

So engunneer, I should do an if else statement then? I wish I thought of that, thanks. I will try. Using something similar to this:

Code:

if A_ScreenWidth = 1680
{
  Gosub, Script400

}
else
Gosub, Script1600

SCRIPT1600:

if A_ScreenWidth = 1600
{
    MsgBox,,User Error, THIS IS GOOD 1600
    return
}
else
msgbox, yOU HAVE THE WRONG SETTING, pLEASE CHANGE AND RESTART
RETURN


Script400:

{
F1::
send
    MsgBox,,User Error, THIS IS GOOD 1600
    return
}


I guess I was making much harder than it has to be.
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Mon Nov 19, 2007 2:56 am    Post subject: Reply with quote

that is still harder..


show me your two imagesearch lines as they are now.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group