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 

command line parameter not working with DllCall

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
rejetto



Joined: 05 May 2008
Posts: 5
Location: Roma, Italy

PostPosted: Mon May 05, 2008 12:37 am    Post subject: command line parameter not working with DllCall Reply with quote

hello, i discovered this wonderful tool some minutes ago, and i'd like to start with a big "thank you" for it. Very Happy

I hope my request is not annoying, i searched for an existing solution before asking.

I'm tring this simple script, meant to change mouse speed, found after a quick search.
DllCall("SystemParametersInfo", Int,113, Int,0, UInt,%1%, Int,2)

as you can see, i put the %1% to let me change the speed at command line.

It just doesn't work: mouse speed is not affected.
It works if i put a constant value, like 5.
What's wrong with it?

Thank you in advance
Back to top
View user's profile Send private message
sinkfaze



Joined: 19 Mar 2008
Posts: 138

PostPosted: Mon May 05, 2008 12:53 am    Post subject: Reply with quote

This post might be of some assistance.
Back to top
View user's profile Send private message
Lexikos



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

PostPosted: Mon May 05, 2008 5:24 am    Post subject: Reply with quote

In expressions, only double-references are enclosed in percent signs. For instance, if the first command-line arg is "20", %1% in an expression refers to a variable named "20", which is likely to be empty.

Variables with purely numeric names can't be accessed directly by an expression. Instead, use a double-reference or copy the value to another variable:
Code:
1 = first parameter

a = %1%
b = 1

MsgBox % a . "`n" . %b%
Back to top
View user's profile Send private message
rejetto



Joined: 05 May 2008
Posts: 5
Location: Roma, Italy

PostPosted: Mon May 05, 2008 10:41 am    Post subject: Reply with quote

That solved my problem, thank you!

I post here the solution for those with my same problem and hitting this thread while searching

Code:

a = %1%
DllCall("SystemParametersInfo", Int,113, Int,0, UInt,a, Int,2)
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3958
Location: Pittsburgh

PostPosted: Mon May 05, 2008 5:24 pm    Post subject: Reply with quote

Lexikos wrote:
use a double-reference
How?
Back to top
View user's profile Send private message
Lexikos



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

PostPosted: Mon May 05, 2008 9:48 pm    Post subject: Reply with quote

Code:
a = 1
DllCall("SystemParametersInfo", Int,113, Int,0, UInt,%a%, Int,2)
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3958
Location: Pittsburgh

PostPosted: Mon May 05, 2008 9:57 pm    Post subject: Reply with quote

Which method is better?
Maybe we should include in our scripts something like
Code:
zero:=0, one:=1, two:=2 ;...
When a command line parameter is needed, we can just write %one%, assuming %zero% > 0.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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