
jimollerhead
Active Members-
Posts
33 -
Joined
-
Last visited
Everything posted by jimollerhead
-
WARNING about Run command and Notepad++
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
OK thanks very much for trying that out SadBunny....and thanks for the info kylomas. @TheSaint, yes I knew this, in fact it was pointed out to me by Jon when I asked him to do a quick sanity check on my text about AutoIt on my website as I had used 2 caps on that as well! Thanks to all in general for the replies, as I said earlier it works fine on my own Lenovo at home but this works machine still doesn't like it...I'm not that fussed though now I know it works for everyone else. -
WARNING about Run command and Notepad++
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
OK folks, I put the original post on from work so I was a bit surprised by the response (especially SadBunny's unjustified accusation) so here's some feedback.... I am actually reading from an ini file like so: $Editor = IniRead("Textreme.ini", "Global Settings", "TextEditor", "Notepad.exe") The ini file has this: [Global Settings] TextEditor="C:Program Files (x86)Notepad++notepad++.exe" I began the debug exercise by using msgbox to echo back the contents of $Editor and it was fine. This has worked fine until quite recently and I don't know why it has suddenly started acting up... foolishly I have left the RAM drive with the most recent version at work so I can't try it on my Win8 64 bit machine here but my work machine is Win7 64 bit. The +'s are fine as I retyped them from the keyboard. After the debugging within the main app echoed the path correctly, I decided on a 'pare down to the bone' test with a stub. The stub I used was something like: Global $RunHandle $RunHandle = Run("C:Program Files (x86)Notepad++notepad++.exe") MsgBox(0, "Run Result", "Handle: " & $RunHandle & " Erc: " & @error) In fact I just ran this on my Win8 machine and it invokes Notepad++ fine.... I will try some more stuff at work and come back to let you know. As I said it failed at work with a handle of 0 and an @error of 1 which was a surprise as it had worked perfectly up to now. If anyone would be willing to try it out "in anger" for me then you can download Textreme from jollybean.uk... if it works fine for you (just use "Open Source File" to save having to create and run a process) then it must be something weird that has been done to my work machine. If that's the case then sorry for the false warning! Regards and thanks for the replies, Jim. P.S. Just editing this to add an afterthought... you say ShellExecute is 'better' than Run... could you say why? and when, in that case, you would ever use Run rather than ShellExecute? -
Just a word to the wise folks about trying to invoke notepad++.exe using the Run command: it won't work! For some reason the Run command does not like the 2 +'s at the end of the filename. I have tried and proved this by creating a stub that does nothing else but try to kick it off and it fails with a 0 handle and an @error of 1 until I remove the 2 +'s and then it fires it up nicely. This is, of course, only of use to me as other users who have installed Notepad++ won't want to rename the exe file as this will break the upgrade path. This is most annoying as I use the full path to notepad++ in an ini file to allow users to choose their favourite editor when using my app and it defaults to Notepad (as it is designed to do) because it cannot "find" notepad++ (which was how I came to investigate the problem in the first place). This didn't used to happen in earlier versions, any ideas Jon? It might even be the notepad++'s exe file used to not have the 2 +'s in but I have no way of finding this out.
-
Problems using GuiRegisterMsg
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Apologies for not responding to the convo this afternoon Guinness but I was just checking the thread in my lunch-hour so could not engage in a 'live' interaction....I do find your nick a tad ironic given that I am an Englishman marooned in the ROI and I cannot stand the stuff! [grin].....and not only that I live next door to the original site of the first Guinness brewery! (which has just been sold BTW) -
Problems using GuiRegisterMsg
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Well that's one of the most surprising things I have read in the forum -- that someone was "aware" of Textreme! It's very much just a hobby project that was originally much simpler and for my own use only, that I have expanded the versatility of over time. As I use my own name in here you can now, I guess, make the link from the warp of my initial and surname to the website name! ) I don't make any efforts to hide the WhoIs info so it would hardly take Clouseau to track down the registered owner! Personally, I am not really "anti" anything *provided there is supporting information*. The 3rd and 4th parameters of the GUIRegisterMsg-responding function obviously contain different things depending upon which of the Windows messages you are intercepting. How you all know what these are is a mystery to me as is how you find out about the DLL functions, what they do, and the parameters they expect/return. There is nowt to be found in the help file (nor would I expect there to be, TBH) so you must have some esoteric info gained from somewhere that I have no knowledge of! -
Problems using GuiRegisterMsg
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Thanks for carrying on with this folks even though I managed a solution (of sorts) @Guinness, I did indeed spot that example in the helpfile, however knowing the X/Y coordinates at the time of the double-click would give me no end of grief in performing other programming cartwheels in order to figure out which of the many (and dynamically created and destroyed within the app) input fields named 'EditN' the mouse cursor was over.... my main problem in the end was switching from the CLASSNN descriptor to the ID which I had to do by going via the handle.... it would be nice for the double-click to be actually ON the edit field rather than close to it but I am happy with "good enough" rather than "perfect" using the 80/20 rule of programming!! In case you are curious what I am up to, the executable is called Textreme and downloadable from jollybean.co.uk -- I had an enhancement request from a user asking if it would be possible to have a pop-up editor for the functon parameters as some of his search strings were quite long and he'd like to see them in full without having to sideways-scroll the input box. BTW, the current release doesn't yet incorporate the Long String Editor, because the same user asked for a batch run function which is even more work! @kylomas - Whilst I am sure that your example is a neat and elegant solution, I use AutoIT to *avoid* DLL-hell, not to jump straight in welly-deep! Thank you for contributing though and, even though I am not taking on your solution, you have apparently helped out Melba23 in the process! -
Problems using GuiRegisterMsg
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Sorted! Found this little beauty in a Forum example: _WinAPI_GetDlgCtrlID - Thank you, thank you, thank you, Authenticity!! It effectively is just a converter that takes a handle in and spits an ID (i.e. what you get from the Create...statement) out! Here's the finally working beast: #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GuiConstantsEx.au3> #include <EditConstants.au3> #include <ListBoxConstants.au3> #include <WinAPI.au3> Global $InputFileId Global $OutputFileId Global $winMain Global $GUIMsg Global $EditCtrlId Global $EditCtrlName Global $EditCtrlHandle Global $DoubleClick = False $winMain = GUICreate ("Test for Editing Long Strings", 800, 560, -1, -1) GUICtrlCreateLabel("File to Process", 22,30) GUICtrlCreateLabel("Output File", 40,60) $InputFileId = GUICtrlCreateInput ( "", 100, 25, 400, 20) $OutputFileId = GUICtrlCreateInput ( "", 100, 55, 400, 20) $btnInputFile = GUICtrlCreateButton ( "Browse for File", 520, 22, 110, 25) $btnOPFolder = GUICtrlCreateButton ( "Browse for Location", 520, 53, 110, 25) ; Create the list of actions $ActionList = GUICtrlCreateList( "", 25, 260, 70, 200) GUICtrlSetData($ActionList, "Delete|Exclude|Include|Insert|Kill Blanks|Move|Remove|Replace|Switch", "Delete") GUISetState(@SW_SHOW, $winMain) GUIRegisterMsg($WM_LBUTTONDBLCLK, "DblClick") While 1 $GUIMsg = GUIGetMsg() Switch $GUIMsg Case $GUI_EVENT_CLOSE ExitLoop Case $btnInputFile MsgBox(0, "Info", "Input Button pressed") Case $btnOPFolder MsgBox(0, "Info", "Output Button pressed") EndSwitch If $DoubleClick Then EditText() EndIf WEnd Func DblClick($Window, $Caller, $p1, $p2) ; $EditCtrlId = $p2 ; BitAND($p1, 0x0000FFFF) $EditCtrlName = ControlGetFocus("Test for Editing Long Strings") $EditCtrlHandle = ControlGetHandle("Test for Editing Long Strings", "", $EditCtrlName) $EditCtrlId = _WinAPI_GetDlgCtrlID($EditCtrlHandle) msgbox(0,"DOUBLE-CLICK!","Control: " & $EditCtrlId & @CRLF & "ControlName: " & $EditCtrlName & @CRLF & "Handle: " & $EditCtrlHandle) $DoubleClick = True Return $GUI_RUNDEFMSG EndFunc Func EditText() Local $winEdit Local $edtString Local $btnAccept Local $btnReject Local $Response Local $RetString If StringInStr($EditCtrlName,"Edit") > 0 Then $winEdit = GUICreate("Long String Editor", 790, 100, -1, -1, $WS_BORDER) $edtString = GUICtrlCreateEdit("This is a potentially long string", 5, 5, 780, 20, $ES_AUTOHSCROLL) $btnAccept = GUICtrlCreateButton( "Accept String", 240, 33, 100, 30) $btnReject = GUICtrlCreateButton( "Reject String", 440, 33, 100, 30) GUISetState(@SW_SHOW, $winEdit) GUICtrlSetState($edtString, $GUI_FOCUS) While 1 $Response = GUIGetMsg() Select Case $Response = $btnReject ExitLoop Case $Response = $btnAccept ; GUICtrlSetData(5, $RetString) GUICtrlSetData($EditCtrlId, $RetString) ExitLoop Case Else $RetString = GUICtrlRead($edtString) EndSelect WEnd GUIDelete($winEdit) EndIf $DoubleClick = False EndFunc -
Problems using GuiRegisterMsg
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
OK thanks for the link...I was expecting some kind of performance-related reason rather than being too gormless to differentiate locals and globals without explicitly saying so. As I've been programming professionally with 3GLs since the early 80's (Basic then Pascal, the king of 3GLs, then C) I think I am OK to manage to make the differentiation unaided. I will, however take the advice for future AutoIt code if only to make it more readable for posting in the forum. My far more pressing issue is trying to identify the ID for the control that has the focus in my code! Regards, Jim. -
Problems using GuiRegisterMsg
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Thanks for the quick reply Guinnes, but I don't think that's what my main problem was... I was doing too much in the EditText function (despite having read sevreal times in the Forum that you should "get in and out fast" when interrupting the messaging! Here is an "almost there" version....my main problem now is detecting the field that had the focus when the double-click occurred. Using the ControlGetFocus function returns the CLASNN name which is useless for later when I want to copy the string back into the calling field because I need the internal ID then. I suspect I can get it by diddling around with the third parameter but the usual bitshifting that you use with WM_COMMAND doesn't work with WM_LBUTTONDBLCLK.... Here's the revised "almost there" version: (BTW I did try to use the 'AutoIT code' thing to paste last time but it just sat there and would not accept my mouse click) -- I'll research the "Don't use dim" thing if you can tell me what section of the helpfile it's in -- most examples use Dim and nothing says don't use it.... #include #include #include #include #include Dim $InputFileId Dim $OutputFileId Dim $winMain Dim $GUIMsg Dim $EditCtrlId Dim $EditCtrlName Dim $EditCtrlHandle Dim $DoubleClick = False GUIRegisterMsg($WM_LBUTTONDBLCLK, "DblClick") $winMain = GUICreate ("Test for Editing Long Strings", 800, 560, -1, -1) GUICtrlCreateLabel("File to Process", 22,30) GUICtrlCreateLabel("Output File", 40,60) $InputFileId = GUICtrlCreateInput ( "", 100, 25, 400, 20) $OutputFileId = GUICtrlCreateInput ( "", 100, 55, 400, 20) $btnInputFile = GUICtrlCreateButton ( "Browse for File", 520, 22, 110, 25) $btnOPFolder = GUICtrlCreateButton ( "Browse for Location", 520, 53, 110, 25) ; Create the list of actions $ActionList = GUICtrlCreateList( "", 25, 260, 70, 200) GUICtrlSetData($ActionList, "Delete|Exclude|Include|Insert|Kill Blanks|Move|Remove|Replace|Switch", "Delete") GUISetState(@SW_SHOW, $winMain) While 1 $GUIMsg = GUIGetMsg() Switch $GUIMsg Case $GUI_EVENT_CLOSE ExitLoop Case $btnInputFile MsgBox(0, "Info", "Input Button pressed") Case $btnOPFolder MsgBox(0, "Info", "Output Button pressed") EndSwitch If $DoubleClick Then EditText() EndIf WEnd Func DblClick($Window, $Caller, $p1, $p2) $EditCtrlId = $p2 ; BitAND($p1, 0x0000FFFF) $EditCtrlName = ControlGetFocus("Test for Editing Long Strings") $EditCtrlHandle = ControlGetHandle("Test for Editing Long Strings", "", $EditCtrlName) msgbox(0,"DOUBLE-CLICK!","Control: " & $EditCtrlId & @CRLF & "ControlName: " & $EditCtrlName & @CRLF & "Handle: " & $EditCtrlHandle) $DoubleClick = True Return $GUI_RUNDEFMSG EndFunc Func EditText() Dim $winEdit Dim $edtString Dim $btnAccept Dim $btnReject Dim $Response Dim $RetString If StringInStr($EditCtrlName,"Edit") > 0 Then $winEdit = GUICreate("Long String Editor", 790, 100, -1, -1, $WS_BORDER) $edtString = GUICtrlCreateEdit("This is a potentially long string", 5, 5, 780, 20, $ES_AUTOHSCROLL) $btnAccept = GUICtrlCreateButton( "Accept String", 240, 33, 100, 30) $btnReject = GUICtrlCreateButton( "Reject String", 440, 33, 100, 30) GUISetState(@SW_SHOW, $winEdit) GUICtrlSetState($edtString, $GUI_FOCUS) While 1 $Response = GUIGetMsg() Select Case $Response = $btnReject ExitLoop Case $Response = $btnAccept GUICtrlSetData(5, $RetString) ; GUICtrlSetData($EditCtrlHandle, $RetString) ExitLoop Case Else $RetString = GUICtrlRead($edtString) EndSelect WEnd GUIDelete($winEdit) EndIf $DoubleClick = False EndFunc -
Hello Folks, I'm not an AutoIt noob but I am new to the GuiRegisterMsg command. What I am trying to do is to pop up a "long string edit" window when user double-clicks. Ideally I wanted it to be a duouble-click in the Input box itself but I couldn't get this to work so I was going to settle for a double-click *near* the input box. Here's a severely curtailed version of my almost 1300-line script. From the msgbox "tell-tale" it appears that the GuiRegisterMsg definition interferes with the GuiGetMsg function and it 'remembers' the last GuiGetMsg return value -- is there some way to 'flush' the holding area? Note that there are bits in there from experiments -- if I comment out the While-Wend and replace it with the sleep line you can better see what I am trying to acheive. The list box is just to give a different kind of control than an input field to have the focus, it's contents are not relevant to the snippet, only to the full app. All help gratefully acknowledged! Here's the code snippet: #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GuiConstantsEx.au3> #include <EditConstants.au3> #include <ListBoxConstants.au3> Dim $InputFileId Dim $OutputFileId Dim $winMain Dim $GUIMsg GUIRegisterMsg($WM_LBUTTONDBLCLK, "EditText") $winMain = GUICreate ("Test for Editing Long Strings", 800, 560, -1, -1) GUICtrlCreateLabel("File to Process", 22,30) GUICtrlCreateLabel("Output File", 40,60) $InputFileId = GUICtrlCreateInput ( "", 100, 25, 400, 20) $OutputFileId = GUICtrlCreateInput ( "", 100, 55, 400, 20) $btnInputFile = GUICtrlCreateButton ( "Browse for File", 520, 22, 110, 25) $btnOPFolder = GUICtrlCreateButton ( "Browse for Location", 520, 53, 110, 25) ; Create the list of actions $ActionList = GUICtrlCreateList( "", 25, 260, 70, 200) GUICtrlSetData($ActionList, "Delete|Exclude|Include|Insert|Kill Blanks|Move|Remove|Replace|Switch", "Delete") GUISetState(@SW_SHOW, $winMain) While 1 $GUIMsg = GUIGetMsg() Switch $GUIMsg Case $GUI_EVENT_CLOSE ExitLoop Case $btnInputFile MsgBox(0, "Info", "Input Button pressed") Case $btnOPFolder MsgBox(0, "Info", "Output Button pressed") EndSwitch WEnd Func EditText($Window, $Caller, $p1, $p2) Dim $winEdit Dim $CtrlName Dim $edtString Dim $btnAccept Dim $btnReject Dim $Response Dim $RetString Dim $CtrlId Dim $ActCode Dim $HasFocus $CtrlName = ControlGetFocus("Test for Editing Long Strings") msgbox(0,"DOUBLE-CLICK!","Control: " & $CtrlId & @CRLF & "Action: " & $ActCode & @CRLF & "CtrlName: " & $CtrlName) If StringInStr($CtrlName,"Edit") > 0 Then $winEdit = GUICreate("Long String Editor", 790, 100, -1, -1, $WS_BORDER) $edtString = GUICtrlCreateEdit("This is a potentially long string", 5, 5, 780, 20, $ES_AUTOHSCROLL) $btnAccept = GUICtrlCreateButton( "Accept String", 240, 33, 100, 30) $btnReject = GUICtrlCreateButton( "Reject String", 440, 33, 100, 30) GUISetState(@SW_SHOW, $winEdit) GUICtrlSetState($edtString, $GUI_FOCUS) ; sleep(5000) ;#cs While 1 $Response = GUIGetMsg() if $Response = $btnAccept Then ExitLoop EndIf Select Case $Response = $btnReject ExitLoop Case $Response = $btnAccept ; GUICtrlSetData($CtrlName, $RetString) ExitLoop Case Else $RetString = GUICtrlRead($edtString) EndSelect WEnd ;#ce Else Return $GUI_RUNDEFMSG EndIf GUICtrlSetData($CtrlName, $RetString) GUIDelete($winEdit) Return $GUI_RUNDEFMSG EndFunc
-
sound with keypress (turn off)
jimollerhead replied to Natas70's topic in AutoIt General Help and Support
I have hit exactly the same problem. It seems that even though you are using _isPressed to detect the keystroke, Windows interprets the keypress as a keying error before your program gets to react to it and plays the default error sound which is annoying when I am also playing a sound when the keys are pressed. This doesn't happen with HoTKeySet but I don't want an application-wide keypress function call, just a detection within a small subroutine at a specific time so this doesn't help. I did hope that there might be an Opt setting that would suppress system sounds but no joy. -
Where can I download a copy of K8055.au3?
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Ah-ha.... cue the clanking of the penny dropping and the blowing away of cobwebs from my memory...! It seems that the posting by the nfwu person is actually the Windows-compatible list of calls to the DLL (using the CallDLL command - surprise!) so that they can be used with the USB<function> syntax within an AutoIT script (my example script uses it!). If anyone else is thinking of copying this list of calls into their own k8055.au3 file I should warn you that there are a couple of misspellings ('Chanel' for one) and 'Return $Result[0]' will also fail due to it not being an array variable (just comment out the [0] or the whole $Result[0] -- it seems to have been done in the first one but left in the later ones) What is a bit surprising is that later posters in the thread say that it worked for them but hey-ho... -
Where can I download a copy of K8055.au3?
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Thanks for the quick response but I already followed that link and it is Linux specific. I KNOW this library existed once because I have got the example script with the #include at the top but it's so long since I did anything with the board that the au3 has got lost in the throes of various PC and O/S upgrades. I backed up my source code but forgot about the library. Hmph! -
Lordy lordy, please help convince me that I am not losing it and haven't imagined once having a copy of the K8055.au3 include file? It contains a set of functions that in turn call the routines in the K8055 DLL file but I can't find my copy anywhere NOR can I find a mention of it (the windows version that is) anywhere in the forums... Even Google can't find anything useful. Does anyone have a copy of this library I could download? Thanks, Jim.
-
Here's a 'prettier' version of one.... the spacebar picks and the enter key calls house. ----------------------------------------------------------------------------------- #include <ButtonConstants.au3> #include <GUIEdit.au3> #include <GUIConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Opt("MustDeclareVars", 1) HotKeySet("{SPACE}", "PickNumber") HotKeySet("{ENTER}", "HouseCalled") HotKeySet("{ESC}", "QuitGame") Const $Font = "Comic Sans MS" Const $FontSize = 24 Const $xOrigin = 190 Const $yOrigin = 15 Const $xIncrement = 60 Const $yIncrement = 50 Const $CellWidth = 55 Const $CellHeight = 45 Dim $Event Dim $winMain Dim $FixedNums[90] Dim $RandomNums[90] Dim $Board[10][9] Dim $LastNumber Dim $NextNumber Dim $NextCall Dim $BoardX Dim $BoardY dim $nn dim $nc $winMain = GUICreate("BINGO CALLER", 800, 600, -1, -1) StartGame() DrawBoard() GUISetState(@SW_SHOW, $winMain) While 1 $Event = GUIGetMsg() Switch $Event Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func StartGame() MixNumbers() ClearBoard() $NextNumber = 0 EndFunc Func MixNumbers() Dim $x Dim $RandNum For $i = 0 To 89 $FixedNums[$i] = $i + 1 Next For $x = 0 To 89 $RandNum = Random(0, 89 - $x, 1) $RandomNums[$x] = $FixedNums[$RandNum] $FixedNums[$RandNum] = $FixedNums[89 - $x] Next EndFunc ;==>MixNumbers Func DrawBoard() Dim $xpos Dim $ypos Dim $winBoard Dim $Border1 Dim $Border2 For $xpos = 0 To 9 For $ypos = 0 To 8 $Board[$xpos][$ypos] = GUICtrlCreateLabel("", $xOrigin + ($xpos * $xIncrement), $yOrigin + ($ypos * $yIncrement), $CellWidth, $CellHeight, $ES_CENTER) GUICtrlSetFont(-1, $FontSize, 1000, -1, $Font) GUICtrlSetBkColor(-1, 0xff00ff) GUICtrlSetColor(-1, 0xffffff) $Border1 = GUICtrlCreateGraphic($xOrigin - 5, $yOrigin - 5, 1, 1) GUICtrlSetGraphic($Border1, $GUI_GR_PENSIZE, 3) GUICtrlSetGraphic($Border1, $GUI_GR_COLOR, 0x000000) GUICtrlSetGraphic($Border1, $GUI_GR_RECT, -1, -1, $CellWidth * 11 + 2, $CellHeight * 10 + 7) Next Next $LastNumber = GUICtrlCreateLabel("", 12, 12, 159, 149, $ES_CENTER) GUICtrlSetBkColor(-1, 0x0000ff) GUICtrlSetColor(-1, 0xffff00) GUICtrlSetFont(-1, 72, 1000, -1, $Font) $Border2 = GUICtrlCreateGraphic(10, 10, 1, 1) GUICtrlSetGraphic($Border2, $GUI_GR_PENSIZE, 3) GUICtrlSetGraphic($Border2, $GUI_GR_COLOR, 0x000000) GUICtrlSetGraphic($Border2, $GUI_GR_RECT, -1, -1, 165, 155) EndFunc ;==>DrawBoard Func PickNumber() If $NextNumber = 90 Then HouseCalled() EndIf $NextCall = $RandomNums[$NextNumber] $BoardX = Mod($NextCall - 1, 10) $BoardY = ($NextCall - $BoardX) / 10 GUICtrlSetData($Board[$BoardX][$BoardY], $NextCall) GUICtrlSetData($LastNumber, $NextCall) $NextNumber = $NextNumber + 1 GUICtrlSetData($nn, $nextnumber) GUICtrlSetData($nc, $nextcall) EndFunc ;==>PickNumber Func HouseCalled() Dim $HouseLabel Dim $btnContinue Dim $btnNewGame Dim $btnStop Dim $Choice $HouseLabel = GUICtrlCreateLabel("HOUSE CALLED!", 190, 485, 600, 100, $ES_CENTER) GUICtrlSetFont(-1, 48, 700, -1, $Font) $btnContinue = GUICtrlCreateButton("Continue", 9, 195, 165, 70) GUICtrlSetFont(-1, 20, 700, -1, $Font) $btnNewGame = GUICtrlCreateButton("New Game", 9, 295, 165, 70) GUICtrlSetFont(-1, 20, 700, -1, $Font) $btnStop = GUICtrlCreateButton("Stop", 9, 395, 165, 70) GUICtrlSetFont(-1, 20, 700, -1, $Font) While 1 $Choice = GUIGetMsg(1) Select Case $Choice[0] = $btnContinue ExitLoop Case $Choice[0] = $btnNewGame StartGame() ExitLoop Case $Choice[0] = $btnStop QuitGame() Case $Choice[0] = $GUI_EVENT_CLOSE QuitGame() EndSelect WEnd GUICtrlDelete($btnStop) GUICtrlDelete($btnNewGame) GUICtrlDelete($btnContinue) GUICtrlDelete($HouseLabel) EndFunc ;==>HouseCalled Func ClearBoard() Dim $xpos Dim $ypos For $xpos = 0 To 9 For $ypos = 0 To 8 GUICtrlSetData($Board[$xpos][$ypos], "") Next Next GUICtrlSetData($LastNumber, "") EndFunc ;==>ClearBoard Func QuitGame() Exit EndFunc ;==>QuitGame
-
Autoit GUI Calendar Problem
jimollerhead replied to ToyBoi's topic in AutoIt General Help and Support
It seems unfortunate that if you want the datepicker to present pretty wordy dates, you have to do any conversion yourself. It can often be easier to use your own function to do a conversion and then compare the integer values in order to do date arithmetic... here's an example from one of my recent programs (slightly adapted to give a standalone test): #include <GUIConstantsEx.au3> Dim $DateId Dim $DateInteger GUICreate ("Date reformat", 200, 100, -1, -1) GUICtrlCreateLabel("Choose Date", 10, 10) $DateId = GUICtrlCreateDate ("", 10, 40, 120) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd $DateInteger = DateToInt(GUICtrlRead($DateId)) MsgBox(0,"Converted Dates", "Date Integer: " & $DateInteger) Func DateToInt($InDate) Dim $DateArray Dim $MonthNum $DateArray = StringSplit($InDate, " ", 2) Switch $DateArray[1] Case "January" $MonthNum = "01" Case "February" $MonthNum = "02" Case "March" $MonthNum = "03" Case "April" $MonthNum = "04" Case "May" $MonthNum = "05" Case "June" $MonthNum = "06" Case "July" $MonthNum = "07" Case "August" $MonthNum = "08" Case "September" $MonthNum = "09" Case "October" $MonthNum = "10" Case "November" $MonthNum = "11" Case "December" $MonthNum = "12" EndSwitch Return Int($DateArray[2] & $MonthNum & $DateArray[0]) EndFunc -
Not a big deal, but I have a 2-dimensional array, currently 10 x 4 (the 4 being constant for each first element) I wondered if it was possible to compute the max array element for the first subscript? Given that I am populating the array in my code it isn't a big deal (I have just declared a constant that I alter when I add rows to the array) but it kindof "offends my programmers sensibilities" to not be able to determine the max first subscript programmatically.
-
How do I include the plus symbol in a string?
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Woooohooo.... I finally got it by using "{SHIFTDOWN}={SHIFTUP}" TGFT I can go home happy now!! -
This is driving me crazy... I have tried to use Send to send a string containing a plus symbol to a SQLPlus session (for an outer join in a statement) and the thing just WILL NOT print... I've tried ..& Chr(43) &... with no joy whatsoever and also tried escaping it with \.... surely to god there must be SOME way to achieve this?? Someone save my sanity PLEASE -- I've been fighting with this for nearly 3 hours!!
-
Search and Replace in notepad
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Just in case anyone is interested, the project is now complete and has been successfully installed on someone else's machine. I compiled the script that "does the work" and incorporated the exe file (along with several SQL scripts, a ReadMe and an ini file) into another compilation that does the install and creates a desktop shortcut. Something I came across late were the INI file functions -- I had been opening and reading from the INI file manually and cursed when I found them -- it simplified the code immensely!! Jim. -
Hi please answer my noob question :D
jimollerhead replied to Canasian's topic in AutoIt General Help and Support
As someone who has been writing programs in various languages for the last 21 years, it aiin't the language that's the problem, it's working out the algorithmic solution. A typical example was my "Search and Replace" Notepad grief in another thread -- God know's why it never occurred to me to just open the file and read it... I must be getting senile!! Jim. -
Search and Replace in notepad
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Yeah I guess so -- just that the file solution hadn't occurred to me until randallc suggested it! Regards, Jim. -
Search and Replace in notepad
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Hi All, I finally had to give up with the notepad thing, it was just too flakey... I think the problem is that autoIT works so hellishly fast that it presses the keys faster than any human could and notepad cannot cope -- I tried the OPTKey delays but it still was dodgy, sometimes it worked sometimes it didn't. My final solution, as suggested by randallc, was this and it works a treat... and faster than in notepad (when it worked): $FileIn = FileOpen("PVCS-inserts.txt", 0) $FileOut = FileOpen("PVCS-inserts.sql", 2) While 1 $SQLtext = FileReadLine($FileIn) If @error = -1 Then ExitLoop $SQLtext = StringReplace($SQLtext, "&", "'||CHR(38)||'") $SQLtext = StringReplace($SQLtext, "SolvCV", "SolvCT"); FileWriteLine($FileOut, $SQLtext) WEnd I'm a stubborn sod and hate being beaten and this works consistently well (I had the syntax wrong before). A more 'elegant' solution too. Phew! -- onwards and upwards... Thanks to all who contributed (and to Lar who had obviously been furiously running test stubs to find out the cause!) Best, Jim. -
Search and Replace in notepad
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Well I was not too chuffed with the string functions in vbscript so decided to have one last go with StringReplace.... and it doesn't bloody work!!! Why is nothing working for me??? This is the code fragment: $FileIn = FileOpen("PVCS-inserts.txt", 0) $FileOut = FileOpen("PVCS-inserts.sql", 2) ;I cut and pasted the example form the help file -- this worked! $SQLtext = StringReplace("this is a line of text", " ", "-") $numreplacements = @extended MsgBox(0, "New string is", $SQLtext) MsgBox(0, "The number of replacements done was", $numreplacements) ;This is my code and the string is identical at the bottom as it is at the top.... (sigh) While 1 $SQLtext = FileReadLine($FileIn) msgbox(0, "top of the loop", $SQLtext) If @error = -1 Then ExitLoop StringReplace($SQLtext, "SolvCV", "SolvCT") FileWriteLine($FileOut, $SQLtext) msgbox(0, "bottom of the loop", $SQLtext) Wend -
Search and Replace in notepad
jimollerhead replied to jimollerhead's topic in AutoIt General Help and Support
Yeah I spoke too soon.... weird things have started to happen....this is my test script: RunWait("Notepad.exe C:\PVCS\PVCS-inserts.sql") WinWaitActive("PVCS-inserts.sql - Notepad") WinMenuSelectItem("PVCS-inserts.sql - Notepad", "", "&Edit", "&Replace") Send("{SHIFTDOWN}7{SHIFTUP}{TAB}'{SHIFTDOWN}\\{SHIFTUP}CHR{SHIFTDOWN}9{SHIFTUP}38{SHIFTDOWN}0\\{SHIFTUP}'{TAB}{TAB}{TAB}{ENTER}") Do Send("{SHIFTDOWN}{TAB}{SHIFTUP}{ENTER}{TAB}{ENTER}") Until WinActive("Notepad") First time through it just opens the file and sits there with an autoit icon in the system tray Second time through it works and spawns a second autoit icon in the system tray Third time through, still two icons, but when it exits, the "Notepad" window flickers a few times and I start to get carriage returns repeatedly entered into my file and have to use task manager to kill it. The string replace sounds a good option but I have had enough and am gonna use vbscript Thanks for all the replies, Jim.