Sign in to follow this  
Followers 0
Pieter

Wrong Dialog Shows Up

2 posts in this topic

For some reason, the Insert filename dialog shows up when I press ALT+SHIFT+D instead of the Add a new wallpaper dialog. I don't know why. Can somebody tell me?

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        Pieter De Decker
;
; Script Function:
;   Adds wallpapers to the Wallpaper directory of Wallpaper Manager
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GuiConstants.au3>
Break(0)
#NoTrayIcon
Opt("GUIOnEventMode", 1)
HotKeySet("!+d", "AddWP")
HotKeySet("!+x", "ExitWPD")
; Generate Add window
GuiCreate("Add a new wallpaper", 371, 124,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
    GUISetOnEvent($GUI_EVENT_CLOSE, "CancelAddWP")
$PhotoDownloadURL = GuiCtrlCreateInput("http://", 10, 50, 350, 20)
$Introtext = GuiCtrlCreateLabel("Please enter the URL of the wallpaper that you want to add.", 10, 10, 340, 30)
$Btn_OK = GuiCtrlCreateButton("Download", 10, 90, 170, 30)
    GUICtrlSetOnEvent( $Btn_OK, "Downloader")
$Btn_Cancel = GuiCtrlCreateButton("Cancel", 190, 90, 170, 30)
    GUICtrlSetOnEvent( $Btn_Cancel, "CancelAddWP")
GUISetState(@SW_HIDE, "Add a new wallpaper")

; Generate Filename window
GuiCreate("Insert filename", 371, 124,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
    GUISetOnEvent($GUI_EVENT_CLOSE, "CancelAddWP")
$FileName = GuiCtrlCreateInput("", 10, 50, 350, 20)
$Introtext2 = GuiCtrlCreateLabel("Please enter a filename.", 10, 10, 340, 30)
$Btn_OK2 = GuiCtrlCreateButton("Save", 10, 90, 170, 30)
    GUICtrlSetOnEvent($Btn_OK, "HideFilenameWindow")    
$Btn_Cancel2 = GuiCtrlCreateButton("Cancel", 190, 90, 170, 30)
    GUICtrlSetOnEvent($Btn_Cancel, "CancelAddWP")

; Hide both windows
GUISetState( @SW_HIDE, "Add a new wallpaper")
GUISetState( @SW_HIDE, "Insert filename")   

IdleMode()

; Wait, that's all you have to do...
Func IdleMode()
    While 1
    ; endless waiting loop
        Sleep(500)              ; some sleep to be sure not to overload the machine
    WEnd
EndFunc

; Time for some action, user requested to add a new wallpaper
Func AddWP()
    GuiSetState( @SW_SHOW, "Add a new wallpaper")
    $clipbrdstring = ClipGet()
    If StringInStr($clipbrdstring, "http://") = 1 And StringInStr($clipbrdstring, ".jpg") = 1 Or StringInStr($clipbrdstring, ".bmp") = 1 Or StringInStr($clipbrdstring, ".gif") = 1 Then
        GUICtrlSetData( $PhotoDownloadURL, $clipbrdstring)
    EndIf
EndFunc

; We're ready to start the download
Func Downloader()
    GUISetState( @SW_HIDE, "Add a new wallpaper")
    Opt("TrayIconHide", 0)
    $PhotoDownloadURL_Text = GUICtrlRead($PhotoDownloadURL)
    $PhotoFilenamePos = StringInStr($PhotoDownloadURL_Text, "/", 0, -1)
    $PhotoFilenamePos = $PhotoFileNamePos + 1
    $PhotoFilename = StringMid($PhotoDownloadURL_Text, $PhotoFilenamePos)
    GUICtrlSetData($FileName, $PhotoFilename)
    GUISetState( @SW_SHOW, "Insert filename")
    TrayTip("Wallpaper Manager", "Downloading new wallpaper...", 5, 1)
    InetGet(GUICtrlRead($PhotoDownloadURL), @ScriptDir & "\Wallpapers\" & $PhotoFilename, 0, 0)
    TrayTip("Wallpaper Manager", "Download complete.", 5, 1)
    Sleep(5000)
    Opt("TrayIconHide", 1)
EndFunc

; Run this after running the file name dialog thingy
Func HideFilenameWindow()
    GUISetState( @SW_HIDE, "Insert filename")
EndFunc

; Run this when users cancels the add process
Func CancelAddWP()
    GUISetState( @SW_HIDE, "Add a new wallpaper")
    GUISetState( @SW_HIDE, "Insert filename")
    IdleMode()
EndFunc

; Simple hotkey definition to quit
Func ExitWPD()
    Exit
EndFunc


iPod + Online calendars = iPodCALsync

Share this post


Link to post
Share on other sites



look at the guicreate lines and the guisetstate lines:

remove IdleMode where not needed.

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        Pieter De Decker
;
; Script Function:
;   Adds wallpapers to the Wallpaper directory of Wallpaper Manager
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GuiConstants.au3>
Break(0)
#NoTrayIcon
Opt("GUIOnEventMode", 1)
HotKeySet("!+d", "AddWP")
HotKeySet("!+x", "ExitWPD")
; Generate Add window
$GUI_ADD = GUICreate("Add a new wallpaper", 371, 124, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)); Assign handle to var.
$PhotoDownloadURL = GUICtrlCreateInput("http://", 10, 50, 350, 20)
$Introtext = GUICtrlCreateLabel("Please enter the URL of the wallpaper that you want to add.", 10, 10, 340, 30)
$Btn_OK = GUICtrlCreateButton("Download", 10, 90, 170, 30)
$Btn_Cancel = GUICtrlCreateButton("Cancel", 190, 90, 170, 30)
GUISetState(@SW_HIDE, "Add a new wallpaper")

; Generate Filename window
$GUI_INSERT = GUICreate("Insert filename", 371, 124, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) ; Assign handle to var.
$FileName = GUICtrlCreateInput("", 10, 50, 350, 20)
$Introtext2 = GUICtrlCreateLabel("Please enter a filename.", 10, 10, 340, 30)
$Btn_OK2 = GUICtrlCreateButton("Save", 10, 90, 170, 30)
$Btn_Cancel2 = GUICtrlCreateButton("Cancel", 190, 90, 170, 30)

GUISetOnEvent($GUI_EVENT_CLOSE, "CancelAddWP")
GUICtrlSetOnEvent($Btn_OK, "Downloader")
GUICtrlSetOnEvent($Btn_Cancel, "CancelAddWP")
GUICtrlSetOnEvent($Btn_OK2, "HideFilenameWindow")
GUICtrlSetOnEvent($Btn_Cancel2, "CancelAddWP")

; Hide both windows
GUISetState(@SW_HIDE, $GUI_ADD); use the handle
GUISetState(@SW_HIDE, $GUI_INSERT); use the handle

IdleMode()

; Wait, that's all you have to do...
Func IdleMode()
    While 1
    ; endless waiting loop
        Sleep(500)             ; some sleep to be sure not to overload the machine
    WEnd
EndFunc  ;==>IdleMode

; Time for some action, user requested to add a new wallpaper
Func AddWP()
    GUISetState(@SW_SHOW, $GUI_ADD); use the handle
    $clipbrdstring = ClipGet()
    If StringInStr($clipbrdstring, "http://") = 1 And StringInStr($clipbrdstring, ".jpg") = 1 Or StringInStr($clipbrdstring, ".bmp") = 1 Or StringInStr($clipbrdstring, ".gif") = 1 Then
        GUICtrlSetData($PhotoDownloadURL, $clipbrdstring)
    EndIf
EndFunc  ;==>AddWP

; We're ready to start the download
Func Downloader()
    GUISetState(@SW_HIDE, $GUI_ADD)
    Opt("TrayIconHide", 0)
    $PhotoDownloadURL_Text = GUICtrlRead($PhotoDownloadURL)
    $PhotoFilenamePos = StringInStr($PhotoDownloadURL_Text, "/", 0, -1)
    $PhotoFilenamePos = $PhotoFilenamePos + 1
    $PhotoFilename = StringMid($PhotoDownloadURL_Text, $PhotoFilenamePos)
    GUICtrlSetData($FileName, $PhotoFilename)
    GUISetState(@SW_SHOW, $GUI_INSERT)
    TrayTip("Wallpaper Manager", "Downloading new wallpaper...", 5, 1)
    InetGet(GUICtrlRead($PhotoDownloadURL), @ScriptDir & "\Wallpapers\" & $PhotoFilename, 0, 0)
    TrayTip("Wallpaper Manager", "Download complete.", 5, 1)
    Sleep(5000)
    Opt("TrayIconHide", 1)
EndFunc  ;==>Downloader

; Run this after running the file name dialog thingy
Func HideFilenameWindow()
    GUISetState(@SW_HIDE, $GUI_ADD); use the handle
    GUISetState(@SW_HIDE, $GUI_INSERT); use the handle
EndFunc  ;==>HideFilenameWindow

; Run this when users cancels the add process
Func CancelAddWP()
    GUISetState(@SW_HIDE, $GUI_ADD); use the handle
    GUISetState(@SW_HIDE, $GUI_INSERT); use the handle
EndFunc  ;==>CancelAddWP

; Simple hotkey definition to quit
Func ExitWPD()
    Exit
EndFunc  ;==>ExitWPD

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0