Compiled AHK Produces Chinese File Names

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
SlCantre939
Posts: 11
Joined: 08 Feb 2023, 11:37

Compiled AHK Produces Chinese File Names

Post by SlCantre939 » 29 Mar 2023, 15:43

Hi Everyone,
This one has me stumped.
When I run the script uncompiled, it runs correctly putting out file names in English.

But when I compile it, (Yes just downloaded latest version of compiler), I get Chinese file names.
Any suggestion appreciated.
Thanks
English and Chinese File Names.jpg
English and Chinese File Names.jpg (54.44 KiB) Viewed 402 times
Attachments
image.png
image.png (45.36 KiB) Viewed 402 times

User avatar
boiler
Posts: 16965
Joined: 21 Dec 2014, 02:44

Re: Compiled AHK Produces Chinese File Names

Post by boiler » 29 Mar 2023, 15:48

You posted in the v2 section, but your other posts are using v1. Do you mean this to be in the v2 section or should I move it?

SlCantre939
Posts: 11
Joined: 08 Feb 2023, 11:37

Re: Compiled AHK Produces Chinese File Names

Post by SlCantre939 » 29 Mar 2023, 16:05

The main script is in V2, it does call FindText and UIA_Interface which are both V1.
Sorry where should I put it?
Thanks

User avatar
boiler
Posts: 16965
Joined: 21 Dec 2014, 02:44

Re: Compiled AHK Produces Chinese File Names

Post by boiler » 29 Mar 2023, 16:19

How are you accomplishing that? Are you using autohotkey.dll or something else that lets you run v1 libraries from v2, such as this approach? If not, it could be that your main script is actually v1 as well, and it's running in v1 even though you may also have v2 installed. You can put your script directly in a post reply in between [code][/code] tags.

SlCantre939
Posts: 11
Joined: 08 Feb 2023, 11:37

Re: Compiled AHK Produces Chinese File Names

Post by SlCantre939 » 29 Mar 2023, 16:35

The full script is 360 lines. I can put it out there if you think that is okay.
The reason I didn't is that it works perfectly in AHK mode just not in exe.
Let me know if you want the full script loaded.
I'm still new to the forum and don't want to over step.
Thanks for your direction.

User avatar
boiler
Posts: 16965
Joined: 21 Dec 2014, 02:44

Re: Compiled AHK Produces Chinese File Names

Post by boiler » 29 Mar 2023, 17:00

If you put it in between the code tags as mentioned, that's fine. It would be better if you had a smaller script that exhibited the same issue. That's the one of the best ways to troubleshoot a problem anyway. Create a short script that isolates the issue, then solve that and implement the fix into your main script.

SlCantre939
Posts: 11
Joined: 08 Feb 2023, 11:37

Re: Compiled AHK Produces Chinese File Names

Post by SlCantre939 » 29 Mar 2023, 22:30

Extracted the first 100 rows of script and removed several steps to simplify the test.
Ran the script from Visual Studio Code and the file name was in English.
Compiled the script and during row 106 where the file path & name are assigned to the file name, it posted as Chinese.
File saved with Chinese name. File sizes and contents are the same between the two runs.

Code: Select all

#Include ..\lib
#Include UIA_Interface.ahk
#include FindText.ahk

SetWorkingDir "C:\Users\Sammy\Documents\Windwarddata\CSV files"
MyTrigger := "C:\Users\Sammy\Documents\Windwarddata\CSV files\trigger.csv"
; Trigger step removed

UIA := UIA_Interface()
if !WinExist("GLS Admin Extract Views - Power BI Desktop")
{
  Run "C:\Users\Sammy\Desktop\GLS Admin Extract Views.pbix"
  Sleep 10000
}
WaitforPBIX:
  if !WinExist("GLS Admin Extract Views - Power BI Desktop")
  {
    ; OutputDebug "wait for pbix load released"
    Sleep 10000
    Goto WaitforPBIX
  }
  Else
  {
    sleep 10000
  }

  WinActivate ("GLS Admin Extract Views - Power BI Desktop")
  Sleep 1000
  WinMaximize
  Sleep 1000

  hWnd := WinExist("GLS Admin Extract Views - Power BI Desktop")
  pbi := UIA.ElementFromHandle(hWnd)

RetryRefresh:

  pbi.findfirstbyname("Refresh").click() ; Refresh databases

  sleep 5000
