AFrenchCroissant Posted May 4, 2022 Posted May 4, 2022 Hello everyone Today i got back to making simple (and slow) AutoIT scripts, but as always, i find a problem that i can't really seem to resolve by myself, and would like someone more talented than me to help me. So here is the problem: I'm trying to get a date that the user put in a DateBox (i don't really know the name of this thing, but it's created by using GUICtrlCreateDate), in a specific format (yyyyMMdd, WITHOUT THE SLASH). I tried using the GuiCtrlSendMsg but it only works one time... I am out of ideas so here is the script expandcollapse popup#include <GuiConstantsEx.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") Global $LABEL, $EDIT, $ARCHIVE, $VIEW, $DATE, $iMsg, $sData, $Website, $Style, $Date ; Create the GUI window and controls GUICreate("WayBack Machine Archiver", 350, 200, (@DesktopWidth - 350) / 2, (@DesktopHeight - 200) / 2) $DATE = GUICtrlCreateDate("", 225, 13, 100, 20, $DTS_SHORTDATEFORMAT) $LABEL = GUICtrlCreateLabel("Enter Website URL in the feild below", 30, 15, 300, 45) $EDIT = GUICtrlCreateEdit("www.example.com", 30, 60, 300, 21, $ES_NOHIDESEL) $ARCHIVE = GUICtrlCreateButton("Archive Website", 200, 95, 120, 30) $VIEW = GUICtrlCreateButton("View Archive", 37, 95, 125, 30) GUICtrlSendMsg($DATE, $DTM_SETFORMATW, 1, "yyyyMMdd") ; Run the GUI until it is closed GUISetState() While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE ExitLoop ;When button is pressed, label text is changed ;to combobox value Case $iMsg = $ARCHIVE $Website = GUICtrlRead($EDIT) GUICtrlSetData($LABEL, "Archiving Website : " & $Website & "...") $oHTTP.Open("GET", "https://web.archive.org/save/" & $Website) $oHTTP.Send() $oReceived = $oHTTP.ResponseText if @error Then MsgBox(0,"error", ":(") EndIf $oStatusCode = $oHTTP.Status if @error Then MsgBox(0,"error", ":(") EndIf If Not $oStatusCode == 200 Then ;~ MsgBox (0, "Archiving failed !", "Archiving failed, I don't know much more...") Else ShellExecute("https://web.archive.org/web/" & $Website) GUICtrlSetData($LABEL, "Done !") EndIf Case $iMsg = $VIEW $Website = GUICtrlRead($EDIT) $Date = GUICtrlRead($DATE) ShellExecute ("https://web.archive.org/web/" & $Date & "/" & $Website ) ;~ Case $iMsg = $DATE ;~ $Website = GUICtrlRead($EDIT) ;~ $Date = GUICtrlRead($DATE) ;NOT WORKING :(( EndSelect WEnd Thanks again ! 😀 Â
Solution Musashi Posted May 4, 2022 Solution Posted May 4, 2022 I just skimmed the script (time for me to go to bed 😴) , but one point caught my eye. You use the variables $DATE (for the controlID) and $Date (for the date). Since AutoIt is not case sensitive on variable names, this can cause problems. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
AFrenchCroissant Posted May 5, 2022 Author Posted May 5, 2022 Thanks ! I didn't AutoIT wasn't case sensitive
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now