Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. I managed to compile the Python script to an EXE. And my memory said I only needed that Testing.exe file, but clearly not, so I now have heaps of required files, all adding up to 12.2 Mb. So much for a nice small script. Anyway .... That done, the next thing was passing the ImageId value on the command-line. That took a bit of research, but I got there, and was reminded just how horrible it is to program with Python. So I have added and also replaced with the following in my Python script. import sys ImageId = sys.argv[1] hash1 = qhash(ImageId) And now before I go any further, I need to check if this has all been worth the trouble. In other words, I need to find an ebook on my Kobo device that doesn't have any cover images assigned, grab its ImageId value via the SQL database file, and then run that through my Python script, to get the two numbered folder names. Then create those folders on my Kobo device, and then add the three correctly named cover image files to that path. Then fire up my device and see if the covers are now displaying where they should be. If that works, then we will be cooking with gas, and all the hassle would have finally been worth it ... and I will feel back in control of my device. And of course that means I can finally finish my Kobo Cover Fixer program, and call it a full success. Meanwhile, I am sure that TheDcoder will come up with the AutoIt code solution, and I can ditch my Python script. But if not, then I can certainly make do ... and always have something to tease TheDcoder about.
  3. Today
  4. Okay, I managed to check that a Python script would work and produce the results I want. Testing.py def qhash (inputstr): instr = "" if isinstance (inputstr, str): instr = inputstr elif isinstance (inputstr, unicode): instr = inputstr.encode ("utf8") else: return -1 h = 0x00000000 for i in range (0, len (instr)): h = (h << 4) + ord(instr[i]) h ^= (h & 0xf0000000) >> 23 h &= 0x0fffffff return h hash1 = qhash("ff0a942a-2f28-4aa2-ba97-318fce090264") print("_test_covers - hash1='%s'" % (hash1)) xff = 0xff dir1 = hash1 & xff dir1 &= 0xff print("_test_covers - dir1='%s', xff='%s'" % (dir1, xff)) xff00 = 0xff00 dir2 = (hash1 & xff00) >> 8 print("_test_covers - hash1='%s', dir1='%s', dir2='%s'" % (hash1, dir1, dir2)) That returns the following when run via a BAT file. _test_covers - hash1='12448788' _test_covers - dir1='20', xff='255' _test_covers - hash1='12448788', dir1='20', dir2='244' Press any key to continue . . . Testing.bat @echo off python Testing.py pause cls exit Then I added a print to file statement at the end of the script. with open("output.ini", "a") as f: print("[Sub Folders]", file=f) print(f"dir1={dir1}", file=f) print(f"dir2={dir2}", file=f) And got an easily accessible result in an INI file. [Sub Folders] dir1=20 dir2=244 Now I just have to see if I can compile that script into an EXE, so that a Python install is not required.
  5. Gawd, ChatGPT let me down. It started out well enough, then it kept pretending it had modified its presented code, when it was returning identical code to the last reply. So I then tried to lead it to the variations if gave last night, and it just got silly and repeated my own code, and at one point hard coded (assigned) the values I wanted returned. Then just as I was going to massage it in teh direction I wanted, it gave teh following message. Clearly while it is a new day for me, it must be including all the replies from last night as well, which were a lot more. You'd think they would have some reasonable leeway with different time zones. I had more than a 10 hour break, in which I slept. P.S. And gawd, what an idiot. I just discovered that I mistakenly grabbed the ShiftBit lines from my code and used them in my first example with ChatGPT today. What a horrible mistake, and I thought I took all care not to do that ... bloody brain, can't trust it.
  6. Yesterday
  7. Never really looked much into them. Anyway .... I understand a few things a bit more now. Your reference to qhash being a custom function, had me check the action.py script, and I see now where you got it from (near the start of the script) and then converted. I understand some aspects of your conversion, but not all, so I am taking it on faith you got it right. The other two things I wanted to clear up, were 'return' and 'cursor'. Browsing through the script, searching on 'cursor', I saw some SQL executions, and it suddenly occurred to me that 'cursor' might be an SQL function, and looking that up in my SQL text book, and reading some of what I found, it seems I was right. It would appear that 'cursor' appears to be a row in a database table. Looking at 'return' next, that then appears to be a variable storing all elements of the row. And that the query of result['ImageId']), returns the ImageId element of that row. So that means processing the ImageId as in qhash("ff0a942a-2f28-4aa2-ba97-318fce090264") would be right. So using the following, I got a return of '55'. $result = qhash("ff0a942a-2f28-4aa2-ba97-318fce090264") MsgBox(262144, "Result", $result) So I then used that with what ChatGPT had converted for me of the other relevant Python code. Local $xff = 0xff Local $dir1 = $result & $xff $dir1 &= 0xff Local $xff00 = 0xff00 Local $dir2 = BitShift($result & $xff00, 8) ConsoleWrite("dir1: " & $dir1 & @CRLF) ConsoleWrite("dir2: " & $dir2 & @CRLF) Alas, that gave me wrong values. dir1: 55255255 dir2: 21739 They should be '20' and '244'. So I am about to try some variations with ChatGPT, especially as yesterday it presented a few things, and I have just tried the only one I kept a record of. $dir1 = BitAND(Hex(StringToBinary($result)), 0xFF) $dir2 = BitShift(BitAND(Hex(StringToBinary($result)), 0xFF00), 8) Which gave me the following, still wrong, but at least more in the ballpark. dir1: 207 dir2: 13 By the way, the BitShift portion (function calls) of your converted code are automatically being skipped in favor of AutoIt's regular BitShift function. I did force it to use yours instead, by renaming your function to ShiftBit where relevant. But that resulted in huge number returns for all three values. So that is where I am right now, and hopefully ChatGPT will enable me to succeed this time. Anyway the following is my full code right now. Global $dir1, $dir2, $result, $xff, $xff00 $result = qhash("ff0a942a-2f28-4aa2-ba97-318fce090264") ;MsgBox(262144, "Result", $result) $xff = 0xff $dir1 = $result & $xff $dir1 &= 0xff $xff00 = 0xff00 $dir2 = BitShift($result & $xff00, 8) ;$dir1 = BitAND(Hex(StringToBinary($result)), 0xFF) ;$dir2 = BitShift(BitAND(Hex(StringToBinary($result)), 0xFF00), 8) ConsoleWrite("dir1: " & $dir1 & @CRLF) ConsoleWrite("dir2: " & $dir2 & @CRLF) Exit Func qhash($inputstr) Local $i, $instr = "" If IsString($inputstr) Then $instr = $inputstr Else Return -1 EndIf Local $h = 0x00000000 For $i = 1 To StringLen($instr) $h = BitShift($h, 4) + Asc(StringMid($instr, $i, 1)) $h = BitXor($h, BitShift(BitAND($h, 0xf0000000), -23)) $h = BitAND($h, 0x0fffffff) Next Return $h EndFunc Something else I noticed, was another choice (Unicode) in the original Python qhash function. Any reason why that has been omitted?
  8. my approach #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <ScreenCapture.au3> Global $aArgs = $CmdLine ;~ Global $aArgs = [5, "one", 2, "three", "", "five"] ;test Global $filepath, $sspath, $sspath2, $option If $aArgs[0] = 4 Then $aArgs[0] = "CallArgArray" Call("_main", $aArgs) Else Global $sMsg = "Number of parameters: " & $aArgs[0] & @CRLF For $i = 1 To $aArgs[0] $sMsg &= $i & ") " & $aArgs[$i] & @CRLF Next ToolTip($sMsg , Default, Default, "!! Wrong Number of parameters", 3) Sleep(4000) EndIf Exit Func _main($sArg1, $sArg2, $sArg3, $sArg4) $filepath = $sArg1 $sspath = $sArg2 $sspath2 = $sArg3 $option = $sArg4 ControlFocus("Select Folder to Upload", "", "Edit1") If $option = "screenshot" Then popupIsDisplayed() ElseIf $option = "cancel" Then clickCancelInPopUp() ElseIf $option = "select file" Then selectFile() clickUploadInPopUp() ElseIf $option = "alert screenshot" Then alertISDisplayed() ElseIf $option = "upload" Then clickUploadInAlert() ElseIf $option = "cancel alert" Then clickCancelInAlert() EndIf EndFunc ;==>_main Func popupIsDisplayed() ControlFocus("Select Folder to Upload", "", "Edit1") Sleep(2000) Example() EndFunc ;==>popupIsDisplayed Func clickCancelInPopUp() ControlClick("Select Folder to Upload", "", "Button2") EndFunc ;==>clickCancelInPopUp Func selectFile() ControlSetText("Select Folder to Upload", "", "Edit1", $filepath) Sleep(2000) Example() Sleep(2000) EndFunc ;==>selectFile Func clickUploadInPopUp() ControlClick("Select Folder to Upload", "", "Button1") Sleep(2000) EndFunc ;==>clickUploadInPopUp Func alertISDisplayed() Example2() EndFunc ;==>alertISDisplayed Func clickUploadInAlert() Example2() Send("{Tab}") Send("{Enter}") EndFunc ;==>clickUploadInAlert Func clickCancelInAlert() Example2() Send("{Enter}") EndFunc ;==>clickCancelInAlert Func Example() Local $hBmp ; Capture full screen $hBmp = _ScreenCapture_Capture("") ; Save bitmap to file _ScreenCapture_SaveImage($sspath, $hBmp) EndFunc ;==>Example Func Example2() Local $hBmp ; Capture full screen $hBmp = _ScreenCapture_Capture("") ; Save bitmap to file _ScreenCapture_SaveImage($sspath2, $hBmp) EndFunc ;==>Example2
  9. just do it. For $n = 1 To $CmdLine[0] ConsoleWrite($n & @TAB & '>' & $CmdLine[$n] & '<' & @CRLF) Next Exit I passed 1 "" 3 4 and got 1 >1< 2 >< 3 >3< 4 >4< so yes you can. What I would do in your case is Global $option, $filepath, $sspath, $sspath2 If $CmdLine[0] > 3 Then $option = $CmdLine[4] If $CmdLine[0] > 0 Then $filepath = $CmdLine[1] If $CmdLine[0] > 1 Then $sspath =$CmdLine[2] If $CmdLine[0] > 2 Then $sspath2 = $CmdLine[3] so you don't get the error you got with your code. Then again, you'll have to learn to think and explore on your own. My 2 cents even if you don't like it
  10. Just pass a dummy parameter, like "NULL" or specific character like "*". Anything beside nothing.... ps. In java you need to escape quotation marks if you want to send them, this would be a valid parameter : "\"\"" and it would be interpreted as Null value in AutoIt (like suggested by @argumentum below)
  11. @JosThanks, I found where the issue is. Array in AutoIt is not considering null value(""). Actual: $CmdLine[0] = number of items $CmdLine[1] = folder path $CmdLine[2] = SSPath $CmdLine[3] ="select file" Expected: $CmdLine[0] = number of items $CmdLine[1] = folder path $CmdLine[2] = SSPath $CmdLine[3] = "" $CmdLine[4] ="select file" How can we pass null value ("")?
  12. Add these 3 lines at the top of your script: #include <Array.au3> _ArrayDisplay($CmdLine) Exit ..compile it and run it again. It should show the full $CmdLine array in a popup so you can see what is happening.
  13. @JosI have gone through the Running Scripts topic. I'm still having confusion. I'm passing the array values in this array String[] cmd = { autoItScriptPath, folderPath, SSPath, "","select file" }; to AutoIt $CmdLine[1] is folder path $CmdLine[2] is SSPath $CmdLine[3] is null $CmdLine[4] is "select file" $CmdLine[0] is "\\src\\test\\resources\\autoit\\FileUpload.exe" [AutoIt .exe path] But $CmdLine[0] means total number of items in the array in AutoIt. How to tackle this one?
  14. Hello guys, I am happy, started my first window with chrome at the wished page, but I noted It was not my usual page, I mean, I was not logged in google and furthermore the page kept asking me about cookies so I guess there is a way to pass google my account information right? Moreover, could I pilot a window already present, a page I opened before manually? Thanks guys. Marco
  15. Not going to happen! Please read our forum rules on this topic as we do not allow that to be discussed!
  16. Bud that's just getting the image id from whatever "result" is, it is not related to the hash function. Do you understand the concept of Maps in AutoIt? This is the exact same thing. You can swap it out with any arbitrary string and it will work, no "dictionary" required.
  17. Guess you have some studying to do then! You didn't specify, but the guess is you get the error on one of these: $option = $CmdLine[4] $filepath = $CmdLine[1] $sspath =$CmdLine[2] $sspath2 = $CmdLine[3] Which is because you started the script without (enough) parameters and the coder has forgotten to test for that! So open the AutoIt3 helpfile and look at the Running Scripts topic.
  18. And how is that not the case too with a dictionary lookup? Clearly the following two lines with 'result' are important, and there seems to me to be some kind of lookup at play. result = next(cursor) hash1 = qhash(result['ImageId']) Anyway, I've had enough for one night.
  19. Hello there, I hope this message finds you well. I am relatively new to AutoIt and have been exploring its capabilities for automating tasks on Windows. I have a specific project that I am working on, and I would greatly appreciate any guidance or advice from the experienced members of this community. I need to launch a specific web browser (preferably Chrome or Firefox) and navigate to the login page of the web application. The script should automatically fill in the username and password fields and submit the login form. The login page may include additional elements such as CAPTCHA, which could be a challenge to automate. After successfully logging in, the script should navigate through the web application to reach a specific page where the required data is displayed. What is the best approach to handle web automation with AutoIt for the aforementioned tasks? Are there any recommended libraries or tools that work well with AutoIt for web automation, particularly for handling dynamic web elements and CAPTCHA? Also, I have gone this post: https://www.autoitscript.com/forum/topic/205542-solved-extract-data-from-website-aws-devops-export-to-excel-moved/ which definitely helped me out a lot. Can anyone share sample scripts or code snippets that demonstrate similar automation processes? What are the common pitfalls I should be aware of when automating web interactions using AutoIt? Thank you in advance for your help and assistance.
  20. @Jos Apologies for the discomfort. I didn't write this AutoIt code. It was written by some other person who is currently not in my company now. I'm new to the company and I don't see any person who has AutoIt knowledge in my project. Could you please help resolving this bug if you get time?
  21. That's pure rubbish bud, the output of the qhash function is just a plain number.
  22. Well I did also try to use your version in place of it, but to no avail. In later dealings it seems convinced that the hashes are stored in a dictionary arrangement, based on the use of 'result'. That could well be.
  1. Load more activity
×
×
  • Create New...