Jump to content

Strings Changing Cases?


Recommended Posts

I just recently discovered AutoIt and have my first script below. It uses the program Image Grabber to extract images from all the .avi files in a directory. Below are two images that should help visualize the process.

http://i27.tinypic.com/opr7cx.png

http://i26.tinypic.com/288m3qc.png

All seems to be okay except that the strings seem to change cases occasionally as shown below. I'm not touching the keyboard during the process at all if that rules out anything.

http://i27.tinypic.com/dwbepl.png

I'm not sure if it's the ControlListView() or something like that that is causing the problem. In my test runs, the underscore sometimes gets changed to a hyphen and essentially halts the program because that filename doesn't exist and can't be opened.

http://i31.tinypic.com/244qvrb.png

If there's a possible explanation or another way to do this, I'm open to suggestions. Thanks.

Please ignore any inefficiencies that I'm sure I have. The 'loop' essentially runs once beforehand just to use the GetItemCount to loop through the rest. I'm using version 3.2.12.0 from May 16th, 2008.

$delaytime = 100;ms

Run("Image Grabber.exe")
WinWaitActive("Image Grabber")
sleep($delaytime)

$filenum = 0

ControlClick("Image Grabber", "", "[CLASSNN:Button1]");Open Button
WinWaitActive("Open")
sleep($delaytime)
WinActivate("[CLASS:SysListView321]")

$files = ControlListview("Open", "", "SysListView321", "GetItemCount")

$filename = ControlListView("Open", "", "SysListView321", "GetText", $filenum, 0)
ControlSend("Open", "", "[CLASSNN:Edit1]",$filename)
sleep($delaytime)
ControlClick("Open", "", "[CLASSNN:Button2]")
WinWaitActive("Image Grabber")
sleep($delaytime)
ControlClick("Image Grabber", "", "[CLASSNN:Button2]");Save Button
sleep($delaytime)

$length = StringLen($filename)
$filename = StringLeft($filename, $length - 4);Subtract '.avi' extension because error saving .jpg otherwise

ControlSend("Save As", "", "[CLASSNN:Edit1]",$filename)
WinWaitActive("Save As")
sleep($delaytime)
ControlClick("Save As", "", "[CLASSNN:Button2]")
WinWaitActive("Finished!")
ControlClick("Finished!", "", "[CLASSNN:Button1]")

$filenum = $filenum + 1

;;;;;;;;;;;;;;;;;;;;;

while $filenum < $files
    
ControlClick("Image Grabber", "", "[CLASSNN:Button1]")
WinWaitActive("Open")
sleep($delaytime)
WinActivate("[CLASS:SysListView321]")
$filename = ControlListView("Open", "", "SysListView321", "GetText", $filenum, 0)
ControlSend("Open", "", "[CLASSNN:Edit1]",$filename)
sleep($delaytime)
ControlClick("Open", "", "[CLASSNN:Button2]")
WinWaitActive("Image Grabber")
sleep($delaytime)
ControlClick("Image Grabber", "", "[CLASSNN:Button2]")
sleep($delaytime)

$length = StringLen($filename)
$filename = StringLeft($filename, $length - 4)

ControlSend("Save As", "", "[CLASSNN:Edit1]",$filename)
WinWaitActive("Save As")
sleep($delaytime)
ControlClick("Save As", "", "[CLASSNN:Button2]")
WinWaitActive("Finished!")
ControlClick("Finished!", "", "[CLASSNN:Button1]")

$filenum = $filenum + 1
wend

WinClose("Image Grabber")
Link to comment
Share on other sites

This is known AutoIt Send(),ControlSend() limitation related to non-US keyboard layouts.

As workaround just use

ControlSetText("Save As", "", "[CLASSNN:Edit1]",$filename)

instead of

ControlSend("Save As", "", "[CLASSNN:Edit1]",$filename)

Look here at old topics about that:

http://www.autoitscript.com/forum/index.php?showtopic=32584

http://www.autoitscript.com/forum/index.ph...st&p=215442

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...