AutoHotkey Community

It is currently May 27th, 2012, 8:12 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: SetWallpaper in AHK_L
PostPosted: January 9th, 2012, 11:48 pm 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
As of the last few hours, I have started the move to AHK_L from AHK basic. Please bear with me if the following sounds noobish but I am quite unfamiliar with COM being of a non programming background.
I believe the problem is with the unicode4ansi line but after banging my head at my desk for quite a while, I decided to finally ask for help.:oops:
Sean's code for AHK basic works fine using COM_Unicode4Ansi
I don't know why the following function won't work:

Code:
SetWallpaper(sFile, sOpt) {
   ;sFile := "wallpaper_name"
   ;sOpt  := "STRETCH"
   WPSTYLE_CENTER  := 0
   WPSTYLE_TILE    := 1
   WPSTYLE_STRETCH := 2
   WPSTYLE_MAX     := 3
   CLSID := "{75048700-EF1F-11D0-9888-006097DEACF9}"
   IID := "{F490EB00-1240-11D1-9888-006097DEACF9}"
   pad := ComObjCreate(CLSID, IID)
   DllCall(NumGet(NumGet(1*pad)+28), "Uint", pad, "int64P", WPSTYLE_%sOpt%<<32|8, "Uint", 0)      ; SetWallpaperOptions
   DllCall(NumGet(NumGet(1*pad)+20), "Uint", pad, "Uint", Unicode4Ansi(wFile,sFile), "Uint", 0)      ; SetWallpaper
   DllCall(NumGet(NumGet(1*pad)+12), "Uint", pad, "Uint", 7)   
}


Unicode4Ansi(ByRef wString, sString)
{
   nSize := DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
   VarSetCapacity(wString, nSize * 2)
   DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize)
   Return   &wString
}



Last edited by ..:: Free Radical ::.. on January 10th, 2012, 12:00 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2012, 11:59 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Because. :wink:

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2012, 12:00 am 
i'm not shure if the old COM-Wrapper still works in AHK_L but,
on AHK_L Unicode you don't need a Unicode4Ansi-function, all strings are Unicode already.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2012, 12:07 am 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
nimda wrote:


Thank you for the quick replies. How can I modify the above function?
:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2012, 12:10 am 
you don't need it, throw it out.
just pass the filename as it is.
Code:
 DllCall(NumGet(NumGet(1*pad)+20), "Uint", pad, "Uint", sFile, "Uint", 0)      ; SetWallpaper


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2012, 12:12 am 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
Already tried it before you posted.
That doesn't work either :(
On AHK_L Unicode / XP 32 bit


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2012, 7:41 am 
Doesn't work here either, despite updating for -L. Could the CLSID folders be wrong on some machines? I tried running them from the start menu and got "windows cannot find..." errors. Maybe that's it?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2012, 1:59 pm 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
The CLSIDs are the same as Sean's script. Using this for years on AHK Basic :cry:

Here's Sean's function for COM stdlib with AHK basic for comparison:
SetWallpaper


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, migz99 and 68 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group