Jump to content

jtsteffen

Active Members
  • Posts

    22
  • Joined

  • Last visited

jtsteffen's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. I have been teaching myself how to use the StdoutRead and StdinWrite commands to send and receive text from the plink program. I am trying to automate a script that logs on to a number of IP address. I was successful getting my test system to work, but then when I went to a new IP address, the script locked up. After some troubleshooting, I learned that the plink script was asking me if I wanted to store the key for the new connection (I had already done this for my test connection). If I ran plink from a command window I got this message: "The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is. The server's rsa2 key fingerprint is: ssh-rsa 1040. If you trust this host, enter "y" to add the key to PuTTY's cache and carry on connecting. If you want to carry on connecting just once, without adding the key to the cache, enter "n". If you do not trust this host, press Return to abandon the connection. Store key in cache? (y/n)" I could press "y" from the command window and things would work happily and give me my prompt. However if I delete the key from my computer's registry (HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys) to turn it into an unknown again, the script will not get to my prompt when I run it the next time. I attempted to look use StdoutRead to look for this the warning text and react accordingly, but the StdoutRead never sees the text. I was able to put a Sleep command and then just StdinWrite ("y" & @CR) blindly and it was able to move past the warning text. The problem is, I don't know the quality of my connection and if I don't sleep long enough it may not wait long enough or if I put too long of a sleep, the script wil take to long to run. I want to be able to positively know when I need to send the text and send it only when I have to, when I have to. Does anyone have any idea why I am missing the text? If so could you please give me an idea on how to fix it? I have put some of my code here. It will open a console box and attempt to use plink to connect to a server. If the IP address is already in your host list, the script will take you directly to a prompt ("~ # "). However if it is not, it will just hang, waiting. You need to have plink.exe in the folder you save the program. Set the $vsTestIP, $vsUser, and $vsPW variables at the beginning of the script to the ones you need to use for the test. Any help would be greatly appreciated. #include <Constants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> Local $vsTestIP = "IPADDRESS" Local $vsUser = "USERNAME" Local $vsPW = "PASSWORD" Local $wConsole = GUICreate("SSH Console", 600, 330, 1, 1) Local $hConsoleData = GUICtrlCreateInput ( "", 15, 15 , 570 , 270 , $ES_MULTILINE) Local $bCancel = GUICtrlCreateButton("Cancel", 15, 295, 120, 25) GUISetState(@SW_SHOW, $wConsole) Local $vsDosCommand Local $cLiveStatus Local $vsLine Local $vsLoopData Local $vsConsoleData Local $Msg ; Log on to Unit $vsDosCommand = "plink.exe -ssh " & $vsUser & "@" & $vsTestIP & " -pw " & $vsPW $cLiveStatus = Run(@ComSpec & " /c " & $vsDosCommand, "", @SW_HIDE, $STDOUT_CHILD + $STDIN_CHILD) ; Start Plink.exe ; Wait for Prompt $vsLoopData = "" While Not @error $Msg = GUIGetMsg() If $Msg = $bCancel Or $Msg = $GUI_EVENT_CLOSE Then GUIDelete($hConsoleData) Exit EndIf $vsLine = StdoutRead($cLiveStatus) If $vsLine > "" Then $vsLoopData = $vsLoopData & $vsLine ConsoleWrite("**1 $vsLine = " & @CR & ">" & $vsLine & "<" & @CR & "$vsLoopData = " & @CR & "<" & $vsLoopData & ">" & @CR & @CR) EndIf If StringInStr($vsLoopData, "Store key in cache? (y/n)") Then ; Asking for a key $vsConsoleData = $vsConsoleData & $vsLoopData GUICtrlSetData ($hConsoleData, $vsConsoleData) $vsDosCommand = "y" & @CR ; Accept the key StdinWrite($cLiveStatus, $vsDosCommand) $vsLoopData = "" ElseIf StringRight($vsLoopData, 4) = "~ # " Then ; Got a Prompt $vsConsoleData = $vsConsoleData & $vsLoopData GUICtrlSetData ($hConsoleData, $vsConsoleData) $vsDosCommand = "cd /mnt/nand/0/.extracted/srv/www/timaru/js" & @CR ; Commnand to change folder StdinWrite($cLiveStatus, $vsDosCommand) $vsLoopData = "" MsgBox(0,"Got Prompt", "You Betch Ya") ExitLoop EndIf WEnd
  2. I was able to solve the problem by changing the location of the "_GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints)" command to inside the While WEnd loop as shown below. I am not sure if this is the best way to do this, but the drawing is then redrawn every time the loop is run. This seems like a ineffienct use of the coding, but it does work. If anyone has a better way of doing this, I would like to know. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GDIPlus.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hGUI, $hGraphic, $aPoints[4][2] ; Create GUI $hGUI = GUICreate("GDI+", 400, 300) GUISetState() ; Draw a polygon _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $aPoints[0][0] = 3 $aPoints[1][0] = 150 $aPoints[1][1] = 150 $aPoints[2][0] = 200 $aPoints[2][1] = 100 $aPoints[3][0] = 250 $aPoints[3][1] = 150 MsgBox(4096, "Information", "Fill Polygon") ; Loop until user exits Do _GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints) Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>_Main
  3. I have been playing with the Graphics commands of AutoIt and trying to learn how they work. At this point I am working with _GDIPlus_GraphicsFillPolygon command. I have successfully built the array and made the graphic show up on my window. However I have noticed that if another window opens on top of the one with the graphics or if I move the window manually some place where the graphics is off the screen for a bit, when I move the window with the graphics back to the top and in full view, the graphics are either gone or only partially drawn. Is there any way to keep the graphics displayed on the screen after these events? As for the code, I started with the example code for the _GDIPlus_GraphicsFillPolygon. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GDIPlus.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hGUI, $hGraphic, $aPoints[4][2] ; Create GUI $hGUI = GUICreate("GDI+", 400, 300) GUISetState() ; Draw a polygon _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $aPoints[0][0] = 3 $aPoints[1][0] = 150 $aPoints[1][1] = 150 $aPoints[2][0] = 200 $aPoints[2][1] = 100 $aPoints[3][0] = 250 $aPoints[3][1] = 150 MsgBox(4096, "Information", "Fill Polygon") _GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>_Main To test the problem, you can run that code and then move the window off the screen and then back. The triangle disappears. I've searched the help and the forum, but haven't seen this particular problem discussed. Thanks
  4. Okay, I feel like a moron now. I knew it had to be something easy like that. Thanks for the quick response. I've been banging my head on that one for some time.
  5. Hello I have been trying to get the GUICtrlSetData command to update the text in a Input control and just cannot seem to get it to work. In my troubleshooting, I can get the text to update if I insert theGUICtrlSetData earlier in the code and manually set the value to something, but if I try to do it after returning from a Sub, it will not. I suspect I have to be missing something very easy. I've attached a sample of the code. It looks for a *.db file to load. To use it you would need to create a blank *.db file on your hard drive to find. If anyone can explain why the Input line will not update to the file name after I return from the subroutine, I would be greatly appreciative. Thanks #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <Misc.au3> #include <String.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> ; Important Files to Know Global $vsFold_Reference=@MyDocumentsDir ; My Documents Global $vsFolderName1 ; Path to Folder 1 Global $vsFolderName2 ; Path to Folder 2 Global $vsFileName1 ; Path to File 1 Global $vsFileName2 ; Path to File 2 Global $hFolder1 ; Handle for Folder 1 Global $hFolder2 ; Handle for Folder 2 Global $hFile1 ; Handle for File 1 Global $hFile2 ; Handle for File 2 ; Declare Local Variables ; Button Handles Local $bClose ; Close the Program Local $bDBtoINI ; Convert DBMain.DB to INI file Local $bINItoDB ; Convert INI file to DBMain.db ; Declare GUI Variables Local $wMainWin ; Handle of Window main GUI Local $mFileMenu ; Handle of Menu File Local $iExitItem ; Handle of SubMenu Exit in File Local $mHelpMenu ; Handle of Menu Help Local $mManageINI ; Handle of Menu Manage INI Local $iLoadItem ; Handle of SubMenu Load Local $iSyncIniItem ; Handle of SubMenu for Syncing Data Local $iSplitBaseItem ; Handle of SubMenu for Splitting Base Station Info out of dbmain.db Local $iSplitBaseIniItem ; Handle of SubSubMenu for Splitting INI Base Station Info out of dbmain.ini Local $iSplitBaseDbItem ; Handle of SubSubMenu for Splitting DB Base Staiton Info out of dbmain.db Local $Msg ; Variable handling GUI Control ; Declare Program Variables Local $MsgBoxAns ; Answer to Message Box ; Start the program _Main() Func _Main() ; Create GUI $wMainWin = GUICreate("Test", 500, 300) ; Create Buttons and Check Boxes $bClose = GUICtrlCreateButton("&Close", 390, 140, 90) $bDBtoINI = GUICtrlCreateButton("&DB to INI", 390,15,90,45) $bINItoDB = GUICtrlCreateButton("&INI to DB", 390,75,90,45) ; Create Main GUI Text GUICtrlCreateLabel("File Loaded:", 10, 19, 60, 25) $hFile1 = GUICtrlCreateInput($vsFileName1, 75, 17, 300, 27, $ES_READONLY, $WS_EX_STATICEDGE) GUICtrlCreateLabel("Folder Location:", 10, 62, 60, 25) $hFolder1 = GUICtrlCreateInput($vsFolderName1, 75, 65, 300, 27, $ES_READONLY, $WS_EX_STATICEDGE) ; Create File Menus and Lists $mFileMenu = GUICtrlCreateMenu("File") $iExitItem = GUICtrlCreateMenuItem("Exit", $mFileMenu) $mManageINI = GUICtrlCreateMenu("Manage Database") $iSplitBaseItem = GUICtrlCreateMenu("Split Base Data From", $mManageINI, 1) $iSyncIniItem = GUICtrlCreateMenuItem("Sync Data", $mManageINI, 2) $iSplitBaseIniItem = GUICtrlCreateMenuItem("INI", $iSplitBaseItem) $iSplitBaseDbItem = GUICtrlCreateMenuItem("DB", $iSplitBaseItem) $mHelpMenu = GUICtrlCreateMenu("Help") GUICtrlSetState ($iSyncIniItem, $GUI_DISABLE) GUICtrlSetState ($iSplitBaseIniItem, $GUI_DISABLE) ; Show the GUICreate GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Select Case $Msg = $bClose ; Pressed the close button Exit Case $Msg = $GUI_EVENT_CLOSE ; Corner X pressed Exit Case $Msg = $iSplitBaseDbItem ; Split the Db file into separate files with one Base Station _ClearAllData($wMainWin) GUICtrlSetData($hFile1, $vsFileName1) GUICtrlSetData($hFolder1, StringRight($vsFolderName1,54)) _SelectFile1($wMainWin) GUICtrlSetData($hFile1, $vsFileName1) GUICtrlSetData($hFolder1, StringRight($vsFolderName1,54)) Case $Msg = $iExitItem ; Exit choses from the Main Menu Exit EndSelect Wend EndFunc Func _SelectFile1($wParWin) ; Select the DB1 file to open ; Declare GUI variables Local $vsTempFolder ; Temporary Existing Folder Name ;Start Code $vsTempFolder = FileOpenDialog("Choose the DBMAIN.DB file to Open", $vsFold_Reference, "dbmain.db (*.db)", 1 + 2, "", $wParWin) ; Select desired dbmain.db If @error = 1 Then Return ; If nothing is selected go back to Main Menu ; Extract File and Folder Info $vsFolderName1 = StringLeft($vsTempFolder,(StringInStr($vsTempFolder,"\",0,-1))) ; Get Folder Name from Filename $vsFileName1 = StringRight($vsTempFolder,StringLen($vsTempFolder) - StringInStr($vsTempFolder,"\",0,-1)) ; Get File Name from Filename If StringLower(StringRight($vsTempFolder,3)) <> ".db" Then ; Verify it is a *.db MsgBox(1,"Incorrect File Format",$vsDB1FileName & " is not a valid file to convert. Please make sure the file ends in *.db before attempting to " & _ "Convert it.",0,$wParWin) Return EndIf ; Reassign Reference Folder to current folder If $vsFolderName1 <> "" Then $vsFold_Reference = $vsFolderName1 EndFunc Func _ClearAllData($wParWin) ; clear the data out of the existing variables $vsFolderName1 = "" $vsFolderName2 = "" $vsFileName1 = "" $vsFileName2 = "" $hFolder1 = "" $hFolder2 = "" $hFile1 = "" $hFile2 = "" EndFunc
  6. Good Idea on trying to add it at the end. In this case that would be a okay way to make it work. I would still like to know if anyone has a way to kill it. I did try putting it at the end, but it still added the space. You would think this was an easy thing to fix.
  7. I'm afraid no joy. It is looking like an Outlook thing. It looks like it shows the charage returns as spaces in the message. #include <INet.au3> Dim $viKey[1][5] ; Create Array for Encryption Info $viKey[0][3]="Program Name" $viKey[0][4]="help@abce.com" Local $vsRegLock="ABCDEFGHIJKLMNOPQRST" Local $Message= "Please unlock the program requested in the Subject." & CHR(13) & CHR(13) & $vsRegLock & CHR(13) & CHR(13) & "Thank you." _INetMail($viKey[0][4], "Unlock: " & $viKey[0][3], $Message)
  8. Yep, tried that. It didn't work. I also tried using StringLeft() I suspect it has something to do with adding the @CR in the lines as the first guy mentioned, but I do not know of another way to add a carrage return.
  9. Part of that was actually me trying to get rid of the space. I am using the @CR to end the line and start typing the message on the next line. Do you have a better way of doing this? Two in a row is suppose to give me a blank line between the text.
  10. Hello I've written some code that automatically creates an e-mail for a person to send into our support people with an unlock code. When I create the e-mail everything looks okay except one thing. At the end of each line there is an extra space that gets added. No matter what I do, I keep getting that space. I want the user to be able to double click on the unlock code and only select the characters. However when they double click on the code now, it selects the unlock code but also selects the space at the end of the line. Anyone know what I'm doing wrong and how to fix this. Thanks #include <INet.au3> Dim $viKey[1][5] ; Create Array for Encryption Info $viKey[0][3]="Program Name" $viKey[0][4]="help@abce.com" Local $vsRegLock="ABCDEFGHIJKLMNOPQRST" _INetMail($viKey[0][4], "Unlock: " & $viKey[0][3], "Please unlock the program requested in the Subject" & @CR _ & @CR & StringLeft($vsRegLock, 20) & @CR & @CR & "Thank you.") ; ***
  11. AHHHHH That worked. I take it "-1" does not work any more. Thanks for the quick help.
  12. Here is the complete current script if that would help ; Manages UTM Converter files ; Rev 1.0 February 27, 2010 ; Initial Build ; AutoFarm #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <Misc.au3> _Singleton("UTM Convert") ; Only allow one occurance of this program to Run Opt('MustDeclareVars', 1) ; Declare Global Variables Global $Q=CHR(34) ; Double Quotes Global $Pi=3.14159265358979 ; Value of Pi Global $vsProgramName="AutoFarm UTM to Lat/Long Converter" ; Name of Program Global $vsErrorMessage=0 ; Error Message ; Declare Local Variables ; Program Identification Variables Local $Info_SWVer="1.0" ; Software version Local $Info_SWCre="February 27, 2010" ; Creation date Local $Info_SWUpd="February 27, 2010" ; Update Date ; Button Handles Local $bClose ; Close the Program Local $bUTMtoLL ; Convert UTM to Latitude/Longitude Local $bLLtoUTM ; Convert Latitude/Longitude to UTM ; Declare GUI Variabl Local $wMainWin ; Handle of Window main GUI Local $mFileMenu ; Handle of Menu File Local $msExitItem ; Handle of SubMenu Exit in File Local $mHelpMenu ; Handle of Menu Help Local $msVersion ; Handle of SubMenu Version in Help Local $Msg ; Variable handling GUI Control ; Declare Program Variables Local $vsFold_MyDoc=@MyDocumentsDir ; My Documents Local $MsgBoxAns ; Answer to Message Box ; Start the program _Main() Func _Main() ; Create GUI $wMainWin = GUICreate("UTM to Latitude/Longitude Converter", 800, 300) ; Create Buttons and Check Boxes $bUTMtoLL=GUICtrlCreateButton("UTM to Lat/Long",15 ,247, 120, 25) $bLLtoUTM = GUICtrlCreateButton("Lat/Long to UTM", 150, 247, 120, 25) $bClose = GUICtrlCreateButton("Close", 653, 247, 120, 25) ; Declare GUI Variables Local $hUseDec ; Handle for Use Decimal for Caluclation Button Local $hLatDD ; Handle for Entered Latidude Degrees Local $hLatMM ; Handle for Entered Latitude Minutes Local $hLatSS ; Handle for Entered Latitude Seconds Local $hLatDDME ; Handle for Entered Decimal Degrees Latitude Local $hLLNorth ; Handle for Latitude North Button Local $hLLSouth ; Handle for Latitude South Button Local $hUseDeg ; Handle for Use Degrees for Caluclation Button Local $hLonDD ; Handle for Entered Longitude Degrees Local $hLonMM ; Handle for Entered Longitude Minutes Local $hLonSS ; Handle for Entered Longitude Seconds Local $hLonDDME ; Handle for Entered Decimal Degrees Longitude Local $hLLEast ; Handle for Longitude North Button Local $hLLWest ; Handle for Longitude South Button Local $hUTMZone ; Handle for UTM Zone Local $hUTMCenMed ; Handle for UTM Central Median Local $hNorthing ; Handle for UTM Northing Local $hEasting ; Handle for UTM Easting Local $hUTMNorth ; Handle for UTM North Button Local $hUTMSouth ; Handle for UTM South Button ; Declare Program Variables Local $viLatDD ; Value of Latitude Degrees (Integer) Local $viLatMM ; Value of Latitude Minutes (Integer) Local $vfLatSS ; Value of Latitude Seconds (Floating Point) Local $vfLatDDME ; Value of Latitude Decimal Degrees Entered (Floating Point) Local $vfLatDDCal ; Value of Latitude Decimal Degrees Calculated Local $vsNorth ; Value of Latitude North Holder Local $vsSouth ; Value of Latitude South Holder Local $viLonDD ; Value of Longitude Degrees (Integer) Local $viLonMM ; Value of Longitude Minutes (Integer) Local $vfLonSS ; Value of Longitude Seconds (Floating Point) Local $vfLonDDME ; Value of Longitude Decimal Degrees Entered (Floating Point) Local $vsEast ; Value of Longitude North Holder Local $vsWest ; Value of Longitude South Holder Local $viUTMZone ; Value of UTM Zone (Integer) Local $viUTMCenMed ; Value of UTM Central Meridian (Integer) Local $vfUTMNorthing ; Value of UTM Northing (Floating Point) Local $vfUTMEasting ; Value of UTM Easting (Floating Point) Local $vsUTMNorth ; Value of UTM North Holder Local $vsUTMSouth ; Value of UTM South Holder Local $vTempHolder ; Temporary Value Holder ; Create Borders Around Sections GUICtrlCreateLabel ("", 0, 13, 800, 2, $SS_ETCHEDFRAME) ; Top Line GUICtrlCreateLabel ("", 0, 150, 800, 2, $SS_ETCHEDFRAME) ; Second Line GUICtrlCreateLabel ("", 0, 240, 800, 2, $SS_ETCHEDFRAME) ; Bottom Line GUICtrlCreateLabel ("", 380, 31, 2, 101, $SS_ETCHEDFRAME) ; Top Vertical Line ; GUICtrlCreateLabel ("", 375 , 1, 2, 120, $SS_ETCHEDFRAME) ; GUICtrlCreateLabel ("", 630, 1, 2, 240, $SS_ETCHEDFRAME) ; Create Lables and Text Boxes GUICtrlCreateLabel ("Latitude / Longitude Coordinates", 5, 5) GUICtrlCreateGroup("", 17, 25, 610, 107) $hUseDeg=GUICtrlCreateRadio("Use Degrees, Minutes, Seconds", 27, 35, 200, 20) $hUseDec=GUICtrlCreateRadio("Use Decimals", 400, 35, 200, 20) GUICtrlSetState($hUseDeg, $GUI_CHECKED) GUICtrlSetState($hUseDec, $GUI_UNCHECKED) GUICtrlCreateLabel ( "Latitude:", 27, 72) $hLatDD=GUICtrlCreateInput ( "", 80, 70, 30, 20, $ES_NUMBER) GUICtrlSetState($hLatDD, $GUI_ENABLE) GUICtrlCreateLabel ( "Deg", 112, 72) $hLatMM=GUICtrlCreateInput ( "", 145, 70, 30, 20, $ES_NUMBER) GUICtrlSetState($hLatMM, $GUI_ENABLE) GUICtrlCreateLabel ( "Min", 177, 72) $hLatSS=GUICtrlCreateInput ( "", 207, 70, 110, 20) GUICtrlSetState($hLatSS, $GUI_ENABLE) GUICtrlCreateLabel ( "Sec", 319, 72) $hLatDDME=GUICtrlCreateInput ( "", 400, 70, 130, 20) GUICtrlSetState($hLatDDME, $GUI_DISABLE) GUICtrlCreateLabel ( "Decimal Degrees", 533, 72) GUICtrlCreateLabel ( "Longitude:", 27, 102) $hLonDD=GUICtrlCreateInput ( "", 80, 100, 30, 20, $ES_NUMBER) GUICtrlSetState($hLonDD, $GUI_ENABLE) GUICtrlCreateLabel ( "Deg", 112, 102) $hLonMM=GUICtrlCreateInput ( "", 145, 100, 30, 20, $ES_NUMBER) GUICtrlSetState($hLonMM, $GUI_ENABLE) GUICtrlCreateLabel ( "Min", 177, 102) $hLonSS=GUICtrlCreateInput ( "", 207, 100, 110, 20) GUICtrlSetState($hLonSS, $GUI_ENABLE) GUICtrlCreateLabel ( "Sec", 319, 102) $hLonDDME=GUICtrlCreateInput ( "", 400, 100, 130, 20) GUICtrlSetState($hLonDDME, $GUI_DISABLE) GUICtrlCreateLabel ( "Decimal Degrees", 533, 102) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group GUICtrlCreateGroup("", 645, 56, 145, 39) $hLLNorth=GUICtrlCreateRadio("North", 665, 70, 60, 20) $hLLSouth=GUICtrlCreateRadio("South", 725, 70, 60, 20) GUICtrlSetState($hLLNorth, $GUI_CHECKED) GUICtrlSetState($hLLSouth, $GUI_UNCHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group GUICtrlCreateGroup("", 645, 87, 145, 39) $hLLEast=GUICtrlCreateRadio("East", 665, 100, 60, 20) $hLLWest=GUICtrlCreateRadio("West", 725, 100, 60, 20) GUICtrlSetState($hLLWest, $GUI_CHECKED) GUICtrlSetState($hLLEast, $GUI_UNCHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group GUICtrlCreateLabel ("UTM Coordinates", 5, 144) GUICtrlCreateLabel("UTM Zone:", 27, 170, 70, 30, $ES_NUMBER) $hUTMZone=GUICtrlCreateInput ( "", 90, 168, 30, 20) GUICtrlCreateLabel("Northing:", 157, 170, 60, 20) $hNorthing=GUICtrlCreateInput ( "", 207, 168, 110, 20) GUICtrlCreateLabel("Easting:", 352, 170, 60, 20) $hEasting=GUICtrlCreateInput ( "", 400, 168, 130, 20) GUICtrlCreateLabel("Central Meridian:", 27, 205 , 200, 20) $hUTMCenMed=GUICtrlCreateLabel ( "", 115, 205, 100, 20) GUICtrlCreateGroup("", 645, 155, 145, 39) $hUTMNorth=GUICtrlCreateRadio("North", 665, 168, 60, 20) $hUTMSouth=GUICtrlCreateRadio("South", 725, 168, 60, 20) GUICtrlSetState($hUTMNorth, $GUI_CHECKED) GUICtrlSetState($hUTMSouth, $GUI_UNCHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group ; Create File Menus and Lists $mFileMenu = GUICtrlCreateMenu("File") $msExitItem = GUICtrlCreateMenuItem("Exit", $mFileMenu) $mHelpMenu = GUICtrlCreateMenu("Help") $msVersion = GUICtrlCreateMenuItem("Version", $mHelpMenu) ; Show the GUICreate GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Select Case $Msg = $bClose ; Pressed the close button _AreYouSure() Case $Msg = $GUI_EVENT_CLOSE ; Corner X pressed _AreYouSure() Case $Msg = $msExitItem ; Exit choses from the Main Menu _AreYouSure() Case $Msg = $msVersion ; Show Version from the Main Menu _ShowVersion($wMainWin, $Info_SWCre, $Info_SWUpd, $Info_SWVer) Case $Msg = $hUseDeg ; Switch to Degrees Minutes Seconds GUICtrlSetState($hUseDeg, $GUI_CHECKED) GUICtrlSetState($hUseDec, $GUI_UNCHECKED) GUICtrlSetState($hLatDDME, $GUI_DISABLE) GUICtrlSetState($hLonDDME, $GUI_DISABLE) GUICtrlSetState($hLatDD, $GUI_ENABLE) GUICtrlSetState($hLatMM, $GUI_ENABLE) GUICtrlSetState($hLatSS, $GUI_ENABLE) GUICtrlSetState($hLonDD, $GUI_ENABLE) GUICtrlSetState($hLonMM, $GUI_ENABLE) GUICtrlSetState($hLonSS, $GUI_ENABLE) Case $Msg = $hUseDec ; Switch to Decimal Degrees GUICtrlSetState($hUseDeg, $GUI_UNCHECKED) GUICtrlSetState($hUseDec, $GUI_CHECKED) GUICtrlSetState($hLatDDME, $GUI_ENABLE) GUICtrlSetState($hLonDDME, $GUI_ENABLE) GUICtrlSetState($hLatDD, $GUI_DISABLE) GUICtrlSetState($hLatMM, $GUI_DISABLE) GUICtrlSetState($hLatSS, $GUI_DISABLE) GUICtrlSetState($hLonDD, $GUI_DISABLE) GUICtrlSetState($hLonMM, $GUI_DISABLE) GUICtrlSetState($hLonSS, $GUI_DISABLE) Case $Msg = $bUTMtoLL ; DB to INI button pressed $viUTMZone=GUICtrlRead($hUTMZone) $viUTMCenMed=GUICtrlRead($hUTMCenMed) $vfUTMNorthing=GUICtrlRead($hUTMNorthing) $vfUTMEasting=GUICtrlRead($hUTMEasting) $vsUTMNorth=GUICtrlRead($hUTMNorth) $vsUTMSouth=GUICtrlRead($hUTMSouth) _SelectDBtoINI($wMainWin, $vsFold_MyDoc, $vsUtilFold, $bDBtoINI) Case $Msg = $bLLtoUTM ; Latitude/Longitude to UTM Button pressed If GUICtrlRead($hUseDeg)=$GUI_CHECKED Then ; Is Use Degrees, Minutes, Seconds checked? $viLatDD=GUICtrlRead($hLatDD) $vTempHolder = $viLatDD ; Verify value is withing parameters MsgBox(0, "here1", "What the Heck? Lat=" & $viLatDD & " Temp=" & $vTempHolder ) While $viLatDD<0 or $viLatDD>90 MsgBox(0, "here2", "What the Heck? Lat=" & $viLatDD & " Temp=" & $vTempHolder ) $viLatDD=InputBox("Entry Out of Range", "The Degrees of Latitude must be equal to or between 0 and 90 degrees." & @CR & @CR & "Please enter a correct value.", $viLatDD, " M2", -1, -1, -1, -1, "", $wMainWin) MsgBox(0, "here3", "What the Heck? Lat=" & $viLatDD & " Temp=" & $vTempHolder & " Error=" & @error) If @error=1 Then $viLatDD=$vTempHolder If $viLatDD>$viLatDD And Then MsgBox(0, "Number Only", "Please only enter numbers. Letters, " & $Q & "-" & $Q & ", or " & $Q & "." & $Q & " are not allowed.", "", $wMainWin) $viLatDD=$vTempHolder EndIf WEnd GUICtrlSetData($hLatDD, $viLatDD) $viLatMM=GUICtrlRead($hLatMM) $vTempHolder = $viLatMM ; Verify value is withing parameters While $viLatMM<0 or $viLatMM>60 $viLatMM=InputBox("Entry Out of Range", "The Minutes of Latitude must be equal to or between 0 and 60 degrees." & @CR & @CR & _ "Please enter a correct value.", $viLatMM, " M2", -1, -1, -1, -1, "", $wMainWin) If @error=1 Then $viLatMM=$vTempHolder If Int($viLatMM)<>$viLatMM Then MsgBox(0, "Number Only", "Please only enter numbers. Letters, " & $Q & "-" & $Q & ", or " & $Q & "." & $Q & " are not allowed.", "", $wMainWin) $viLatMM=$vTempHolder EndIf WEnd GUICtrlSetData($hLatMM, $viLatMM) $vfLatSS=GUICtrlRead($hLatSS) $vTempHolder = $vfLatSS ; Verify value is withing parameters While $vfLatSS<0 or $vfLatSS>60 $vfLatSS=InputBox("Entry Out of Range", "The Seconds of Latitude must be equal to or between 0 and 60 degrees." & @CR & @CR & _ "Please enter a correct value.", $vfLatSS, " M", -1, -1, -1, -1, "", $wMainWin) If @error=1 Then $vfLatSS=$vTempHolder If Int($viLatMM)<>$viLatMM Then MsgBox(0, "Number Only", "Please only enter numbers. Letters, " & $Q & "-" & $Q & ", or " & $Q & "." & $Q & " are not allowed.", "", $wMainWin) $viLatMM=$vTempHolder EndIf WEnd GUICtrlSetData($hLatSS, $vfLatSS) $vsNorth=GUICtrlRead($hLLNorth) $vsSouth=GUICtrlRead($hLLSouth) $viLonDD=GUICtrlRead($hLonDD) $vTempHolder = $viLonDD ; Verify value is withing parameters While $viLonDD<0 or $viLatDD>180 $viLonDD=InputBox("Entry Out of Range", "The Degrees of Longitude must be equal to or between 0 and 180 degrees." & @CR & @CR & _ "Please enter a correct value.", $viLonDD, " M3", -1, -1, -1, -1, "", $wMainWin) If @error=1 Then $viLonDD=$vTempHolder WEnd GUICtrlSetData($hLonDD, $viLonDD) $viLonMM=GUICtrlRead($hLonMM) $vTempHolder = $viLonMM ; Verify value is withing parameters While $viLonMM<0 or $viLonMM>60 $viLonMM=InputBox("Entry Out of Range", "The Minutes of Longitude must be equal to or between 0 and 60 degrees." & @CR & @CR & _ "Please enter a correct value.", $viLonMM, " M2", -1, -1, -1, -1, "", $wMainWin) If @error=1 Then $viLonMM=$vTempHolder WEnd GUICtrlSetData($hLonMM, $viLonMM) $vfLonSS=GUICtrlRead($hLonSS) $vTempHolder = $vfLonSS ; Verify value is withing parameters While $vfLonSS<0 or $vfLonSS>60 $vfLonSS=InputBox("Entry Out of Range", "The Seconds of Longitude must be equal to or between 0 and 60 degrees." & @CR & @CR & _ "Please enter a correct value.", $vfLonSS, " M", -1, -1, -1, -1, "", $wMainWin) If @error=1 Then $vfLonSS=$vTempHolder WEnd GUICtrlSetData($hLonSS, $vfLonSS) $vsEast=GUICtrlRead($hLLEast) $vsWest=GUICtrlRead($hLLWest) Else ; $vfLatDDME=GUICtrlRead($hLatDDME) ; $vfLonDDME=GUICtrlRead($hLonDDME) ; $vfLatDDCal=_CalDecimalLat($wMainWin, $viLatDD, $viLatMM, $vfLatSS, $vfLatDDME, $hLLSouth) ; _SelectLLtoUTM($wMainWin, $viLatDD, $viLatMM, $vfLatSS, $vfLatDDME, $hNorth) EndIf EndSelect Wend EndFunc Func _CalDecimalLat($wParWin, $viLatDD, $viLatMM, $vfLatSS, $vfLatDDME, $hLLSouth) ; Declare Program Variables Local $LatDec If $vfLatDDME>0 Then ; Detect Decimal or long entered $LatDec=$vfLatDDME Else $LatDec=($viLatDD + ($viLatMM/60) + ($vfLatSS/3600)) EndIf If $hLLSouth=$GUI_CHECKED Then ; North or South $LatDec=(-1)*$LatDec EndIf Return $LatDec EndFunc Func _CalDecimalsLong($LongDeg, $LongMin, $LongSec, $LongMan, $West) Local $LongDec If $LongMan>0 Then ; Detect Decimal or long entered $LongDec=$LongMan Else $LongDec=($LongDeg + ($LongMin/60) + ($LongSec/3600)) EndIf If $West=$GUI_CHECKED Then ; East or West $LongDec=(-1)*$LongDec EndIf Return $LongDec EndFunc Func _AreYouSure() ; Check if we want to close program ; $MsgBoxAns = MsgBox(36, "Close Program", "Do you wish to Close this program?", 0, $wMainWin) ; If $MsgBoxAns = 6 Then ; Yes was pressed Exit ; EndIf EndFunc Func _SelectLLtoUTM($wParWin) ; Convert from Latitude/Longitude to UTM ; Declare GUI variables Local $hTransResult ; handle for Command line ; Declare variables Local $X ; Counter Variable ; Start Code EndFunc Func _ShowVersion($wParWin, $Info_SWCre, $Info_SWUpd, $Info_SWVer) MsgBox(0, "AutoFarm DMAIN.DB Manager", "AutoFarm Product Specialist Documentation Group" & @CR &@CR & "Software Created: " & $Info_SWCre & @CR & _ "Software Last Modified: " & $Info_SWUpd & @CR & "Version: " & $Info_SWVer, 0, $wParWin) EndFunc Func _ErrorTrap() MsgBox(0, "Error", "There has been an Error." & @CR & @CR & $vsErrorMessage) Exit EndFunc
  13. I have done that during my troubleshooting. If I do put real variables in, I can get the box to display properly. However, I want it to use the default values. Has the way to make it use defaults changed from using "-1" in the command line? I want it to center it vertically and horizontally on the screen. When I do put values in, it always puts it on the upper left hand corner. Any more ideas? Thanks
  14. I originally wrote my code on an older version of AutoIt (3.?.? (Sorry, I don't know the exact version)). I noticed today that there was an updated version (v3.3.4.0) and installed it. After I went to run my script my InputBox no longer worked the way it was in the older version. I added some debug script and found that when I now called my InputBox, it was giving me an error 4: "The InputBox cannot be displayed on any monitor." I didn't change any of the code from the old to new versions and it worked just find on the older version. The items in the version Change log for this command are: - Fixed #1074: Inputbox() positionning on multi monitor. - Changed: InputBox() no longer requires passing both x and y or w and h. - Fixed: InputBox() didn't return focus to the previously active window I don't think any of these issues releate to me. However I do work on a laptop that I sometimes dock with a mulit-monitor system. Right now I'm just working on the laptop. the second issue should not be an issue as I am sending all the settings. I am assuming this error means that I have some of the display variables of the command wrong. I've tried changing some of the and can get the display to show, however I cannot get the default values to be used properly using the "-1" setting. I will attach the section of code where I am using this command. Can someone: 1) Confirm what is meant by the above error message. 2) Explain what I'm doing wrong with my new code? Thanks $viLatDD=GUICtrlRead($hLatDD) $vTempHolder = $viLatDD ; Verify value is withing parameters MsgBox(0, "here1", "What the Heck? Lat=" & $viLatDD & " Temp=" & $vTempHolder ) While $viLatDD<0 or $viLatDD>90 MsgBox(0, "here2", "What the Heck? Lat=" & $viLatDD & " Temp=" & $vTempHolder ) $viLatDD=InputBox("Entry Out of Range", "The Degrees of Latitude must be equal to or between 0 and 90 degrees." & @CR & @CR & "Please enter a correct value.", $viLatDD, " M2", -1, -1, -1, -1, "", $wMainWin) MsgBox(0, "here3", "What the Heck? Lat=" & $viLatDD & " Temp=" & $vTempHolder & " Error=" & @error) If @error=1 Then $viLatDD=$vTempHolder If $viLatDD>$viLatDD And Then MsgBox(0, "Number Only", "Please only enter numbers. Letters, " & $Q & "-" & $Q & ", or " & $Q & "." & $Q & " are not allowed.", "", $wMainWin) $viLatDD=$vTempHolder EndIf WEnd GUICtrlSetData($hLatDD, $viLatDD)
  15. Well I figured it out on my own. For those that care, I'll provide what I come up with. I improved my script in a couple of ways. First of as I researched things I ran across a nice command called "DriveGetDrive" This allowed me to detect only the drives that were available instead of having to deal with a bunch of unknowns. I rewrote the script to search only for the removale drives and then list only those drives in my combo box. Secondly I found the command "DriveStatus" which allowed me to check to see if the drive was ready to write or not. Since the drive was there, but there was no media in it, this allowed me to catch the error before the FileCopy command and thus stopped me from getting the Windows - No Disk error. The modified code I came up with is as follows. CODE#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <Misc.au3> ; Button Handles Global $OKButtonCDW, $CancelButtonCDW ; Buttons for Choose Drive GUI ; Declare Variables ; Declare GUI Variables Global $Msg2 ; Variable handling GUI 2 Control Global $ChooseDriveWin ; Handle on Choose Drive GUICreate Global $DriveGUI ; Handle of Drive Selection Global $FileCopyErr ; Handle for copying a file to check for errors ; Declare Program Variables Global $DataDrive ; Drive Letter for Data Card _LoadCard() Func _LoadCard() Local $DrivesAvailable ; list of drives available Local $DriveList="" ; list of drives available Local $X ; counter Var ; Find all the available "REMOVALBE" Drives $DrivesAvailable = DriveGetDrive( "ALL" ) If @error Then MsgBox(0, "No Drives Found", "No removable drives where detected." & @CR & @CR & "Please verify that a data card has been inseted into a Compact Flash Card Reader, the drive is active, and try again.") Return EndIf For $X = 2 to $DrivesAvailable[0] ; create a string with all the drives $DriveList = $DriveList & $DrivesAvailable[$X] if $X < $DrivesAvailable [0] Then $DriveList = $DriveList & "|" ; separate drives by pipe so they list separately in the combo box EndIf Next ; Create GUI $ChooseDriveWin = GUICreate("Select Drive", 200, 150, -1, -1, -1, -1) ; Create Buttons and Combo Box $OKButtonCDW = GUICtrlCreateButton("OK", 15, 115, 75, 25) $CancelButtonCDW = GUICtrlCreateButton("Cancel", 115, 115, 75, 25) GUICtrlCreateLabel("Insert a blank Data Card into the Computer. Identify the Drive letter." &@CR &@CR & "Select the Drive letter that the Data Card is inserted in",15,5,170,75,$SS_CENTER) $DriveGUI = GUICtrlCreateCombo($DrivesAvailable[1], 75, 75, 50, 15) ; create first drive GUICtrlSetData(-1, $DriveList, $DrivesAvailable[1]) ; add other drives snd set a new default ; Show the GUICreate GUISetState(@SW_SHOW) While 1 $Msg2 = GUIGetMsg() Select Case $Msg2 = $CancelButtonCDW GUIDelete($ChooseDriveWin) ExitLoop Case $Msg2 = $GUI_EVENT_CLOSE ; Closing the dialog box GUIDelete($ChooseDriveWin) ExitLoop Case $Msg2 = $OKButtonCDW $DataDrive = GUICtrlRead ($DriveGUI) GUIDelete($ChooseDriveWin) If DriveStatus($DataDrive) <> "Ready" Then MsgBox(48, "Drive not Ready", "Unable to copy file to Data Card. Check that card is inserted and the correct drive letter was selected and try again." &@CR &@CR & "Press OK when ready to proceed.",-1) Return EndIf SplashTextOn ( "Copying File", "Copying Simulator Program to Data Card" & @CR & @CR & "Sending Commands" & @CR &@CR & "Please Wait", 300,150) $FileCopyErr = FileCopy ( "startRemoteSim", $DataDrive) If $FileCopyErr = 0 Then ; something went wrong SplashOff() MsgBox(48, "File Copy Error", "Unable to copy file to Data Card. Check that card is inserted and the correct drive letter was selected and try again." &@CR &@CR & "Press OK when ready to proceed.",-1) ExitLoop EndIf SplashOff() MsgBox(64, "File Copied", "The file has been copied. Eject Data Card from computer using proper procedures." &@CR &@CR & "Press OK when ready to proceed.",-1) ExitLoop EndSelect Wend EndFunc
×
×
  • Create New...