winJade: How to programmatically add a gadget - winJade

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to programmatically add a gadget Rate Topic: -----

#1 User is offline   Jon Abbott Icon

  • Forum Guru
  • PipPipPipPipPip
  • Group: Expert
  • Posts: 772
  • Joined: 06-July 06
  • I'm running:Vista Ultimate 64-bit SP2

Posted 10 August 2006 - 10:22 PM

AddGadget.exe is attached, simply run it using the full path/filename of the gadget.

How does it work
It runs the .gadget file, waits for the security prompt to appear and then clicks the Install button.
To get around the user clicking away, it repeatedly makes the security dialogue the active window until it's been closed.
If the window isn't found after 5 seconds, it will quit.

It's compiled with AutoIt, the complete code is as follows:

AutoItSetOption("TrayIconHide", 1)

If $CmdLine[0]=0 or $CmdLine[1]="/?" Then
	MsgBox(0, "AddGadget", "Usage: AddGadget ""<path>\<.gadget file>""" & @CR & "   eg: AddGadget ""c:\temp\Clock.gadget""")
	Exit
EndIf

Run("rundll32.exe shell32.dll,ShellExec_RunDLL """ & $CmdLine[1] & """")

While WinWait("Install Gadget - Security Warning", "", 5) = 1
	WinActivate("Install Gadget - Security Warning")
	Send("{LEFT} ")
WEnd

Attached File(s)


0

#2 User is offline   Stanimir Stoyanov Icon

  • Administrator
  • PipPipPipPipPip
  • Group: Administrator
  • Posts: 1,101
  • Joined: 08-May 04
  • Gender:Male
  • I'm running:Build 6000.

Posted 10 August 2006 - 10:38 PM

The application is interesting, but you might want to reconsider the approach to wait for the window and manipulate it. If the window title changes in future builds or users run a localized build of Windows Vista, the script is likely to enter an endless loop even though it will let users 'answer' the security prompt on their own.
Stanimir Stoyanov.
AeroXperience | Co-Founder, Senior Administrator | Weblog
0

#3 User is offline   Jon Abbott Icon

  • Forum Guru
  • PipPipPipPipPip
  • Group: Expert
  • Posts: 772
  • Joined: 06-July 06
  • I'm running:Vista Ultimate 64-bit SP2

Posted 10 August 2006 - 10:46 PM

View PostStanimir Stoyanov, on Aug 10 2006, 11:38 PM, said:

The application is interesting, but you might want to reconsider the approach to wait for the window and manipulate it. If the window title changes in future builds or users run a localized build of Windows Vista, the script is likely to enter an endless loop even though it will let users 'answer' the security prompt on their own.

Sorry, I should have said, it will quit after 5 seconds if it doesn't find the window.
0

#4 User is offline   Sean1337 Icon

  • Newbie
  • Pip
  • Group: Member
  • Posts: 5
  • Joined: 01-March 07
  • I'm running:XP media center/vista modded

Posted 04 March 2007 - 12:18 AM

I still don't understand how to use this -_-
0

#5 User is offline   ricktendo64 Icon

  • Advanced Member
  • PipPipPipPip
  • Group: Loyal Member
  • Posts: 250
  • Joined: 27-October 06
  • I'm running:Windows Vista Ultimate x86

Posted 04 March 2007 - 03:03 AM

Thanks works nicely for XP
Posted ImagePosted Image
Posted Image
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image
0

#6 User is offline   AndreasV Icon

  • Advanced Member
  • PipPipPipPip
  • Group: Expert
  • Posts: 133
  • Joined: 19-January 07
  • I'm running:rc1

Posted 04 March 2007 - 02:43 PM

Auto-Clicking security dialogs is a bad idea - why do you think they are there in the first place?
0

#7 User is offline   Karl Icon

  • =Cold As Ice=
  • PipPipPipPipPip
  • Group: Expert
  • Posts: 3,081
  • Joined: 01-August 04
  • Gender:Male
  • Location:London, UK
  • I'm running:on caffeine

Posted 04 March 2007 - 07:33 PM

Quote

Auto-Clicking security dialogs is a bad idea - why do you think they are there in the first place?


QFE - this was my first thought, as well.
Posted Image
Click above to visit my tech blog! | If you like my post, up my reputation.
0

#8 User is offline   Rafael Icon

  • Forum Guru
  • PipPipPipPipPip
  • Group: Member
  • Posts: 1,432
  • Joined: 29-April 05
  • Gender:Male

Posted 07 March 2007 - 05:53 AM

This does show how security prompts are insecure. Randomization of the window class/title should be done to ensure automation isn't possible. A better solution would be for Microsoft to implement a SecureWindow class that prevents people from getting a window handle via Win32 API.
Stephen got a Microsoft janitorial job; Want Windows 7 builds? Too bad, he got fired for stealing toilet paper.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users