Jump to content

Recommended Posts

  • Moderators
Posted

Hi,

Someone asked today how to have more than one value in a Switch Case statement. Looking at the examples, I see that all the Cases are of the To type - perhaps we should show the whole range of syntax possibilities. Here is a suggested replacement - can you tell I have just eaten? ;)

Local $msg
Switch @HOUR
    Case 6 To 8
        $msg = "Breakfast"
    Case 13, 14
        $msg = "Lunch"
    Case 16
        $msg = "Tea"
    Case 18, 19
        $msg = "Dinner"
    Case Else
        $msg = "Greedy!"
EndSwitch

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 2/22/2013 at 1:44 PM, 'Melba23 said:

Hi,

Someone asked today how to have more than one value in a Switch Case statement. Looking at the examples, I see that all the Cases are of the To type - perhaps we should show the whole range of syntax possibilities. Here is a suggested replacement - can you tell I have just eaten? ;)

M23

Or perhaps something like this.

Local $msg
Switch @HOUR
    Case 6 To 7, 8 to 9
        $msg = "Breakfast"
    Case 13, 14
        $msg = "Lunch"
    Case 16
        $msg = "Tea"
    Case 18, 19
        $msg = "Dinner"
    Case Else
        $msg = "Greedy!"
EndSwitch

Shows that you can have multiple To types on the same line as well.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

  • Moderators
Posted

AZJIO,

Interesting final example. ;)

Do you have a real-world example of when it could be useful - because I am struggling to think of one. :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • Moderators
Posted

AZJIO,

Interesting idea - thank you for showing us. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)

I have accumulated more typos that I have found in the help file. If you have confusion about the structure of this then let me know.

Edit: The very first thing is either my mistake or has been corrected since I last noticed.

Edit: Also, _ArrayDisplay has the word array twice in the helpfile and the calltip.

Displays given 1D or 2D array array in a listview.
Edited by jaberwocky6669
Posted

Thanks. I will have a look at these next month.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

  On 2/23/2013 at 4:16 PM, 'jaberwocky6669 said:

That will give me time to remove the super anal ones like double spaces between sentences which I have since become lax about.

This is what I expect, don't remove them. Also the help file should use American English for consistency with AutoIt functions. I would love to change color to colour, but alas I can't.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • 2 weeks later...
Posted (edited)

Script Editors

Notepad++ need to be added in the list

You can add a button to copy the code in the "GUI Reference - MessageLoop Mode" and in other sections. For example.

#include <FileOperations.au3>
$sKey = '_@#%&'
$sLink = ''
$sPath = @ScriptDir
$aFileList = _FO_FileSearch($sPath, '*.htm*', True, 125, 0)

$iCount = 0
For $i = 1 To $aFileList[0]
    $sText = FileRead($sPath & '\' & $aFileList[$i])
    StringReplace($aFileList[$i], '\', '')
    Switch @extended
        Case 0
            $sLink = 'images/copysmall.gif'
        Case 1
            $sLink = '../images/copysmall.gif'
        Case 2
            $sLink = '../../images/copysmall.gif'
    EndSwitch
    $sText = StringReplace($sText, '<p class="codebox">', '<a href="javascript:ClipBoard(au3_' & $sKey & ');"><IMG title="Копировать в буфер" style="margin: 10px 4px 0px 0px;" src="' & $sLink & '" border="0" align="right"></a>' & @CRLF & '<p id="au3_' & $sKey & '" class="codebox">')
    $iCountRP = @extended
    If Not $iCountRP Then ContinueLoop
    For $j = 1 To $iCountRP
        $sText = StringReplace($sText, $sKey, $j, 2, 2)
    Next
    $iCount += 1
    $sText = StringReplace($sText, '</BODY>', '<textarea ID="holdtext" STYLE="display:none;"></textarea><SCRIPT LANGUAGE="Javascript">function ClipBoard(NumBlok){holdtext.innerText = NumBlok.innerText;Copied = holdtext.createTextRange();Copied.execCommand("Copy");}</SCRIPT></BODY>')
    $hFile = FileOpen($sPath & '\' & $aFileList[$i], 2)
    FileWrite($hFile, $sText)
    FileClose($hFile)
Next
MsgBox(0, 'Yes', 'Count Files = ' & $iCount)
Edited by AZJIO
Posted

Can we add to the helpfile for the command/function Send() the work around for sticking keys - maybe a link to the FAQ?

I have seen this issue come up, and as per this is not a bug, but a computer issue and I think it should be mentioned in the place it is first seen - the help file?

  Reveal hidden contents
All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

  Reveal hidden contents

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Posted

Linking to the Wiki isn't recommended and in terms of my stance on adding this, even if it was documented the question would probably still arise.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Are you saying that it will not be added? If you will not add the link, can you at least post that if you have issue, look in the FAQ?

  Reveal hidden contents
All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

  Reveal hidden contents

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Posted (edited)

I just can't understand how this issue is related to the AutoIt help file. Maybe someone else can shed some light on it.

Edit: I should clarify, the way I see it this is a Microsoft issue and thus has no business being in the help file in my humble opinion, but then again there are a couple of us who work on the help file so I'm happy to hear their opinion on the subject.

Edit 2: I appreciate you helping, but as you can probably understand, not everything should or can be added to the help file.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Moderators
Posted (edited)

guinness,

This problem is a not infrequent question here and, as I indicated in the thread to which nitekram linked, I think it could be worth a line in the Help file:

"In some circumstances Send can cause the modifier (Ctrl-Alt-Shft) keys to remain "stuck down" when they are among the keys sent. This is not an AutoIt bug and some possible remedies can be found in the FAQ in the AutoIt Wiki."

I am not at all hard over on this - you are the guardian of the Help file and I am perfectly ready to accept what you decide. :)

M23

Edited by Melba23
Typo

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

The examples for _IEDocInsertHTML() are broken for IE10 on Win7.

_IEGetObjByName() does NOT return the object. Using _IEGetObjById() does the job.

Here the modified examples.

I modified the color of the text also, since black on darkblue is nearly invisible. Even without IE10.

  Reveal hidden contents

There are also other helpfile examples broken, like _IEDocInsertText().

_IEGetObjByName() should be changed to _IEGetObjById() in most cases.

App: Au3toCmd              UDF: _SingleScript()                             

Posted (edited)

Hotkeyset()

An additional example should include error checking and one function for multiple Hotkeys.

Const $_Stop = 16
Const $_TopMost = 262144
If HotKeySet("{ESC}", "_Hotkey") = 0 Then Exit MsgBox($_Stop+$_TopMost, "Hotkeyset Error", "Hotkey {ESC} already set.")
If HotKeySet("{F1}", "_Hotkey") = 0 Then Exit MsgBox($_Stop+$_TopMost, "Hotkeyset Error", "Hotkey {F1} already set.")
Func _Hotkey()
    Switch @HotKeyPressed
        Case "{ESC}"
            Exit MsgBox($_TopMost, "Hotkey()", "Exit", 0)
        Case "{F1}"
            ShellExecute("http://www.autoitscript.com/autoit3/docs/functions/HotKeySet.htm")
    EndSwitch
EndFunc   ;==>_Hotkey

While Sleep(999999)
WEnd
Edited by Exit

App: Au3toCmd              UDF: _SingleScript()                             

Posted

Thanks Exit. Would you mind replacing the MsgBox values with constant variables and then I will update. Thanks.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Guest
This topic is now closed to further replies.
×
×
  • Create New...