WaitforRefresh:
  pbi := UIA.ElementFromHandle(hWnd)

  sleep 2000

  Text := "|<>*163$71.0000000000000000000000000000000000000000000000000000000000000000s0000M03y007k0000k07y00A00001U0AC00M0000300MA00k0000600kMD7taDUyBs1VVzDnwzXwTs3y37673XC0sk7sA6AC63Q1VUAMTwMMDyS330MszskkTsD660klU1VUk06AA1UnU331k0AMM31ny661zDskk61XsAA1wDVVU00000000000000000000000000000000000000000000000000000000001"

  ok1 := FindText(X, Y, 954, 448, 1244, 612, 0, 0, Text)
  if (ok1 == 0)
  {
    sleep 2000 ;msgbox "Refresh is complete"
  } else
  {
    ; Check to see if refresh failed
    Text := "|<>*206$71.0000000000000000000000000000000000000000000000000000000000000s00000000001k00000000007k02000000U0DU0A00000100zU0IDCD8bbU1z018kUWFAY07z02F122WF80Tz04G4454WE0zy0TY48+94U3zy0VA88YG907zw31DCC7YFUTzw0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"

    if (ok2 := FindText(X, Y, 950, 472, 1531, 879, 0, 0, Text))
    {
      sleep 1000 ; Cancel the refresh
      pbi.findfirstbyNameandType("Cancel", "button").click()
      sleep 4000 ; Go back and retry refresh
      goto RetryRefresh
    }
    sleep 2000 ; Wait for Refresh to finish
    GoTo WaitforRefresh
  }
  sleep 5000

  ;-----------------------------------------------------
  ;       Load Invoices from Proj Job List
  ;-----------------------------------------------------

  WinActivate ("GLS Admin Extract Views - Power BI Desktop")
  pbi.findfirstbyname("MS Proj Exports").click() ; Change to MS Proj Exports tab
  sleep 4000

  
Text:="|<>*157$71.000000000000000000000000k01U01U0k001U0300301003300600600006600A00A0000AA7UPk0M0A7kyMTkzk0k0MTlwllVlU1U0lU1VX1X1U301X033636306037066A6A60A067sAAMAMA0M0A1sMMkMkM0k0M0klVlVlU1U0l1Vb1z3z03zlXz3w1w6w07zX3w3U00000000000000000000001"

if (ok:=FindText(X, Y, 740, 124, 927, 229, 0, 0, Text))
{
  FindText().Click(X, Y, "L")
}Else
{
  MsgBox "Could not find Job List on Proj View"
}
 ; pbi.findfirstbyname("JobUnique").click() ; Activate Invoice View
  sleep 4000

  Text := "|<>*157$21.00000000000kkk66600000000000U"

  if (ok := FindText(X, Y, 1534, 113, 1699, 237, 0, 0, Text))
  {
    FindText().Click(X, Y, "L")
  } else
  {
    MsgBox "Could not find ... on Job List"
    ExitApp
  }
  Sleep 4000	;     Wait 4 Seconds
  pbi.findfirstbyname("Export data").click() ; Select Export data option
  Sleep 4000	;     Wait 4 Seconds
  pbi := UIA.ElementFromHandle(hWnd) ; reload UIA
  sleep 2000
  MySave := pbi.findfirstbyname("Save As")
  MySave := MySave.findfirstbynameandtype("File name:", "edit")
  MySave.Value := "C:\Users\sammy\Documents\WindwardData\CSV Files\jobdata.csv"

  pbi.findfirstbyname("Save").click() ; Click Save Button
  Sleep 4000	;     Wait 4 Seconds
  pbi.findfirstbyname("Yes").click() ; Click Replace File Yes option
  Sleep 8000	;     Wait 8 Seconds sometimes slower
ExitApp

SlCantre939
Posts: 11
Joined: 08 Feb 2023, 11:37

Re: Compiled AHK Produces Chinese File Names

Post by SlCantre939 » 29 Mar 2023, 22:34

English Chinese Test 2.jpg
English Chinese Test 2.jpg (13.15 KiB) Viewed 310 times

User avatar
boiler
Posts: 16965
Joined: 21 Dec 2014, 02:44

Re: Compiled AHK Produces Chinese File Names

Post by boiler » 29 Mar 2023, 23:00

You still haven't answered how you're using v1 libraries if your main script is running as v2. Put these two lines exactly as shown at the top of your script and tell me what it says when you run it:

Code: Select all

v1 := "v2"
MsgBox v1

SlCantre939
Posts: 11
Joined: 08 Feb 2023, 11:37

Re: Compiled AHK Produces Chinese File Names

Post by SlCantre939 » 29 Mar 2023, 23:42

Found the problem.
Had to compile with v1.1.36.02 U64 Unicode 64-bit.bin as the Base File option.
When I did that, all the files populate correctly in English.
34-bit was causing the issue.
Thanks for your direction to try to test it with a smaller script.
That is what helped me find the issue.
Good suggestion.
Thanks

Post Reply

Return to “Ask for Help (v2)”