AutoHotkey Community

It is currently May 25th, 2012, 7:28 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: September 10th, 2007, 7:59 pm 
Online
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8662
Location: Salem, MA
you need to move the buttons on the gui a bit, but TESTED

Code:
;
; Get list of installed printers
;
list := GetInstalledPrinters()
;
; Prompt for default printer
;
;msgbox, % list
Gui, Add, Text, ,Choose new default printer
Gui, Add, DDL, w300 vNewDefault, %list%
Gui, Add, Button, , Save
Gui, Add, Button, , Cancel
gui, show
return



ButtonSave:
Gui, Submit
SetDefaultPrinter(NewDefault)
Msgbox, %NewDefault% is now your default printer
;falls through to exitapp

ButtonCancel:
GuiClose:
exitapp

;Functions
SetDefaultPrinter(sPrinter)
{     
         DllCall(A_WinDir . "\system\winspool.drv\SetDefaultPrinterA", "str", sPrinter)
}

GetInstalledPrinters(Delimiter="|",Default=True)
{
   if (Default = True)
   {
      regread,defaultPrinter,HKCU,Software\Microsoft\Windows NT\CurrentVersion\Windows,device
      stringsplit,defaultName,defaultPrinter,`,
      defaultName := defaultName1
      printerlist =
      loop,HKCU,Software\Microsoft\Windows NT\CurrentVersion\devices
      {
         if (A_LoopRegName = defaultname)
           printerlist = %printerlist%%A_loopRegName%%Delimiter%%Delimiter%
         else
           printerlist = %printerlist%%A_loopRegName%%Delimiter%
      }
   }
   else
   {
      printerlist =
      loop,HKCU,Software\Microsoft\Windows NT\CurrentVersion\devices
      {
         printerlist = %printerlist%%A_loopRegName%%Delimiter%
      }
   }
   StringTrimRight, printerlist, printerlist, StrLen(Delimiter)
   return %printerlist%
}
return


you already returned the list in the exact right format for the Dropdownlist.

Also - no temp files!

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2007, 8:38 pm 
Offline

Joined: June 9th, 2005, 3:35 am
Posts: 29
Location: Clearwater, Florida
engunneer wrote:
you need to move the buttons on the gui a bit, but TESTED


you already returned the list in the exact right format for the Dropdownlist.

Also - no temp files!


Thanks a million! That'll help get me started in my knowledge of GUI. I look forward to playing with radio buttons too. Is the list in the right format for use with radio buttons? If so, at least I wont run into that roadblock.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2007, 8:55 pm 
Online
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8662
Location: Salem, MA
Dave Campbell wrote:
Is the list in the right format for use with radio buttons? If so, at least I wont run into that roadblock.


No. You will have to parse the loop to make the buttons.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: spg SCOTT and 7 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